schwab-api icon indicating copy to clipboard operation
schwab-api copied to clipboard

Shorting?

Open mboop127 opened this issue 1 year ago • 3 comments

Hello - I see there is support for shorting in the API itself, but I cannot see any information on how to short here. Is it possible?

mboop127 avatar Jun 26 '24 21:06 mboop127

I was able to resolve by adding "BuyToCover" and "SellShort" under tradev2's instruction parser.

mboop127 avatar Jun 27 '24 15:06 mboop127

Hi @mboop127, if the changes are straightforward, I'd love for you to create a pull request!

itsjafer avatar Jun 27 '24 16:06 itsjafer

Frustratingly it is not longer working, I am unsure why. Below is the code I changed in TradeV2; perhaps @itsjafer you could explain why you use integers rather than the instruction codes listed in the documentation, and where I might find the integer codes? Flailing, but hoping that could be the explanation.

    if side == "Buy":
        buySellCode = "BUY"
    elif side == "Sell":
        buySellCode = "SELL"
    elif side == "Short":
        buySellCode = "SELL_SHORT"
    elif side == "Cover":
        buySellCode = "BUY_TO_COVER"
    else:
        raise Exception("side must be either Buy or Sell or short, see instruction type on dev portal")

mboop127 avatar Jun 27 '24 19:06 mboop127