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
Feature: Proceed exit while having open order, for backtesting and live #10062
base: develop
Are you sure you want to change the base?
Feature: Proceed exit while having open order, for backtesting and live #10062
Conversation
assert trade | ||
|
||
print(f'trade.liquidation_price: {trade.liquidation_price}') | ||
# TODO QUESTION Why leverage stay at 1.0 ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@xmatthias could you provide me the proper way to edit leverage and stoploss in order to create the test scenario properly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
your test runs on spot markets (the default for default_conf
).
Futures markets are "opt in" ... so you need to re-set trading_mode to futures for leverage to not be ignored.
I'd also use default_conf_usdt
for new tests ... doing tests with BTC feels a bit awkward if you consider it's volatility (most older tests assume a price of 10-15k - which nowadays seems odd) - i always found that to help with trying to do the calculations manually to ensure the test actually makes sense.
# TODO This should FAIL curently as exits is not triggered if trade.has_open_orders | ||
assert res | ||
assert res.exit_reason == ExitType.STOP_LOSS.value | ||
assert sl_order.status == 'closed' # TODO why the stoploss order is not filled ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@xmatthias I must validate that the SL order is properly filled when there is no open entry or exit order, but the SL order is not filled in that case
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think your approach is a bit off if i'm honest.
you're calling backtesting internals (_check_trade_exit()
is not supposed to close the order) - but expect things that happen in other parts of backtesting to also happen.
You CAN make these happen - but it'll not happen automatically if you call partials.
The above called method is just checking, and eventually creating an order.
Handling of the actual order handles after this call - directly in backtest_loop()
.
That'll handle both orders that were created in this iteration - as well as orders that are there from previous candles and didn't fill yet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great thank you for the clarification
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So from what I understand I must do a test strategy that is closer to "test_backtest_one" using "UNITTEST_BTC" data, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"probably" yes ...
9dd125f
to
7dd5648
Compare
7dd5648
to
faeda2a
Compare
Summary
Solve the issue: #9760
Quick changelog
What's new?
This PR aim to allow trade to exit properly while having open order, on backtest and live