diff --git a/alpaca/data/models/bars.py b/alpaca/data/models/bars.py index 7c09e3fb..85dbba9b 100644 --- a/alpaca/data/models/bars.py +++ b/alpaca/data/models/bars.py @@ -35,8 +35,6 @@ class Bar(BaseModel): trade_count: Optional[float] vwap: Optional[float] - model_config = ConfigDict(protected_namespaces=tuple()) - def __init__(self, symbol: str, raw_data: RawData) -> None: """Instantiates a bar diff --git a/alpaca/data/models/base.py b/alpaca/data/models/base.py index 2700ebd4..dfd5d48f 100644 --- a/alpaca/data/models/base.py +++ b/alpaca/data/models/base.py @@ -41,7 +41,6 @@ class BaseDataSet(BaseModel): """ data: Dict[str, List[BaseModel]] = {} - model_config = ConfigDict(protected_namespaces=tuple()) def __getitem__(self, symbol: str) -> Any: """Gives dictionary-like access to multi-symbol data diff --git a/alpaca/data/models/orderbooks.py b/alpaca/data/models/orderbooks.py index 190aec12..77c6a1c8 100644 --- a/alpaca/data/models/orderbooks.py +++ b/alpaca/data/models/orderbooks.py @@ -14,8 +14,6 @@ class OrderbookQuote(BaseModel): price: float = Field(alias="p") size: float = Field(alias="s") - model_config = ConfigDict(protected_namespaces=tuple()) - class Orderbook(BaseModel): """Level 2 ask/bid pair orderbook data. @@ -32,8 +30,6 @@ class Orderbook(BaseModel): bids: List[OrderbookQuote] asks: List[OrderbookQuote] - model_config = ConfigDict(protected_namespaces=tuple()) - def __init__(self, symbol: str, raw_data: RawData) -> None: """Instantiates an Orderbook. diff --git a/alpaca/data/models/quotes.py b/alpaca/data/models/quotes.py index 5635f1aa..a884581c 100644 --- a/alpaca/data/models/quotes.py +++ b/alpaca/data/models/quotes.py @@ -37,8 +37,6 @@ class Quote(BaseModel): conditions: Optional[Union[List[str], str]] = None tape: Optional[str] = None - model_config = ConfigDict(protected_namespaces=tuple()) - def __init__(self, symbol: str, raw_data: RawData) -> None: """Instantiates a Quote diff --git a/alpaca/data/models/screener.py b/alpaca/data/models/screener.py index fa67c7f2..2379d3eb 100644 --- a/alpaca/data/models/screener.py +++ b/alpaca/data/models/screener.py @@ -21,8 +21,6 @@ class ActiveStock(BaseModel): volume: float trade_count: float - model_config = ConfigDict(protected_namespaces=tuple()) - class MostActives(BaseModel): """ @@ -37,8 +35,6 @@ class MostActives(BaseModel): most_actives: List[ActiveStock] last_updated: datetime - model_config = ConfigDict(protected_namespaces=tuple()) - class Mover(BaseModel): """ @@ -55,8 +51,6 @@ class Mover(BaseModel): change: float price: float - model_config = ConfigDict(protected_namespaces=tuple()) - class Movers(BaseModel): """ @@ -74,5 +68,3 @@ class Movers(BaseModel): losers: List[Mover] market_type: MarketType last_updated: datetime - - model_config = ConfigDict(protected_namespaces=tuple()) diff --git a/alpaca/data/models/snapshots.py b/alpaca/data/models/snapshots.py index 1681e56a..22d8dd23 100644 --- a/alpaca/data/models/snapshots.py +++ b/alpaca/data/models/snapshots.py @@ -28,8 +28,6 @@ class Snapshot(BaseModel): daily_bar: Optional[Bar] = None previous_daily_bar: Optional[Bar] = None - model_config = ConfigDict(protected_namespaces=tuple()) - def __init__(self, symbol: str, raw_data: Dict[str, RawData]) -> None: """Instantiates a Snapshot. @@ -81,8 +79,6 @@ class OptionsGreeks(BaseModel): theta: float vega: float - model_config = ConfigDict(protected_namespaces=tuple()) - def __init__(self, raw_data: RawData) -> None: """Instantiates an OptionGreeks object. @@ -110,8 +106,6 @@ class OptionsSnapshot(BaseModel): implied_volatility: Optional[float] = None greeks: Optional[OptionsGreeks] = None - model_config = ConfigDict(protected_namespaces=tuple()) - def __init__(self, symbol: str, raw_data: Dict[str, RawData]) -> None: """Instantiates a Snapshot. diff --git a/alpaca/data/models/trades.py b/alpaca/data/models/trades.py index c8571a4c..472dfdfc 100644 --- a/alpaca/data/models/trades.py +++ b/alpaca/data/models/trades.py @@ -33,8 +33,6 @@ class Trade(BaseModel): conditions: Optional[Union[List[str], str]] = None tape: Optional[str] = None - model_config = ConfigDict(protected_namespaces=tuple()) - def __init__(self, symbol: str, raw_data: RawData) -> None: """Instantiates a Trade history object diff --git a/alpaca/data/requests.py b/alpaca/data/requests.py index 84072a9c..84c5bac9 100644 --- a/alpaca/data/requests.py +++ b/alpaca/data/requests.py @@ -38,8 +38,6 @@ class BaseTimeseriesDataRequest(NonEmptyRequest): currency: Optional[SupportedCurrencies] = None # None = USD sort: Optional[Sort] = None # None = asc - model_config = ConfigDict(protected_namespaces=tuple()) - def __init__(self, **data: Any) -> None: # convert timezone aware datetime to timezone naive UTC datetime if ( @@ -242,8 +240,6 @@ class BaseStockLatestDataRequest(NonEmptyRequest): feed: Optional[DataFeed] = None currency: Optional[SupportedCurrencies] = None # None = USD - model_config = ConfigDict(protected_namespaces=tuple()) - class StockLatestTradeRequest(BaseStockLatestDataRequest): """ @@ -301,8 +297,6 @@ class BaseCryptoLatestDataRequest(NonEmptyRequest): symbol_or_symbols: Union[str, List[str]] - model_config = ConfigDict(protected_namespaces=tuple()) - class CryptoLatestTradeRequest(BaseCryptoLatestDataRequest): """ @@ -356,8 +350,6 @@ class BaseOptionLatestDataRequest(NonEmptyRequest): symbol_or_symbols: Union[str, List[str]] feed: Optional[OptionsFeed] = None - model_config = ConfigDict(protected_namespaces=tuple()) - class OptionLatestQuoteRequest(BaseOptionLatestDataRequest): """ @@ -404,8 +396,6 @@ class StockSnapshotRequest(NonEmptyRequest): feed: Optional[DataFeed] = None currency: Optional[SupportedCurrencies] = None # None = USD - model_config = ConfigDict(protected_namespaces=tuple()) - class CryptoSnapshotRequest(NonEmptyRequest): """ @@ -417,8 +407,6 @@ class CryptoSnapshotRequest(NonEmptyRequest): symbol_or_symbols: Union[str, List[str]] - model_config = ConfigDict(protected_namespaces=tuple()) - class OptionSnapshotRequest(NonEmptyRequest): """ @@ -432,8 +420,6 @@ class OptionSnapshotRequest(NonEmptyRequest): symbol_or_symbols: Union[str, List[str]] feed: Optional[OptionsFeed] = None - model_config = ConfigDict(protected_namespaces=tuple()) - class OptionChainRequest(NonEmptyRequest): """ @@ -461,8 +447,6 @@ class OptionChainRequest(NonEmptyRequest): expiration_date_lte: Optional[Union[date, str]] = None root_symbol: Optional[str] = None - model_config = ConfigDict(protected_namespaces=tuple()) - # ############################## Orderbooks ################################# # @@ -477,8 +461,6 @@ class CryptoLatestOrderbookRequest(NonEmptyRequest): symbol_or_symbols: Union[str, List[str]] - model_config = ConfigDict(protected_namespaces=tuple()) - # ############################## Screener #################################### # @@ -493,8 +475,6 @@ class ScreenerRequest(NonEmptyRequest): top: int = 10 - model_config = ConfigDict(protected_namespaces=tuple()) - class MostActivesRequest(ScreenerRequest): """ @@ -546,5 +526,3 @@ class NewsRequest(NonEmptyRequest): include_content: Optional[bool] = None exclude_contentless: Optional[bool] = None page_token: Optional[str] = None - - model_config = ConfigDict(protected_namespaces=tuple()) diff --git a/docs/conf.py b/docs/conf.py index 80dab09d..21d2a741 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -15,6 +15,11 @@ sys.path.insert(0, os.path.abspath("../")) +# import a module here to avoid an error of: +# NameError: Field "model_fields" conflicts with member {} of protected namespace "model_". +# ref. https://github.com/pydantic/pydantic/discussions/7763#discussioncomment-8417097 +import alpaca.data.models.screener # noqa # pylint: disable=unused-import + # -- Project information ----------------------------------------------------- project = "alpaca-py"