simple turtle
来源:https://uqer.io/community/share/55fe8f58f9f06c597165ef13
start = '2011-01-01'
end = '2015-09-01'
benchmark = 'HS300'
universe = set_universe('HS300')
capital_base = 100000
freq = 'd'
refresh_rate = 1
longest_history=60
pos_pieces=10
window=20
def initialize(account):
pass
def handle_data(account):
highest_price=account.get_attribute_history('highPrice',window)
lowest_price=account.get_attribute_history('lowPrice',window)
for stock in account.universe:
current_price=account.referencePrice[stock]
if current_price > highest_price[stock].max() and account.position.secpos.get(stock,0)==0:
order_to(stock,capital_base/pos_pieces/current_price)
elif current_price < lowest_price[stock].min():
order_to(stock,0)
return