Hello,

 

I'm rounding my orders based on the target USD by using the formula:

target = 28 q = target / data[symbol].Close lot = self.Securities[symbol].SymbolProperties.LotSize lotSize = float(lot) quantity = lotSize * round(q / lotSize) order = self.MarketOrder(symbol, quantity, True))

This works fine paper trading and backtesting but when I livetrade with the Bitfinex I get the error that the quantity is nor a whole multiple of UnitQuantity

 

2021-05-14 15:45:29 New Order Event: Time: 05/14/2021 15:45:29 OrderID: 1 EventID: 1 Symbol: LTCUSD Status: Submitted Quantity: 0.05382936 Message: Bitfinex Order Event 2021-05-14 15:45:29 New Order Event: Time: 05/14/2021 15:45:29 OrderID: 1 EventID: 2 Symbol: LTCUSD Status: Filled Quantity: 0.05382936 FillQuantity: 0.0178164415728 FillPrice: 334.51 OrderFee: 0.0360129184272 USD Message: Bitfinex Order Event Buy 2021-05-14 15:45:32 Runtime Error: InvalidOperationException : Position.Quantity must be a whole number multiple of the UnitQuantity. at QuantConnect.Securities.Positions.Position..ctor(Symbol symbol, Decimal quantity, Decimal unitQuantity) in /LeanCloud/CI.Builder/bin/Debug/src/QuantConnect/Lean/Common/Securities/Positions/Position.cs:line 57 (...) /LeanCloud/CI.Builder/bin/Debug/src/QuantConnect/Lean/Algorithm/QCAlgorithm.Trading.cs:line 190 at OnData order = self.MarketOrder(symbol in main.py:line 330 2021-05-14 15:45:33 New order: LTCUSD quantity 0.05382936 lot 1e-08 price 352.56527

It seems the LotSize is 1e-8 and my Order is for 0.05382936 which match. I've tried rounding to 2 decimal places and 4 but same result everytime.

 

Can someone give a tip on how to round the position correctly? Should I be using Decimal instead of Float?

I don't need much precision on my Strategy but would like to keep it dynamic and not dependent on the symbol.

 

Thanks a lot!