You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
原始的:
for i in range(1, len(data)):
if data.iloc[i - 1]['p_change'] >= 9.5 and data.iloc[i]['p_change'] >= 9.5:
return True
优化后的:
for _p_change in data['p_change'].values:
if _p_change >= 9.5:
if previous_p_change >= 9.5:
return True
else:
previous_p_change = _p_change
else:
previous_p_change = 0.0
原始的:
for index, row in data.iterrows():
if row['close'] > highest_row['close']:
highest_row = row
elif row['close'] < lowest_row['close']:
lowest_row = row
优化后的:
for _close, _volume, _date in zip(data['close'].values, data['volume'].values, data['date'].values):
if _close > highest_row[0]:
highest_row[0] = _close
highest_row[1] = _volume
highest_row[2] = _date
elif _close < lowest_row[0]:
lowest_row[0] = _close
lowest_row[1] = _volume
lowest_row[2] = _date
原始的:
for i in range(1, len(data)):
if data.iloc[i - 1]['p_change'] < -7 \
or (data.iloc[i]['close'] - data.iloc[i]['open']) / data.iloc[i]['open'] * 100 < -7 \
or data.iloc[i - 1]['p_change'] + data.iloc[i]['p_change'] < -10 \
or (data.iloc[i]['close'] - data.iloc[i - 1]['open']) / data.iloc[i - 1]['open'] * 100 < -10:
优化后的:
for _p_change, _close, _open in zip(data['p_change'].values, data['close'].values, data['open'].values):
if _p_change < -7 or (_close - _open) / _open * 100 < -7 \
or previous_p_change + _p_change < -10 \
or (_close - previous_open)/previous_open * 100 < -10:
return False
The text was updated successfully, but these errors were encountered:
myhhub
changed the title
我从性能方面对所有的策略进行了优化,大幅缩短运行时间
从性能方面对策略进行优化的方案,并附上优化代码
Apr 11, 2023
myhhub
changed the title
从性能方面对策略进行优化的方案,并附上优化代码
从性能方面对策略进行优化的方案,可大幅缩短运行时间,附上部分代码
Apr 11, 2023
更多参照:https://github.com/myhhub/InStock
下面给一些示例:
The text was updated successfully, but these errors were encountered: