Ejemplo n.º 1
0
    def setup_db_for_hist_prices_storage(self, stock_sym_list):
        """ Get the price and dividend history and store them to the database for the specified stock sym list.
            The length of time depends on the date_interval specified.
            Connection to database is assuemd to be set.
            For one time large dataset (where the hist data is very large)
            Args:
                stock_sym_list (list): list of stock symbol.

        """

        ## set the class for extraction
        histdata_extract = YFHistDataExtr()
        histdata_extract.set_interval_to_retrieve(360*5)# assume for 5 years information
        histdata_extract.enable_save_raw_file = 0

        for sub_list in self.break_list_to_sub_list(stock_sym_list):
            print ('processing sub list', sub_list)
            histdata_extract.set_multiple_stock_list(sub_list)
            histdata_extract.get_hist_data_of_all_target_stocks()
            histdata_extract.removed_zero_vol_fr_dataset()

            ## save to one particular funciton
            #save to sql -- hist table
            histdata_extract.processed_data_df.to_sql(self.hist_data_tablename, self.con, flavor='sqlite',
                                    schema=None, if_exists='append', index=True,
                                    index_label=None, chunksize=None, dtype=None)

            #save to sql -- div table
            histdata_extract.all_stock_div_hist_df.to_sql(self.divdnt_data_tablename, self.con, flavor='sqlite',
                                    schema=None, if_exists='append', index=True,
                                    index_label=None, chunksize=None, dtype=None)

        self.close_db()
Ejemplo n.º 2
0
    def setup_db_for_hist_prices_storage(self,stock_sym_list,interval):
        #get price history
        histdata_extract = YFHistDataExtr()
        histdata_extract.set_interval_to_retrieve(360*interval)
        histdata_extract.enable_save_raw_file=0
        for sub_list in self.break_list_to_sub_list(stock_sym_list):
            print ('processing sub list', sub_list)
            histdata_extract.set_multiple_stock_list(sub_list)
            histdata_extract.get_hist_data_of_all_target_stocks()
            histdata_extract.removed_zero_vol_fr_dataset()
            # save to SQL table
            histdata_extract.processed_data_df.to_sql(self.hist_data_tablename, self.con, flavor='sqlite',
                                    schema=None, if_exists='append', index=True,
                                    index_label=None, chunksize=None, dtype=None)

        self.close_db()
Ejemplo n.º 3
0
    def setup_db_for_hist_prices_storage(self, stock_sym_list):
        """ Get the price and dividend history and store them to the database for the specified stock sym list.
            The length of time depends on the date_interval specified.
            Connection to database is assuemd to be set.
            For one time large dataset (where the hist data is very large)
            Args:
                stock_sym_list (list): list of stock symbol.

        """

        ## set the class for extraction
        histdata_extract = YFHistDataExtr()
        histdata_extract.set_interval_to_retrieve(
            360 * 5)  # assume for 5 years information
        histdata_extract.enable_save_raw_file = 0

        for sub_list in self.break_list_to_sub_list(stock_sym_list):
            print('processing sub list', sub_list)
            histdata_extract.set_multiple_stock_list(sub_list)
            histdata_extract.get_hist_data_of_all_target_stocks()
            histdata_extract.removed_zero_vol_fr_dataset()

            ## save to one particular funciton
            #save to sql -- hist table
            histdata_extract.processed_data_df.to_sql(self.hist_data_tablename,
                                                      self.con,
                                                      flavor='sqlite',
                                                      schema=None,
                                                      if_exists='append',
                                                      index=True,
                                                      index_label=None,
                                                      chunksize=None,
                                                      dtype=None)

            #save to sql -- div table
            histdata_extract.all_stock_div_hist_df.to_sql(
                self.divdnt_data_tablename,
                self.con,
                flavor='sqlite',
                schema=None,
                if_exists='append',
                index=True,
                index_label=None,
                chunksize=None,
                dtype=None)

        self.close_db()
Ejemplo n.º 4
0
    def setup_db_for_hist_prices_storage(self, stock_sym_list, interval):
        #get price history
        histdata_extract = YFHistDataExtr()
        histdata_extract.set_interval_to_retrieve(360 * interval)
        histdata_extract.enable_save_raw_file = 0
        for sub_list in self.break_list_to_sub_list(stock_sym_list):
            print('processing sub list', sub_list)
            histdata_extract.set_multiple_stock_list(sub_list)
            histdata_extract.get_hist_data_of_all_target_stocks()
            histdata_extract.removed_zero_vol_fr_dataset()
            # save to SQL table
            histdata_extract.processed_data_df.to_sql(self.hist_data_tablename,
                                                      self.con,
                                                      flavor='sqlite',
                                                      schema=None,
                                                      if_exists='append',
                                                      index=True,
                                                      index_label=None,
                                                      chunksize=None,
                                                      dtype=None)

        self.close_db()