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

Trading After Hours #32

Closed
grzesir opened this issue Apr 8, 2021 · 7 comments
Closed

Trading After Hours #32

grzesir opened this issue Apr 8, 2021 · 7 comments

Comments

@grzesir
Copy link
Contributor

grzesir commented Apr 8, 2021

How can we trade stocks after hours?

@SlimBeji
Copy link
Contributor

Can I have more details about what we want to achieve exactly? The first thing I think of is to use the lifecycle method after_market_closes but maybe we want a more complex behavior.

@neilsmurphy
Copy link
Contributor

This is an interesting point.

I'm wondering if an override in the is_market_open method would help where one could manually extend the hours of the day. This issue comes up a lot. When just using bars and time, trading times/restrictions can be added in manually. e.g. Client only wants to trade the LSE or afterhour coins.

This can come up too when clients just want to set the times they trade. I've had clients not want to have their algo trade during lunch.

@neilsmurphy
Copy link
Contributor

I wonder if we couldn't have an option for the user to create a parameter dictionary that would give hours (and maybe days) where trading is permitted or excluded. These could have labels for the keys. For example:

trading_hours = dict(
    late_start=dict(
        start=datetime.time(0, 0),
        end=datetime.time(9, 35),
        trading=False,
    ),
    lunch=dict(
        start=datetime.time(11, 45),
        end=datetime.time(13, 15),
        trading=False,
    )
)

We could then layer this logic over the is_market_open logic to determine market openness.

@grzesir
Copy link
Contributor Author

grzesir commented Apr 10, 2021 via email

@SlimBeji
Copy link
Contributor

@grzesir Is this matter specific to crypto trading or are there some stocks that can be traded outside opening hours.

@neilsmurphy I think it is possible to add the dictionary trading_hours you suggested to how the method StrategyExecutor._run_trading_session behave without too much trouble (Inside the while statement). We can also add a function to be executed in that time range.

@grzesir grzesir closed this as completed Feb 16, 2022
@dclong
Copy link

dclong commented Mar 14, 2024

Is this feature implemented? If so, any doc on it?

@grzesir
Copy link
Contributor Author

grzesir commented Mar 14, 2024 via email

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

4 participants