alpacahq / Alpaca-API

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

"POST create a Watchlist" ignores passed symbols #93

Closed mtcliatt closed 4 years ago

mtcliatt commented 4 years ago

Watchlists can be successfully created by hitting the endpoint v2/watchlists, however the API ignores the value given for symbol.

The documentation states this endpoint will accept an array of symbols, but it returns an error when symbols is passed and doesn't return an error when symbol is passed instead (probably related to #91). When passing symbol, the watchlist is successfully created, although the assets in the new watchlist are empty.

Petersoj commented 4 years ago

I'm not able to reproduce this.

POST https://paper-api.alpaca.markets/v2/watchlists

APCA-API-KEY-ID: <KEY ID>
APCA-API-SECRET-KEY: <SECRET>
Accept: */*
Content-Type: text/plain
Accept-Encoding: gzip, deflate
Accept-Language: en-us

{"name":"Apple Watchlist","symbols":["AAPL"]}

Returns:

HTTP/1.1 200 OK

Server: nginx/1.13.0
Date: Mon, 16 Dec 2019 06:27:24 GMT
Content-Type: application/json; charset=UTF-8
Connection: keep-alive
Vary: Origin
Content-Length: 422

{
    "id": "e8fd81cb-a604-4608-a54f-729577fb4019",
    "account_id": "<my account id>",
    "created_at": "2019-12-16T06:27:24.385196Z",
    "updated_at": "2019-12-16T06:27:24.385196Z",
    "name": "Apple Watchlist",
    "assets": [
        {
            "id": "b0b6dd9d-8b9b-48a9-ba46-b9d54906e415",
            "class": "us_equity",
            "exchange": "NASDAQ",
            "symbol": "AAPL",
            "name": "",
            "status": "active",
            "tradable": true,
            "marginable": true,
            "shortable": true,
            "easy_to_borrow": true
        }
    ]
}

It still works with multiple tickers in the symbols string array.

mtcliatt commented 4 years ago

Thanks for the fast response! Good call, you're right, this was just a mistake on my end.

For posterity: I was storing the value of symbols as a string rather than a list, so it wasn't properly encoded.