Example #1
0
def run_backtesting_analysis_engine(strategy):
    """

    """
    backtesting_analysis_engine = EventEngineBase()
    event_backtesting = EventBacktestingAnalysis()
    event_backtesting.event_data_dict["strategy"] = strategy

    backtesting_analysis_engine.put(event_backtesting)

    backtesting_analysis_engine.register(EventType.EVENT_BACKTESTING_ANALYSIS.value,
                                         EventBacktestingAnalysis.save_backtesting_record_to_csv)
    backtesting_analysis_engine.register(EventType.EVENT_BACKTESTING_ANALYSIS.value,
                                         EventBacktestingAnalysis.show_backtesting_indicator)

    backtesting_analysis_engine.start(timer=False)
    backtesting_analysis_engine.stop()
Example #2
0
def run_broker_engine(strategy):
    """
    deal 交易撮合,更新 OrderData DealData AccountData PositionData
    OrderData(返回状态:已成 已撤(检查可用资金 可用数量不合格)等)
    :param new_order_data:
    :return:
    """
    broker_engine = EventEngineBase()
    event_deal = EventDeal()
    event_deal.event_data_dict["strategy"] = strategy
    broker_engine.put(event_deal)

    broker_engine.register(EventType.EVENT_DEAL.value, EventDeal.initialize_deal_data)
    broker_engine.register(EventType.EVENT_DEAL.value, EventDeal.slippage_calculate)
    broker_engine.register(EventType.EVENT_DEAL.value, EventDeal.commission_calculate)
    broker_engine.register(EventType.EVENT_DEAL.value, EventDeal.update_position_list)
    broker_engine.register(EventType.EVENT_DEAL.value, EventDeal.update_account_list)
    broker_engine.register(EventType.EVENT_DEAL.value, Environment().refresh_current_data)

    broker_engine.start(timer=False)
    broker_engine.stop()
def run_mission_engine(strategy):
    """
    order  和 risk management 两个事件, ,同样使用event_engine,本地计算的engine,重新隔离出一个engine
    在risk management
    更新 OrderData,的状态:已报
    :param order_data:
    :return:
    """
    mission_engine = EventEngineBase()

    event_order = EventOrder()
    mission_engine.put(event_order)

    mission_engine.register(EventType.EVENT_ORDER.value,
                            EventOrder.integer_conversion)
    mission_engine.register(EventType.EVENT_ORDER.value,
                            EventOrder.account_available_check)
    mission_engine.register(EventType.EVENT_ORDER.value,
                            EventOrder.position_available_volume_check)

    event_risk_management = EventRiskManagement()
    event_risk_management.event_data_dict["strategy"] = strategy
    mission_engine.put(event_risk_management)

    mission_engine.register(EventType.EVENT_RISK_MANAGEMENT.value,
                            EventRiskManagement.black_namelist_check)
    mission_engine.register(EventType.EVENT_RISK_MANAGEMENT.value,
                            EventRiskManagement.change_order_status)
    mission_engine.register(EventType.EVENT_RISK_MANAGEMENT.value,
                            EventRiskManagement.send_order)

    mission_engine.start()
    mission_engine.stop()