- buy_BTFD: added params

- stock::fetch: support slice by date if loaded from file

git-svn-id: http://moon:8086/svn/projects/Stock@334 fda53097-d464-4ada-af97-ba876c37ca34
This commit is contained in:
2019-12-27 14:13:48 +00:00
parent a739314378
commit 8e8b9c2d95
3 changed files with 22 additions and 13 deletions
+13 -6
View File
@@ -72,11 +72,18 @@ class Stock(object):
hdf = pd.HDFStore(filename, 'r')
data = hdf[self.symbol] * self.currency_corr
N = len(data.index)
self.data['index'] = np.array(data.index[0:N])
self.data['close'] = np.array(data['close'][0:N])
self.data['high'] = np.array(data['high'][0:N])
self.data['low'] = np.array(data['low'][0:N])
start_pos = 0
end_pos = 0
for index in data.index:
end_pos += 1
if str(end) in index:
break
self.data['index'] = np.array(data.index[start_pos:end_pos])
self.data['close'] = np.array(data['close'][start_pos:end_pos])
self.data['high'] = np.array(data['high'][start_pos:end_pos])
self.data['low'] = np.array(data['low'][start_pos:end_pos])
hdf.close()
@@ -113,7 +120,7 @@ class Stock(object):
self.data['macd_fdd'] = np.transpose(yf_dd)
def analyze(self, buy_callback, range_days):
return agent.buy_BTFD(self.symbol, self.data, marker_key='close_n', cand_window=5, range_days=range_days, buy_callback=buy_callback)
return agent.buy_BTFD(self.symbol, self.data, params=self.params['btfd'], marker_key='close_n', range_days=range_days, buy_callback=buy_callback)
@staticmethod
def has_candidate(data, key):