-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_tiger.py
58 lines (41 loc) · 1.23 KB
/
test_tiger.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
import json
import utils_tiger
import pandas as pd
import time
import utils_common
with open('./tiger.json') as fin:
config = json.loads(fin.read())
pass
utils_tiger.set_config(config)
# symbols = utils_common.file2list('./symbols.txt')
# df: pd.DataFrame = utils_tiger.get_trade_ticks(
# ['SPY'], 20000, begin_index=None, end_index=None)
# print(df)
# df.to_csv('temp.csv', index=False)
push_client = utils_tiger.get_push_client(config)
quote_client = utils_tiger.get_quote_client(config)
class MyClass(object):
def on_quote_change(self, *args):
print(args)
pass
def on_quote_change(*args):
print(args)
def on_disconnect():
while True:
try:
push_client._connect()
break
except Exception as e:
print('error happend when connect')
pass
pass
pass
myobj = MyClass()
push_client.quote_changed = on_quote_change
push_client.disconnect_callback = on_disconnect
push_client.subscribe_quote(
['CLmain','SPY'], utils_tiger.tiger_consts.QuoteKeyType.ALL)
time.sleep(60)
push_client.unsubscribe_quote(['SPY', 'UGAZ','CLmain','NGmain'])
push_client.disconnect()
#print(utils_tiger.get_bars_minute_dt(quote_client, ['UGAZ'], '2020-03-19'))