jmfernandes / robin_stocks

This is a library to use with Robinhood Financial App. It currently supports trading crypto-currencies, options, and stocks. In addition, it can be used to get real time ticker information, assess the performance of your portfolio, and can also get tax documents, total dividends paid, and more. More info at
http://www.robin-stocks.com
MIT License
1.69k stars 458 forks source link

Market orders not getting filled? #137

Open fisonoto opened 4 years ago

fisonoto commented 4 years ago

I use robin_stocks to trigger market buys and sells in Robinhood. But sometimes (usually when a stock price moves quickly), the market order will not get filled. This is on stocks with plenty of volume during market hours, and market orders from the Robinhood UI are filled immediately. Has anyone else experienced this?

fisonoto commented 4 years ago

It's almost as though the market order is acting like a limit order. When I look at the payload return price (return value of order_buy_market/order_sell_market), the pending order will not be filled until it passes through that order price.

unrealgecko commented 4 years ago

I am getting the same. The orders sit there pending yet if you hand type them into the GUI via mobile or desktop, they go through almost immediately. There's a bit of a disconnect somewhere from this to the real robinhood. (selecting markets, order priority or something goes on behind the scenes with R using the retail front)

unrealgecko commented 4 years ago

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)

kfmfe04 commented 4 years ago

I am also getting the canceled orders on fractional shares (sporadically - some are certainly getting through).

Now, if I resubmit those orders manually through the iOS app, the exact same orders have never failed to fill for me.

That leads me to suspect that there's something off about the fractional share functionality in robin_stocks.

unrealgecko commented 4 years ago

the app seems to use the ask for buys and the bid for sells. it ensures quick order fulfillment but not the greatest for us. try changing your pricetype in your order.

order_buy_fractional_by_quantity(symbol, quantity, timeInForce='gtc', priceType='ask_price, bid_price or mark_price', extendedHours=False)

ps make sure you are up to date with the package. also, I have been using buy order market function with fractional shares with no issues (other than stocks with low volume/liquidity either sit pending or get canceled after submission) I'm looking to switch from market to limit orders anyways due to being nickel and dimed out of some of my profits.

good luck!

SuperSixFor commented 3 years ago

I was having this issue with order_sell/buy_crypto_by_quantity function. @unrealgecko I tried adding priceType to this function, but ofc theres no arguments for this function... returns error.

I changed functions to order_crypto and is placing and filling market orders correctly. Not a fix but a workaround, it looks like the bid/ask values need to be added to the first function in order to work properly.

Now I'm bleeding nickels and dimes everywhere!