forked from robcarver17/ibswigsystematicexamples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test5_IB.py
71 lines (63 loc) · 2.04 KB
/
test5_IB.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
from sysIB.wrapper_v5 import IBWrapper, IBclient
from swigibpy import Contract as IBcontract
import time
from pprint import pprint
if __name__ == "__main__":
"""
Example of getting contract and account details
"""
callback = IBWrapper()
client = IBclient(callback)
ibcontract = IBcontract()
ibcontract.secType = "FUT"
ibcontract.symbol = "GBL"
ibcontract.exchange = "DTB"
# Get contract details
cdetails = client.get_contract_details(ibcontract)
# In particular we want the expiry. You cannot just use
# cdetails['expiry'][:6] to map back to the yyyymm expiry since certain
# contracts expire the month before they should!
pprint(cdetails)
# will look something like:
[{'contractMonth': '201612',
'currency': 'EUR',
'evMultiplier': 0.0,
'evRule': '',
'exchange': 'DTB',
'expiry': '20161208',
'liquidHours': '20160925:CLOSED;20160926:0800-2205',
'longName': 'Euro Bund (10 Year Bond)',
'minTick': 0.01,
'secType': 'FUT',
'symbol': 'GBL',
'timeZoneId': 'MET',
'tradingHours': '20160925:CLOSED;20160926:0800-2205',
'underConId': 11284196},
{'contractMonth': '201703',
'currency': 'EUR',
'evMultiplier': 0.0,
'evRule': '',
'exchange': 'DTB',
'expiry': '20170308',
'liquidHours': '20160925:CLOSED;20160926:0800-2205',
'longName': 'Euro Bund (10 Year Bond)',
'minTick': 0.01,
'secType': 'FUT',
'symbol': 'GBL',
'timeZoneId': 'MET',
'tradingHours': '20160925:CLOSED;20160926:0800-2205',
'underConId': 11284196},
{'contractMonth': '201706',
'currency': 'EUR',
'evMultiplier': 0.0,
'evRule': '',
'exchange': 'DTB',
'expiry': '20170608',
'liquidHours': '20160925:CLOSED;20160926:0800-2205',
'longName': 'Euro Bund (10 Year Bond)',
'minTick': 0.01,
'secType': 'FUT',
'symbol': 'GBL',
'timeZoneId': 'MET',
'tradingHours': '20160925:CLOSED;20160926:0800-2205',
'underConId': 11284196}]