Skip to content
Merged
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
11 changes: 10 additions & 1 deletion polygon/rest/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
from .aggs import AggsClient
from .trades import TradesClient
from .quotes import QuotesClient
from .reference import MarketsClient, TickersClient, SplitsClient, DividendsClient
from .reference import (
MarketsClient,
TickersClient,
SplitsClient,
DividendsClient,
ConditionsClient,
ExchangesClient,
)


class RESTClient(
Expand All @@ -12,5 +19,7 @@ class RESTClient(
TickersClient,
SplitsClient,
DividendsClient,
ConditionsClient,
ExchangesClient,
):
pass
15 changes: 3 additions & 12 deletions polygon/rest/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,6 @@
from .tickers import *
from .splits import *
from .dividends import *

from enum import Enum


class Sort(Enum):
ASC = "asc"
DESC = "desc"


class Order(Enum):
ASC = "asc"
DESC = "desc"
from .conditions import *
from .exchanges import *
from .shared import *
52 changes: 52 additions & 0 deletions polygon/rest/models/conditions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
from typing import Optional
from .shared import AssetClass, DataType
from dataclasses import dataclass


@dataclass
class SipMapping:
CTA: Optional[str] = None
OPRA: Optional[str] = None
UTP: Optional[str] = None


@dataclass
class Consolidated:
updates_high_low: Optional[bool] = None
updates_open_close: Optional[bool] = None
updates_volume: Optional[bool] = None


@dataclass
class MarketCenter:
updates_high_low: Optional[bool] = None
updates_open_close: Optional[bool] = None
updates_volume: Optional[bool] = None


@dataclass
class UpdateRules:
consolidated: Optional[Consolidated] = None
market_center: Optional[MarketCenter] = None


@dataclass
class Condition:
"Condition contains data for a condition that Polygon.io uses."
abbreviation: Optional[str] = None
asset_class: Optional[AssetClass] = None
data_types: Optional[DataType] = None
description: Optional[str] = None
exchange: Optional[int] = None
id: Optional[int] = None
legacy: Optional[bool] = None
name: Optional[str] = None
sip_mapping: Optional[SipMapping] = None
Type: Optional[
str
] = None # todo: 'type' is a keyword so here I capitalized. Should we capital case all dataclasses?
update_rules: Optional[UpdateRules] = None

@staticmethod
def from_dict(d):
return Condition(**d)
17 changes: 1 addition & 16 deletions polygon/rest/models/dividends.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,8 @@
from typing import Optional
from enum import Enum
from .shared import DividendType, Frequency
from dataclasses import dataclass


class DividendType(Enum):
CD = "CD"
SC = "SC"
LT = "LT"
ST = "ST"


class Frequency(Enum):
OneTime = 0
Anually = 1
BiAnually = 2
Quarterly = 4
Monthly = 12


@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."
Expand Down
22 changes: 22 additions & 0 deletions polygon/rest/models/exchanges.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
from typing import Optional
from .shared import AssetClass, Locale, ExchangeType
from dataclasses import dataclass


@dataclass
class Exchange:
"Exchange contains data for a condition that Polygon.io uses."
acronym: Optional[str] = None
asset_class: Optional[AssetClass] = None
id: Optional[int] = None
locale: Optional[Locale] = None
mic: Optional[str] = None
name: Optional[str] = None
operating_mic: Optional[str] = None
participant_id: Optional[str] = None
type: Optional[ExchangeType] = None
url: Optional[str] = None

@staticmethod
def from_dict(d):
return Exchange(**d)
19 changes: 16 additions & 3 deletions polygon/rest/models/markets.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,20 @@
from typing import Optional, Dict
from typing import Optional
from dataclasses import dataclass


@dataclass
class Currencies:
crypto: Optional[str] = None
fx: Optional[str] = None


@dataclass
class Exchanges:
nasdaq: Optional[str] = None
nyse: Optional[str] = None
otc: Optional[str] = None


@dataclass
class MarketHoliday:
"MarketHoliday contains data for upcoming market holidays and their open/close times."
Expand All @@ -21,9 +34,9 @@ def from_dict(d):
class MarketStatus:
"MarketStatus contains data for the current trading status of the exchanges and overall financial markets."
after_hours: Optional[bool] = None
currencies: Optional[Dict[str, str]] = None
currencies: Optional[Currencies] = None
early_hours: Optional[bool] = None
exchanges: Optional[Dict[str, str]] = None
exchanges: Optional[Exchanges] = None
market: Optional[str] = None
server_time: Optional[str] = None

Expand Down
62 changes: 62 additions & 0 deletions polygon/rest/models/shared.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
from enum import Enum


class Sort(Enum):
ASC = "asc"
DESC = "desc"


class Order(Enum):
ASC = "asc"
DESC = "desc"


class Locale(Enum):
US = "us"
GLOBAL = "global"


class Market(Enum):
STOCKS = "stocks"
CRYPTO = "crypto"
FX = "fx"


class AssetClass(Enum):
STOCKS = "stocks"
OPTIONS = "options"
CRYPTO = "crypto"
FX = "fx"


class DividendType(Enum):
CD = "CD"
SC = "SC"
LT = "LT"
ST = "ST"


class Frequency(Enum):
OneTime = 0
Anually = 1
BiAnually = 2
Quarterly = 4
Monthly = 12


class DataType(Enum):
DataTrade = "trade"
DataBBO = "bbo"
DataNBBO = "nbbo"


class SIP(Enum):
CTA = "CTA"
UTP = "UTP"
OPRA = "OPRA"


class ExchangeType(Enum):
exchange = "exchange"
TRF = "TRF"
SIP = "SIP"
20 changes: 1 addition & 19 deletions polygon/rest/models/tickers.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,8 @@
from typing import Optional, List
from enum import Enum
from .shared import Locale, Market, AssetClass
from dataclasses import dataclass


class Locale(Enum):
US = "us"
GLOBAL = "global"


class Market(Enum):
STOCKS = "stocks"
CRYPTO = "crypto"
FX = "fx"


class AssetClass(Enum):
STOCKS = "stocks"
OPTIONS = "options"
CRYPTO = "crypto"
FX = "fx"


@dataclass
class Address:
address1: Optional[str] = None
Expand Down
Loading