Path: blob/master/finrl/meta/data_processors/processor_quantconnect.py
732 views
from __future__ import annotations12import numpy as np345class QuantConnectEngineer:6def __init__(self):7pass89def data_fetch(start_time, end_time, stock_list, resolution=Resolution.Daily):10# resolution: Daily, Hour, Minute, Second11qb = QuantBook()12for stock in stock_list:13qb.AddEquity(stock)14history = qb.History(qb.Securities.Keys, start_time, end_time, resolution)15return history1617def preprocess(df, stock_list):18df = df[["open", "high", "low", "close", "volume"]]19if_first_time = True20for stock in stock_list:21if if_first_time:22ary = df.loc[stock].values23if_first_time = False24else:25temp = df.loc[stock].values26ary = np.hstack((ary, temp))27return ary282930