alpacahq / Alpaca-API

The Alpaca API is a developer interface for trading operations and market data reception through the Alpaca platform.
https://alpaca.markets/
141 stars 13 forks source link

qty required on notional orders #191

Open d-e-s-o opened 2 years ago

d-e-s-o commented 2 years ago

Describe the bug It appears that despite the docs stating that setting notional on a new order implicitly sets qty to null, that is not actually what happens:

  - name: notional
    type: string<number>
    desc: Ordered notional amount. If entered, `qty` will be null. Can take up to 9 decimal points.

What we see:

curl -X POST -H "APCA-API-KEY-ID: $APCA_API_KEY_ID" -H "APCA-API-SECRET-KEY: $APCA_API_SECRET_KEY" -H "Content-Type: application/json" https://paper-api.alpaca.markets/v2/orders --data '{"symbol":"SPY","notional":"3333333.33333333","side":"buy","order_class":"simple","type":"market","time_in_force":"day","limit_price":null,"stop_price":null,"trail_price":null,"trail_percent":null,"take_profit":null,"stop_loss":null,"extended_hours":false,"client_order_id":null}'
{"code":40010001,"message":"qty is required"}

Interestingly, I couldn't even get it working with qty being null. Has anybody actually tested the notional stuff?

To Reproduce Steps to reproduce the behavior:

curl -X POST -H "APCA-API-KEY-ID: $APCA_API_KEY_ID" -H "APCA-API-SECRET-KEY: $APCA_API_SECRET_KEY" -H "Content-Type: application/json" https://paper-api.alpaca.markets/v2/orders --data '{"symbol":"SPY","notional":"3333333.33333333","side":"buy","order_class":"simple","type":"market","time_in_force":"day","limit_price":null,"stop_price":null,"trail_price":null,"trail_percent":null,"take_profit":null,"stop_loss":null,"extended_hours":false,"client_order_id":null}'

Expected behavior The order should go through.