rterp / SumZeroTrading

A Java API for Developing Automated Trading Applications for the Equity, Futures, and Currency Markets
http://rterp.github.io/SumZeroTrading/
Other
145 stars 47 forks source link

IB Order Events are modifying Ticker objects #42

Closed rterp closed 7 years ago

rterp commented 7 years ago

It appears IB Order Events are modifying ticker objects which is causing anything that uses ticker.equals() to return false after an order event is fired, when before the order event the equals() method would have returned true.

rterp commented 7 years ago

Ok, this issue has been fixed. The problem is that the Ticker object contains a NumberFormat, and was using this object in its equals() and hashcode() methods. When an order is placed, the order is serialized to a file for persistence. Apparently the process of serializing the NumberFormat changes its hashcode, thus changing the hashcode of the Ticker. I've removed the NumberFormat from the calculation of the Ticker object and it seems to be working now.