MCPcopy Create free account
hub / github.com/ccxt/ccxt / parse_trade

Method parse_trade

python/ccxt/async_support/bithumb.py:708–778  ·  view source on GitHub ↗
(self, trade: dict, market: Market = None)

Source from the content-addressed store, hash-verified

706 return self.parse_ohlcvs(data, market, timeframe, since, limit)
707
708 def parse_trade(self, trade: dict, market: Market = None) -> Trade:
709 #
710 # fetchTrades(public)
711 #
712 # {
713 # "transaction_date":"2020-04-23 22:21:46",
714 # "type":"ask",
715 # "units_traded":"0.0125",
716 # "price":"8667000",
717 # "total":"108337"
718 # }
719 #
720 # fetchOrder(private)
721 #
722 # {
723 # "transaction_date": "1572497603902030",
724 # "price": "8601000",
725 # "units": "0.005",
726 # "fee_currency": "KRW",
727 # "fee": "107.51",
728 # "total": "43005"
729 # }
730 #
731 # a workaround for their bug in date format, hours are not 0-padded
732 timestamp = None
733 transactionDatetime = self.safe_string(trade, 'transaction_date')
734 if transactionDatetime is not None:
735 parts = transactionDatetime.split(' ')
736 numParts = len(parts)
737 if numParts > 1:
738 transactionDate = parts[0]
739 transactionTime = parts[1]
740 if len(transactionTime) < 8:
741 transactionTime = '0' + transactionTime
742 timestamp = self.parse8601(transactionDate + ' ' + transactionTime)
743 else:
744 timestamp = self.safe_integer_product(trade, 'transaction_date', 0.001)
745 if timestamp is not None:
746 timestamp -= 9 * 3600000 # they report UTC + 9 hours, server in Korean timezone
747 type = None
748 side = self.safe_string(trade, 'type')
749 side = 'sell' if (side == 'ask') else 'buy'
750 id = self.safe_string(trade, 'cont_no')
751 market = self.safe_market(None, market)
752 priceString = self.safe_string(trade, 'price')
753 amountString = self.fix_comma_number(self.safe_string_2(trade, 'units_traded', 'units'))
754 costString = self.safe_string(trade, 'total')
755 fee = None
756 feeCostString = self.safe_string(trade, 'fee')
757 if feeCostString is not None:
758 feeCurrencyId = self.safe_string(trade, 'fee_currency')
759 feeCurrencyCode = self.common_currency_code(feeCurrencyId)
760 fee = {
761 'cost': feeCostString,
762 'currency': feeCurrencyCode,
763 }
764 return self.safe_trade({
765 'id': id,

Callers

nothing calls this directly

Calls 10

safe_marketMethod · 0.95
fix_comma_numberMethod · 0.95
safe_stringMethod · 0.80
splitMethod · 0.80
safe_integer_productMethod · 0.80
safe_string_2Method · 0.80
common_currency_codeMethod · 0.80
safe_tradeMethod · 0.80
parse8601Method · 0.45
iso8601Method · 0.45

Tested by

no test coverage detected