-
Notifications
You must be signed in to change notification settings - Fork 1
/
test_case1.py
42 lines (33 loc) · 1.35 KB
/
test_case1.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
from historical_bars import TestApp
from historical_bars import SetupLogger
import logging
import argparse
SetupLogger()
logging.getLogger().setLevel(logging.ERROR)
cmdLineParser = argparse.ArgumentParser("api tests")
# cmdLineParser.add_option("-c", action="store_True", dest="use_cache", default = False, help = "use the cache")
# cmdLineParser.add_option("-f", action="store", type="string", dest="file", default="", help="the input file")
cmdLineParser.add_argument("-p", "--port", action="store", type=int,
dest="port", default=7497, help="The TCP port to use")
cmdLineParser.add_argument("-C", "--global-cancel", action="store_true",
dest="global_cancel", default=False,
help="whether to trigger a globalCancel req")
args = cmdLineParser.parse_args()
print("Using args", args)
logging.debug("Using args %s", args)
# print(args)
# tc = TestClient(None)
# tc.reqMktData(1101, ContractSamples.USStockAtSmart(), "", False, None)
# print(tc.reqId2nReq)
# sys.exit(1)
app = TestApp()
if args.global_cancel:
app.globalCancelOnly = True
# ! [connect]
app.connect("127.0.0.1", args.port, clientId=0)
# ! [connect]
print("serverVersion:%s connectionTime:%s" % (app.serverVersion(),
app.twsConnectionTime()))
# ! [clientrun]
app.run()
# ! [clientrun]