In [1]:
from get_kabu_data import get_kabu_data
from datetime import datetime
import pandas as pd
code = '4348'
start1 = datetime(2018, 9, 15)
end1 = datetime(2018, 10, 5)
ohlc1 = get_kabu_data(code, start1, end1)
In [2]:
ohlc1
Out[2]:
In [3]:
ohlc1['2018-09-26':'2018-09-28'] = 0
ohlc1
Out[3]:
In [4]:
start2 = datetime(2018, 9, 25)
end2 = datetime(2018, 10, 1)
ohlc2 = get_kabu_data(code, start2, end2)
ohlc2
In [5]:
for i in ohlc2.index:
if i in ohlc1.index:
check = ohlc2.loc[i].equals(ohlc1.loc[i])
print(i,check)
if not check:
ohlc1.loc[i] = ohlc2.loc[i]
else:
ohlc1.loc[i] = ohlc2.loc[i]
if not ('2017-09-24' in ohlc1.index):
ohlc1.loc['2017-09-24'] = [2000.0,2010.0,1999.0,2005.0,100000]
ohlc1
Out[5]:
株式分割に対応するには?
In [6]:
ohlc1.loc[:, 'Open':'Close'] = ohlc1.loc[:, 'Open':'Close']/4
ohlc1.loc[:, 'Volume'] = ohlc1.loc[:, 'Volume']*4
In [7]:
ohlc1
Out[7]:
コメント