-
Notifications
You must be signed in to change notification settings - Fork 0
/
slack_app.py
48 lines (37 loc) · 1.73 KB
/
slack_app.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
import moonwatch_utils as moon
import time as t
from apscheduler.schedulers.background import BackgroundScheduler
from apscheduler.executors.pool import ThreadPoolExecutor
from apscheduler.triggers.cron import CronTrigger
executors = {
"default":ThreadPoolExecutor(max_workers=10)
}
def main():
# Uncomment to run tasks manually on re-deploy (aka testing in prod lol)
#postEODStatusUpdate('GME')
moon.updateHistoricalData('GME')
#postTrendImage('GME')
#moon.postGoodMorningMessage()
#moon.updateStonkxData('GME')
# Set up scheduler tasks
scheduler = BackgroundScheduler(executors=executors)
# Price update with uplifting emoji every half hour during trading hours
scheduler.add_job(moon.updateStonkxData, CronTrigger.from_crontab('*/30 * * * *'), args=["GME"])
# Update historical data & provide EOD summary after market close
scheduler.add_job(moon.updateHistoricalData, CronTrigger.from_crontab('2 20 * * *'), args=["GME"])
scheduler.add_job(moon.postEODStatusUpdate, CronTrigger.from_crontab('5 20 * * *'), args=["GME"])
# Post full trend and metrics at midday and market close
scheduler.add_job(moon.postTrendImage, CronTrigger.from_crontab('0 17 * * *'), args=["GME"])
scheduler.add_job(moon.postTrendImage, CronTrigger.from_crontab('5 20 * * *'), args=["GME"])
# GOOD MUORNEEENG!!!
scheduler.add_job(moon.postGoodMorningMessage, CronTrigger.from_crontab('25 13 * * *'), args=None)
# Let 'er rip
scheduler.start()
try:
# This is here to simulate application activity (which keeps the main thread alive).
while True:
t.sleep(2)
except (KeyboardInterrupt, SystemExit):
scheduler.shutdown()
if __name__ == "__main__":
main()