Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't place bracket orders (stop-loss and take-profit) one after the other #257

Open
Tzion opened this issue Apr 2, 2024 · 1 comment
Open

Comments

@Tzion
Copy link

Tzion commented Apr 2, 2024

Description

Getting InvalidOrder Exception when trying to place bracket orders (stop-loss and take-profit) during backtesting of a strategy (paper trade)

blankly.utils.exceptions.InvalidOrder: Not enough base currency. Available: 0.0. hold: 1.0. requested: 1.0.

# Place orders
state.interface.market_order(symbol, side='buy', size=1)
state.interface.take_profit_order(symbol, size=1, price=take_profit)
state.interface.stop_loss_order(symbol, size=1, price=stop_loss)  # Getting the exception here

It happens due to the fact that the quantity is being held after take-profit order

settings.json

Paper account on Binance exchange
Using default settings

Error (if applicable)

> `blankly.utils.exceptions.InvalidOrder: Not enough base currency. Available: 0.0. hold: 1.0. requested: 1.0.` 

Platform Info

  • Python version: 3.10.13
  • Platform: mac-os Ventura 13.5.2 (22G91)
@Tzion
Copy link
Author

Tzion commented Apr 3, 2024

After some investigation I realize that this is the way Binance (and probably other crypto exchanges) works - by holding the fund after placing an order.
I've tried to do it on Paper exchange (exchange = PaperTrade(Binance())) hoping it will allow me send the orders, and yet the second one is invalid.

[(Maybe this issue should be tagged by feature request - support of OCO (one cancel other) orders]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant