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

"Extended hours and market hours mismatch." #453

Open
doctorcolossus opened this issue Dec 22, 2023 · 2 comments
Open

"Extended hours and market hours mismatch." #453

doctorcolossus opened this issue Dec 22, 2023 · 2 comments

Comments

@doctorcolossus
Copy link

doctorcolossus commented Dec 22, 2023

I am a new robin_stocks user, so apologies if I am missing something, but extended hours trading does not seem to work correctly for me. I am using robin_stocks 3.0.6.

It is currently 18:30 in NYC and the after-hours session is open.

The documentation for robin_stocks.robinhood.orders.order() notes: "Premium users only." I am a gold subscriber, and I am able to trade during extended hours and on the 24-hour market normally through the web application.

The documentation also says that extendedHours should be Optional[str]), and I tried both a string ("true") and a boolean (True).

However, both:

robin_stocks.robinhood.orders.order(symbol        = "DIS",
                                    quantity      = 1,
                                    side          = "buy",
                                    limitPrice    = 91.02,
                                    extendedHours = True)

... and:

robin_stocks.robinhood.orders.order(symbol        = "DIS",
                                    quantity      = 1,
                                    side          = "buy",
                                    limitPrice    = 91.02,
                                    extendedHours = "true")

... return:

{'non_field_errors': ['Extended hours and market hours mismatch.']}

... for me.

Am I doing something wrong, or is something broken?

I almost always select extended hours when placing orders normally through the web application, even during the standard market hours trading session, so that my targets can execute after the closing bell or in the pre-market session on subsequent days. So I don't understand this message and what needs to match. After all, it is extended hours now, so why shouldn't I be able to place an extended hours order now? 🧐

@doctorcolossus doctorcolossus changed the title extended hours: "Extended hours and market hours mismatch." Dec 22, 2023
@doctorcolossus
Copy link
Author

doctorcolossus commented Dec 23, 2023

Okay, I figured out what the issue is. The following works:

robin_stocks.robinhood.orders.order(symbol        = "DIS",
                                    quantity      = 1,
                                    side          = "buy",
                                    limitPrice    = 91.02,
                                    extendedHours = True,
                                    market_hours  = "extended_hours")

Namely, the market_hours argument must be set to "extended_hours". So this does indeed seem to be a bug. If the user passes extendedHours = True, then market_hours should be updated to correctly correspond. The market_hours argument doesn't seem to be documented at all yet, except in a comment on line 848 of robinhood/orders.py which says:
'market_hours': market_hours, # choices are ['regular_hours', 'all_day_hours']

It doesn't mention the option of "extended_hours" (which I found by inspecting XHR browser requests), or that this argument needs to be set to correspond with the extendedHours argument, and nothing about market_hours is included yet in the docstring.

@doctorcolossus
Copy link
Author

doctorcolossus commented Dec 23, 2023

pull request 454

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