Skip to content

Commit

Permalink
- fix message header on telegram notif
Browse files Browse the repository at this point in the history
- fix date format when showing in telegram notif
- edit some retun value from _signal
  • Loading branch information
wahyubiman committed Jul 2, 2022
1 parent a2e88e4 commit 2ada439
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
13 changes: 10 additions & 3 deletions app/notification/tele.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ async def send_notif(signals):
Return:
None """
LOG.info('Send notification via Telegram Bot')
msg_header = """----- Signal RSI cross above 42.5 or below 57.5 -----
msg_header = """----- Market Structure Break Alert 1H -----
"""
msg = """"""
Expand All @@ -25,8 +25,15 @@ async def send_notif(signals):
await bot.start(bot_token=os.getenv('TELE_BOT_TOKEN'))
entity = await bot.get_entity(TG_CHANNEL_NAME)
msg += msg_header
for signal in signals:
msg += "-> {} \n".format(signal)
for i in signals:
if i == 0:
msg += f"""MSB High Break :
"""
elif i == 1:
msg += f"""MSB Low Break :
"""
for signal in signals[i]:
msg += "-> {} \n".format(signal)
msg += f"""
>>> {str(pd.to_datetime(time.time(), unit='s').tz_localize('UTC').tz_convert('Asia/Jakarta').strftime('%m/%d/%Y %H:%M:%S'))}"""
await bot.send_message(entity, msg)
Expand Down
13 changes: 7 additions & 6 deletions app/strategy/indicator_alert.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,17 +63,18 @@ async def _signal(self, ohlcvs):

LOG.info('Calculating signal . . .')
try:
result = []
result_up = []
result_down = []
for ohlcv in ohlcvs:
last = ohlcv[-3:-2]
# check LONG or SHORT signal
if (last.break_h.values[0] == 1) & (last.ema_fast.values[0] < last.close.values[0]):
result.append(
f'{ohlcv.name} - MSB High Break on ${last.close.values[0]} @{last.timestamp.values[0]}')
result_up.append(
f'{ohlcv.name} - ${last.close.values[0]} on {last.timestamp[-1:].dt.strftime("%d/%m/%Y %H:%M:%S").astype(str)}')
elif (last.break_l.values[0] == 1) & (last.ema_fast.values[0] > last.close.values[0]):
result.append(
f'{ohlcv.name} - MSB Low Break on ${last.close.values[0]} @{last.timestamp.values[0]}')
return result
result_down.append(
f'{ohlcv.name} - ${last.close.values[0]} on {last.timestamp[-1:].dt.strftime("%d/%m/%Y %H:%M:%S").astype(str)}')
return [result_up, result_down]
except Exception as e:
LOG.exception(e)

Expand Down

0 comments on commit 2ada439

Please sign in to comment.