-
Notifications
You must be signed in to change notification settings - Fork 0
/
data_scheduler.py
99 lines (81 loc) · 3 KB
/
data_scheduler.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
from rq import Queue
import redis
from update_redis_ds import populate_redis_moneyflow_history, populate_redis_eod_today_raw, populate_redis_eod_today_yahoo
import time
import datetime
from apscheduler.schedulers.blocking import BlockingScheduler
from utils import util
import dateutil.parser
### Need to come up with better solutio########
#tickerList = util.getTickerListWithSPY()
#tickerList = util.getTickerList('SP-500')
#tickerList = util.getTickerList('FTSE-100')
#tickerList = util.getTickerList('HKG-100')
#tickerList = util.getTickerList('CBOE-ALL')
tickerList = ['AGN']
def get_redis_conn():
return util.get_redis_conn_nopool()
sched = BlockingScheduler()
#@sched.scheduled_job('interval', minutes=45)
#@sched.scheduled_job('date')
def timed_job():
print('This job is run immideately...')
# Tell RQ what Redis connection to use
redis_conn = util.get_redis_conn()
print('This job is run immideately...$$$$$$$$$$$$$')
q = Queue(connection=redis_conn) # no args implies the default queue
job = q.enqueue(populate_redis_eod_history, "EOD", tickerList)
print job.result # => None
time.sleep(600)
print job.result # => 889
#@sched.scheduled_job('date')
#@sched.scheduled_job('cron', day_of_week='mon-fri', hour=17)
def scheduled_job():
print('This job is run every weekday at 7pm.')
redis_conn = util.get_redis_conn()
q = Queue(connection=redis_conn)
job = q.enqueue(populate_redis_eod_today, "EOD", tickerList)
print job.result # => None
time.sleep(10)
print job.result # => 889
@sched.scheduled_job('date')
#@sched.scheduled_job('cron', day_of_week='mon-fri', hour=17)
def populate_moneyflow():
print('This job is to populate cashflow')
redis_conn = util.get_redis_conn()
q = Queue(connection=redis_conn, default_timeout=1500)
job = q.enqueue(populate_redis_moneyflow_history, tickerList)
print job.result # => None
time.sleep(10)
print job.result # => 889
#@sched.scheduled_job('date')
#@sched.scheduled_job('cron', day_of_week='mon-fri', hour=17)
def populate_rawEOD():
print('This job is run every weekday at 7pm.')
redis_conn = util.get_redis_conn()
q = Queue(connection=redis_conn)
job = q.enqueue(populate_redis_eod_today_raw, "EOD", tickerList)
print job.result # => None
time.sleep(10)
print job.result # => 889
#@sched.scheduled_job('date')
#@sched.scheduled_job('cron', day_of_week='mon-fri', hour=17)
def populate_rawEOD_GOOG():
print('This job is run every weekday at 7pm.')
redis_conn = util.get_redis_conn()
q = Queue(connection=redis_conn)
job = q.enqueue(populate_redis_eod_today_yahoo, "GOOG", tickerList)
print job.result # => None
time.sleep(10)
print job.result # => 889
#@sched.scheduled_job('date')
#@sched.scheduled_job('cron', day_of_week='mon-fri', hour=17)
def populate_rawEOD_YAHOO():
print('This job is run every weekday at 7pm.')
redis_conn = util.get_redis_conn()
q = Queue(connection=redis_conn)
job = q.enqueue(populate_redis_eod_today_yahoo, "YAHOO", tickerList)
print job.result # => None
time.sleep(10)
print job.result # => 889
sched.start()