wiki/examples/py/binance-fetch-ohlcv-closing-time-2.md
# -*- coding: utf-8 -*-
import os
import sys
import asciichart
import ccxt # noqa: E402
class MyBinance(ccxt.binance):
def parse_ohlcv(self, ohlcv, market=None):
#
# [
# 1591478520000,
# "0.02501300",
# "0.02501800",
# "0.02500000",
# "0.02500000",
# "22.19000000",
# 1591478579999,
# "0.55490906",
# 40,
# "10.92900000",
# "0.27336462",
# "0"
# ]
#
return [
self.safe_integer(ohlcv, 6),
self.safe_number(ohlcv, 1),
self.safe_number(ohlcv, 2),
self.safe_number(ohlcv, 3),
self.safe_number(ohlcv, 4),
self.safe_number(ohlcv, 5),
]
exchange = MyBinance()
symbol = 'BTC/USDT'
timeframe = '1h'
ohlcvs = exchange.fetch_ohlcv(symbol, timeframe)
for ohlcv in ohlcvs:
print([exchange.iso8601(ohlcv[0])] + ohlcv[1:])