BigQuant使用文档

回测如何设置手续费和保证金率

由qxiao创建,最终由qxiao 被浏览 187 用户

回测如何设置手续费和保证金率

可以在Initial函数中通过context的set_commission设置

def initialize(context):
    """初始化"""
    print("initialize")    

    # 股票设置费率的示例
    context.set_commission(equities_commission=PerOrder(buy_cost=0.0003, sell_cost=0.0013, min_cost=5.0))    

    # 期货设置费率的示例
    comm_dict = {
        # 开仓,平仓,平今手续费
        'I':(0.00012, 0.00006, 0.00012),
        'RB':(0.000045, 0.000045, 0.000045)
    }
    context.set_commission(futures_commission=PerContract(comm_dict))

    # 期货设置保证金率
    context.set_margin('RB', 0.05)

\

标签

回测股票
评论
  • 如下报错是啥意思? 023-03-04 23:45:40.533965 strategy strategy exception:Traceback (most recent call last): File "bigtrader/strategy/engine.py", line 713, in bigtrader2.bigtrader.strategy.engine.StrategyEngine._call_strategy_func File "bigtrader/strategy/strategy_base.py", line 2281, in bigtrader2.bigtrader.strategy.strategy_base.StrategyBase.call_handle_data File "", line 23, in m3_handle_data_bigquant_run rt=data.current(code, "price") File "/var/app/enabled/bigtrader2/bigtrader/protocol.py", line 285, in current return self.__data_engine.get_current_value(asset, curr_dt, fields) File "bigtrader/mdata/engine.py", line 702, in bigtrader2.bigtrader.mdata.engine.DataEngine._get_minute_value_from_df AttributeError: 'NoneType' object has no attribute 'get_value' --- AttributeError Traceback (most recent call last) in 52 ) 53 \---> 54 m3 = M.hftrade.v2( 55 instruments=m1.data, 56 start_date='', in m3_handle_data_bigquant_run(context, data) 21 r=\[\] 22 for code in context.instruments: \---> 23 rt=data.current(code, "price") 24 r.append(rt) 25 print(r) AttributeError: 'NoneType' object has no attribute 'get_value'
{link}