<gh_stars>1-10
from huobi.impl.utils.channelparser import ChannelParser
from huobi.model import Trade


class TradeEvent:
    """
    The trade received by subscription of trade.

    :member
        symbol: The symbol you subscribed.
        timestamp: The UNIX formatted timestamp generated by server in UTC.
        trade_list: The trade list. The content is Trade class.
    """

    def __init__(self):
        self.symbol = ""
        self.timestamp = 0
        self.trade_list = list()

    @staticmethod
    def json_parse(json_wrapper):
        ch = json_wrapper.get_string("ch")
        parse = ChannelParser(ch)
        trade_event = TradeEvent()
        trade_event.symbol = parse.symbol
        trade_event.timestamp = json_wrapper.get_int("ts")
        tick = json_wrapper.get_object("tick")
        data_array = tick.get_array("data")
        trade_list = list()
        for item in data_array.get_items():
            trade = Trade.json_parse(item)
            trade_list.append(trade)
        trade_event.trade_list = trade_list
        return trade_event

    def print_object(self, format_data=""):
        from huobi.base.printobject import PrintBasic
        PrintBasic.print_basic(self.symbol, "Symbol")
        PrintBasic.print_basic(self.timestamp, "Timestamp")
        if len(self.trade_list):
            for trade in self.trade_list:
                trade.print_object()
                print()
from huobi.impl.utils.channelparser import ChannelParser
from huobi.model import Trade


class TradeEvent:
    """
    The trade received by subscription of trade.

    :member
        symbol: The symbol you subscribed.
        timestamp: The UNIX formatted timestamp generated by server in UTC.
        trade_list: The trade list. The content is Trade class.
    """

    def __init__(self):
        self.symbol = ""
        self.timestamp = 0
        self.trade_list = list()

    @staticmethod
    def json_parse(json_wrapper):
        ch = json_wrapper.get_string("ch")
        parse = ChannelParser(ch)
        trade_event = TradeEvent()
        trade_event.symbol = parse.symbol
        trade_event.timestamp = json_wrapper.get_int("ts")
        tick = json_wrapper.get_object("tick")
        data_array = tick.get_array("data")
        trade_list = list()
        for item in data_array.get_items():
            trade = Trade.json_parse(item)
            trade_list.append(trade)
        trade_event.trade_list = trade_list
        return trade_event

    def print_object(self, format_data=""):
        from huobi.base.printobject import PrintBasic
        PrintBasic.print_basic(self.symbol, "Symbol")
        PrintBasic.print_basic(self.timestamp, "Timestamp")
        if len(self.trade_list):
            for trade in self.trade_list:
                trade.print_object()
                print()
The trade received by subscription of trade.      :member         symbol: The symbol you subscribed.         timestamp: The UNIX formatted timestamp generated by server in UTC.         trade_list: The trade list. The content is Trade class.