-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathalts-short.py
executable file
·65 lines (52 loc) · 2.43 KB
/
alts-short.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/bin/python3
import ccxt, pandas, requests, os
def telegram_bot_sendtext(bot_message):
bot_token = os.environ.get('TELEGRAM_LIVERMORE')
chat_id = "@swinglivermore"
send_text = 'https://api.telegram.org/bot' + bot_token + '/sendMessage?chat_id=' + chat_id + '&parse_mode=html&text=' + bot_message
response = requests.get(send_text)
return response.json()
def get_klines(coin, interval):
pair = coin #+ "USDT"
tohlcv_colume = ['timestamp', 'open', 'high', 'low', 'close', 'volume']
return pandas.DataFrame(ccxt.bybit().fetch_ohlcv(pair, interval , limit=101), columns=tohlcv_colume)
def heikin_ashi(klines):
heikin_ashi_df = pandas.DataFrame(index=klines.index.values, columns=['open', 'high', 'low', 'close'])
heikin_ashi_df['close'] = (klines['open'] + klines['high'] + klines['low'] + klines['close']) / 4
for i in range(len(klines)):
if i == 0: heikin_ashi_df.iat[0, 0] = klines['open'].iloc[0]
else: heikin_ashi_df.iat[i, 0] = (heikin_ashi_df.iat[i-1, 0] + heikin_ashi_df.iat[i-1, 3]) / 2
heikin_ashi_df.insert(0,'timestamp', klines['timestamp'])
heikin_ashi_df['high'] = heikin_ashi_df.loc[:, ['open', 'close']].join(klines['high']).max(axis=1)
heikin_ashi_df['low'] = heikin_ashi_df.loc[:, ['open', 'close']].join(klines['low']).min(axis=1)
heikin_ashi_df["color"] = heikin_ashi_df.apply(color, axis=1)
heikin_ashi_df["body"] = abs(heikin_ashi_df['open'] - heikin_ashi_df['close'])
return heikin_ashi_df
def color(HA):
if HA['open'] < HA['close']: return "GREEN"
elif HA['open'] > HA['close']: return "RED"
else: return "INDECISIVE"
def fuck_alts(coin):
btc_direction = heikin_ashi(get_klines("BTCUSDT", "6h"))
btc_is_red = btc_direction['color'].iloc[-1] == "RED"
alt_direction = heikin_ashi(get_klines(coin, "6h"))
alt_dumping = alt_direction['low'].iloc[-1] < alt_direction['low'].iloc[-2]
if btc_is_red and alt_dumping:
print("💥 SHORT ALTS 💥 " + coin)
telegram_bot_sendtext("💥 SHORT ALTS 💥 " + coin)
return True
else:
print("🐺 WAIT 🐺 " + coin)
return False
altcoins = ["1000CATUSDT",
"GOATUSDT",
"RADUSDT",
"ETHUSDT"]
try:
while altcoins:
try:
for coin in altcoins[:]:
if fuck_alts(coin): altcoins.remove(coin)
except Exception as e: print(e)
except KeyboardInterrupt:
print("\n\nAborted.\n")