Skip to content

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

Closed as not planned
@shajmanfaiz

Description

@shajmanfaiz

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestwontfixThis will not be worked on

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions