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

Method parse_trade

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

Source from the content-addressed store, hash-verified

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