From 36d5020cd0d372102dd6e65c5d9ab347e131e145 Mon Sep 17 00:00:00 2001 From: Bryce Lampe Date: Sat, 24 Sep 2011 18:33:40 -0700 Subject: [PATCH] generate code passes pyflakes --- ib/ext/EClientSocket.py | 8 +++----- ib/ext/EReader.py | 6 ++++-- ib/ext/EWrapperMsgGenerator.py | 8 +++++--- ib/ext/TagValue.py | 1 + 4 files changed, 13 insertions(+), 10 deletions(-) diff --git a/ib/ext/EClientSocket.py b/ib/ext/EClientSocket.py index fe389bf..73ccf5b 100644 --- a/ib/ext/EClientSocket.py +++ b/ib/ext/EClientSocket.py @@ -15,7 +15,6 @@ from logging import debug -from ib.ext.AnyWrapper import AnyWrapper from ib.ext.ComboLeg import ComboLeg from ib.ext.EClientErrors import EClientErrors from ib.ext.EReader import EReader @@ -25,7 +24,6 @@ from ib.lib import synchronized, Socket, DataInputStream, DataOutputStream from ib.lib import Double, Integer -from socket import SHUT_RDWR from threading import RLock mlock = RLock() @@ -144,7 +142,7 @@ def eConnect(self, host, port, clientId): try: socket = Socket(host, port) self.eConnect(socket, clientId) - except (Exception, ), e: + except (Exception, ): self.eDisconnect() self.connectionError() @@ -197,12 +195,12 @@ def eDisconnect(self): try: if self.reader is not None: self.reader.interrupt() - except (Exception, ), e: + except (Exception, ): pass try: if dos is not None: dos.close() - except (Exception, ), e: + except (Exception, ): pass @synchronized(mlock) diff --git a/ib/ext/EReader.py b/ib/ext/EReader.py index b5291a6..41120f2 100644 --- a/ib/ext/EReader.py +++ b/ib/ext/EReader.py @@ -24,6 +24,8 @@ from ib.ext.TickType import TickType from ib.ext.UnderComp import UnderComp from ib.ext.Util import Util +from ib.ext.TagValue import TagValue +from ib.ext.EClientErrors import EClientErrors from ib.lib.logger import logger @@ -391,14 +393,14 @@ def processMsg(self, msgId): if not Util.StringIsEmpty(order.m_algoStrategy): algoParamsCount = self.readInt() if algoParamsCount > 0: - order.m_algoParams = Vector(algoParamsCount) + order.m_algoParams = list() ## for-while i = 0 while i < algoParamsCount: tagValue = TagValue() tagValue.m_tag = self.readStr() tagValue.m_value = self.readStr() - order.m_algoParams.add(tagValue) + order.m_algoParams.append(tagValue) i += 1 orderState = OrderState() if version >= 16: diff --git a/ib/ext/EWrapperMsgGenerator.py b/ib/ext/EWrapperMsgGenerator.py index 7329702..5ae0fec 100644 --- a/ib/ext/EWrapperMsgGenerator.py +++ b/ib/ext/EWrapperMsgGenerator.py @@ -15,6 +15,8 @@ from ib.ext.AnyWrapperMsgGenerator import AnyWrapperMsgGenerator from ib.ext.Util import Util +from ib.ext.TickType import TickType +from ib.ext.EClientSocket import EClientSocket class EWrapperMsgGenerator(AnyWrapperMsgGenerator): """ generated source for EWrapperMsgGenerator @@ -42,7 +44,7 @@ def tickOptionComputation(cls, tickerId, 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" + toAdd = "id=" + tickerId + " " + TickType.getField(field) + ": vol = " + (impliedVol if impliedVol >= 0 and (impliedVol != float('inf')) else "N/A") + " delta = " + (delta if abs(delta) <= 1 else "N/A") + " gamma = " + (gamma if abs(gamma) <= 1 else "N/A") + " vega = " + (vega if abs(vega) <= 1 else "N/A") + " theta = " + (theta if abs(theta) <= 1 else "N/A") + " optPrice = " + (optPrice if optPrice >= 0 and (optPrice != float('inf')) else "N/A") + " pvDividend = " + (pvDividend if pvDividend >= 0 and (pvDividend != float('inf')) else "N/A") + " undPrice = " + (undPrice if undPrice >= 0 and (undPrice != float('inf')) else "N/A") return toAdd @classmethod @@ -84,7 +86,7 @@ def openOrder(cls, orderId, contract, order, orderState): if "BAG" == contract.m_secType: if contract.m_comboLegsDescrip is not None: msg += " comboLegsDescrip=" + contract.m_comboLegsDescrip - if (order.m_basisPoints != Double.MAX_VALUE): + if (order.m_basisPoints != float('inf')): msg += " basisPoints=" + order.m_basisPoints msg += " basisPointsType=" + order.m_basisPointsType if contract.m_underComp is not None: @@ -251,7 +253,7 @@ def scannerDataEnd(cls, reqId): @classmethod def currentTime(cls, time): - return "current time = " + time + " (" + DateFormat.getDateTimeInstance().format(Date(time * 1000)) + ")" + return "current time = " + time @classmethod def fundamentalData(cls, reqId, data): diff --git a/ib/ext/TagValue.py b/ib/ext/TagValue.py index 2fddb6d..f80e0ec 100644 --- a/ib/ext/TagValue.py +++ b/ib/ext/TagValue.py @@ -14,6 +14,7 @@ # WARNING: all changes to this file will be lost. from ib.lib.overloading import overloaded +from ib.ext.Util import Util class TagValue(object): """ generated source for TagValue