Ejemplo n.º 1
0
    def parse_transaction(self, raw):
        """
        :param raw: {}
            Raw trade
        :return: Transaction
            Parsed Transaction
        """

        coin_bought, amount_bought, coin_sold, amount_sold = \
            self.get_coins_amounts(raw)
        coin_buy = CoinAmount(coin_bought, amount_bought, True) \
            if coin_bought else None
        coin_sell = CoinAmount(coin_sold, amount_sold, False) \
            if coin_sold else None

        return Transaction(raw, coin_buy, coin_sell, self.get_date(raw),
                           self.get_transaction_type(raw),
                           self.is_successful(raw), self.get_commission(raw))
Ejemplo n.º 2
0
 def get_commission(self, raw):
     try:
         commission_data = raw["network"]
         return Commission(
             commission_data,
             CoinAmount(commission_data["transaction_fee"]["currency"],
                        commission_data["transaction_fee"]["amount"],
                        False), self.get_date(raw),
             commission_data["status"] == "confirmed")
     except:
         return None
Ejemplo n.º 3
0
 def get_commission(self, raw):
     if "commissionAsset" in raw:
         return Commission(
             raw,
             CoinAmount(
                 raw["commissionAsset"],
                 raw["commission"],
                 False
             ),
             self.get_date(raw),
             self.is_successful(raw)
         )
     return None
Ejemplo n.º 4
0
 def get_commission(self, raw):
     fee_coin, amount = self.get_fee(raw)
     return Commission(raw, CoinAmount(fee_coin, amount, False),
                       self.get_date(raw), self.is_successful(raw))