コード例 #1
0
def update_trader_info(runtime):    
    """
    更新账户信息。
    """
    #//update trader info
    runtime['trader_info_full'] = broker_stub.get_trader(api.TraderRequest_get_trader_full())
    runtime['account_info'] = runtime['trader_info_full'].account
    runtime['order_info'] = tradingObjects.order_info(runtime['trader_info_full'])
    runtime['positions_info'] = tradingObjects.positions_info(runtime['trader_info_full'])
    runtime['trader_info_count'] += 1
コード例 #2
0
def update_trader_info_looped(runtime):
    """
    循环版本更新账户信息。
    """
    while True:
        runtime['trader_info_full'] = broker_stub.get_trader(api.TraderRequest_get_trader_full())
        runtime['account_info'] = runtime['trader_info_full'].account
        runtime['order_info'] = tradingObjects.order_info(runtime['trader_info_full'])
        runtime['positions_info'] = tradingObjects.positions_info(runtime['trader_info_full'])
        runtime['trader_info_count'] += 1        
コード例 #3
0
ファイル: trading.py プロジェクト: YimoZhu/JiukunTornament
def initStrategy(runtime):
    """
    初始化策略。
    """
    #api.cancel_all()
    #api.close_all_at_market()

    runtime['trader_info_full'] = api.get_trader_full()
    runtime['account_info'] = runtime['trader_info_full'].account
    runtime['order_info'] = tradingObjects.order_info(
        runtime['trader_info_full'])
    runtime['positions_info'] = tradingObjects.positions_info(
        runtime['trader_info_full'])

    runtime['TARGETS_MAPPING'] = {
        'A001.PSE': 'A000.PSE',
        'A002.PSE': 'A000.PSE',
        'B001.PSE': 'B000.PSE',
        'B002.PSE': 'B000.PSE'
    }

    runtime['snapshots_count'] = 0
    runtime['snapshots'] = tradingObjects.snapshots(
        data_stream.next().instruments)

    runtime['isOpen_A001.PSE'] = True
    runtime['isOpen_A002.PSE'] = True
    runtime['isOpen_B001.PSE'] = True
    runtime['isOpen_B002.PSE'] = True

    runtime['loopCount_A001.PSE'] = 0
    runtime['loopCount_A002.PSE'] = 0
    runtime['loopCount_B001.PSE'] = 0
    runtime['loopCount_B002.PSE'] = 0

    runtime['trader_info_count'] = 0

    runtime['net_A001.PSE'] = 0
    runtime['net_A002.PSE'] = 0
    runtime['net_B001.PSE'] = 0
    runtime['net_B002.PSE'] = 0

    runtime['isDigested_A001.PSE'] = 0
    runtime['isDigested_A002.PSE'] = 0
    runtime['isDigested_B001.PSE'] = 0
    runtime['isDigested_B002.PSE'] = 0
    runtime['isDigested_arbitrage'] = 0

    runtime['targetNetPos_A001.PSE'] = 0
    runtime['targetNetPos_A002.PSE'] = 0
    runtime['targetNetPos_B001.PSE'] = 0
    runtime['targetNetPos_B002.PSE'] = 0