ibapi-stable 10.37.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ibapi/__init__.py +16 -0
- ibapi/account_summary_tags.py +70 -0
- ibapi/client.py +4891 -0
- ibapi/client_utils.py +412 -0
- ibapi/comm.py +100 -0
- ibapi/commission_and_fees_report.py +31 -0
- ibapi/common.py +315 -0
- ibapi/connection.py +126 -0
- ibapi/const.py +12 -0
- ibapi/contract.py +265 -0
- ibapi/decoder.py +1711 -0
- ibapi/decoder_utils.py +420 -0
- ibapi/enum_implem.py +20 -0
- ibapi/errors.py +43 -0
- ibapi/execution.py +95 -0
- ibapi/ineligibility_reason.py +18 -0
- ibapi/message.py +186 -0
- ibapi/news.py +13 -0
- ibapi/object_implem.py +12 -0
- ibapi/order.py +263 -0
- ibapi/order_cancel.py +21 -0
- ibapi/order_condition.py +289 -0
- ibapi/order_state.py +117 -0
- ibapi/orderdecoder.py +539 -0
- ibapi/protobuf/CancelOrderRequest_pb2.py +38 -0
- ibapi/protobuf/ComboLeg_pb2.py +37 -0
- ibapi/protobuf/Contract_pb2.py +39 -0
- ibapi/protobuf/DeltaNeutralContract_pb2.py +37 -0
- ibapi/protobuf/ErrorMessage_pb2.py +37 -0
- ibapi/protobuf/ExecutionDetailsEnd_pb2.py +37 -0
- ibapi/protobuf/ExecutionDetails_pb2.py +39 -0
- ibapi/protobuf/ExecutionFilter_pb2.py +37 -0
- ibapi/protobuf/ExecutionRequest_pb2.py +38 -0
- ibapi/protobuf/Execution_pb2.py +37 -0
- ibapi/protobuf/GlobalCancelRequest_pb2.py +38 -0
- ibapi/protobuf/OpenOrder_pb2.py +40 -0
- ibapi/protobuf/OpenOrdersEnd_pb2.py +37 -0
- ibapi/protobuf/OrderAllocation_pb2.py +37 -0
- ibapi/protobuf/OrderCancel_pb2.py +37 -0
- ibapi/protobuf/OrderCondition_pb2.py +37 -0
- ibapi/protobuf/OrderState_pb2.py +38 -0
- ibapi/protobuf/OrderStatus_pb2.py +37 -0
- ibapi/protobuf/Order_pb2.py +51 -0
- ibapi/protobuf/PlaceOrderRequest_pb2.py +39 -0
- ibapi/protobuf/SoftDollarTier_pb2.py +37 -0
- ibapi/reader.py +49 -0
- ibapi/scanner.py +77 -0
- ibapi/server_versions.py +159 -0
- ibapi/softdollartier.py +16 -0
- ibapi/tag_value.py +22 -0
- ibapi/ticktype.py +117 -0
- ibapi/utils.py +233 -0
- ibapi/wrapper.py +885 -0
- ibapi_stable-10.37.2.dist-info/METADATA +136 -0
- ibapi_stable-10.37.2.dist-info/RECORD +57 -0
- ibapi_stable-10.37.2.dist-info/WHEEL +5 -0
- ibapi_stable-10.37.2.dist-info/top_level.txt +1 -0
ibapi/contract.py
ADDED
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Copyright (C) 2025 Interactive Brokers LLC. All rights reserved. This code is subject to the terms
|
|
3
|
+
and conditions of the IB API Non-Commercial License or the IB API Commercial License, as applicable.
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
from ibapi.object_implem import Object
|
|
7
|
+
from ibapi.const import UNSET_DECIMAL, UNSET_DOUBLE
|
|
8
|
+
|
|
9
|
+
from ibapi.utils import intMaxString
|
|
10
|
+
from ibapi.utils import floatMaxString
|
|
11
|
+
from ibapi.utils import decimalMaxString
|
|
12
|
+
from enum import Enum
|
|
13
|
+
|
|
14
|
+
"""
|
|
15
|
+
SAME_POS = open/close leg value is same as combo
|
|
16
|
+
OPEN_POS = open
|
|
17
|
+
CLOSE_POS = close
|
|
18
|
+
UNKNOWN_POS = unknown
|
|
19
|
+
"""
|
|
20
|
+
(SAME_POS, OPEN_POS, CLOSE_POS, UNKNOWN_POS) = range(4)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class ComboLeg(Object):
|
|
24
|
+
def __init__(self):
|
|
25
|
+
self.conId = 0 # type: int
|
|
26
|
+
self.ratio = 0 # type: int
|
|
27
|
+
self.action = "" # BUY/SELL/SHORT
|
|
28
|
+
self.exchange = ""
|
|
29
|
+
self.openClose = 0 # type: int # LegOpenClose enum values
|
|
30
|
+
# for stock legs when doing short sale
|
|
31
|
+
self.shortSaleSlot = 0
|
|
32
|
+
self.designatedLocation = ""
|
|
33
|
+
self.exemptCode = -1
|
|
34
|
+
|
|
35
|
+
def __str__(self):
|
|
36
|
+
return ",".join(
|
|
37
|
+
(
|
|
38
|
+
intMaxString(self.conId),
|
|
39
|
+
intMaxString(self.ratio),
|
|
40
|
+
str(self.action),
|
|
41
|
+
str(self.exchange),
|
|
42
|
+
intMaxString(self.openClose),
|
|
43
|
+
intMaxString(self.shortSaleSlot),
|
|
44
|
+
str(self.designatedLocation),
|
|
45
|
+
intMaxString(self.exemptCode),
|
|
46
|
+
)
|
|
47
|
+
)
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
class DeltaNeutralContract(Object):
|
|
51
|
+
def __init__(self):
|
|
52
|
+
self.conId = 0 # type: int
|
|
53
|
+
self.delta = 0.0 # type: float
|
|
54
|
+
self.price = 0.0 # type: float
|
|
55
|
+
|
|
56
|
+
def __str__(self):
|
|
57
|
+
return ",".join(
|
|
58
|
+
(str(self.conId), floatMaxString(self.delta), floatMaxString(self.price))
|
|
59
|
+
)
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
class Contract(Object):
|
|
63
|
+
def __init__(self):
|
|
64
|
+
self.conId = 0
|
|
65
|
+
self.symbol = ""
|
|
66
|
+
self.secType = ""
|
|
67
|
+
self.lastTradeDateOrContractMonth = ""
|
|
68
|
+
self.lastTradeDate = ""
|
|
69
|
+
self.strike = UNSET_DOUBLE # float !!
|
|
70
|
+
self.right = ""
|
|
71
|
+
self.multiplier = ""
|
|
72
|
+
self.exchange = ""
|
|
73
|
+
self.primaryExchange = "" # pick an actual (ie non-aggregate) exchange that the contract trades on.
|
|
74
|
+
# DO NOT SET TO SMART.
|
|
75
|
+
self.currency = ""
|
|
76
|
+
self.localSymbol = ""
|
|
77
|
+
self.tradingClass = ""
|
|
78
|
+
self.includeExpired = False
|
|
79
|
+
self.secIdType = "" # CUSIP;SEDOL;ISIN;RIC
|
|
80
|
+
self.secId = ""
|
|
81
|
+
self.description = ""
|
|
82
|
+
self.issuerId = ""
|
|
83
|
+
|
|
84
|
+
# combos
|
|
85
|
+
self.comboLegsDescrip = (
|
|
86
|
+
""
|
|
87
|
+
) # type: str #received in open order 14 and up for all combos
|
|
88
|
+
self.comboLegs = [] # type: list[ComboLeg]
|
|
89
|
+
self.deltaNeutralContract = None
|
|
90
|
+
|
|
91
|
+
def __str__(self):
|
|
92
|
+
s = (
|
|
93
|
+
"ConId: %s, Symbol: %s, SecType: %s, LastTradeDateOrContractMonth: %s, Strike: %s, Right: %s, Multiplier: %s, Exchange: %s, PrimaryExchange: %s, "
|
|
94
|
+
"Currency: %s, LocalSymbol: %s, TradingClass: %s, IncludeExpired: %s, SecIdType: %s, SecId: %s, Description: %s, "
|
|
95
|
+
"IssuerId: %s"
|
|
96
|
+
% (
|
|
97
|
+
intMaxString(self.conId),
|
|
98
|
+
str(self.symbol),
|
|
99
|
+
str(self.secType),
|
|
100
|
+
str(self.lastTradeDateOrContractMonth),
|
|
101
|
+
floatMaxString(self.strike),
|
|
102
|
+
str(self.right),
|
|
103
|
+
str(self.multiplier),
|
|
104
|
+
str(self.exchange),
|
|
105
|
+
str(self.primaryExchange),
|
|
106
|
+
str(self.currency),
|
|
107
|
+
str(self.localSymbol),
|
|
108
|
+
str(self.tradingClass),
|
|
109
|
+
str(self.includeExpired),
|
|
110
|
+
str(self.secIdType),
|
|
111
|
+
str(self.secId),
|
|
112
|
+
str(self.description),
|
|
113
|
+
str(self.issuerId),
|
|
114
|
+
)
|
|
115
|
+
)
|
|
116
|
+
s += "Combo:" + self.comboLegsDescrip
|
|
117
|
+
|
|
118
|
+
if self.comboLegs:
|
|
119
|
+
for leg in self.comboLegs:
|
|
120
|
+
s += ";" + str(leg)
|
|
121
|
+
|
|
122
|
+
if self.deltaNeutralContract:
|
|
123
|
+
s += ";" + str(self.deltaNeutralContract)
|
|
124
|
+
|
|
125
|
+
return s
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
class ContractDetails(Object):
|
|
129
|
+
def __init__(self):
|
|
130
|
+
self.contract = Contract()
|
|
131
|
+
self.marketName = ""
|
|
132
|
+
self.minTick = 0.0
|
|
133
|
+
self.orderTypes = ""
|
|
134
|
+
self.validExchanges = ""
|
|
135
|
+
self.priceMagnifier = 0
|
|
136
|
+
self.underConId = 0
|
|
137
|
+
self.longName = ""
|
|
138
|
+
self.contractMonth = ""
|
|
139
|
+
self.industry = ""
|
|
140
|
+
self.category = ""
|
|
141
|
+
self.subcategory = ""
|
|
142
|
+
self.timeZoneId = ""
|
|
143
|
+
self.tradingHours = ""
|
|
144
|
+
self.liquidHours = ""
|
|
145
|
+
self.evRule = ""
|
|
146
|
+
self.evMultiplier = 0
|
|
147
|
+
self.aggGroup = 0
|
|
148
|
+
self.underSymbol = ""
|
|
149
|
+
self.underSecType = ""
|
|
150
|
+
self.marketRuleIds = ""
|
|
151
|
+
self.secIdList = None
|
|
152
|
+
self.realExpirationDate = ""
|
|
153
|
+
self.lastTradeTime = ""
|
|
154
|
+
self.stockType = ""
|
|
155
|
+
self.minSize = UNSET_DECIMAL
|
|
156
|
+
self.sizeIncrement = UNSET_DECIMAL
|
|
157
|
+
self.suggestedSizeIncrement = UNSET_DECIMAL
|
|
158
|
+
# BOND values
|
|
159
|
+
self.cusip = ""
|
|
160
|
+
self.ratings = ""
|
|
161
|
+
self.descAppend = ""
|
|
162
|
+
self.bondType = ""
|
|
163
|
+
self.couponType = ""
|
|
164
|
+
self.callable = False
|
|
165
|
+
self.putable = False
|
|
166
|
+
self.coupon = 0
|
|
167
|
+
self.convertible = False
|
|
168
|
+
self.maturity = ""
|
|
169
|
+
self.issueDate = ""
|
|
170
|
+
self.nextOptionDate = ""
|
|
171
|
+
self.nextOptionType = ""
|
|
172
|
+
self.nextOptionPartial = False
|
|
173
|
+
self.notes = ""
|
|
174
|
+
# FUND values
|
|
175
|
+
self.fundName = ""
|
|
176
|
+
self.fundFamily = ""
|
|
177
|
+
self.fundType = ""
|
|
178
|
+
self.fundFrontLoad = ""
|
|
179
|
+
self.fundBackLoad = ""
|
|
180
|
+
self.fundBackLoadTimeInterval = ""
|
|
181
|
+
self.fundManagementFee = ""
|
|
182
|
+
self.fundClosed = False
|
|
183
|
+
self.fundClosedForNewInvestors = False
|
|
184
|
+
self.fundClosedForNewMoney = False
|
|
185
|
+
self.fundNotifyAmount = ""
|
|
186
|
+
self.fundMinimumInitialPurchase = ""
|
|
187
|
+
self.fundSubsequentMinimumPurchase = ""
|
|
188
|
+
self.fundBlueSkyStates = ""
|
|
189
|
+
self.fundBlueSkyTerritories = ""
|
|
190
|
+
self.fundDistributionPolicyIndicator = FundDistributionPolicyIndicator.NoneItem
|
|
191
|
+
self.fundAssetType = FundAssetType.NoneItem
|
|
192
|
+
self.ineligibilityReasonList = None
|
|
193
|
+
|
|
194
|
+
def __str__(self):
|
|
195
|
+
s = ",".join(
|
|
196
|
+
(
|
|
197
|
+
str(self.contract),
|
|
198
|
+
str(self.marketName),
|
|
199
|
+
floatMaxString(self.minTick),
|
|
200
|
+
str(self.orderTypes),
|
|
201
|
+
str(self.validExchanges),
|
|
202
|
+
intMaxString(self.priceMagnifier),
|
|
203
|
+
intMaxString(self.underConId),
|
|
204
|
+
str(self.longName),
|
|
205
|
+
str(self.contractMonth),
|
|
206
|
+
str(self.industry),
|
|
207
|
+
str(self.category),
|
|
208
|
+
str(self.subcategory),
|
|
209
|
+
str(self.timeZoneId),
|
|
210
|
+
str(self.tradingHours),
|
|
211
|
+
str(self.liquidHours),
|
|
212
|
+
str(self.evRule),
|
|
213
|
+
intMaxString(self.evMultiplier),
|
|
214
|
+
str(self.underSymbol),
|
|
215
|
+
str(self.underSecType),
|
|
216
|
+
str(self.marketRuleIds),
|
|
217
|
+
intMaxString(self.aggGroup),
|
|
218
|
+
str(self.secIdList),
|
|
219
|
+
str(self.realExpirationDate),
|
|
220
|
+
str(self.stockType),
|
|
221
|
+
str(self.cusip),
|
|
222
|
+
str(self.ratings),
|
|
223
|
+
str(self.descAppend),
|
|
224
|
+
str(self.bondType),
|
|
225
|
+
str(self.couponType),
|
|
226
|
+
str(self.callable),
|
|
227
|
+
str(self.putable),
|
|
228
|
+
str(self.coupon),
|
|
229
|
+
str(self.convertible),
|
|
230
|
+
str(self.maturity),
|
|
231
|
+
str(self.issueDate),
|
|
232
|
+
str(self.nextOptionDate),
|
|
233
|
+
str(self.nextOptionType),
|
|
234
|
+
str(self.nextOptionPartial),
|
|
235
|
+
str(self.notes),
|
|
236
|
+
decimalMaxString(self.minSize),
|
|
237
|
+
decimalMaxString(self.sizeIncrement),
|
|
238
|
+
decimalMaxString(self.suggestedSizeIncrement),
|
|
239
|
+
str(self.ineligibilityReasonList),
|
|
240
|
+
)
|
|
241
|
+
)
|
|
242
|
+
|
|
243
|
+
return s
|
|
244
|
+
|
|
245
|
+
|
|
246
|
+
class ContractDescription(Object):
|
|
247
|
+
def __init__(self):
|
|
248
|
+
self.contract = Contract()
|
|
249
|
+
self.derivativeSecTypes = [] # type: list[str]
|
|
250
|
+
|
|
251
|
+
class FundAssetType(Enum):
|
|
252
|
+
NoneItem = ("None", "None")
|
|
253
|
+
Others = ("000", "Others"),
|
|
254
|
+
MoneyMarket = ("001", "Money Market")
|
|
255
|
+
FixedIncome = ("002", "Fixed Income")
|
|
256
|
+
MultiAsset = ("003", "Multi-asset")
|
|
257
|
+
Equity = ("004", "Equity")
|
|
258
|
+
Sector = ("005", "Sector")
|
|
259
|
+
Guaranteed = ("006", "Guaranteed")
|
|
260
|
+
Alternative = ("007", "Alternative")
|
|
261
|
+
|
|
262
|
+
class FundDistributionPolicyIndicator(Enum):
|
|
263
|
+
NoneItem = ("None", "None")
|
|
264
|
+
AccumulationFund = ("N", "Accumulation Fund")
|
|
265
|
+
IncomeFund = ("Y", "Income Fund")
|