예제 #1
0
 def _serializeCandle(self, candle, period):
     timestamp = int((candle[0] - datetime.datetime(1970, 1, 1)).total_seconds())
     (p_open, p_open_frac) = utils.float_to_fixed(candle[1].open_price)
     (p_high, p_high_frac) = utils.float_to_fixed(candle[1].max_price)
     (p_low, p_low_frac) = utils.float_to_fixed(candle[1].min_price)
     (p_close, p_close_frac) = utils.float_to_fixed(candle[1].close_price)
     return struct.pack("<IQIIqiqiqiqiiI", 0x02, timestamp, 0, 0x01, p_open, p_open_frac, p_high, p_high_frac, p_low, p_low_frac, p_close, p_close_frac,
                 int(candle[1].volume), int(period))
예제 #2
0
 def _serializeTick(self, tick):
     timestamp = int((tick[0] - datetime.datetime(1970, 1, 1)).total_seconds())
     (price_int, price_frac) = utils.float_to_fixed(tick[1].price)
     return struct.pack("<IQIIqii", 0x01, timestamp, 0, 0x01, price_int, price_frac, int(tick[1].volume))