Finam.ru скачать итсторические данные
<DATE>;<TIME>;<OPEN>;<HIGH>;<LOW>;<CLOSE>;<VOL>
20160104;000000;101.0000000;101.7800000;97.9400000;98.0100000;51183990
20160105;000000;97.9400000;99.2400000;97.1600000;98.8900000;48997370
20160106;000000;98.7200000;99.5600000;96.8300000;96.8500000;40688180
Загрузка в backtrader:
import pandas as pd
def get_finam() :
df = pd.read_csv('SBER_160101_180523.csv')
df = df.rename(columns={'<DATE>':'Date','<OPEN>':'Open','<HIGH>':'High','<LOW>':'Low','<CLOSE>':'Close','<VOL>':'Volume'})
df['Date'] = pd.to_datetime(df['Date'], format='%Y%m%d')
df['Openinterest']=0
df = df.drop('<TIME>',1)
#df = df[(df['datetime'] > '2018-1-1') & (df['datetime'] <= '2018-2-1')]
df = df[(df['Date'] >= '2017-6-1')]
df = df.set_index('Date')
return df
df = get_finam()
data = bt.feeds.PandasData(dataname=df)
# Add the Data Feed to Cerebro
cerebro.adddata(data)
Прототип
<DATE>;<TIME>;<OPEN>;<HIGH>;<LOW>;<CLOSE>;<VOL>
20160104;000000;101.0000000;101.7800000;97.9400000;98.0100000;51183990
20160105;000000;97.9400000;99.2400000;97.1600000;98.8900000;48997370
20160106;000000;98.7200000;99.5600000;96.8300000;96.8500000;40688180
Загрузка в backtrader:
import pandas as pd
def get_finam() :
df = pd.read_csv('SBER_160101_180523.csv')
df = df.rename(columns={'<DATE>':'Date','<OPEN>':'Open','<HIGH>':'High','<LOW>':'Low','<CLOSE>':'Close','<VOL>':'Volume'})
df['Date'] = pd.to_datetime(df['Date'], format='%Y%m%d')
df['Openinterest']=0
df = df.drop('<TIME>',1)
#df = df[(df['datetime'] > '2018-1-1') & (df['datetime'] <= '2018-2-1')]
df = df[(df['Date'] >= '2017-6-1')]
df = df.set_index('Date')
return df
df = get_finam()
data = bt.feeds.PandasData(dataname=df)
# Add the Data Feed to Cerebro
cerebro.adddata(data)
Прототип
Комментариев нет:
Отправить комментарий