-
Notifications
You must be signed in to change notification settings - Fork 1
/
RunTransFetchJob.py
74 lines (57 loc) · 2.29 KB
/
RunTransFetchJob.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
__author__ = 'chengye'
from TransJob import insertTrans, getTransFromUrl
from DepthJob import insertDepth, getDepthFromUrl
import TransJob
import DepthJob
import time
from pymongo import MongoClient
import sys, os
import schedule
import logging
logging.basicConfig(filename = os.path.join(os.getcwd(), 'RunTransFetchJob.log'), level = logging.INFO)
logging.info("Connect to mongodb at " + sys.argv[1])
client = MongoClient(sys.argv[1])
db = client.trans
db2 = client.depths
def MTGOXJob():
n = insertTrans(getTransFromUrl(TransJob.URL_MTGOX), db.mtgoxbtcusd, "mtgoxbtcusd")
logging.info("MTGOXJob " + ", new transaction: " + str(n))
def BTCCHINAJob():
n = insertTrans(getTransFromUrl(TransJob.URL_BTCCHINA), db.btcchinabtccny, "btcchinabtccny")
logging.info("BTCCHINAJob " + ", new transaction: " + str(n))
def BTECJob():
n = insertTrans(getTransFromUrl(TransJob.URL_BTCE), db.btcebtcusd, "btcebtcusd")
logging.info("BTECJob " + ", new transaction: " + str(n))
def OKCOINJob():
n = insertTrans(getTransFromUrl(TransJob.URL_OKCOIN), db.okcoinbtccny, "okcoinbtccny")
logging.info("OKCOINJob " + ", new transaction: " + str(n))
def OKCOINLTCJob():
n = insertTrans(getTransFromUrl(TransJob.URL_OKCOIN_LTC), db.okcoinltccny, "okcoinltccny")
logging.info("OKCOINLTCJob " + ", new transaction: " + str(n))
def FXBTCJob():
n = insertTrans(getTransFromUrl(TransJob.URL_FXBTC), db.fxbtccny, "fxbtccny")
logging.info("FXBTCJob " + ", new transaction: " + str(n))
def CNBTCJob():
n = insertTrans(getTransFromUrl(TransJob.URL_CNBTC), db.cnbtc, "cnbtc")
logging.info("CNBTC " + ", new transaction: " + str(n))
def CNBTC_DEPTH_JOB():
f = insertDepth(getDepthFromUrl(DepthJob.URL_CNBTC), db2.cnbtc)
if f:
logging.info("CNBTC " + ", new depth get")
def HUOBIJob():
n = insertTrans(getTransFromUrl(TransJob.URL_HUOBI), db.huobi, "huobi")
logging.info("HUOBI " + ", new transaction: " + str(n))
#schedule.every(5).seconds.do(MTGOXJob)
#time.sleep(1)
schedule.every(5).seconds.do(BTCCHINAJob)
time.sleep(1)
#schedule.every(5).seconds.do(BTECJob)
#time.sleep(1)
schedule.every(5).seconds.do(CNBTCJob)
time.sleep(1)
schedule.every(5).seconds.do(CNBTC_DEPTH_JOB)
time.sleep(1)
schedule.every(5).seconds.do(HUOBIJob)
while True:
schedule.run_pending()
time.sleep(1)