Example #1
0
 def on_market_rtn_depth_market_data_n(self, p_api, p_depth_market_data_n):
     """
     callback on market server when receive market data
     :param p_api:  c_void_p
     :param p_depth_market_data_n: DepthMarketDataNField
     :return:
     """
     depth_market_data = get_depth_market_data(p_depth_market_data_n)
     bids = get_all_bids(p_depth_market_data_n)
     asks = get_all_asks(p_depth_market_data_n)
     self._do_log({
         "p_api": p_api,
         "depth_market_data": depth_market_data,
         "bids": bids,
         "asks": asks
     })
Example #2
0
 def on_market_rtn_depth_market_data_n(self, p_api, p_depth_market_data_n):
     """
     callback on market server when receive market data
     :param p_api:  c_void_p
     :param p_depth_market_data_n: DepthMarketDataNField
     :return:
     """
     depth_market_data = get_depth_market_data(p_depth_market_data_n)
     bids = get_all_bids(p_depth_market_data_n)
     asks = get_all_asks(p_depth_market_data_n)
     self._do_log({
         "p_api": p_api,
         "depth_market_data": depth_market_data,
         "bids": bids,
         "asks": asks
     })
Example #3
0
    def on_market_rtn_depth_market_data_n(self, p_api, p_depth_market_data_n):
        depth_market_data = get_depth_market_data(p_depth_market_data_n)
        if not self.market_data.get(str(depth_market_data.InstrumentID)):
            self.market_data[str(depth_market_data.InstrumentID)] = []
        self.market_data[str(depth_market_data.InstrumentID)].append(depth_market_data)
        print(str(depth_market_data.InstrumentID) + "  " + str(depth_market_data.UpdateTime))
        # 循环获取各买档
        bid_count = get_bid_count(p_depth_market_data_n)
        print u"买档:%s" % bid_count
        for i in range(1, bid_count + 1):
            dp = get_bid(p_depth_market_data_n, i)
            print u"买%s:%s %s" % (i, dp.Price, dp.Size)

        # 一次获取所有卖档数据
        asks = get_all_asks(p_depth_market_data_n)
        print u"卖档:%s" % len(asks)
        for i in range(0, len(asks)):
            dp = asks[i]
            print u"卖%s:%s %s" % (i + 1, dp.Price, dp.Size)