kdxing / ibpy

Automatically exported from code.google.com/p/ibpy
Other
0 stars 0 forks source link

Error handling itself raises a TypeError due to wrong # of arguments (overloading appears not to be working) #13

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
when i try to place an invalid order via placeOrder, IbPy attempts to send me 
an EClientErrors.FAIL_SEND_ORDER but fails; the attempt to send the error 
itself has an error.

i get:

error trace:

(parts of the error trace in my application code omitted except for this first 
bit at line 789:)

--> 789         self._ib.placeOrder(self._increment_nextValidOrderId, contract, 
order.makeIbOrder())
    790 
    791 

/usr/local/lib/python2.7/dist-packages/ib/opt/sender.pyc in wrapperMethod(*args)
     69             def wrapperMethod(*args):
     70                 self.dispatcher(name+'Before', dict(zip(before.__slots__, args)))
---> 71                 result = value(*args)
     72                 self.dispatcher(name+'After', dict(zip(after.__slots__, args)))
     73                 return result

/usr/local/lib/python2.7/dist-packages/ib/lib/__init__.pyc in inner(*args, 
**kwds)
     43             lock.acquire()
     44             try:
---> 45                 return func(*args, **kwds)
     46             finally:
     47                 lock.release()

/usr/local/lib/python2.7/dist-packages/ib/ext/EClientSocket.pyc in 
placeOrder(self, id, contract, order)
    775                 self.send(order.m_whatIf)
    776         except (Exception, ), e:
--> 777             self.error(id, EClientErrors.FAIL_SEND_ORDER, str(e))
    778             self.close()
    779 

/usr/local/lib/python2.7/dist-packages/ib/lib/overloading.pyc in __call__(self, 
*args)
     80         if func is None:
     81             self.cache[types] = func = self.find_func(types)
---> 82         return func(*args)
     83 
     84     def find_func(self, types):

/usr/local/lib/python2.7/dist-packages/ib/lib/__init__.pyc in inner(*args, 
**kwds)
     43             lock.acquire()
     44             try:
---> 45                 return func(*args, **kwds)
     46             finally:
     47                 lock.release()

TypeError: error() takes exactly 2 arguments (4 given)

Original issue reported on code.google.com by bshanks....@gmail.com on 22 Dec 2011 at 5:52

GoogleCodeExporter commented 8 years ago
one workaround appears to be to go to all of the times that error is called in  
EClientSocket.py within an "except" clause and replace each instance with
  self.close(); raise

i used interactive search and replace in vi: %s/self.error(/self.close(); 
raise; self.error(/gc

now an informative error trace is raised

Original comment by bshanks....@gmail.com on 22 Dec 2011 at 6:30