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

order_buy_limit extended hours "Ensure that there are no more than 8 digits before the decimal point." #435

Open
justindavies opened this issue Sep 8, 2023 · 5 comments

Comments

@justindavies
Copy link

Love the library first off. I usually place fractional shares during market hours, but have been experimenting with extended hours trading with full shares.

When I try this (when it's extended trading):

ret = r.order_buy_limit(account_number="XXXXXX", symbol="BBCP", quantity=1, timeInForce='gfd', limitPrice="8.42000000", extendedHours=True)

I get the following error:

{'price': ['Ensure that there are no more than 8 digits before the decimal point.']}

If I do the same trade using the web, it all goes through fine. The price I used was the same that was in the payload on the web just to confirm, so I'm not sure what I'm doing wrong here.

Thanks!

@joeld1
Copy link

joeld1 commented Sep 10, 2023

@justindavies I think this might be related to #429 ,

When you call

r.order_buy_limit

which has a signature of:

order_buy_limit(symbol, quantity, limitPrice, account_number=None, timeInForce='gtc', extendedHours=False, jsonify=True)

That method calls

order(symbol, quantity, "buy", account_number, limitPrice, None, timeInForce, extendedHours, jsonify)

When your parameters are passed in, the resulting call is

order("BBCP", 1, "buy", "XXXXXX", "8.42000000", None, 'gfd', True, True)

The original signature for the order method is

order(symbol, quantity, side, limitPrice=None, stopPrice=None, account_number=None, timeInForce='gtc', extendedHours=False, jsonify=True, market_hours='regular_hours')

When your parameters are passed in according to position, you get:

order(symbol="BBCP", quantity=1, side="buy", limitPrice="XXXXXX", stopPrice="8.42000000", account_number=None, timeInForce='gfd', extendedHours=True, jsonify=True, market_hours='regular_hours')

The order method calls

round_price(limitPrice)

which in your case is

round_price("XXXXXX")

...

@justindavies I think that's what's causing your error. In order to avoid it, I would probably just use the order method and explicitly pass in your parameters while defining side = 'buy', stopPrice=None.

...
@jmfernandes , would it be unreasonable to refactor the methods to call the order method using keyword arguments instead of positional arguments?

Thanks, I enjoy your repo and would love to help out however possible :) !

@justindavies
Copy link
Author

Perfect, that sorted the problem for me and the Order is accepted in extended hours trading. Only problem now is whenever I submit that order, a few seconds later I get a message in RH saying the order has failed due to an error:

Submit Order:
We've received your limit order to buy 5 shares of MTRX through your brokerage account at a maximum of $8.79 per share.

If this order isn't filled by the end of extended hours today (6:00pm ET), it will expire.

A few seconds later:
Update 😧 Your order to buy 5 shares of MTRX through your brokerage account failed due to an error, and wasn't submitted to the market.

@joeld1
Copy link

joeld1 commented Sep 26, 2023

That's strange. I usually also provide this and they go through

extendedHours = True, 
market_hours='all_day_hours',
timeInForce='gtc'

@mw66
Copy link

mw66 commented Nov 10, 2023

is it possible to get the extended hour stock price?

Any code example?

Thanks

@joeld1
Copy link

joeld1 commented Nov 11, 2023

It should be possible using the get_latest_price method. get_latest_price already includes extended hours by default.

image

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

3 participants