Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

How to close on session end #1290

Open
Open
@ironhak

Description

Hello!

Let's say I'm backtesting futures, and the session ends every day at 16:00 and it starts again at 17:00. What if I want to close a trade at session close?

I can't do like if self.data.df.index.time == "16:00": self.position.close() otherwise the closing order will be executed at next bar, that would be the first bar of the new session.

I know I could close at one bar prior to the close, but I specifically need to close the trade at closing price of 16:00 bar for reproducibility reasons with another platform.

Also I'm aware of trade_on_close, but I still need trades to be opened at next bar open.

Any idea? Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

        AltStyle によって変換されたページ (->オリジナル) /