Open ChaceCarlson opened 4 years ago
My trouble is that sometime the order failed and i dont know why. Thanks
Same, the orders fail and return "'Order quantity cannot include fractional shares.'" even though I'm using robin_stocks.order_buy_fractional_by_quantity(ticker, shares_to_buy, timeInForce='gfd')
I'd say remove that method completely, you can do fractional share orders just by passing floats to the order_buy_market
method.
Do not forget the timeInForce='gfd'
, fractional share orders only work if GFD.
I am having issues with fractional shares as well. I get notifications on Robinhood that the orders that are "canceled" and "failed" right after submission. I have also tried fractional_by_price and market with the same results.
r.orders.order_buy_market(ticker, amount_to_trade, timeInForce ='gfd')
r.orders.order_buy_fractional_by_price(ticker, amount_to_trade, timeInForce ='gfd')
once in a bluemoon an order will execute flawlessly. most of the time it's an endless loop of failed and cancelled orders.
I can use the web or mobile interface and submit the same order for the same amount and it executes every time. Something seems amiss...
Orders are getting filled less and less than using the official mobile or desktop GUI. We are missing something when we submit the orders to their API.
Either market or fractions have the same issue... Robinhood. haha
upon further investigation of the order info of these unfilled/canceled orders, the info pulled from .orders.get_stock_order_info() or the print(order -r.order_buy/sell_market() shows that the price is None and the quantity = 0 on all the orders that fail for me. THE FAIL: 'average_price': None, 'created_at': '16:44:50.068221Z', 'cumulative_quantity': '0.00000000', THE FILLED: then you get a filled order with 'average_price': '51.76010000', 'created_at': '16:44:56.138764Z', 'cumulative_quantity': '0.13794400', which is what was submitted both times.
Robinhood fails at getting the info or their fractional stock functionality still needs some bugs worked out. Either way, pull the stock info and look at the order info.
I am unable to find why certain stocks (even high volume) fail at both fractional and whole stock buys & sells. sometimes it goes 1 for 10 before getting filled, the rest canceled by Robinhood for that None price.
My workaround is a check on the order ID to see if it is pending or confirmed and if it is, wait. if canceled, it repeats the order submission and checks again. repeating over and over until filled. (I also wrote a fill or kill but Robinhood needs time to fill the orders, avg being a few seconds to a few minutes, beyond that, I force cancel again and repeat the order)
I have experienced the same issue. I believe there is additional overhead when Robinhood processes fractional orders, and they are perfectly willing to drop an order and mark as 'cancelled'. Scripting the same trades using the web interface (Selenium/Gecko instead of robin_stocks) results in an error message when placing too many fractional orders: "Too many requests for fractional orders."
"Too many requests for fractional orders." and "rejected orders" are two separate problems that I have experienced with fractional orders. The former can be ameliorated by putting a sleep timer to lower the frequency of order firing off, whereas the latter is unaffected by inserting sleeps. As a sanity check, I tried re-sending rejected orders via RH's iOS app manually - using that procedure, I have never had a rejection. This leads me to believe that something needs to be fixed in our API.
Any progress on this? If I can hear anything, I can contribute for updating as well.
any updates?
sell fractional by price instead of quantity. convert your stock sale amount to its dollar equivalent ahead of time, just simply stock_amount * bid_price
I ran a bot for almost a whole year and this never failed
if that fixed your problem and you use Brave browser, plz consider sending a tip :D
for me if I round the quantity to 6 decimals, it works, if I round to 8 decimals it fails with the "'Order quantity cannot include fractional shares.'" error
The function "order_buy_fractional_by_quantity" has a keyword argument in the description titled "share_type", however there is no code to support this keyword.
Also, entering a non-integer in the quantity field (ie attempting to purchase 0.5 shares), does not send a buy order.
Thank you.