Back to Ccxt

Binance Ema

wiki/examples/py/binance-ema.md

4.5.52690 B
Original Source
python
# -*- coding: utf-8 -*-

import os
import sys
import pandas_ta as ta
import pandas as pd


import ccxt  # noqa: E402


print('CCXT Version:', ccxt.__version__)


def main():
   exchange = ccxt.binance()
   markets = exchange.load_markets()
   # exchange.verbose = True  # uncomment for debugging purposes
   ohlcv = exchange.fetch_ohlcv('BTC/USDT', '1m')
   if len(ohlcv):
       df = pd.DataFrame(ohlcv, columns=['timestamp', 'open', 'high', 'low', 'close', 'volume'])
       df['datetime'] = pd.to_datetime(df['timestamp'], unit='ms')
       ema = df.ta.ema()
       df = pd.concat([df, ema], axis=1)
       print(df)


main()