jeremyis78 / JBookTrader

A Java ATS for market-depth-based trading strategies
BSD 3-Clause "New" or "Revised" License
6 stars 6 forks source link

should JBookTrader use doubles for position/share sizes? #9

Open jeremyis78 opened 6 years ago

jeremyis78 commented 6 years ago

Since the project has been upgraded to use tws api 9.72 which supports fractional position sizes, I'm curious if there is a reason for JBookTrader to support fractional shares (com.jbooktrader.platform.position.OpenOrder::sharesFilled which will cause a ripple effect across the project). It seems the main thrust of JBookTrader has been to trade futures, however I'm curious how others are using it and whether adding double support would be beneficial.

Pros: Of course stock ownership could have fractional shares (e.g. DRIP), but are users of JBookTrader actually auto trading EXISTING positions of fractional shares?

Additionally, com.ib.client.Order::totalQuantity(double) takes a double meaning one can technically place an order for fractional shares; whether certain scenarios are accepted/rejected on the server side I don't know, e.g. placing an order to buy 1.5 contracts of ES. I don't trade Forex, but I hear those positions can be fractional: https://groups.io/g/twsapi/topic/4048205

Cons: We keep it simple and don't have to deal with the complexities of double comparisons (see https://github.com/jeremyis78/JBookTrader/blob/master/jbooktrader/src/main/java/com/jbooktrader/platform/position/PositionManager.java#L47). That may be enough to sway me but I'm asking others and how you use it:

Is there any valid reason for JBookTrader (an automated trading system) to support trading in fractional shares?