diff --git a/polygon/modelclass.py b/polygon/modelclass.py deleted file mode 100644 index 5499d15c..00000000 --- a/polygon/modelclass.py +++ /dev/null @@ -1,27 +0,0 @@ -import inspect -import typing -from dataclasses import dataclass - - -_T = typing.TypeVar("_T") - - -def modelclass(cls: typing.Type[_T]) -> typing.Type[_T]: - cls = dataclass(cls) - attributes = [ - a - for a in cls.__dict__["__annotations__"].keys() - if not a.startswith("__") and not inspect.isroutine(a) - ] - - def init(self, *args, **kwargs): - for i, a in enumerate(args): - if i < len(attributes): - self.__dict__[attributes[i]] = a - for k, v in kwargs.items(): - if k in attributes: - self.__dict__[k] = v - - cls.__init__ = init # type: ignore[assignment] - - return cls diff --git a/polygon/rest/models/aggs.py b/polygon/rest/models/aggs.py index cb624121..503d8d33 100644 --- a/polygon/rest/models/aggs.py +++ b/polygon/rest/models/aggs.py @@ -1,8 +1,8 @@ +from dataclasses import dataclass from typing import Optional -from ...modelclass import modelclass -@modelclass +@dataclass class Agg: "Contains aggregate data for a given ticker symbol over a given date range in a custom time window size." open: Optional[float] = None @@ -30,7 +30,7 @@ def from_dict(d): ) -@modelclass +@dataclass class GroupedDailyAgg: "Contains daily open, high, low, and close (OHLC) data for a given date." ticker: Optional[str] = None @@ -60,7 +60,7 @@ def from_dict(d): ) -@modelclass +@dataclass class DailyOpenCloseAgg: "Contains data for open, close and afterhours prices of a ticker symbol on a specified date." after_hours: Optional[float] = None @@ -92,7 +92,7 @@ def from_dict(d): ) -@modelclass +@dataclass class PreviousCloseAgg: "Contains data for the previous day's open, high, low, and close (OHLC) of the specified stock ticker." ticker: Optional[str] = None diff --git a/polygon/rest/models/conditions.py b/polygon/rest/models/conditions.py index 98baa261..8ed0aea8 100644 --- a/polygon/rest/models/conditions.py +++ b/polygon/rest/models/conditions.py @@ -1,8 +1,8 @@ -from typing import Optional, List -from ...modelclass import modelclass +from dataclasses import dataclass +from typing import List, Optional -@modelclass +@dataclass class SipMapping: "Contains data for a mapping to a symbol for each SIP that has a given condition." CTA: Optional[str] = None @@ -14,7 +14,7 @@ def from_dict(d): return SipMapping(**d) -@modelclass +@dataclass class Consolidated: "Contains data for aggregation rules on a consolidated (all exchanges) basis." updates_high_low: Optional[bool] = None @@ -26,7 +26,7 @@ def from_dict(d): return Consolidated(**d) -@modelclass +@dataclass class MarketCenter: "Contains data for aggregation rules on a per-market-center basis." updates_high_low: Optional[bool] = None @@ -38,7 +38,7 @@ def from_dict(d): return MarketCenter(**d) -@modelclass +@dataclass class UpdateRules: "Contains data for a list of aggregation rules." consolidated: Optional[Consolidated] = None @@ -60,7 +60,7 @@ def from_dict(d): ) -@modelclass +@dataclass class Condition: "Condition contains data for a condition that Polygon.io uses." abbreviation: Optional[str] = None diff --git a/polygon/rest/models/contracts.py b/polygon/rest/models/contracts.py index 469779b6..92f6c21a 100644 --- a/polygon/rest/models/contracts.py +++ b/polygon/rest/models/contracts.py @@ -1,8 +1,8 @@ -from typing import Optional, List -from ...modelclass import modelclass +from dataclasses import dataclass +from typing import List, Optional -@modelclass +@dataclass class Underlying: "Underlying contains data for an underlying or deliverable associated with an option contract." amount: Optional[float] = None @@ -14,7 +14,7 @@ def from_dict(d): return Underlying(**d) -@modelclass +@dataclass class OptionsContract: "OptionsContract contains data for a specified ticker symbol." additional_underlyings: Optional[List[Underlying]] = None @@ -45,7 +45,6 @@ def from_dict(d): primary_exchange=d.get("primary_exchange", None), shares_per_contract=d.get("shares_per_contract", None), strike_price=d.get("strike_price", None), - size=d.get("size", None), ticker=d.get("ticker", None), underlying_ticker=d.get("underlying_ticker", None), ) diff --git a/polygon/rest/models/dividends.py b/polygon/rest/models/dividends.py index ef9adff0..3483b0cf 100644 --- a/polygon/rest/models/dividends.py +++ b/polygon/rest/models/dividends.py @@ -1,8 +1,8 @@ +from dataclasses import dataclass from typing import Optional -from ...modelclass import modelclass -@modelclass +@dataclass class Dividend: "Dividend contains data for a historical cash dividend, including the ticker symbol, declaration date, ex-dividend date, record date, pay date, frequency, and amount." cash_amount: Optional[float] = None diff --git a/polygon/rest/models/exchanges.py b/polygon/rest/models/exchanges.py index cd93a7d9..40e82c65 100644 --- a/polygon/rest/models/exchanges.py +++ b/polygon/rest/models/exchanges.py @@ -1,8 +1,8 @@ +from dataclasses import dataclass from typing import Optional -from ...modelclass import modelclass -@modelclass +@dataclass class Exchange: "Exchange contains data for a condition that Polygon.io uses." acronym: Optional[str] = None diff --git a/polygon/rest/models/financials.py b/polygon/rest/models/financials.py index 1a480c48..ee63c857 100644 --- a/polygon/rest/models/financials.py +++ b/polygon/rest/models/financials.py @@ -1,8 +1,8 @@ -from typing import Optional, Dict -from ...modelclass import modelclass +from dataclasses import dataclass +from typing import Dict, Optional -@modelclass +@dataclass class DataPoint: "An individual financial data point." formula: Optional[str] = None @@ -17,7 +17,7 @@ def from_dict(d): return DataPoint(**d) -@modelclass +@dataclass class ExchangeGainsLosses: "Contains exchange gains losses data for a cash flow statement." formula: Optional[str] = None @@ -32,7 +32,7 @@ def from_dict(d): return ExchangeGainsLosses(**d) -@modelclass +@dataclass class NetCashFlow: "Contains net cash flow data for a cash flow statement." formula: Optional[str] = None @@ -47,7 +47,7 @@ def from_dict(d): return NetCashFlow(**d) -@modelclass +@dataclass class NetCashFlowFromFinancingActivities: "Contains net cash flow from financing activities data for a cash flow statement." formula: Optional[str] = None @@ -62,7 +62,7 @@ def from_dict(d): return NetCashFlowFromFinancingActivities(**d) -@modelclass +@dataclass class CashFlowStatement: "Contains cash flow statement data." exchange_gains_losses: Optional[ExchangeGainsLosses] = None @@ -94,7 +94,7 @@ def from_dict(d): ) -@modelclass +@dataclass class ComprehensiveIncomeLoss: "Contains comprehensive income loss data for comprehensive income." formula: Optional[str] = None @@ -109,7 +109,7 @@ def from_dict(d): return ComprehensiveIncomeLoss(**d) -@modelclass +@dataclass class ComprehensiveIncomeLossAttributableToParent: "Contains comprehensive income loss attributable to parent data for comprehensive income." formula: Optional[str] = None @@ -124,7 +124,7 @@ def from_dict(d): return ComprehensiveIncomeLossAttributableToParent(**d) -@modelclass +@dataclass class OtherComprehensiveIncomeLoss: "Contains other comprehensive income loss data for comprehensive income." formula: Optional[str] = None @@ -139,7 +139,7 @@ def from_dict(d): return OtherComprehensiveIncomeLoss(**d) -@modelclass +@dataclass class ComprehensiveIncome: "Contains comprehensive income data." comprehensive_income_loss: Optional[ComprehensiveIncomeLoss] = None @@ -173,7 +173,7 @@ def from_dict(d): ) -@modelclass +@dataclass class BasicEarningsPerShare: "Contains basic earning per share data for an income statement." formula: Optional[str] = None @@ -188,7 +188,7 @@ def from_dict(d): return BasicEarningsPerShare(**d) -@modelclass +@dataclass class CostOfRevenue: "Contains cost of revenue data for an income statement." formula: Optional[str] = None @@ -203,7 +203,7 @@ def from_dict(d): return CostOfRevenue(**d) -@modelclass +@dataclass class GrossProfit: "Contains gross profit data for an income statement." formula: Optional[str] = None @@ -218,7 +218,7 @@ def from_dict(d): return GrossProfit(**d) -@modelclass +@dataclass class OperatingExpenses: "Contains operating expenses data for an income statement." formula: Optional[str] = None @@ -233,7 +233,7 @@ def from_dict(d): return OperatingExpenses(**d) -@modelclass +@dataclass class Revenues: "Contains revenues data for an income statement." formula: Optional[str] = None @@ -248,7 +248,7 @@ def from_dict(d): return Revenues(**d) -@modelclass +@dataclass class IncomeStatement: "Contains income statement data." basic_earnings_per_share: Optional[BasicEarningsPerShare] = None @@ -284,7 +284,7 @@ def from_dict(d): ) -@modelclass +@dataclass class Financials: "Contains financial data." balance_sheet: Optional[Dict[str, DataPoint]] = None @@ -320,7 +320,7 @@ def from_dict(d): ) -@modelclass +@dataclass class StockFinancial: "StockFinancial contains historical financial data for a stock ticker." cik: Optional[str] = None diff --git a/polygon/rest/models/indicators.py b/polygon/rest/models/indicators.py index aedada5a..f8a082df 100644 --- a/polygon/rest/models/indicators.py +++ b/polygon/rest/models/indicators.py @@ -1,10 +1,10 @@ -from sqlite3 import Timestamp -from typing import Optional, Any, Dict, List, Union -from ...modelclass import modelclass +from dataclasses import dataclass +from typing import List, Optional + from .aggs import Agg -@modelclass +@dataclass class IndicatorValue: "Contains one datum for indicators with a single value." timestamp: Optional[int] = None @@ -18,7 +18,7 @@ def from_dict(d): ) -@modelclass +@dataclass class MACDIndicatorValue: "Contains one datum for all MACD values." timestamp: Optional[int] = None @@ -36,7 +36,7 @@ def from_dict(d): ) -@modelclass +@dataclass class IndicatorUnderlying: "Contains the URL to call to get the aggs used for building the indicator." url: Optional[str] = None @@ -50,7 +50,7 @@ def from_dict(d): ) -@modelclass +@dataclass class SingleIndicatorResults: "Contains indicator values and Underlying." values: Optional[List[IndicatorValue]] = None @@ -69,7 +69,7 @@ def from_dict(d): RSIIndicatorResults = SingleIndicatorResults -@modelclass +@dataclass class MACDIndicatorResults: "Contains indicator values and Underlying." values: Optional[List[MACDIndicatorValue]] = None diff --git a/polygon/rest/models/markets.py b/polygon/rest/models/markets.py index 4e68abd4..b39625ab 100644 --- a/polygon/rest/models/markets.py +++ b/polygon/rest/models/markets.py @@ -1,8 +1,8 @@ +from dataclasses import dataclass from typing import Optional -from ...modelclass import modelclass -@modelclass +@dataclass class MarketCurrencies: "Contains currency market status data." crypto: Optional[str] = None @@ -13,7 +13,7 @@ def from_dict(d): return MarketCurrencies(**d) -@modelclass +@dataclass class MarketExchanges: "Contains exchange market status data." nasdaq: Optional[str] = None @@ -25,7 +25,7 @@ def from_dict(d): return MarketExchanges(**d) -@modelclass +@dataclass class MarketIndices: "Contains indices market status data." s_and_p: Optional[str] = None @@ -44,7 +44,7 @@ def from_dict(d): return MarketIndices(**d) -@modelclass +@dataclass class MarketHoliday: "MarketHoliday contains data for upcoming market holidays and their open/close times." close: Optional[str] = None @@ -59,7 +59,7 @@ def from_dict(d): return MarketHoliday(**d) -@modelclass +@dataclass class MarketStatus: "MarketStatus contains data for the current trading status of the exchanges and overall financial markets." after_hours: Optional[bool] = None diff --git a/polygon/rest/models/quotes.py b/polygon/rest/models/quotes.py index c4f2c00f..04394789 100644 --- a/polygon/rest/models/quotes.py +++ b/polygon/rest/models/quotes.py @@ -1,8 +1,8 @@ -from typing import Optional, List -from ...modelclass import modelclass +from dataclasses import dataclass +from typing import List, Optional -@modelclass +@dataclass class Quote: "Quote contains quote data for a specified ticker symbol." ask_exchange: Optional[int] = None @@ -24,7 +24,7 @@ def from_dict(d): return Quote(**d) -@modelclass +@dataclass class LastQuote: "LastQuote contains data for the most recent NBBO (Quote) tick for a given stock." ticker: Optional[str] = None @@ -62,7 +62,7 @@ def from_dict(d): ) -@modelclass +@dataclass class ForexQuote: "Contains data for a forex quote." ask: Optional[float] = None @@ -75,7 +75,7 @@ def from_dict(d): return ForexQuote(**d) -@modelclass +@dataclass class LastForexQuote: "ForexLastQuote contains data for the last quote tick for a forex currency pair." last: Optional[ForexQuote] = None @@ -89,7 +89,7 @@ def from_dict(d): ) -@modelclass +@dataclass class RealTimeCurrencyConversion: "RealTimeCurrencyConversion contains data for currency conversions using the latest market conversion rates." converted: Optional[float] = None diff --git a/polygon/rest/models/snapshot.py b/polygon/rest/models/snapshot.py index ceb5f7f8..65ac8fe0 100644 --- a/polygon/rest/models/snapshot.py +++ b/polygon/rest/models/snapshot.py @@ -1,11 +1,12 @@ -from typing import Optional, List, Dict +from dataclasses import dataclass +from typing import Dict, List, Optional + from .aggs import Agg from .quotes import LastQuote from .trades import LastTrade -from ...modelclass import modelclass -@modelclass +@dataclass class MinuteSnapshot: "Most recent minute bar." accumulated_volume: Optional[float] = None @@ -35,7 +36,7 @@ def from_dict(d): ) -@modelclass +@dataclass class IndicesSession: "Contains data for the most recent daily bar in an options contract." change: Optional[float] = None @@ -51,7 +52,7 @@ def from_dict(d): return IndicesSession(**d) -@modelclass +@dataclass class IndicesSnapshot: value: Optional[float] = None name: Optional[str] = None @@ -78,7 +79,7 @@ def from_dict(d): ) -@modelclass +@dataclass class TickerSnapshot: "Contains the most up-to-date market data for all traded ticker symbols." day: Optional[Agg] = None @@ -112,7 +113,7 @@ def from_dict(d): ) -@modelclass +@dataclass class DayOptionContractSnapshot: "Contains data for the most recent daily bar in an options contract." change: Optional[float] = None @@ -131,7 +132,7 @@ def from_dict(d): return DayOptionContractSnapshot(**d) -@modelclass +@dataclass class OptionDetails: "Contains details for an options contract." contract_type: Optional[str] = None @@ -146,7 +147,7 @@ def from_dict(d): return OptionDetails(**d) -@modelclass +@dataclass class LastQuoteOptionContractSnapshot: "Contains data for the most recent quote in an options contract." ask: Optional[float] = None @@ -162,7 +163,7 @@ def from_dict(d): return LastQuoteOptionContractSnapshot(**d) -@modelclass +@dataclass class LastTradeOptionContractSnapshot: "Contains data for the most recent trade for an options contract." price: Optional[float] = None @@ -177,7 +178,7 @@ def from_dict(d): return LastTradeOptionContractSnapshot(**d) -@modelclass +@dataclass class Greeks: "Contains data for the greeks in an options contract." delta: Optional[float] = None @@ -190,7 +191,7 @@ def from_dict(d): return Greeks(**d) -@modelclass +@dataclass class UnderlyingAsset: "Contains data for the underlying stock in an options contract." change_to_break_even: Optional[float] = None @@ -205,7 +206,7 @@ def from_dict(d): return UnderlyingAsset(**d) -@modelclass +@dataclass class OptionContractSnapshot: "Contains data for the snapshot of an option contract of a stock equity." break_even_price: Optional[float] = None @@ -253,7 +254,7 @@ def from_dict(d): ) -@modelclass +@dataclass class OrderBookQuote: "Contains data for a book bid or ask." price: Optional[float] = None @@ -267,7 +268,7 @@ def from_dict(d): ) -@modelclass +@dataclass class SnapshotTickerFullBook: "Contains the current level 2 book of a single ticker. This is the combined book from all of the exchanges." ticker: Optional[str] = None @@ -299,7 +300,7 @@ def from_dict(d): ) -@modelclass +@dataclass class UniversalSnapshotSession: """Contains data about the most recent trading session for an asset.""" @@ -322,7 +323,7 @@ def from_dict(d): return UniversalSnapshotSession(**d) -@modelclass +@dataclass class UniversalSnapshotLastQuote: """Contains the most recent quote for an asset.""" @@ -340,7 +341,7 @@ def from_dict(d): return UniversalSnapshotLastQuote(**d) -@modelclass +@dataclass class UniversalSnapshotLastTrade: """Contains the most recent trade for an asset.""" @@ -359,7 +360,7 @@ def from_dict(d): return UniversalSnapshotLastTrade(**d) -@modelclass +@dataclass class UniversalSnapshotUnderlyingAsset: """Contains data for the underlying stock in an options contract.""" @@ -375,7 +376,7 @@ def from_dict(d): return UniversalSnapshotUnderlyingAsset(**d) -@modelclass +@dataclass class UniversalSnapshotDetails: """Contains details for an options contract.""" @@ -384,13 +385,14 @@ class UniversalSnapshotDetails: expiration_date: Optional[str] = None shares_per_contract: Optional[float] = None strike_price: Optional[float] = None + underlying_ticker: Optional[str] = None @staticmethod def from_dict(d): return UniversalSnapshotDetails(**d) -@modelclass +@dataclass class UniversalSnapshot: """Contains snapshot data for an asset.""" diff --git a/polygon/rest/models/splits.py b/polygon/rest/models/splits.py index 93244c50..337df7b6 100644 --- a/polygon/rest/models/splits.py +++ b/polygon/rest/models/splits.py @@ -1,8 +1,8 @@ +from dataclasses import dataclass from typing import Optional -from ...modelclass import modelclass -@modelclass +@dataclass class Split: "Split contains data for a historical stock split, including the ticker symbol, the execution date, and the factors of the split ratio." execution_date: Optional[str] = None diff --git a/polygon/rest/models/summaries.py b/polygon/rest/models/summaries.py index 21e6f395..5bed3393 100644 --- a/polygon/rest/models/summaries.py +++ b/polygon/rest/models/summaries.py @@ -1,10 +1,10 @@ -from sqlite3 import Timestamp +from dataclasses import dataclass from typing import Optional -from ...modelclass import modelclass + from .tickers import Branding -@modelclass +@dataclass class Session: "Contains Session data for the summaries endpoint." change: Optional[float] = None @@ -25,7 +25,7 @@ def from_dict(d): return Session(**d) -@modelclass +@dataclass class Options: "Contains options data for the summaries endpoint" contract_type: Optional[str] = None @@ -40,7 +40,7 @@ def from_dict(d): return Options(**d) -@modelclass +@dataclass class SummaryResult: "Contains summary result data for a list of tickers" price: Optional[float] = None diff --git a/polygon/rest/models/tickers.py b/polygon/rest/models/tickers.py index 9a2484ac..72373359 100644 --- a/polygon/rest/models/tickers.py +++ b/polygon/rest/models/tickers.py @@ -1,9 +1,8 @@ -from typing import Optional, List +from dataclasses import dataclass +from typing import List, Optional -from ...modelclass import modelclass - -@modelclass +@dataclass class CompanyAddress: "Contains address data for a ticker detail." address1: Optional[str] = None @@ -18,7 +17,7 @@ def from_dict(d): return CompanyAddress(**d) -@modelclass +@dataclass class Branding: "Contains branding data for a ticker detail." icon_url: Optional[str] = None @@ -32,7 +31,7 @@ def from_dict(d): return Branding(**d) -@modelclass +@dataclass class Publisher: "Contains publisher data for ticker news." favicon_url: Optional[str] = None @@ -45,7 +44,7 @@ def from_dict(d): return Publisher(**d) -@modelclass +@dataclass class Ticker: "Ticker contains data for a specified ticker symbol." active: Optional[bool] = None @@ -71,7 +70,7 @@ def from_dict(d): return Ticker(**d) -@modelclass +@dataclass class TickerDetails: "TickerDetails contains data for a specified ticker symbol." active: Optional[bool] = None @@ -143,7 +142,7 @@ def from_dict(d): ) -@modelclass +@dataclass class TickerNews: "TickerDetails contains data for news articles relating to a stock ticker symbol." amp_url: Optional[str] = None @@ -177,7 +176,7 @@ def from_dict(d): ) -@modelclass +@dataclass class TickerTypes: "TickerTypes contains data for ticker types." asset_class: Optional[str] = None @@ -190,7 +189,7 @@ def from_dict(d): return TickerTypes(**d) -@modelclass +@dataclass class RelatedCompany: """ Get a list of tickers related to the queried ticker based on News and Returns data. @@ -205,7 +204,7 @@ def from_dict(d): ) -@modelclass +@dataclass class TickerChange: ticker: str @@ -214,7 +213,7 @@ def from_dict(d): return TickerChange(**d) -@modelclass +@dataclass class TickerChangeEvent: type: str date: str @@ -225,7 +224,7 @@ def from_dict(d): return TickerChangeEvent(**d) -@modelclass +@dataclass class TickerChangeResults: name: str composite_figi: str diff --git a/polygon/rest/models/trades.py b/polygon/rest/models/trades.py index 25b9adc7..8c2f2934 100644 --- a/polygon/rest/models/trades.py +++ b/polygon/rest/models/trades.py @@ -1,8 +1,8 @@ -from typing import Optional, List -from ...modelclass import modelclass +from dataclasses import dataclass +from typing import List, Optional -@modelclass +@dataclass class Trade: "Trade contains trade data for a specified ticker symbol." conditions: Optional[List[int]] = None @@ -23,7 +23,7 @@ def from_dict(d): return Trade(**d) -@modelclass +@dataclass class LastTrade: "Contains data for the most recent trade for a given ticker symbol." ticker: Optional[str] = None @@ -59,7 +59,7 @@ def from_dict(d): ) -@modelclass +@dataclass class CryptoTrade: "Contains data for a crypto trade." conditions: Optional[List[int]] = None diff --git a/polygon/websocket/models/models.py b/polygon/websocket/models/models.py index d6fa0c29..e4120763 100644 --- a/polygon/websocket/models/models.py +++ b/polygon/websocket/models/models.py @@ -1,9 +1,10 @@ -from typing import Optional, List, Union, NewType +from dataclasses import dataclass +from typing import List, NewType, Optional, Union + from .common import EventType -from ...modelclass import modelclass -@modelclass +@dataclass class EquityAgg: """EquityAgg contains aggregate data for either stock tickers, option contracts or index tickers.""" @@ -44,7 +45,7 @@ def from_dict(d): ) -@modelclass +@dataclass class CurrencyAgg: "CurrencyAgg contains aggregate data for either forex currency pairs or crypto pairs." event_type: Optional[Union[str, EventType]] = None @@ -76,7 +77,7 @@ def from_dict(d): ) -@modelclass +@dataclass class EquityTrade: "EquityTrade contains trade data for either stock tickers or option contracts." event_type: Optional[Union[str, EventType]] = None @@ -110,7 +111,7 @@ def from_dict(d): ) -@modelclass +@dataclass class CryptoTrade: "CryptoTrade contains trade data for a crypto pair." event_type: Optional[Union[str, EventType]] = None @@ -138,7 +139,7 @@ def from_dict(d): ) -@modelclass +@dataclass class EquityQuote: "EquityQuote contains quote data for either stock tickers or option contracts." event_type: Optional[Union[str, EventType]] = None @@ -178,7 +179,7 @@ def from_dict(d): ) -@modelclass +@dataclass class ForexQuote: "ForexQuote contains quote data for a forex currency pair." event_type: Optional[Union[str, EventType]] = None @@ -200,7 +201,7 @@ def from_dict(d): ) -@modelclass +@dataclass class CryptoQuote: "CryptoQuote contains quote data for a crypto pair." event_type: Optional[Union[str, EventType]] = None @@ -228,7 +229,7 @@ def from_dict(d): ) -@modelclass +@dataclass class Imbalance: "Imbalance contains imbalance event data for a given stock ticker symbol." event_type: Optional[Union[str, EventType]] = None @@ -258,7 +259,7 @@ def from_dict(d): ) -@modelclass +@dataclass class LimitUpLimitDown: "LimitUpLimitDown contains LULD event data for a given stock ticker symbol." event_type: Optional[Union[str, EventType]] = None @@ -284,7 +285,7 @@ def from_dict(d): ) -@modelclass +@dataclass class Level2Book: "Level2Book contains level 2 book data for a given crypto pair." event_type: Optional[Union[str, EventType]] = None @@ -308,7 +309,7 @@ def from_dict(d): ) -@modelclass +@dataclass class IndexValue: event_type: Optional[Union[str, EventType]] = None value: Optional[float] = None @@ -325,7 +326,7 @@ def from_dict(d): ) -@modelclass +@dataclass class LaunchpadValue: event_type: Optional[Union[str, EventType]] = None value: Optional[float] = None @@ -342,7 +343,7 @@ def from_dict(d): ) -@modelclass +@dataclass class FairMarketValue: event_type: Optional[Union[str, EventType]] = None fmv: Optional[float] = None diff --git a/test_rest/test_contracts.py b/test_rest/test_contracts.py index 98c836a6..f3799018 100644 --- a/test_rest/test_contracts.py +++ b/test_rest/test_contracts.py @@ -1,6 +1,7 @@ -from polygon.rest.models import OptionsContract from base import BaseTest +from polygon.rest.models import OptionsContract + class ContractsTest(BaseTest): def test_get_options_contract(self): @@ -15,7 +16,6 @@ def test_get_options_contract(self): primary_exchange="BATO", shares_per_contract=100, strike_price=2.5, - size=None, ticker="O:EVRI240119C00002500", underlying_ticker="EVRI", ) @@ -34,7 +34,6 @@ def test_list_options_contracts(self): primary_exchange="BATO", shares_per_contract=100, strike_price=65, - size=None, ticker="O:A220520C00065000", underlying_ticker="A", ), @@ -48,7 +47,6 @@ def test_list_options_contracts(self): primary_exchange="BATO", shares_per_contract=100, strike_price=70, - size=None, ticker="O:A220520C00070000", underlying_ticker="A", ), @@ -62,7 +60,6 @@ def test_list_options_contracts(self): primary_exchange="BATO", shares_per_contract=100, strike_price=75, - size=None, ticker="O:A220520C00075000", underlying_ticker="A", ), @@ -76,7 +73,6 @@ def test_list_options_contracts(self): primary_exchange="BATO", shares_per_contract=100, strike_price=80, - size=None, ticker="O:A220520C00080000", underlying_ticker="A", ), @@ -90,7 +86,6 @@ def test_list_options_contracts(self): primary_exchange="BATO", shares_per_contract=100, strike_price=85, - size=None, ticker="O:A220520C00085000", underlying_ticker="A", ), @@ -104,7 +99,6 @@ def test_list_options_contracts(self): primary_exchange="BATO", shares_per_contract=100, strike_price=90, - size=None, ticker="O:A220520C00090000", underlying_ticker="A", ), @@ -118,7 +112,6 @@ def test_list_options_contracts(self): primary_exchange="BATO", shares_per_contract=100, strike_price=95, - size=None, ticker="O:A220520C00095000", underlying_ticker="A", ), @@ -132,7 +125,6 @@ def test_list_options_contracts(self): primary_exchange="BATO", shares_per_contract=100, strike_price=100, - size=None, ticker="O:A220520C00100000", underlying_ticker="A", ), @@ -146,7 +138,6 @@ def test_list_options_contracts(self): primary_exchange="BATO", shares_per_contract=100, strike_price=105, - size=None, ticker="O:A220520C00105000", underlying_ticker="A", ), @@ -160,7 +151,6 @@ def test_list_options_contracts(self): primary_exchange="BATO", shares_per_contract=100, strike_price=110, - size=None, ticker="O:A220520C00110000", underlying_ticker="A", ), @@ -174,7 +164,6 @@ def test_list_options_contracts(self): primary_exchange="BATO", shares_per_contract=100, strike_price=115, - size=None, ticker="O:A220520C00115000", underlying_ticker="A", ), @@ -188,7 +177,6 @@ def test_list_options_contracts(self): primary_exchange="BATO", shares_per_contract=100, strike_price=120, - size=None, ticker="O:A220520C00120000", underlying_ticker="A", ), @@ -202,7 +190,6 @@ def test_list_options_contracts(self): primary_exchange="BATO", shares_per_contract=100, strike_price=125, - size=None, ticker="O:A220520C00125000", underlying_ticker="A", ), @@ -216,7 +203,6 @@ def test_list_options_contracts(self): primary_exchange="BATO", shares_per_contract=100, strike_price=130, - size=None, ticker="O:A220520C00130000", underlying_ticker="A", ), @@ -230,7 +216,6 @@ def test_list_options_contracts(self): primary_exchange="BATO", shares_per_contract=100, strike_price=135, - size=None, ticker="O:A220520C00135000", underlying_ticker="A", ), @@ -244,7 +229,6 @@ def test_list_options_contracts(self): primary_exchange="BATO", shares_per_contract=100, strike_price=140, - size=None, ticker="O:A220520C00140000", underlying_ticker="A", ), @@ -258,7 +242,6 @@ def test_list_options_contracts(self): primary_exchange="BATO", shares_per_contract=100, strike_price=145, - size=None, ticker="O:A220520C00145000", underlying_ticker="A", ), @@ -272,7 +255,6 @@ def test_list_options_contracts(self): primary_exchange="BATO", shares_per_contract=100, strike_price=150, - size=None, ticker="O:A220520C00150000", underlying_ticker="A", ), @@ -286,7 +268,6 @@ def test_list_options_contracts(self): primary_exchange="BATO", shares_per_contract=100, strike_price=155, - size=None, ticker="O:A220520C00155000", underlying_ticker="A", ), @@ -300,7 +281,6 @@ def test_list_options_contracts(self): primary_exchange="BATO", shares_per_contract=100, strike_price=160, - size=None, ticker="O:A220520C00160000", underlying_ticker="A", ), diff --git a/test_rest/test_modelclass.py b/test_rest/test_modelclass.py index 651a6393..3f06cd80 100644 --- a/test_rest/test_modelclass.py +++ b/test_rest/test_modelclass.py @@ -1,31 +1,22 @@ -from polygon.rest.models import Agg from base import BaseTest +from polygon.rest.models import Agg + class ModelclassTest(BaseTest): def test_extra_field(self): - a = Agg( - open=1.5032, - high=1.5064, - low=1.4489, - close=1.4604, - volume=642646396.0, - vwap=1.469, - timestamp=1112331600000, - transactions=82132, - ) - b = Agg( - open=1.5032, - high=1.5064, - low=1.4489, - close=1.4604, - volume=642646396.0, - vwap=1.469, - timestamp=1112331600000, - transactions=82132, - extra_field=22, - ) - self.assertEqual(a, b) + with self.assertRaises(TypeError): + b = Agg( + open=1.5032, + high=1.5064, + low=1.4489, + close=1.4604, + volume=642646396.0, + vwap=1.469, + timestamp=1112331600000, + transactions=82132, + extra_field=22, + ) def test_init_order(self): a = Agg(