-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy path__mainbot__.py
72 lines (56 loc) · 2.31 KB
/
__mainbot__.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
66
67
68
69
70
71
72
from apscheduler.schedulers.asyncio import AsyncIOScheduler
from OnlineBot.MACD import bot as MACDBOT
from OnlineBot.StochAstic import bot as StochAsticBOT
from OnlineBot.RSI import bot as RSIBOT
import threading
import schedule
import time
try:
import asyncio
except ImportError:
import trollius as asyncio
scheduler_trader_macd_div = AsyncIOScheduler()
scheduler_trader_stochastic_div = AsyncIOScheduler()
scheduler_trader_rsi_div = AsyncIOScheduler()
scheduler_news = AsyncIOScheduler()
account_name = 'mehrshadpc'
symbol = 'XAUUSD_i'
def trader_macd_div_threaded():
job_thread = threading.Thread(target=MACDBOT.Run, args = [symbol, account_name])
job_thread.start()
job_thread.join()
def trader_stochastic_div_threaded():
job_thread = threading.Thread(target=StochAsticBOT.Run, args = [symbol, account_name])
job_thread.start()
job_thread.join()
def trader_rsi_div_threaded():
job_thread = threading.Thread(target=RSIBOT.Run, args = [symbol, account_name])
job_thread.start()
job_thread.join()
def news_threaded():
job_thread = threading.Thread(target=news_task)
job_thread.start()
job_thread.join()
def Run():
# Schedules the job_function to be executed Monday through Friday at between 12-16 at specific times.
minute_trader = '0,5,10,15,20,25,30,35,40,45,50,55'
days = 'sat,sun,mon,tue,wed,thu,fri'
minute_news = '10'
hour_news = '00,12'
trader_macd_div_threaded()
trader_rsi_div_threaded()
trader_stochastic_div_threaded()
scheduler_trader_macd_div.add_job(func=trader_macd_div_threaded, trigger='cron', day_of_week=days, hour='00-23', minute=minute_trader, timezone='UTC')
scheduler_trader_stochastic_div.add_job(func=trader_stochastic_div_threaded, trigger='cron', day_of_week=days, hour='00-23', minute=minute_trader, timezone='UTC')
scheduler_trader_rsi_div.add_job(func=trader_rsi_div_threaded, trigger='cron', day_of_week=days, hour='00-23', minute=minute_trader, timezone='UTC')
scheduler_news.add_job(func=news_threaded, trigger='cron', day_of_week='mon-fri', hour=hour_news, minute=minute_news, timezone='UTC')
# Start the scheduler
scheduler_trader_macd_div.start()
scheduler_trader_stochastic_div.start()
scheduler_trader_rsi_div.start()
scheduler_news.start()
try:
asyncio.get_event_loop().run_forever()
except (KeyboardInterrupt, SystemExit):
pass
Run()