请 [注册] 或 [登录]  | 返回主站

量化交易吧 /  量化平台 帖子:3364856 新帖:14

小市值股票,干就完事了,不在乎回撤

牛市来了发表于:5 月 10 日 06:25回复(1)

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
 

全部回复

0/140

量化课程

    移动端课程