def get_baseline(ticker, start, end): if ticker == 'crypto': print('*********') else: dji = YahooDownloader( start_date=start, end_date=end, ticker_list=[ticker] ).fetch_data() print('here ' * 20) print(dji.head()) return dji
def main(): parser = build_parser() options = parser.parse_args() # add following folders if not os.path.exists("./" + config.DATA_SAVE_DIR): os.makedirs("./" + config.DATA_SAVE_DIR) # From config.py file get following: # start_date START_DATE = config.START_DATE # end_date END_DATE = config.END_DATE # list of stocks# STOCK_LIST = config.DOW_30_TICKER print("All stocks used for training:", STOCK_LIST) print("Historical data are used from: ", START_DATE) print("Till end date: ", END_DATE) # Download and save the data in a pandas DataFrame: data_frame = YahooDownloader(start_date=START_DATE, end_date=END_DATE, ticker_list=STOCK_LIST).fetch_data() print("Data Frame shape is: ", data_frame.shape) print("Data Frame format is following: \n\n", data_frame.head()) ## ## Save downloaded data to file ## if os.path.exists("./" + config.DATA_SAVE_DIR + "/" + options.name + ".csv"): os.remove("./" + config.DATA_SAVE_DIR + "/" + options.name + ".csv") print("The download data file deleted") else: print("The download data file does not exist") data_frame.to_csv("./" + config.DATA_SAVE_DIR + "/" + options.name + ".csv") print( "Successfuly completed the task of downloading and saving financial data." )
# Download and save the data in a pandas DataFrame: data_df = YahooDownloader(start_date = '2009-01-01', end_date = '2021-01-01', ticker_list = ['AAPL']).fetch_data() # In[9]: data_df.shape # In[10]: data_df.head() # In[11]: data_df=pd.read_csv(r'C:\Users\e0690420\rl_forex\finrl\preprocessing\datasets\chicago_pmi\EURUSD\ohlc\EURUSD_Chicago_Pmi_2018-01-31 - Copy.csv') data_df.rename(columns = {"time": "date"}, inplace = True) data_df.date = pd.to_datetime(data_df.date) data_df['day'] = data_df['date'].dt.dayofweek data_df['tic'] = 'A' data_df.head() # <a id='3'></a>