Created
August 7, 2022 21:40
-
-
Save ugik/363a4a5649c016bd54d5c36bdb57a46c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# setup EMA indicator values | |
def setup_ema(): | |
ticksAgo = datetime.datetime.now() - timedelta(hours= 24) | |
candlesticks = client.get_historical_klines(EXCHANGE, Client.KLINE_INTERVAL_3MINUTE, str(ticksAgo)) | |
for candle in candlesticks: | |
del candle[-6:] | |
ema = pd.DataFrame(candlesticks, columns=['date', EXCHANGE+'_O', EXCHANGE+'_H', \ | |
EXCHANGE+'_L', EXCHANGE+'_C', EXCHANGE+'_V']) | |
ema['date'] = pd.to_datetime(sma['date'], unit='ms') | |
ema[EXCHANGE+'_O'] = ema[EXCHANGE+'_O'].astype(float) | |
ema[EXCHANGE+'_H'] = ema[EXCHANGE+'_H'].astype(float) | |
ema[EXCHANGE+'_L'] = ema[EXCHANGE+'_L'].astype(float) | |
ema[EXCHANGE+'_C'] = ema[EXCHANGE+'_C'].astype(float) | |
ema[EXCHANGE+'_V'] = ema[EXCHANGE+'_V'].astype(float) | |
# use 3-minute delta as API uses tick beginning time | |
ema['date'] = ema['date'] + pd.to_timedelta(3, unit='m') | |
ema = sma.set_index('date') | |
# add triple EMA | |
ema['EMA20'] = talib.EMA(ema[EXCHANGE+'_C'], timeperiod = 20) | |
ema['EMA50'] = talib.EMA(ema[EXCHANGE+'_C'], timeperiod = 50) | |
ema['EMA200'] = talib.EMA(ema[EXCHANGE+'_C'], timeperiod = 200) | |
return ema |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment