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

Enhancement: Add order_validity and trade_validity Parameters to buy and sell Methods #1169

Open
shajmanfaiz opened this issue Sep 3, 2024 · 0 comments

Comments

@shajmanfaiz
Copy link

shajmanfaiz commented Sep 3, 2024

Expected Behavior

I'd like to request an enhancement to the Backtesting.py library that introduces two new parameters, order_validity and trade_validity, to the buy and sell methods within the Strategy class. order_validity = 10 the order auto cacels after 10 bar after the order if not filled and trade_validity = 20 the trade auto cancels after 20 bar after the order is filled and if trade not already exited (by sl or tp)

Implementation example

def buy(
self, *, size=1, limit=100, sl=95, tp=110, order_validity=10, trade_validity=20
):
def sell(
self, *, size=1, limit=100, sl=105, tp=90, order_validity=10, trade_validity=20
):

Additional info

If anyone already has implemented or interested please comment down.

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