You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi,
I want to backtest with order size of fixed amount (fixed_bet). Previous suggestion was to use fixed_bet/self.equity or fixed_bet/self.data.Close[-1]. Such sizes produce no trades and zero pnl.
I tried self.sell(size=0.05) or self.buy(size=0.5), but result is the same - zero.
After deep dive I think the problem is in class Broker where the size_float is converted into the size_int inside _process_orders.
size = order.size
if -1 < size < 1:
size = copysign(int((self.margin_available * self._leverage * abs(size))
// adjusted_price), size)
# Not enough cash/margin even for a single unit
if not size:
self.orders.remove(order)
continue
assert size == round(size)
need_size = int(size)
I am trading PERPETUALS, where BTC index price is around 100_000 USD today, but I can trade them at notional as small as 10 USD. I set initial cash at 1_000_000, so I have enough equity. Nothing helps. And the reason, I think, is above.
PS. After trades I am forced to re-scale all trades, which is inconvenient, because I have to rebuild statistics.
PPS. Yes, I have seen earlier issues and replies, but do not find then satisfactory.
For example, this solution produces zero order_size.
Hi,
I want to backtest with order size of fixed amount (fixed_bet). Previous suggestion was to use
fixed_bet/self.equity
orfixed_bet/self.data.Close[-1]
. Such sizes produce no trades and zero pnl.I tried
self.sell(size=0.05)
orself.buy(size=0.5)
, but result is the same - zero.After deep dive I think the problem is in
class Broker
where thesize_float
is converted into thesize_int
inside_process_orders
.I am trading PERPETUALS, where BTC index price is around 100_000 USD today, but I can trade them at notional as small as 10 USD. I set initial cash at 1_000_000, so I have enough equity. Nothing helps. And the reason, I think, is above.
PS. After trades I am forced to re-scale all trades, which is inconvenient, because I have to rebuild statistics.
PPS. Yes, I have seen earlier issues and replies, but do not find then satisfactory.
For example, this solution produces zero order_size.
Thanks.
The text was updated successfully, but these errors were encountered: