Repository navigation
Expand file tree
/
Copy pathmain.py
More file actions
55 lines (39 loc) · 1.29 KB
/
Copy pathmain.py
File metadata and controls
55 lines (39 loc) · 1.29 KB
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
"""
This file sends messages to a Telegram Bot if an alert has been triggered.
Author: Zetra
Date : 2023-07-17
"""
import ast
<
5B46
div>
import logging
import os
import schedule
import time
from dotenv import dotenv_values
# Own modules
from alerts.fibonacci import fibonacci_breakout
from alerts.chart_patterns import alerts_chart_patterns
# Grab the .env file according to OS
if "/home/ubuntu" == os.path.abspath(''):
config = dotenv_values(os.path.join("/var/zetralert/zetralerts/",".env"))
else:
config = dotenv_values(os.path.join(os.path.abspath(''),".env"))
# Set the logger
logging.basicConfig(filename='zetralerts.log', filemode='w', format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', level=logging.INFO)
# Get the env variables
LIVE = ast.literal_eval(config["LIVE"])
ALERT = int(config["ALERT"])
def check_trigger():
"""
Check any of the below have been triggered
"""
# All the alerts
funcs = [fibonacci_breakout, alerts_chart_patterns]
for fn in funcs:
resp = fn("EURUSD", "15min", LIVE=LIVE)
if not resp:
logging.info("Just checked trigger and no alert.")
if __name__ == "__main__":
schedule.every(ALERT).minute.do(check_trigger)
while True:
schedule.run_pending()
time.sleep(1)