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

Method parse_timeframe

python/ccxt/base/exchange.py:1859–1878  ·  view source on GitHub ↗
(timeframe)

Source from the content-addressed store, hash-verified

1857
1858 @staticmethod
1859 def parse_timeframe(timeframe):
1860 amount = int(timeframe[0:-1])
1861 unit = timeframe[-1]
1862 if 'y' == unit:
1863 scale = 31536000 # 60 * 60 * 24 * 365
1864 elif 'M' == unit:
1865 scale = 2592000 # 60 * 60 * 24 * 30
1866 elif 'w' == unit:
1867 scale = 604800 # 60 * 60 * 24 * 7
1868 elif 'd' == unit:
1869 scale = 86400 # 60 * 60 * 24
1870 elif 'h' == unit:
1871 scale = 3600 # 60 * 60
1872 elif 'm' == unit:
1873 scale = 60
1874 elif 's' == unit:
1875 scale = 1
1876 else:
1877 raise NotSupported('timeframe unit {} is not supported'.format(unit))
1878 return amount * scale
1879
1880 @staticmethod
1881 def round_timeframe(timeframe, timestamp, direction=ROUND_DOWN):

Callers 15

test_parse_timeframeFunction · 0.95
build_ohlcvcMethod · 0.95
fetch_ohlcvMethod · 0.80
fetch_ohlcvMethod · 0.80
fetch_ohlcvMethod · 0.80
fetch_ohlcvMethod · 0.80
fetch_ohlcvMethod · 0.80
fetch_utaohlcvMethod · 0.80
fetch_spot_ohlcvMethod · 0.80

Calls 2

NotSupportedClass · 0.90
formatMethod · 0.45

Tested by 5

test_parse_timeframeFunction · 0.76
test_fetch_ohlcvFunction · 0.64
test_fetch_ohlcvFunction · 0.64
test_watch_ohlcvFunction · 0.64