Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

j2py translation of 9.65 source

  • Loading branch information...
commit 8ee2aa98738e5fe5cc2dd42ad7af9b2abd4905a8 1 parent bd545e2
@blampe authored
View
19 ib/ext/ComboLeg.py
@@ -31,10 +31,11 @@ class ComboLeg(object):
m_openClose = 0
m_shortSaleSlot = 0
m_designatedLocation = ""
+ m_exemptCode = 0
@overloaded
def __init__(self):
- pass # super(ComboLeg, self).__init__(0, 0, None, None, 0, 0, None)
+ pass # super(ComboLeg, self).__init__(0, 0, None, None, 0, 0, None, -1)
@__init__.register(object, int, int, str, str, int)
def __init___0(self, p_conId,
@@ -42,7 +43,7 @@ def __init___0(self, p_conId,
p_action,
p_exchange,
p_openClose):
- pass # super(ComboLeg, self).__init__(p_conId, p_ratio, p_action, p_exchange, p_openClose, 0, None)
+ pass # super(ComboLeg, self).__init__(p_conId, p_ratio, p_action, p_exchange, p_openClose, 0, None, -1)
@__init__.register(object, int, int, str, str, int, int, str)
def __init___1(self, p_conId,
@@ -52,6 +53,17 @@ def __init___1(self, p_conId,
p_openClose,
p_shortSaleSlot,
p_designatedLocation):
+ pass # super(ComboLeg, self).__init__(p_conId, p_ratio, p_action, p_exchange, p_openClose, p_shortSaleSlot, p_designatedLocation, -1)
+
+ @__init__.register(object, int, int, str, str, int, int, str, int)
+ def __init___2(self, p_conId,
+ p_ratio,
+ p_action,
+ p_exchange,
+ p_openClose,
+ p_shortSaleSlot,
+ p_designatedLocation,
+ p_exemptCode):
self.m_conId = p_conId
self.m_ratio = p_ratio
self.m_action = p_action
@@ -59,6 +71,7 @@ def __init___1(self, p_conId,
self.m_openClose = p_openClose
self.m_shortSaleSlot = p_shortSaleSlot
self.m_designatedLocation = p_designatedLocation
+ self.m_exemptCode = p_exemptCode
def __eq__(self, p_other):
if self is p_other:
@@ -67,7 +80,7 @@ def __eq__(self, p_other):
if p_other is None:
return False
l_theOther = p_other
- if (self.m_conId != l_theOther.m_conId) or (self.m_ratio != l_theOther.m_ratio) or (self.m_openClose != l_theOther.m_openClose) or (self.m_shortSaleSlot != l_theOther.m_shortSaleSlot):
+ if (self.m_conId != l_theOther.m_conId) or (self.m_ratio != l_theOther.m_ratio) or (self.m_openClose != l_theOther.m_openClose) or (self.m_shortSaleSlot != l_theOther.m_shortSaleSlot) or (self.m_exemptCode != l_theOther.m_exemptCode):
return False
if (Util.StringCompareIgnCase(self.m_action, l_theOther.m_action) != 0) or (Util.StringCompareIgnCase(self.m_exchange, l_theOther.m_exchange) != 0) or (Util.StringCompareIgnCase(self.m_designatedLocation, l_theOther.m_designatedLocation) != 0):
return False
View
14 ib/ext/Contract.py
@@ -33,6 +33,8 @@ class Contract(Cloneable):
m_localSymbol = ""
m_primaryExch = ""
m_includeExpired = bool()
+ m_secIdType = ""
+ m_secId = ""
m_comboLegsDescrip = ""
m_comboLegs = None
m_underComp = None
@@ -49,7 +51,7 @@ def clone(self):
retval.m_comboLegs = self.m_comboLegs[:]
return retval
- @__init__.register(object, int, str, str, str, float, str, str, str, str, str, list, str, bool)
+ @__init__.register(object, int, str, str, str, float, str, str, str, str, str, list, str, bool, str, str)
def __init___0(self, p_conId,
p_symbol,
p_secType,
@@ -62,7 +64,9 @@ def __init___0(self, p_conId,
p_localSymbol,
p_comboLegs,
p_primaryExch,
- p_includeExpired):
+ p_includeExpired,
+ p_secIdType,
+ p_secId):
self.m_conId = p_conId
self.m_symbol = p_symbol
self.m_secType = p_secType
@@ -76,6 +80,8 @@ def __init___0(self, p_conId,
self.m_localSymbol = p_localSymbol
self.m_comboLegs = p_comboLegs
self.m_primaryExch = p_primaryExch
+ self.m_secIdType = p_secIdType
+ self.m_secId = p_secId
def __eq__(self, p_other):
if self is p_other:
@@ -94,6 +100,10 @@ def __eq__(self, p_other):
return False
if (Util.StringCompare(self.m_expiry, l_theOther.m_expiry) != 0) or (Util.StringCompare(self.m_right, l_theOther.m_right) != 0) or (Util.StringCompare(self.m_multiplier, l_theOther.m_multiplier) != 0) or (Util.StringCompare(self.m_localSymbol, l_theOther.m_localSymbol) != 0):
return False
+ if (Util.StringCompare(self.m_secIdType, l_theOther.m_secIdType) != 0):
+ return False
+ if (Util.StringCompare(self.m_secId, l_theOther.m_secId) != 0):
+ return False
if not Util.VectorEqualsUnordered(self.m_comboLegs, l_theOther.m_comboLegs):
return False
if (self.m_underComp != l_theOther.m_underComp):
View
25 ib/ext/ContractDetails.py
@@ -29,6 +29,13 @@ class ContractDetails(object):
m_validExchanges = ""
m_underConId = 0
m_longName = ""
+ m_contractMonth = ""
+ m_industry = ""
+ m_category = ""
+ m_subcategory = ""
+ m_timeZoneId = ""
+ m_tradingHours = ""
+ m_liquidHours = ""
m_cusip = ""
m_ratings = ""
m_descAppend = ""
@@ -51,7 +58,7 @@ def __init__(self):
self.m_minTick = 0
self.m_underConId = 0
- @__init__.register(object, Contract, str, str, float, str, str, int, str)
+ @__init__.register(object, Contract, str, str, float, str, str, int, str, str, str, str, str, str, str, str)
def __init___0(self, p_summary,
p_marketName,
p_tradingClass,
@@ -59,7 +66,14 @@ def __init___0(self, p_summary,
p_orderTypes,
p_validExchanges,
p_underConId,
- p_longName):
+ p_longName,
+ p_contractMonth,
+ p_industry,
+ p_category,
+ p_subcategory,
+ p_timeZoneId,
+ p_tradingHours,
+ p_liquidHours):
self.m_summary = p_summary
self.m_marketName = p_marketName
self.m_tradingClass = p_tradingClass
@@ -68,5 +82,12 @@ def __init___0(self, p_summary,
self.m_validExchanges = p_validExchanges
self.m_underConId = p_underConId
self.m_longName = p_longName
+ self.m_contractMonth = p_contractMonth
+ self.m_industry = p_industry
+ self.m_category = p_category
+ self.m_subcategory = p_subcategory
+ self.m_timeZoneId = p_timeZoneId
+ self.m_tradingHours = p_tradingHours
+ self.m_liquidHours = p_liquidHours
View
5 ib/ext/EClientErrors.py
@@ -65,6 +65,11 @@ def __init__(self, i, errString):
FAIL_SEND_REQCURRTIME = CodeMsgPair(531, "Request Current Time Sending Error - ")
FAIL_SEND_REQFUNDDATA = CodeMsgPair(532, "Request Fundamental Data Sending Error - ")
FAIL_SEND_CANFUNDDATA = CodeMsgPair(533, "Cancel Fundamental Data Sending Error - ")
+ FAIL_SEND_REQCALCIMPLIEDVOLAT = CodeMsgPair(534, "Request Calculate Implied Volatility Sending Error - ")
+ FAIL_SEND_REQCALCOPTIONPRICE = CodeMsgPair(535, "Request Calculate Option Price Sending Error - ")
+ FAIL_SEND_CANCALCIMPLIEDVOLAT = CodeMsgPair(536, "Cancel Calculate Implied Volatility Sending Error - ")
+ FAIL_SEND_CANCALCOPTIONPRICE = CodeMsgPair(537, "Cancel Calculate Option Price Sending Error - ")
+ FAIL_SEND_REQGLOBALCANCEL = CodeMsgPair(538, "Request Global Cancel Sending Error - ")
def __init__(self):
pass
View
178 ib/ext/EClientSocket.py
@@ -33,7 +33,7 @@ class EClientSocket(object):
""" generated source for EClientSocket
"""
- CLIENT_VERSION = 45
+ CLIENT_VERSION = 48
SERVER_VERSION = 38
EOL = 0
BAG_SEC_TYPE = "BAG"
@@ -81,6 +81,11 @@ def faMsgTypeName(cls, faDataType):
CANCEL_REAL_TIME_BARS = 51
REQ_FUNDAMENTAL_DATA = 52
CANCEL_FUNDAMENTAL_DATA = 53
+ REQ_CALC_IMPLIED_VOLAT = 54
+ REQ_CALC_OPTION_PRICE = 55
+ CANCEL_CALC_IMPLIED_VOLAT = 56
+ CANCEL_CALC_OPTION_PRICE = 57
+ REQ_GLOBAL_CANCEL = 58
MIN_SERVER_VER_REAL_TIME_BARS = 34
MIN_SERVER_VER_SCALE_ORDERS = 35
MIN_SERVER_VER_SNAPSHOT_MKT_DATA = 35
@@ -95,6 +100,16 @@ def faMsgTypeName(cls, faDataType):
MIN_SERVER_VER_ALGO_ORDERS = 41
MIN_SERVER_VER_EXECUTION_DATA_CHAIN = 42
MIN_SERVER_VER_NOT_HELD = 44
+ MIN_SERVER_VER_SEC_ID_TYPE = 45
+ MIN_SERVER_VER_PLACE_ORDER_CONID = 46
+ MIN_SERVER_VER_REQ_MKT_DATA_CONID = 47
+ MIN_SERVER_VER_REQ_CALC_IMPLIED_VOLAT = 49
+ MIN_SERVER_VER_REQ_CALC_OPTION_PRICE = 50
+ MIN_SERVER_VER_CANCEL_CALC_IMPLIED_VOLAT = 50
+ MIN_SERVER_VER_CANCEL_CALC_OPTION_PRICE = 50
+ MIN_SERVER_VER_SSHORTX_OLD = 51
+ MIN_SERVER_VER_SSHORTX = 52
+ MIN_SERVER_VER_REQ_GLOBAL_CANCEL = 53
m_anyWrapper = None
m_dos = None
m_connected = bool()
@@ -275,11 +290,17 @@ def reqMktData(self, tickerId, contract, genericTickList, snapshot):
if contract.m_underComp is not None:
self.error(tickerId, EClientErrors.UPDATE_TWS, " It does not support delta-neutral orders.")
return
- VERSION = 8
+ if self.m_serverVersion < self.MIN_SERVER_VER_REQ_MKT_DATA_CONID:
+ if contract.m_conId > 0:
+ self.error(tickerId, EClientErrors.UPDATE_TWS, " It does not support conId parameter.")
+ return
+ VERSION = 9
try:
self.send(self.REQ_MKT_DATA)
self.send(VERSION)
self.send(tickerId)
+ if self.m_serverVersion >= self.MIN_SERVER_VER_REQ_MKT_DATA_CONID:
+ self.send(contract.m_conId)
self.send(contract.m_symbol)
self.send(contract.m_secType)
self.send(contract.m_expiry)
@@ -459,7 +480,11 @@ def reqContractDetails(self, reqId, contract):
if self.m_serverVersion < 4:
self.error(EClientErrors.NO_VALID_ID, EClientErrors.UPDATE_TWS.code(), EClientErrors.UPDATE_TWS.msg())
return
- VERSION = 5
+ if self.m_serverVersion < self.MIN_SERVER_VER_SEC_ID_TYPE:
+ if not self.IsEmpty(contract.m_secIdType) or not self.IsEmpty(contract.m_secId):
+ self.error(reqId, EClientErrors.UPDATE_TWS, " It does not support secIdType and secId parameters.")
+ return
+ VERSION = 6
try:
self.send(self.REQ_CONTRACT_DATA)
self.send(VERSION)
@@ -479,6 +504,9 @@ def reqContractDetails(self, reqId, contract):
self.send(contract.m_localSymbol)
if self.m_serverVersion >= 31:
self.send(contract.m_includeExpired)
+ if self.m_serverVersion >= self.MIN_SERVER_VER_SEC_ID_TYPE:
+ self.send(contract.m_secIdType)
+ self.send(contract.m_secId)
except (Exception, ), e:
self.error(EClientErrors.NO_VALID_ID, EClientErrors.FAIL_SEND_REQCONTRACT, str(e))
self.close()
@@ -618,11 +646,36 @@ def placeOrder(self, id, contract, order):
if order.m_notHeld:
self.error(id, EClientErrors.UPDATE_TWS, " It does not support notHeld parameter.")
return
- VERSION = 27 if self.m_serverVersion < self.MIN_SERVER_VER_NOT_HELD else 28
+ if self.m_serverVersion < self.MIN_SERVER_VER_SEC_ID_TYPE:
+ if not self.IsEmpty(contract.m_secIdType) or not self.IsEmpty(contract.m_secId):
+ self.error(id, EClientErrors.UPDATE_TWS, " It does not support secIdType and secId parameters.")
+ return
+ if self.m_serverVersion < self.MIN_SERVER_VER_PLACE_ORDER_CONID:
+ if contract.m_conId > 0:
+ self.error(id, EClientErrors.UPDATE_TWS, " It does not support conId parameter.")
+ return
+ if self.m_serverVersion < self.MIN_SERVER_VER_SSHORTX:
+ if (order.m_exemptCode != -1):
+ self.error(id, EClientErrors.UPDATE_TWS, " It does not support exemptCode parameter.")
+ return
+ if self.m_serverVersion < self.MIN_SERVER_VER_SSHORTX:
+ if not contract.m_comboLegs.isEmpty():
+ comboLeg = ComboLeg()
+ ## for-while
+ i = 0
+ while i < len(contract.m_comboLegs):
+ comboLeg = contract.m_comboLegs[i]
+ if (comboLeg.m_exemptCode != -1):
+ self.error(id, EClientErrors.UPDATE_TWS, " It does not support exemptCode parameter.")
+ return
+ i += 1
+ VERSION = 27 if self.m_serverVersion < self.MIN_SERVER_VER_NOT_HELD else 31
try:
self.send(self.PLACE_ORDER)
self.send(VERSION)
self.send(id)
+ if self.m_serverVersion >= self.MIN_SERVER_VER_PLACE_ORDER_CONID:
+ self.send(contract.m_conId)
self.send(contract.m_symbol)
self.send(contract.m_secType)
self.send(contract.m_expiry)
@@ -636,6 +689,9 @@ def placeOrder(self, id, contract, order):
self.send(contract.m_currency)
if self.m_serverVersion >= 2:
self.send(contract.m_localSymbol)
+ if self.m_serverVersion >= self.MIN_SERVER_VER_SEC_ID_TYPE:
+ self.send(contract.m_secIdType)
+ self.send(contract.m_secId)
self.send(order.m_action)
self.send(order.m_totalQuantity)
self.send(order.m_orderType)
@@ -679,6 +735,8 @@ def placeOrder(self, id, contract, order):
if self.m_serverVersion >= self.MIN_SERVER_VER_SSHORT_COMBO_LEGS:
self.send(comboLeg.m_shortSaleSlot)
self.send(comboLeg.m_designatedLocation)
+ if self.m_serverVersion >= self.MIN_SERVER_VER_SSHORTX_OLD:
+ self.send(comboLeg.m_exemptCode)
i += 1
if self.m_serverVersion >= 9:
self.send("")
@@ -696,6 +754,8 @@ def placeOrder(self, id, contract, order):
if self.m_serverVersion >= 18:
self.send(order.m_shortSaleSlot)
self.send(order.m_designatedLocation)
+ if self.m_serverVersion >= self.MIN_SERVER_VER_SSHORTX_OLD:
+ self.send(order.m_exemptCode)
if self.m_serverVersion >= 19:
self.send(order.m_ocaType)
if self.m_serverVersion < 38:
@@ -1030,6 +1090,116 @@ def cancelFundamentalData(self, reqId):
self.error(reqId, EClientErrors.FAIL_SEND_CANFUNDDATA, str(e))
self.close()
+ @synchronized(mlock)
+ def calculateImpliedVolatility(self, reqId, contract, optionPrice, underPrice):
+ if not self.m_connected:
+ self.error(EClientErrors.NO_VALID_ID, EClientErrors.NOT_CONNECTED, "")
+ return
+ if self.m_serverVersion < self.MIN_SERVER_VER_REQ_CALC_IMPLIED_VOLAT:
+ self.error(reqId, EClientErrors.UPDATE_TWS, " It does not support calculate implied volatility requests.")
+ return
+ VERSION = 1
+ try:
+ self.send(self.REQ_CALC_IMPLIED_VOLAT)
+ self.send(VERSION)
+ self.send(reqId)
+ self.send(contract.m_conId)
+ self.send(contract.m_symbol)
+ self.send(contract.m_secType)
+ self.send(contract.m_expiry)
+ self.send(contract.m_strike)
+ self.send(contract.m_right)
+ self.send(contract.m_multiplier)
+ self.send(contract.m_exchange)
+ self.send(contract.m_primaryExch)
+ self.send(contract.m_currency)
+ self.send(contract.m_localSymbol)
+ self.send(optionPrice)
+ self.send(underPrice)
+ except (Exception, ), e:
+ self.error(reqId, EClientErrors.FAIL_SEND_REQCALCIMPLIEDVOLAT, str(e))
+ self.close()
+
+ @synchronized(mlock)
+ def cancelCalculateImpliedVolatility(self, reqId):
+ if not self.m_connected:
+ self.error(EClientErrors.NO_VALID_ID, EClientErrors.NOT_CONNECTED, "")
+ return
+ if self.m_serverVersion < self.MIN_SERVER_VER_CANCEL_CALC_IMPLIED_VOLAT:
+ self.error(reqId, EClientErrors.UPDATE_TWS, " It does not support calculate implied volatility cancellation.")
+ return
+ VERSION = 1
+ try:
+ self.send(self.CANCEL_CALC_IMPLIED_VOLAT)
+ self.send(VERSION)
+ self.send(reqId)
+ except (Exception, ), e:
+ self.error(reqId, EClientErrors.FAIL_SEND_CANCALCIMPLIEDVOLAT, str(e))
+ self.close()
+
+ @synchronized(mlock)
+ def calculateOptionPrice(self, reqId, contract, volatility, underPrice):
+ if not self.m_connected:
+ self.error(EClientErrors.NO_VALID_ID, EClientErrors.NOT_CONNECTED, "")
+ return
+ if self.m_serverVersion < self.MIN_SERVER_VER_REQ_CALC_OPTION_PRICE:
+ self.error(reqId, EClientErrors.UPDATE_TWS, " It does not support calculate option price requests.")
+ return
+ VERSION = 1
+ try:
+ self.send(self.REQ_CALC_OPTION_PRICE)
+ self.send(VERSION)
+ self.send(reqId)
+ self.send(contract.m_conId)
+ self.send(contract.m_symbol)
+ self.send(contract.m_secType)
+ self.send(contract.m_expiry)
+ self.send(contract.m_strike)
+ self.send(contract.m_right)
+ self.send(contract.m_multiplier)
+ self.send(contract.m_exchange)
+ self.send(contract.m_primaryExch)
+ self.send(contract.m_currency)
+ self.send(contract.m_localSymbol)
+ self.send(volatility)
+ self.send(underPrice)
+ except (Exception, ), e:
+ self.error(reqId, EClientErrors.FAIL_SEND_REQCALCOPTIONPRICE, str(e))
+ self.close()
+
+ @synchronized(mlock)
+ def cancelCalculateOptionPrice(self, reqId):
+ if not self.m_connected:
+ self.error(EClientErrors.NO_VALID_ID, EClientErrors.NOT_CONNECTED, "")
+ return
+ if self.m_serverVersion < self.MIN_SERVER_VER_CANCEL_CALC_OPTION_PRICE:
+ self.error(reqId, EClientErrors.UPDATE_TWS, " It does not support calculate option price cancellation.")
+ return
+ VERSION = 1
+ try:
+ self.send(self.CANCEL_CALC_OPTION_PRICE)
+ self.send(VERSION)
+ self.send(reqId)
+ except (Exception, ), e:
+ self.error(reqId, EClientErrors.FAIL_SEND_CANCALCOPTIONPRICE, str(e))
+ self.close()
+
+ @synchronized(mlock)
+ def reqGlobalCancel(self):
+ if not self.m_connected:
+ self.error(EClientErrors.NO_VALID_ID, EClientErrors.NOT_CONNECTED, "")
+ return
+ if self.m_serverVersion < self.MIN_SERVER_VER_REQ_GLOBAL_CANCEL:
+ self.error(EClientErrors.NO_VALID_ID, EClientErrors.UPDATE_TWS, " It does not support globalCancel requests.")
+ return
+ VERSION = 1
+ try:
+ self.send(self.REQ_GLOBAL_CANCEL)
+ self.send(VERSION)
+ except (Exception, ), e:
+ self.error(EClientErrors.NO_VALID_ID, EClientErrors.FAIL_SEND_REQGLOBALCANCEL, str(e))
+ self.close()
+
@overloaded
@synchronized(mlock)
def error(self, err):
View
46 ib/ext/EReader.py
@@ -138,14 +138,33 @@ def processMsg(self, msgId):
delta = self.readDouble()
if abs(delta) > 1:
delta = Double.MAX_VALUE
- modelPrice = float()
- pvDividend = float()
- if (tickType == TickType.MODEL_OPTION):
- modelPrice = self.readDouble()
+ optPrice = Double.MAX_VALUE
+ pvDividend = Double.MAX_VALUE
+ gamma = Double.MAX_VALUE
+ vega = Double.MAX_VALUE
+ theta = Double.MAX_VALUE
+ undPrice = Double.MAX_VALUE
+ if version >= 6 or (tickType == TickType.MODEL_OPTION):
+ optPrice = self.readDouble()
+ if optPrice < 0:
+ optPrice = Double.MAX_VALUE
pvDividend = self.readDouble()
- else:
- modelPrice = pvDividend = Double.MAX_VALUE
- self.eWrapper().tickOptionComputation(tickerId, tickType, impliedVol, delta, modelPrice, pvDividend)
+ if pvDividend < 0:
+ pvDividend = Double.MAX_VALUE
+ if version >= 6:
+ gamma = self.readDouble()
+ if abs(gamma) > 1:
+ gamma = Double.MAX_VALUE
+ vega = self.readDouble()
+ if abs(vega) > 1:
+ vega = Double.MAX_VALUE
+ theta = self.readDouble()
+ if abs(theta) > 1:
+ theta = Double.MAX_VALUE
+ undPrice = self.readDouble()
+ if undPrice < 0:
+ undPrice = Double.MAX_VALUE
+ self.eWrapper().tickOptionComputation(tickerId, tickType, impliedVol, delta, optPrice, pvDividend, gamma, vega, theta, undPrice)
elif msgId == self.TICK_GENERIC:
version = self.readInt()
tickerId = self.readInt()
@@ -302,6 +321,11 @@ def processMsg(self, msgId):
order.m_settlingFirm = self.readStr()
order.m_shortSaleSlot = self.readInt()
order.m_designatedLocation = self.readStr()
+ if (self.m_parent.serverVersion() == 51):
+ self.readInt()
+ else:
+ if version >= 23:
+ order.m_exemptCode = self.readInt()
order.m_auctionStrategy = self.readInt()
order.m_startingPrice = self.readDouble()
order.m_stockRefPrice = self.readDouble()
@@ -451,6 +475,14 @@ def processMsg(self, msgId):
if version >= 5:
contract.m_longName = self.readStr()
contract.m_summary.m_primaryExch = self.readStr()
+ if version >= 6:
+ contract.m_contractMonth = self.readStr()
+ contract.m_industry = self.readStr()
+ contract.m_category = self.readStr()
+ contract.m_subcategory = self.readStr()
+ contract.m_timeZoneId = self.readStr()
+ contract.m_tradingHours = self.readStr()
+ contract.m_liquidHours = self.readStr()
self.eWrapper().contractDetails(reqId, contract)
elif msgId == self.BOND_CONTRACT_DATA:
version = self.readInt()
View
8 ib/ext/EWrapper.py
@@ -30,8 +30,12 @@ def tickOptionComputation(self, tickerId,
field,
impliedVol,
delta,
- modelPrice,
- pvDividend):
+ optPrice,
+ pvDividend,
+ gamma,
+ vega,
+ theta,
+ undPrice):
raise NotImplementedError()
def tickGeneric(self, tickerId, tickType, value):
View
17 ib/ext/EWrapperMsgGenerator.py
@@ -36,12 +36,13 @@ def tickOptionComputation(cls, tickerId,
field,
impliedVol,
delta,
- modelPrice,
- pvDividend):
- toAdd = "id=" + tickerId + " " + TickType.getField(field) + ": vol = " + Double.toString(impliedVol) if impliedVol >= 0 and (impliedVol != Double.MAX_VALUE) else "N/A" + " delta = " + Double.toString(delta) if Math.abs(delta) <= 1 else "N/A"
- if (field == TickType.MODEL_OPTION):
- toAdd += ": modelPrice = " + Double.toString(modelPrice) if modelPrice >= 0 and (modelPrice != Double.MAX_VALUE) else "N/A"
- toAdd += ": pvDividend = " + Double.toString(pvDividend) if pvDividend >= 0 and (pvDividend != Double.MAX_VALUE) else "N/A"
+ optPrice,
+ pvDividend,
+ gamma,
+ vega,
+ theta,
+ undPrice):
+ toAdd = "id=" + tickerId + " " + TickType.getField(field) + ": vol = " + Double.toString(impliedVol) if impliedVol >= 0 and (impliedVol != Double.MAX_VALUE) else "N/A" + " delta = " + Double.toString(delta) if Math.abs(delta) <= 1 else "N/A" + " gamma = " + Double.toString(gamma) if Math.abs(gamma) <= 1 else "N/A" + " vega = " + Double.toString(vega) if Math.abs(vega) <= 1 else "N/A" + " theta = " + Double.toString(theta) if Math.abs(theta) <= 1 else "N/A" + " optPrice = " + Double.toString(optPrice) if optPrice >= 0 and (optPrice != Double.MAX_VALUE) else "N/A" + " pvDividend = " + Double.toString(pvDividend) if pvDividend >= 0 and (pvDividend != Double.MAX_VALUE) else "N/A" + " undPrice = " + Double.toString(undPrice) if undPrice >= 0 and (undPrice != Double.MAX_VALUE) else "N/A"
return toAdd
@classmethod
@@ -79,7 +80,7 @@ def orderStatus(cls, orderId,
@classmethod
def openOrder(cls, orderId, contract, order, orderState):
- msg = "open order: orderId=" + orderId + " action=" + order.m_action + " quantity=" + order.m_totalQuantity + " symbol=" + contract.m_symbol + " exchange=" + contract.m_exchange + " secType=" + contract.m_secType + " type=" + order.m_orderType + " lmtPrice=" + order.m_lmtPrice + " auxPrice=" + order.m_auxPrice + " TIF=" + order.m_tif + " localSymbol=" + contract.m_localSymbol + " client Id=" + order.m_clientId + " parent Id=" + order.m_parentId + " permId=" + order.m_permId + " outsideRth=" + order.m_outsideRth + " hidden=" + order.m_hidden + " discretionaryAmt=" + order.m_discretionaryAmt + " triggerMethod=" + order.m_triggerMethod + " goodAfterTime=" + order.m_goodAfterTime + " goodTillDate=" + order.m_goodTillDate + " faGroup=" + order.m_faGroup + " faMethod=" + order.m_faMethod + " faPercentage=" + order.m_faPercentage + " faProfile=" + order.m_faProfile + " shortSaleSlot=" + order.m_shortSaleSlot + " designatedLocation=" + order.m_designatedLocation + " ocaGroup=" + order.m_ocaGroup + " ocaType=" + order.m_ocaType + " rule80A=" + order.m_rule80A + " allOrNone=" + order.m_allOrNone + " minQty=" + order.m_minQty + " percentOffset=" + order.m_percentOffset + " eTradeOnly=" + order.m_eTradeOnly + " firmQuoteOnly=" + order.m_firmQuoteOnly + " nbboPriceCap=" + order.m_nbboPriceCap + " auctionStrategy=" + order.m_auctionStrategy + " startingPrice=" + order.m_startingPrice + " stockRefPrice=" + order.m_stockRefPrice + " delta=" + order.m_delta + " stockRangeLower=" + order.m_stockRangeLower + " stockRangeUpper=" + order.m_stockRangeUpper + " volatility=" + order.m_volatility + " volatilityType=" + order.m_volatilityType + " deltaNeutralOrderType=" + order.m_deltaNeutralOrderType + " deltaNeutralAuxPrice=" + order.m_deltaNeutralAuxPrice + " continuousUpdate=" + order.m_continuousUpdate + " referencePriceType=" + order.m_referencePriceType + " trailStopPrice=" + order.m_trailStopPrice + " scaleInitLevelSize=" + Util.IntMaxString(order.m_scaleInitLevelSize) + " scaleSubsLevelSize=" + Util.IntMaxString(order.m_scaleSubsLevelSize) + " scalePriceIncrement=" + Util.DoubleMaxString(order.m_scalePriceIncrement) + " account=" + order.m_account + " settlingFirm=" + order.m_settlingFirm + " clearingAccount=" + order.m_clearingAccount + " clearingIntent=" + order.m_clearingIntent + " notHeld=" + order.m_notHeld + " whatIf=" + order.m_whatIf
+ msg = "open order: orderId=" + orderId + " action=" + order.m_action + " quantity=" + order.m_totalQuantity + " symbol=" + contract.m_symbol + " exchange=" + contract.m_exchange + " secType=" + contract.m_secType + " type=" + order.m_orderType + " lmtPrice=" + order.m_lmtPrice + " auxPrice=" + order.m_auxPrice + " TIF=" + order.m_tif + " localSymbol=" + contract.m_localSymbol + " client Id=" + order.m_clientId + " parent Id=" + order.m_parentId + " permId=" + order.m_permId + " outsideRth=" + order.m_outsideRth + " hidden=" + order.m_hidden + " discretionaryAmt=" + order.m_discretionaryAmt + " triggerMethod=" + order.m_triggerMethod + " goodAfterTime=" + order.m_goodAfterTime + " goodTillDate=" + order.m_goodTillDate + " faGroup=" + order.m_faGroup + " faMethod=" + order.m_faMethod + " faPercentage=" + order.m_faPercentage + " faProfile=" + order.m_faProfile + " shortSaleSlot=" + order.m_shortSaleSlot + " designatedLocation=" + order.m_designatedLocation + " exemptCode=" + order.m_exemptCode + " ocaGroup=" + order.m_ocaGroup + " ocaType=" + order.m_ocaType + " rule80A=" + order.m_rule80A + " allOrNone=" + order.m_allOrNone + " minQty=" + order.m_minQty + " percentOffset=" + order.m_percentOffset + " eTradeOnly=" + order.m_eTradeOnly + " firmQuoteOnly=" + order.m_firmQuoteOnly + " nbboPriceCap=" + order.m_nbboPriceCap + " auctionStrategy=" + order.m_auctionStrategy + " startingPrice=" + order.m_startingPrice + " stockRefPrice=" + order.m_stockRefPrice + " delta=" + order.m_delta + " stockRangeLower=" + order.m_stockRangeLower + " stockRangeUpper=" + order.m_stockRangeUpper + " volatility=" + order.m_volatility + " volatilityType=" + order.m_volatilityType + " deltaNeutralOrderType=" + order.m_deltaNeutralOrderType + " deltaNeutralAuxPrice=" + order.m_deltaNeutralAuxPrice + " continuousUpdate=" + order.m_continuousUpdate + " referencePriceType=" + order.m_referencePriceType + " trailStopPrice=" + order.m_trailStopPrice + " scaleInitLevelSize=" + Util.IntMaxString(order.m_scaleInitLevelSize) + " scaleSubsLevelSize=" + Util.IntMaxString(order.m_scaleSubsLevelSize) + " scalePriceIncrement=" + Util.DoubleMaxString(order.m_scalePriceIncrement) + " account=" + order.m_account + " settlingFirm=" + order.m_settlingFirm + " clearingAccount=" + order.m_clearingAccount + " clearingIntent=" + order.m_clearingIntent + " notHeld=" + order.m_notHeld + " whatIf=" + order.m_whatIf
if "BAG" == contract.m_secType:
if contract.m_comboLegsDescrip is not None:
msg += " comboLegsDescrip=" + contract.m_comboLegsDescrip
@@ -146,7 +147,7 @@ def contractDetails(cls, reqId, contractDetails):
@classmethod
def contractDetailsMsg(cls, contractDetails):
- msg = "marketName = " + cls.contractDetails.m_marketName + "\n" + "tradingClass = " + cls.contractDetails.m_tradingClass + "\n" + "minTick = " + cls.contractDetails.m_minTick + "\n" + "price magnifier = " + cls.contractDetails.m_priceMagnifier + "\n" + "orderTypes = " + cls.contractDetails.m_orderTypes + "\n" + "validExchanges = " + cls.contractDetails.m_validExchanges + "\n" + "underConId = " + cls.contractDetails.m_underConId + "\n" + "longName = " + cls.contractDetails.m_longName + "\n"
+ msg = "marketName = " + cls.contractDetails.m_marketName + "\n" + "tradingClass = " + cls.contractDetails.m_tradingClass + "\n" + "minTick = " + cls.contractDetails.m_minTick + "\n" + "price magnifier = " + cls.contractDetails.m_priceMagnifier + "\n" + "orderTypes = " + cls.contractDetails.m_orderTypes + "\n" + "validExchanges = " + cls.contractDetails.m_validExchanges + "\n" + "underConId = " + cls.contractDetails.m_underConId + "\n" + "longName = " + cls.contractDetails.m_longName + "\n" + "contractMonth = " + cls.contractDetails.m_contractMonth + "\n" + "industry = " + cls.contractDetails.m_industry + "\n" + "category = " + cls.contractDetails.m_category + "\n" + "subcategory = " + cls.contractDetails.m_subcategory + "\n" + "timeZoneId = " + cls.contractDetails.m_timeZoneId + "\n" + "tradingHours = " + cls.contractDetails.m_tradingHours + "\n" + "liquidHours = " + cls.contractDetails.m_liquidHours + "\n"
return msg
@classmethod
View
1  ib/ext/Makefile
@@ -26,7 +26,6 @@ src:
$(modules):
j2py -i $(addprefix $(srcdir), $(addsuffix .java, $(basename $@))) -o $@ -c ib.ext.cfg -c ib.ext.cfg.$(basename $@)
-
modules-clean: clean-modules
clean-modules:
rm -rf $(modules)
View
4 ib/ext/Order.py
@@ -69,6 +69,7 @@ class Order(object):
m_origin = 0
m_shortSaleSlot = 0
m_designatedLocation = ""
+ m_exemptCode = 0
m_discretionaryAmt = float()
m_eTradeOnly = bool()
m_firmQuoteOnly = bool()
@@ -105,6 +106,7 @@ def __init__(self):
self.m_origin = self.CUSTOMER
self.m_transmit = True
self.m_designatedLocation = self.EMPTY_STR
+ self.m_exemptCode = -1
self.m_minQty = Integer.MAX_VALUE
self.m_percentOffset = Double.MAX_VALUE
self.m_nbboPriceCap = Double.MAX_VALUE
@@ -135,7 +137,7 @@ def __eq__(self, p_other):
l_theOther = p_other
if (self.m_permId == l_theOther.m_permId):
return True
- if (self.m_orderId != l_theOther.m_orderId) or (self.m_clientId != l_theOther.m_clientId) or (self.m_totalQuantity != l_theOther.m_totalQuantity) or (self.m_lmtPrice != l_theOther.m_lmtPrice) or (self.m_auxPrice != l_theOther.m_auxPrice) or (self.m_ocaType != l_theOther.m_ocaType) or (self.m_transmit != l_theOther.m_transmit) or (self.m_parentId != l_theOther.m_parentId) or (self.m_blockOrder != l_theOther.m_blockOrder) or (self.m_sweepToFill != l_theOther.m_sweepToFill) or (self.m_displaySize != l_theOther.m_displaySize) or (self.m_triggerMethod != l_theOther.m_triggerMethod) or (self.m_outsideRth != l_theOther.m_outsideRth) or (self.m_hidden != l_theOther.m_hidden) or (self.m_overridePercentageConstraints != l_theOther.m_overridePercentageConstraints) or (self.m_allOrNone != l_theOther.m_allOrNone) or (self.m_minQty != l_theOther.m_minQty) or (self.m_percentOffset != l_theOther.m_percentOffset) or (self.m_trailStopPrice != l_theOther.m_trailStopPrice) or (self.m_origin != l_theOther.m_origin) or (self.m_shortSaleSlot != l_theOther.m_shortSaleSlot) or (self.m_discretionaryAmt != l_theOther.m_discretionaryAmt) or (self.m_eTradeOnly != l_theOther.m_eTradeOnly) or (self.m_firmQuoteOnly != l_theOther.m_firmQuoteOnly) or (self.m_nbboPriceCap != l_theOther.m_nbboPriceCap) or (self.m_auctionStrategy != l_theOther.m_auctionStrategy) or (self.m_startingPrice != l_theOther.m_startingPrice) or (self.m_stockRefPrice != l_theOther.m_stockRefPrice) or (self.m_delta != l_theOther.m_delta) or (self.m_stockRangeLower != l_theOther.m_stockRangeLower) or (self.m_stockRangeUpper != l_theOther.m_stockRangeUpper) or (self.m_volatility != l_theOther.m_volatility) or (self.m_volatilityType != l_theOther.m_volatilityType) or (self.m_continuousUpdate != l_theOther.m_continuousUpdate) or (self.m_referencePriceType != l_theOther.m_referencePriceType) or (self.m_deltaNeutralAuxPrice != l_theOther.m_deltaNeutralAuxPrice) or (self.m_basisPoints != l_theOther.m_basisPoints) or (self.m_basisPointsType != l_theOther.m_basisPointsType) or (self.m_scaleInitLevelSize != l_theOther.m_scaleInitLevelSize) or (self.m_scaleSubsLevelSize != l_theOther.m_scaleSubsLevelSize) or (self.m_scalePriceIncrement != l_theOther.m_scalePriceIncrement) or (self.m_whatIf != l_theOther.m_whatIf) or (self.m_notHeld != l_theOther.m_notHeld):
+ if (self.m_orderId != l_theOther.m_orderId) or (self.m_clientId != l_theOther.m_clientId) or (self.m_totalQuantity != l_theOther.m_totalQuantity) or (self.m_lmtPrice != l_theOther.m_lmtPrice) or (self.m_auxPrice != l_theOther.m_auxPrice) or (self.m_ocaType != l_theOther.m_ocaType) or (self.m_transmit != l_theOther.m_transmit) or (self.m_parentId != l_theOther.m_parentId) or (self.m_blockOrder != l_theOther.m_blockOrder) or (self.m_sweepToFill != l_theOther.m_sweepToFill) or (self.m_displaySize != l_theOther.m_displaySize) or (self.m_triggerMethod != l_theOther.m_triggerMethod) or (self.m_outsideRth != l_theOther.m_outsideRth) or (self.m_hidden != l_theOther.m_hidden) or (self.m_overridePercentageConstraints != l_theOther.m_overridePercentageConstraints) or (self.m_allOrNone != l_theOther.m_allOrNone) or (self.m_minQty != l_theOther.m_minQty) or (self.m_percentOffset != l_theOther.m_percentOffset) or (self.m_trailStopPrice != l_theOther.m_trailStopPrice) or (self.m_origin != l_theOther.m_origin) or (self.m_shortSaleSlot != l_theOther.m_shortSaleSlot) or (self.m_discretionaryAmt != l_theOther.m_discretionaryAmt) or (self.m_eTradeOnly != l_theOther.m_eTradeOnly) or (self.m_firmQuoteOnly != l_theOther.m_firmQuoteOnly) or (self.m_nbboPriceCap != l_theOther.m_nbboPriceCap) or (self.m_auctionStrategy != l_theOther.m_auctionStrategy) or (self.m_startingPrice != l_theOther.m_startingPrice) or (self.m_stockRefPrice != l_theOther.m_stockRefPrice) or (self.m_delta != l_theOther.m_delta) or (self.m_stockRangeLower != l_theOther.m_stockRangeLower) or (self.m_stockRangeUpper != l_theOther.m_stockRangeUpper) or (self.m_volatility != l_theOther.m_volatility) or (self.m_volatilityType != l_theOther.m_volatilityType) or (self.m_continuousUpdate != l_theOther.m_continuousUpdate) or (self.m_referencePriceType != l_theOther.m_referencePriceType) or (self.m_deltaNeutralAuxPrice != l_theOther.m_deltaNeutralAuxPrice) or (self.m_basisPoints != l_theOther.m_basisPoints) or (self.m_basisPointsType != l_theOther.m_basisPointsType) or (self.m_scaleInitLevelSize != l_theOther.m_scaleInitLevelSize) or (self.m_scaleSubsLevelSize != l_theOther.m_scaleSubsLevelSize) or (self.m_scalePriceIncrement != l_theOther.m_scalePriceIncrement) or (self.m_whatIf != l_theOther.m_whatIf) or (self.m_notHeld != l_theOther.m_notHeld) or (self.m_exemptCode != l_theOther.m_exemptCode):
return False
if (Util.StringCompare(self.m_action, l_theOther.m_action) != 0) or (Util.StringCompare(self.m_orderType, l_theOther.m_orderType) != 0) or (Util.StringCompare(self.m_tif, l_theOther.m_tif) != 0) or (Util.StringCompare(self.m_ocaGroup, l_theOther.m_ocaGroup) != 0) or (Util.StringCompare(self.m_orderRef, l_theOther.m_orderRef) != 0) or (Util.StringCompare(self.m_goodAfterTime, l_theOther.m_goodAfterTime) != 0) or (Util.StringCompare(self.m_goodTillDate, l_theOther.m_goodTillDate) != 0) or (Util.StringCompare(self.m_rule80A, l_theOther.m_rule80A) != 0) or (Util.StringCompare(self.m_faGroup, l_theOther.m_faGroup) != 0) or (Util.StringCompare(self.m_faProfile, l_theOther.m_faProfile) != 0) or (Util.StringCompare(self.m_faMethod, l_theOther.m_faMethod) != 0) or (Util.StringCompare(self.m_faPercentage, l_theOther.m_faPercentage) != 0) or (Util.StringCompare(self.m_openClose, l_theOther.m_openClose) != 0) or (Util.StringCompare(self.m_designatedLocation, l_theOther.m_designatedLocation) != 0) or (Util.StringCompare(self.m_deltaNeutralOrderType, l_theOther.m_deltaNeutralOrderType) != 0) or (Util.StringCompare(self.m_account, l_theOther.m_account) != 0) or (Util.StringCompare(self.m_settlingFirm, l_theOther.m_settlingFirm) != 0) or (Util.StringCompare(self.m_clearingAccount, l_theOther.m_clearingAccount) != 0) or (Util.StringCompare(self.m_clearingIntent, l_theOther.m_clearingIntent) != 0) or (Util.StringCompare(self.m_algoStrategy, l_theOther.m_algoStrategy) != 0):
return False
View
27 ib/ext/TickType.py
@@ -67,6 +67,15 @@ class TickType(object):
SHORTABLE = 46
FUNDAMENTAL_RATIOS = 47
RT_VOLUME = 48
+ HALTED = 49
+ BID_YIELD = 50
+ ASK_YIELD = 51
+ LAST_YIELD = 52
+ CUST_OPTION_COMPUTATION = 53
+ TRADE_COUNT = 54
+ TRADE_RATE = 55
+ VOLUME_RATE = 56
+ LAST_RTH_TRADE = 57
@classmethod
def getField(cls, tickType):
@@ -168,6 +177,24 @@ def getField(cls, tickType):
return "fundamentals"
elif tickType == cls.RT_VOLUME:
return "RTVolume"
+ elif tickType == cls.HALTED:
+ return "halted"
+ elif tickType == cls.BID_YIELD:
+ return "bidYield"
+ elif tickType == cls.ASK_YIELD:
+ return "askYield"
+ elif tickType == cls.LAST_YIELD:
+ return "lastYield"
+ elif tickType == cls.CUST_OPTION_COMPUTATION:
+ return "custOptComp"
+ elif tickType == cls.TRADE_COUNT:
+ return "trades"
+ elif tickType == cls.TRADE_RATE:
+ return "trades/min"
+ elif tickType == cls.VOLUME_RATE:
+ return "volume/min"
+ elif tickType == cls.LAST_RTH_TRADE:
+ return "lastRTHTrade"
else:
return "unknown"
View
2  ib/ext/src/Makefile
@@ -1,4 +1,4 @@
-ibsources_jar := twsapi_unixmac.jar
+ibsources_jar := twsapi_unixmac_965.jar
ibsources_url := "http://www.interactivebrokers.com/download/$(ibsources_jar)"
Please sign in to comment.
Something went wrong with that request. Please try again.