Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace modelclass with dataclass #687

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 0 additions & 27 deletions polygon/modelclass.py

This file was deleted.

10 changes: 5 additions & 5 deletions polygon/rest/models/aggs.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
14 changes: 7 additions & 7 deletions polygon/rest/models/conditions.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
9 changes: 4 additions & 5 deletions polygon/rest/models/contracts.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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),
)
4 changes: 2 additions & 2 deletions polygon/rest/models/dividends.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions polygon/rest/models/exchanges.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
38 changes: 19 additions & 19 deletions polygon/rest/models/financials.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -94,7 +94,7 @@ def from_dict(d):
)


@modelclass
@dataclass
class ComprehensiveIncomeLoss:
"Contains comprehensive income loss data for comprehensive income."
formula: Optional[str] = None
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -284,7 +284,7 @@ def from_dict(d):
)


@modelclass
@dataclass
class Financials:
"Contains financial data."
balance_sheet: Optional[Dict[str, DataPoint]] = None
Expand Down Expand Up @@ -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
Expand Down
16 changes: 8 additions & 8 deletions polygon/rest/models/indicators.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -18,7 +18,7 @@ def from_dict(d):
)


@modelclass
@dataclass
class MACDIndicatorValue:
"Contains one datum for all MACD values."
timestamp: Optional[int] = None
Expand All @@ -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
Expand All @@ -50,7 +50,7 @@ def from_dict(d):
)


@modelclass
@dataclass
class SingleIndicatorResults:
"Contains indicator values and Underlying."
values: Optional[List[IndicatorValue]] = None
Expand All @@ -69,7 +69,7 @@ def from_dict(d):
RSIIndicatorResults = SingleIndicatorResults


@modelclass
@dataclass
class MACDIndicatorResults:
"Contains indicator values and Underlying."
values: Optional[List[MACDIndicatorValue]] = None
Expand Down
Loading
Loading