nothing
import jqdata def initialize(context): g.security='000001.XSHE' set_benchmark('000300.XSHG') set_option('use_real_price',True) run_daily(market_open,time='every_bar')
def market_open(context): security=g.security close_data=attribute_history(security,5,'id',['close']) MA5=close_data['close'].mean() current_price=close_data['close'][-1] cash=context.profolio.available_cash if current_price>1.01*MA5: order_value(security,cash) log.info('Buying %s'%(security)) elif current_price<MA5 and context.profolio.positions[security].closeable_amount>0: order_target(security,0) log.info('Selling %s'%(security)) record(stock_price=current_price)
File "<ipython-input-25-fa5fc04057b3>", line 8 order_value(security,cash) ^ IndentationError: expected an indented block
if current_price>1.01*MA5: order_value(security,cash) log.info('Buying %s'%(security)) elif current_price<MA5 and context.profolio.positions[security].closeable_amount>0: order_target(security,0) log.info('Selling %s'%(security)) record(stock_price=current_price)
File "<ipython-input-20-f7252b9a9fdd>", line 2 order_value(security,cash) ^ IndentationError: expected an indented block
本社区仅针对特定人员开放
查看需注册登录并通过风险意识测评
5秒后跳转登录页面...
交易匠人:震荡行情多耐心,黄金早间有望延续...
交易匠人:黄金震荡回踩1708,有波段机会
移动端课程