Skip to content

Commit

Permalink
added examples/py/normalize-sparse-candle-timestamp.py fix #3034
Browse files Browse the repository at this point in the history
  • Loading branch information
kroitor committed Jun 5, 2018
1 parent 95fd1f6 commit 6a28acc
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions examples/py/normalize-sparse-candle-timestamps.py
@@ -0,0 +1,33 @@
# -*- coding: utf-8 -*-

import os
import sys
import datetime
from pprint import pprint

root = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
sys.path.append(root + '/python')

import ccxt # noqa: E402

exchange = ccxt.cryptopia({ 'enableRateLimit': True })

symbol = 'ETH/BTC'
timeframe = '1h'

candles = exchange.fetch_ohlcv(symbol, timeframe)

# timeframe duration in seconds
duration = exchange.parse_timeframe (timeframe)

# timeframe duration in milliseconds
duration *= 1000

pprint([[
exchange.iso8601 (int(round(candle[0] / duration)) * duration),
candle[1],
candle[2],
candle[3],
candle[4],
candle[5]
] for candle in candles])

0 comments on commit 6a28acc

Please sign in to comment.