コード例 #1
0
ファイル: main.py プロジェクト: bitcoinland/bitex
    def on_trade_history_request(self, msg):
        since       = msg.get('Since') 
        page        = msg.get('Page', 0)
        page_size   = msg.get('PageSize', 100)
        filter      = msg.get('Filter')

        offset      = page * page_size

        if self.is_broker():
          columns = [ 'TradeID' , 'Market',  'Side', 'Price', 'Size',
                      'Buyer'   , 'Seller', 'Created', 'BuyerUsername' ,'SellerUsername' ]
        else:
          columns = [ 'TradeID' , 'Market',  'Side', 'Price', 'Size',
                      'Buyer'   , 'Seller', 'Created' ]


        trade_list = generate_trade_history(self.application.db_session, page_size, offset, show_username=self.is_broker(), since=since)

        response_msg = {
            'MsgType'           : 'U33', # TradeHistoryResponse
            'TradeHistoryReqID' : msg.get('TradeHistoryReqID'),
            'Page'              : page,
            'PageSize'          : page_size,
            'Columns'           : columns,
            'TradeHistoryGrp'   : trade_list
        }
        if since:
          response_msg['Since'] = since

        self.write_message(str(json.dumps(response_msg, cls=JsonEncoder)))
コード例 #2
0
ファイル: main.py プロジェクト: Anderson-Juhasc/bitex
    def on_trade_history_request(self, msg):
        page        = msg.get('Page', 0)
        page_size   = msg.get('PageSize', 100)
        filter      = msg.get('Filter')

        offset      = page * page_size

        columns = [ 'TradeID'           , 'Market',  'Side', 'Price', 'Size', 
                    'Buyer'             , 'Seller', 'Created' ]

        trade_list = generate_trade_history(page_size, offset)

        response_msg = {
            'MsgType'           : 'U33', # TradeHistoryResponse
            'TradeHistoryReqID' : msg.get('TradeHistoryReqID'),
            'Page'              : page,
            'PageSize'          : page_size,
            'Columns'           : columns,
            'TradeHistoryGrp'   : trade_list
        }

        self.write_message(str(json.dumps(response_msg, cls=JsonEncoder)))