forked from cameronhh/bybit-trading-bot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
43 lines (35 loc) · 1.47 KB
/
main.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
import logging
import time
from apscheduler.schedulers.blocking import BlockingScheduler
from bot import TradingBot
logging.basicConfig( level=logging.DEBUG, # TODO: work out how to do logging properly
format='%(asctime)s %(message)s',
filename='logs/main.log')
sched = BlockingScheduler({ # TODO separate this out into a config file
'apscheduler.executors.default': {
'class': 'apscheduler.executors.pool:ThreadPoolExecutor',
'max_workers': '20'
},
'apscheduler.executors.processpool': {
'type': 'processpool',
'max_workers': '5'
},
'apscheduler.job_defaults.coalesce': 'false',
'apscheduler.job_defaults.max_instances': '3',
'apscheduler.timezone': 'UTC',
})
logger = logging.getLogger("main")
TIME_PERIOD_SECS = 300
@sched.scheduled_job('cron', year='*', month='*', day='*', week='*', day_of_week='*', hour='*', minute='4,9,14,19,24,29,34,39,44,49,54,59', second='50')
def trade_job():
logger.debug(f"running trade job")
bot = TradingBot(test=True)
while int(time.time()) % TIME_PERIOD_SECS != 0:
pass
bot.worker()
# @sched.scheduled_job('cron', year='*', month='*', day='*', week='*', day_of_week='*', hour='0,2,4,6,8,10,12,14,16,18,20,22,', minute='0', second='0')
# def backtest_job():
# logger.debug(f"running backtest job at time: {time.gmtime()}")
# pipeline = WTPipeline(test=True, load_klines=True, validate=False)
# pipeline.run_pipeline()
sched.start()