Пример #1
0
    def retrieve_hist_data_fr_database(self):
        """ Retrieve the hist data from web using yahoo_finance_historical_data_extract module.
            Set to self.raw_all_stock_df

        """

        c = FinanceDataStore(self.database_path)
        c.retrieve_hist_data_fr_db(self.stocklist, 0)
        c.extr_hist_price_by_date(200)
        self.raw_all_stock_df = c.hist_price_df
    def retrieve_hist_data_fr_database(self):
        """ Retrieve the hist data from web using yahoo_finance_historical_data_extract module.
            Set to self.raw_all_stock_df

        """

        c = FinanceDataStore(self.database_path)
        c.retrieve_hist_data_fr_db(self.stocklist,0)
        c.extr_hist_price_by_date(200)
        self.raw_all_stock_df = c.hist_price_df
            
            print "Getting Trends data -- Done. \n"
            #full_stock_data_df.to_csv(r'c:\data\full_oct21.csv', index = False)

        if 'c_pre' in partial_run:
            """ Update the database """
            print 'Updating the database with latest hist price.'
            datastore = FinanceDataStore(db_full_path)
            stock_list = list(ss.modified_df['SYMBOL'])
            datastore.scan_and_input_recent_prices(stock_list,5)
            print 'Updating the database with latest hist price -- Done\n'

        if 'c' in partial_run:
            ## using database to retrieve the data
            datastore = FinanceDataStore(db_full_path)
            datastore.retrieve_hist_data_fr_db()

            ## 3 days trends data
            print "Getting Trends data"
            trend_ext = YFHistDataExtr()
            trend_ext.set_bypass_data_download()
            trend_ext.set_raw_dataset(datastore.hist_price_df, datastore.hist_div_df)
            trend_ext.run_all_hist_data()
            full_stock_data_df = pandas.merge(ss.modified_df, trend_ext.all_stock_combined_post_data_df, on = 'SYMBOL', how ='left')
            
            print "Getting Trends data -- Done. \n"
            full_stock_data_df.to_csv(final_store_filename, index = False)

        if 'd_pre' in partial_run:
            """ Skip the company data info and just join based on store data."""
            print 'Use backup data for company data.'