Skip to content

Commit 5ff5a5a

Browse files
Darcy-Lindeclickingbuttons
authored andcommitted
Conditions And Exchanges (#127)
1 parent b25b4d1 commit 5ff5a5a

File tree

9 files changed

+243
-59
lines changed

9 files changed

+243
-59
lines changed

polygon/rest/__init__.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
11
from .aggs import AggsClient
22
from .trades import TradesClient
33
from .quotes import QuotesClient
4-
from .reference import MarketsClient, TickersClient, SplitsClient, DividendsClient
4+
from .reference import (
5+
MarketsClient,
6+
TickersClient,
7+
SplitsClient,
8+
DividendsClient,
9+
ConditionsClient,
10+
ExchangesClient,
11+
)
512

613

714
class RESTClient(
@@ -12,5 +19,7 @@ class RESTClient(
1219
TickersClient,
1320
SplitsClient,
1421
DividendsClient,
22+
ConditionsClient,
23+
ExchangesClient,
1524
):
1625
pass

polygon/rest/models/__init__.py

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,6 @@
55
from .tickers import *
66
from .splits import *
77
from .dividends import *
8-
9-
from enum import Enum
10-
11-
12-
class Sort(Enum):
13-
ASC = "asc"
14-
DESC = "desc"
15-
16-
17-
class Order(Enum):
18-
ASC = "asc"
19-
DESC = "desc"
8+
from .conditions import *
9+
from .exchanges import *
10+
from .shared import *

polygon/rest/models/conditions.py

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
from typing import Optional
2+
from .shared import AssetClass, DataType
3+
from dataclasses import dataclass
4+
5+
6+
@dataclass
7+
class SipMapping:
8+
CTA: Optional[str] = None
9+
OPRA: Optional[str] = None
10+
UTP: Optional[str] = None
11+
12+
13+
@dataclass
14+
class Consolidated:
15+
updates_high_low: Optional[bool] = None
16+
updates_open_close: Optional[bool] = None
17+
updates_volume: Optional[bool] = None
18+
19+
20+
@dataclass
21+
class MarketCenter:
22+
updates_high_low: Optional[bool] = None
23+
updates_open_close: Optional[bool] = None
24+
updates_volume: Optional[bool] = None
25+
26+
27+
@dataclass
28+
class UpdateRules:
29+
consolidated: Optional[Consolidated] = None
30+
market_center: Optional[MarketCenter] = None
31+
32+
33+
@dataclass
34+
class Condition:
35+
"Condition contains data for a condition that Polygon.io uses."
36+
abbreviation: Optional[str] = None
37+
asset_class: Optional[AssetClass] = None
38+
data_types: Optional[DataType] = None
39+
description: Optional[str] = None
40+
exchange: Optional[int] = None
41+
id: Optional[int] = None
42+
legacy: Optional[bool] = None
43+
name: Optional[str] = None
44+
sip_mapping: Optional[SipMapping] = None
45+
Type: Optional[
46+
str
47+
] = None # todo: 'type' is a keyword so here I capitalized. Should we capital case all dataclasses?
48+
update_rules: Optional[UpdateRules] = None
49+
50+
@staticmethod
51+
def from_dict(d):
52+
return Condition(**d)

polygon/rest/models/dividends.py

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,8 @@
11
from typing import Optional
2-
from enum import Enum
2+
from .shared import DividendType, Frequency
33
from dataclasses import dataclass
44

55

6-
class DividendType(Enum):
7-
CD = "CD"
8-
SC = "SC"
9-
LT = "LT"
10-
ST = "ST"
11-
12-
13-
class Frequency(Enum):
14-
OneTime = 0
15-
Anually = 1
16-
BiAnually = 2
17-
Quarterly = 4
18-
Monthly = 12
19-
20-
216
@dataclass
227
class Dividend:
238
"Dividend contains data for a historical cash dividend, including the ticker symbol, declaration date, ex-dividend date, record date, pay date, frequency, and amount."

polygon/rest/models/exchanges.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
from typing import Optional
2+
from .shared import AssetClass, Locale, ExchangeType
3+
from dataclasses import dataclass
4+
5+
6+
@dataclass
7+
class Exchange:
8+
"Exchange contains data for a condition that Polygon.io uses."
9+
acronym: Optional[str] = None
10+
asset_class: Optional[AssetClass] = None
11+
id: Optional[int] = None
12+
locale: Optional[Locale] = None
13+
mic: Optional[str] = None
14+
name: Optional[str] = None
15+
operating_mic: Optional[str] = None
16+
participant_id: Optional[str] = None
17+
type: Optional[ExchangeType] = None
18+
url: Optional[str] = None
19+
20+
@staticmethod
21+
def from_dict(d):
22+
return Exchange(**d)

polygon/rest/models/markets.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,20 @@
1-
from typing import Optional, Dict
1+
from typing import Optional
22
from dataclasses import dataclass
33

44

5+
@dataclass
6+
class Currencies:
7+
crypto: Optional[str] = None
8+
fx: Optional[str] = None
9+
10+
11+
@dataclass
12+
class Exchanges:
13+
nasdaq: Optional[str] = None
14+
nyse: Optional[str] = None
15+
otc: Optional[str] = None
16+
17+
518
@dataclass
619
class MarketHoliday:
720
"MarketHoliday contains data for upcoming market holidays and their open/close times."
@@ -21,9 +34,9 @@ def from_dict(d):
2134
class MarketStatus:
2235
"MarketStatus contains data for the current trading status of the exchanges and overall financial markets."
2336
after_hours: Optional[bool] = None
24-
currencies: Optional[Dict[str, str]] = None
37+
currencies: Optional[Currencies] = None
2538
early_hours: Optional[bool] = None
26-
exchanges: Optional[Dict[str, str]] = None
39+
exchanges: Optional[Exchanges] = None
2740
market: Optional[str] = None
2841
server_time: Optional[str] = None
2942

polygon/rest/models/shared.py

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
from enum import Enum
2+
3+
4+
class Sort(Enum):
5+
ASC = "asc"
6+
DESC = "desc"
7+
8+
9+
class Order(Enum):
10+
ASC = "asc"
11+
DESC = "desc"
12+
13+
14+
class Locale(Enum):
15+
US = "us"
16+
GLOBAL = "global"
17+
18+
19+
class Market(Enum):
20+
STOCKS = "stocks"
21+
CRYPTO = "crypto"
22+
FX = "fx"
23+
24+
25+
class AssetClass(Enum):
26+
STOCKS = "stocks"
27+
OPTIONS = "options"
28+
CRYPTO = "crypto"
29+
FX = "fx"
30+
31+
32+
class DividendType(Enum):
33+
CD = "CD"
34+
SC = "SC"
35+
LT = "LT"
36+
ST = "ST"
37+
38+
39+
class Frequency(Enum):
40+
OneTime = 0
41+
Anually = 1
42+
BiAnually = 2
43+
Quarterly = 4
44+
Monthly = 12
45+
46+
47+
class DataType(Enum):
48+
DataTrade = "trade"
49+
DataBBO = "bbo"
50+
DataNBBO = "nbbo"
51+
52+
53+
class SIP(Enum):
54+
CTA = "CTA"
55+
UTP = "UTP"
56+
OPRA = "OPRA"
57+
58+
59+
class ExchangeType(Enum):
60+
exchange = "exchange"
61+
TRF = "TRF"
62+
SIP = "SIP"

polygon/rest/models/tickers.py

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,8 @@
11
from typing import Optional, List
2-
from enum import Enum
2+
from .shared import Locale, Market, AssetClass
33
from dataclasses import dataclass
44

55

6-
class Locale(Enum):
7-
US = "us"
8-
GLOBAL = "global"
9-
10-
11-
class Market(Enum):
12-
STOCKS = "stocks"
13-
CRYPTO = "crypto"
14-
FX = "fx"
15-
16-
17-
class AssetClass(Enum):
18-
STOCKS = "stocks"
19-
OPTIONS = "options"
20-
CRYPTO = "crypto"
21-
FX = "fx"
22-
23-
246
@dataclass
257
class Address:
268
address1: Optional[str] = None

0 commit comments

Comments
 (0)