Getting this error when trying to place orders via the go sdk:
Order of | 7 TSLA buy | did not go through: invalid position_intent specified (HTTP 422, Code 40010001)
I am just using the example long-short provided by the examples directory. I was getting this error on my own code as well so i moved to the example to see if that would fix it, to no avail.
submit order function:
func (alp longShortAlgo) submitOrder(qty int, symbol string, side string) error {
if qty > 0 {
adjSide := alpaca.Side(side)
decimalQty := decimal.NewFromInt(int64(qty))
_, err := algo.tradeClient.PlaceOrder(alpaca.PlaceOrderRequest{
Symbol: symbol,
Qty: &decimalQty,
Side: adjSide,
Type: "market",
TimeInForce: "day",
})
if err == nil {
fmt.Printf("Market order of | %d %s %s | completed\n", qty, symbol, side)
} else {
fmt.Printf("Order of | %d %s %s | did not go through: %s\n", qty, symbol, side, err)
}
return err
}
fmt.Printf("Quantity is <= 0, order of | %d %s %s | not sent\n", qty, symbol, side)
return nil
}