[Paper trade functionality]
Say I’m currently holding long 10 shares of AAPL, but I desire to hold long 40 shares in total.
If I put an OrderSide.BUY for 30 shares, it gives the error:
“message”:“insufficient qty available for order (requested: 30, available: 10)”,“symbol”:“AAPL”}
Note that any existing open orders for AAPL have been closed a long time ago (e.g. the existing 10 long).
Am I using the wrong interface? I’m currently using in Python:
# Setting parameters for our buy order
market_order_data = MarketOrderRequest(
symbol=ticker,
qty=shares,
side=side,
time_in_force=TimeInForce.GTC
)
# Submitting the order and then printing the returned object
market_order = self.trading_client.submit_order(market_order_data)
One obvious solution is to issue two market orders instead of one (i.e. liquidate the existing 10 shares via a OrderSide.SELL and then issue another Orderside.BUY for 40 shares), but this seems strange, especially if I wanted to take this code to live trading, since in live trading it would impose more transaction costs than necessary.
Needless to say, I also have the same problem with trying to go from shorts to longs. Example:
Say i’m holding short -10 shares AAPL, and I desire to hold a total long position of 40 shares. Trying to issue an OrderSide.BUY of 50 shares gives a similar error.
Any help appreciated! Thank you,
Paul