alpacahq / alpaca-py

The Official Python SDK for Alpaca API
https://alpaca.markets/sdks/python/getting_started.html
Apache License 2.0
605 stars 149 forks source link

[Bug]: NewsRequest classs param:symbols designed to take List[str] for symbols but can only take a single symbol as str #526

Open neili02 opened 2 weeks ago

neili02 commented 2 weeks ago

Is there an existing issue for this?

Current Behavior

Error when using NewsRequest with multiple symbols.

from alpaca.data.historical.news import NewsClient
from alpaca.data.requests import NewsRequest

NewsClient().getnews(request_params=NewsRequest(symbols=['AAPL','GOOGL'])

results in error.

Expected Behavior

No response

SDK Version I encountered this issue in

alpaca-py v0.31.0

Steps To Reproduce

ValidationError: 1 validation error for NewsRequest
symbols
  Input should be a valid string [type=string_type, input_value=['AAPL', 'GOOGL'], input_type=list]
    For further information visit https://errors.pydantic.dev/2.6/v/string_type

Filled out the Steps to Reproduce section?

Anything else?

No response

hiohiohio commented 2 weeks ago

https://github.com/hiohiohio/alpaca-py/blob/791ce40d01914ad967ae14a2f11d66449af119d4/alpaca/data/requests.py#L389

symbols (Optional[str]): The comma-separated list of symbols to query news for.

@neili02 the parameter currently does not support list. Please convert to comma separated str.

NewsClient().getnews(request_params=NewsRequest(symbols=",".join(['AAPL','GOOGL']))
neili02 commented 1 week ago

Okay, thanks.