Beispiel #1
0
 def addTrade(self, dateTime, tid, price, amount):
     dataDict = {
         "id": tid,
         "price": price,
         "amount": amount
         }
     eventDict = {}
     eventDict["data"] = json.dumps(dataDict)
     self.__events.append((wsclient.WebSocketClient.ON_TRADE, wsclient.Trade(dateTime, eventDict)))
Beispiel #2
0
    def addTrade(self, dateTime, tid, price, amount):
        # To avoid collisions.
        if dateTime == self.__lastDateTime:
            dateTime += datetime.timedelta(microseconds=len(self.__events))
        self.__lastDateTime = dateTime

        eventDict = {
            "data": {
                "id": tid,
                "price": price,
                "amount": amount,
                "microtimestamp":
                int(dt.datetime_to_timestamp(dateTime) * 1e6),
                "type": 0,
            },
            "channel": "live_trades_btcusd",
        }
        self.__events.append(
            (wsclient.WebSocketClient.Event.TRADE, wsclient.Trade(eventDict)))