From a363476919919d97c2065d531a12c4277d3a29a0 Mon Sep 17 00:00:00 2001 From: clickingbuttons Date: Mon, 25 Apr 2022 11:48:58 -0400 Subject: [PATCH 1/4] copy rfc over (#114) --- polygon/rest/__init__.py | 7 +- polygon/rest/aggs.py | 39 + polygon/rest/base.py | 90 + polygon/rest/client.py | 253 -- polygon/rest/models/__init__.py | 229 +- polygon/rest/models/aggs.py | 26 + polygon/rest/models/definitions.py | 4180 ---------------------------- polygon/rest/models/trades.py | 23 + polygon/rest/models/unmarshal.py | 9 - polygon/rest/trades.py | 41 + rest-example.py | 31 +- 11 files changed, 242 insertions(+), 4686 deletions(-) create mode 100644 polygon/rest/aggs.py create mode 100644 polygon/rest/base.py delete mode 100644 polygon/rest/client.py create mode 100644 polygon/rest/models/aggs.py delete mode 100644 polygon/rest/models/definitions.py create mode 100644 polygon/rest/models/trades.py delete mode 100644 polygon/rest/models/unmarshal.py create mode 100644 polygon/rest/trades.py diff --git a/polygon/rest/__init__.py b/polygon/rest/__init__.py index fb5d2b40..89861e3a 100644 --- a/polygon/rest/__init__.py +++ b/polygon/rest/__init__.py @@ -1 +1,6 @@ -from .client import RESTClient +from .aggs import AggsClient +from .trades import TradesClient + +class RESTClient(AggsClient, TradesClient): + pass + diff --git a/polygon/rest/aggs.py b/polygon/rest/aggs.py new file mode 100644 index 00000000..b345d0e1 --- /dev/null +++ b/polygon/rest/aggs.py @@ -0,0 +1,39 @@ +from .base import BaseClient +from typing import Optional, Any, Dict, List, Union +from .models import Agg, Sort + +# https://polygon.io/docs/stocks +class AggsClient(BaseClient): + def get_aggs(self, + ticker: str, + multiplier: int, + timespan: str, + # "from" is a keyword in python https://www.w3schools.com/python/python_ref_keywords.asp + from_: str, + to: str, + adjusted: Optional[bool]=None, + sort: Optional[Union[str, Sort]]=None, + limit: Optional[int]=None, + params: Optional[Dict[str, Any]]=None, + raw: bool=False + ) -> List[Agg]: + """ + Get aggregate bars for a ticker over a given date range in custom time window sizes. + + :param ticker: The ticker symbol. + :param multiplier: The size of the timespan multiplier. + :param timespan: The size of the time window. + :param _from: The start of the aggregate time window. + :param to: The end of the aggregate time window. + :param adjusted: Whether or not the results are adjusted for splits. By default, results are adjusted. Set this to false to get results that are NOT adjusted for splits. + :param sort: Sort the results by timestamp. asc will return results in ascending order (oldest at the top), desc will return results in descending order (newest at the top).The end of the aggregate time window. + :param limit: Limits the number of base aggregates queried to create the aggregate results. Max 50000 and Default 5000. Read more about how limit is used to calculate aggregate results in our article on Aggregate Data API Improvements. + :param params: Any additional query params + :param raw: Return raw object instead of results object + :return: List of aggregates + :rtype: List[Agg] + """ + url = f"/v2/aggs/ticker/{ticker}/range/{multiplier}/{timespan}/{from_}/{to}" + + return self._get(path=url, params=self._get_params(self.get_aggs, locals()), resultKey="results", deserializer=Agg.from_dict, raw=raw) + diff --git a/polygon/rest/base.py b/polygon/rest/base.py new file mode 100644 index 00000000..2cbd985d --- /dev/null +++ b/polygon/rest/base.py @@ -0,0 +1,90 @@ +import os +import json +import urllib3 +import inspect +from enum import Enum +from typing import Optional, Any + +base = 'https://api.polygon.io' +env_key = "POLYGON_API_KEY" + +# https://urllib3.readthedocs.io/en/stable/reference/urllib3.poolmanager.html +class BaseClient: + def __init__( + self, + api_key: Optional[str] = os.getenv(env_key), + connect_timeout: float = 10.0, + read_timeout: float = 10.0, + num_pools: int = 10, + retries = 3, + base: str = base + ): + if api_key is None: + raise Exception(f"Must specify env var {env_key} or pass api_key in constructor") + self.API_KEY = api_key + self.BASE = base + + # https://urllib3.readthedocs.io/en/stable/reference/urllib3.connectionpool.html#urllib3.HTTPConnectionPool + self.client = urllib3.PoolManager(num_pools=num_pools, headers={ + 'Authorization': 'Bearer ' + self.API_KEY + }) + self.timeout=urllib3.Timeout(connect=connect_timeout, read=read_timeout) + self.retries = retries + + def _decode(self, resp): + return json.loads(resp.data.decode('utf-8')) + + def _get(self, path: str, params: Optional[dict] = None, resultKey: Optional[str] = None, deserializer = None, raw: bool = False) -> Any: + if params is None: + params = {} + params = {str(k): str(v) for k, v in params.items() if v is not None} + resp = self.client.request('GET', self.BASE + path, fields=params, retries=self.retries) + + if resp.status != 200: + raise Exception(resp.data.decode('utf-8')) + + if raw: + return resp + + obj = self._decode(resp) + + if resultKey: + obj = obj[resultKey] + + if deserializer: + obj = [deserializer(o) for o in obj] + + return obj + + def _get_params(self, fn, caller_locals): + params = caller_locals["params"] + if params is None: + params = {} + # https://docs.python.org/3.7/library/inspect.html#inspect.Signature + for argname, v in inspect.signature(fn).parameters.items(): + # https://docs.python.org/3.7/library/inspect.html#inspect.Parameter + if argname in ['params', 'raw']: + continue + if v.default != v.empty: + # timestamp_lt -> timestamp.lt + val = caller_locals.get(argname, v.default) + if isinstance(val, Enum): + val = val.value + if val is not None: + params[argname.replace("_", ".")] = val + + return params + + def _paginate(self, path: str, params: dict, raw: bool, deserializer): + while True: + resp = self._get(path=path, params=params, deserializer=deserializer, raw=True) + if raw: + return resp + decoded = self._decode(resp) + for t in decoded["results"]: + yield deserializer(t) + if "next_url" in decoded: + path = decoded["next_url"].replace(self.BASE, '') + params = {} + else: + return diff --git a/polygon/rest/client.py b/polygon/rest/client.py deleted file mode 100644 index 3b05fd75..00000000 --- a/polygon/rest/client.py +++ /dev/null @@ -1,253 +0,0 @@ -from typing import Dict, Type - -import requests - -from polygon.rest import models -from polygon.rest.models import unmarshal - - -class RESTClient: - """ This is a custom generated class """ - DEFAULT_HOST = "api.polygon.io" - - def __init__(self, auth_key: str, timeout: int=None): - self.auth_key = auth_key - self.url = "https://" + self.DEFAULT_HOST - - self._session = requests.Session() - self._session.params["apiKey"] = self.auth_key - self.timeout = timeout - - def __enter__(self): - return self - - def __exit__(self, *args): - self.close() - - def close(self): - self._session.close() - - def _handle_response(self, response_type: str, endpoint: str, params: Dict[str, str]) -> Type[models.AnyDefinition]: - resp: requests.Response = self._session.get(endpoint, params=params, timeout=self.timeout) - if resp.status_code == 200: - return unmarshal.unmarshal_json(response_type, resp.json()) - else: - resp.raise_for_status() - - def reference_tickers(self, **query_params) -> models.ReferenceTickersApiResponse: - endpoint = f"{self.url}/v2/reference/tickers" - return self._handle_response("ReferenceTickersApiResponse", endpoint, query_params) - - def reference_tickers_v3(self, next_url=None, **query_params) -> models.ReferenceTickersV3ApiResponse: - endpoint = f"{self.url}/v3/reference/tickers" if not next_url else next_url - return self._handle_response("ReferenceTickersV3ApiResponse", endpoint, query_params) - - def reference_ticker_types(self, **query_params) -> models.ReferenceTickerTypesApiResponse: - endpoint = f"{self.url}/v2/reference/types" - return self._handle_response("ReferenceTickerTypesApiResponse", endpoint, query_params) - - def reference_ticker_details(self, symbol, **query_params) -> models.ReferenceTickerDetailsApiResponse: - endpoint = f"{self.url}/v1/meta/symbols/{symbol}/company" - return self._handle_response("ReferenceTickerDetailsApiResponse", endpoint, query_params) - - def reference_ticker_details_vx(self, symbol, **query_params) -> models.ReferenceTickerDetailsV3ApiResponse: - endpoint = f"{self.url}/vX/reference/tickers/{symbol}" - return self._handle_response("ReferenceTickerDetailsV3ApiResponse", endpoint, query_params) - - def reference_ticker_news(self, symbol, **query_params) -> models.ReferenceTickerNewsApiResponse: - endpoint = f"{self.url}/v1/meta/symbols/{symbol}/news" - return self._handle_response("ReferenceTickerNewsApiResponse", endpoint, query_params) - - def reference_ticker_news_v2(self, **query_params) -> models.ReferenceTickerNewsV2ApiResponse: - endpoint = f"{self.url}/v2/reference/news" - return self._handle_response("ReferenceTickerNewsV2ApiResponse", endpoint, query_params) - - def reference_markets(self, **query_params) -> models.ReferenceMarketsApiResponse: - endpoint = f"{self.url}/v2/reference/markets" - return self._handle_response("ReferenceMarketsApiResponse", endpoint, query_params) - - def reference_locales(self, **query_params) -> models.ReferenceLocalesApiResponse: - endpoint = f"{self.url}/v2/reference/locales" - return self._handle_response("ReferenceLocalesApiResponse", endpoint, query_params) - - def reference_stock_splits(self, symbol, **query_params) -> models.ReferenceStockSplitsApiResponse: - endpoint = f"{self.url}/v2/reference/splits/{symbol}" - return self._handle_response("ReferenceStockSplitsApiResponse", endpoint, query_params) - - def reference_stock_dividends(self, symbol, **query_params) -> models.ReferenceStockDividendsApiResponse: - endpoint = f"{self.url}/v2/reference/dividends/{symbol}" - return self._handle_response("ReferenceStockDividendsApiResponse", endpoint, query_params) - - def reference_stock_financials(self, symbol, **query_params) -> models.ReferenceStockFinancialsApiResponse: - endpoint = f"{self.url}/v2/reference/financials/{symbol}" - return self._handle_response("ReferenceStockFinancialsApiResponse", endpoint, query_params) - - def reference_market_status(self, **query_params) -> models.ReferenceMarketStatusApiResponse: - endpoint = f"{self.url}/v1/marketstatus/now" - return self._handle_response("ReferenceMarketStatusApiResponse", endpoint, query_params) - - def reference_market_holidays(self, **query_params) -> models.ReferenceMarketHolidaysApiResponse: - endpoint = f"{self.url}/v1/marketstatus/upcoming" - return self._handle_response("ReferenceMarketHolidaysApiResponse", endpoint, query_params) - - def stocks_equities_exchanges(self, **query_params) -> models.StocksEquitiesExchangesApiResponse: - endpoint = f"{self.url}/v1/meta/exchanges" - return self._handle_response("StocksEquitiesExchangesApiResponse", endpoint, query_params) - - def stocks_equities_historic_trades(self, symbol, date, - **query_params) -> models.StocksEquitiesHistoricTradesApiResponse: - endpoint = f"{self.url}/v1/historic/trades/{symbol}/{date}" - return self._handle_response("StocksEquitiesHistoricTradesApiResponse", endpoint, query_params) - - def historic_trades_v2(self, ticker, date, **query_params) -> models.HistoricTradesV2ApiResponse: - endpoint = f"{self.url}/v2/ticks/stocks/trades/{ticker}/{date}" - return self._handle_response("HistoricTradesV2ApiResponse", endpoint, query_params) - - def stocks_equities_historic_quotes(self, symbol, date, - **query_params) -> models.StocksEquitiesHistoricQuotesApiResponse: - endpoint = f"{self.url}/v1/historic/quotes/{symbol}/{date}" - return self._handle_response("StocksEquitiesHistoricQuotesApiResponse", endpoint, query_params) - - def historic_n___bbo_quotes_v2(self, ticker, date, **query_params) -> models.HistoricNBboQuotesV2ApiResponse: - endpoint = f"{self.url}/v2/ticks/stocks/nbbo/{ticker}/{date}" - return self._handle_response("HistoricNBboQuotesV2ApiResponse", endpoint, query_params) - - def stocks_equities_last_trade_for_a_symbol(self, symbol, - **query_params) -> models.StocksEquitiesLastTradeForASymbolApiResponse: - endpoint = f"{self.url}/v1/last/stocks/{symbol}" - return self._handle_response("StocksEquitiesLastTradeForASymbolApiResponse", endpoint, query_params) - - def stocks_equities_last_quote_for_a_symbol(self, symbol, - **query_params) -> models.StocksEquitiesLastQuoteForASymbolApiResponse: - endpoint = f"{self.url}/v1/last_quote/stocks/{symbol}" - return self._handle_response("StocksEquitiesLastQuoteForASymbolApiResponse", endpoint, query_params) - - def stocks_equities_daily_open_close(self, symbol, date, - **query_params) -> models.StocksEquitiesDailyOpenCloseApiResponse: - endpoint = f"{self.url}/v1/open-close/{symbol}/{date}" - return self._handle_response("StocksEquitiesDailyOpenCloseApiResponse", endpoint, query_params) - - def stocks_equities_condition_mappings(self, ticktype, - **query_params) -> models.StocksEquitiesConditionMappingsApiResponse: - endpoint = f"{self.url}/v1/meta/conditions/{ticktype}" - return self._handle_response("StocksEquitiesConditionMappingsApiResponse", endpoint, query_params) - - def stocks_equities_snapshot_all_tickers(self, - **query_params) -> models.StocksEquitiesSnapshotAllTickersApiResponse: - endpoint = f"{self.url}/v2/snapshot/locale/us/markets/stocks/tickers" - return self._handle_response("StocksEquitiesSnapshotAllTickersApiResponse", endpoint, query_params) - - def stocks_equities_snapshot_single_ticker(self, ticker, - **query_params) -> models.StocksEquitiesSnapshotSingleTickerApiResponse: - endpoint = f"{self.url}/v2/snapshot/locale/us/markets/stocks/tickers/{ticker}" - return self._handle_response("StocksEquitiesSnapshotSingleTickerApiResponse", endpoint, query_params) - - def stocks_equities_snapshot_gainers_losers(self, direction, - **query_params) -> models.StocksEquitiesSnapshotGainersLosersApiResponse: - endpoint = f"{self.url}/v2/snapshot/locale/us/markets/stocks/{direction}" - return self._handle_response("StocksEquitiesSnapshotGainersLosersApiResponse", endpoint, query_params) - - def stocks_equities_previous_close(self, ticker, **query_params) -> models.StocksEquitiesPreviousCloseApiResponse: - endpoint = f"{self.url}/v2/aggs/ticker/{ticker}/prev" - return self._handle_response("StocksEquitiesPreviousCloseApiResponse", endpoint, query_params) - - def stocks_equities_aggregates(self, ticker, multiplier, timespan, from_, to, - **query_params) -> models.StocksEquitiesAggregatesApiResponse: - endpoint = f"{self.url}/v2/aggs/ticker/{ticker}/range/{multiplier}/{timespan}/{from_}/{to}" - return self._handle_response("StocksEquitiesAggregatesApiResponse", endpoint, query_params) - - def stocks_equities_grouped_daily(self, locale, market, date, - **query_params) -> models.StocksEquitiesGroupedDailyApiResponse: - endpoint = f"{self.url}/v2/aggs/grouped/locale/{locale}/market/{market}/{date}" - return self._handle_response("StocksEquitiesGroupedDailyApiResponse", endpoint, query_params) - - def forex_currencies_historic_forex_ticks(self, from_, to, date, - **query_params) -> models.ForexCurrenciesHistoricForexTicksApiResponse: - endpoint = f"{self.url}/v1/historic/forex/{from_}/{to}/{date}" - return self._handle_response("ForexCurrenciesHistoricForexTicksApiResponse", endpoint, query_params) - - def forex_currencies_real_time_currency_conversion(self, from_, to, - **query_params) -> models.ForexCurrenciesRealTimeCurrencyConversionApiResponse: - endpoint = f"{self.url}/v1/conversion/{from_}/{to}" - return self._handle_response("ForexCurrenciesRealTimeCurrencyConversionApiResponse", endpoint, query_params) - - def forex_currencies_last_quote_for_a_currency_pair(self, from_, to, - **query_params) -> models.ForexCurrenciesLastQuoteForACurrencyPairApiResponse: - endpoint = f"{self.url}/v1/last_quote/currencies/{from_}/{to}" - return self._handle_response("ForexCurrenciesLastQuoteForACurrencyPairApiResponse", endpoint, query_params) - - def forex_currencies_grouped_daily(self, date, **query_params) -> models.ForexCurrenciesGroupedDailyApiResponse: - endpoint = f"{self.url}/v2/aggs/grouped/locale/global/market/fx/{date}" - return self._handle_response("ForexCurrenciesGroupedDailyApiResponse", endpoint, query_params) - - def forex_currencies_previous_close(self, ticker, **query_params) -> models.ForexCurrenciesGroupedDailyApiResponse: - endpoint = f"{self.url}/v2/aggs/ticker/{ticker}/prev" - return self._handle_response("ForexCurrenciesPreviousCloseApiResponse", endpoint, query_params) - - def forex_currencies_snapshot_all_tickers(self, - **query_params) -> models.ForexCurrenciesSnapshotAllTickersApiResponse: - endpoint = f"{self.url}/v2/snapshot/locale/global/markets/forex/tickers" - return self._handle_response("ForexCurrenciesSnapshotAllTickersApiResponse", endpoint, query_params) - - def forex_currencies_snapshot_single_ticker(self, ticker, **query_params) -> models.ForexCurrenciesSnapshotSingleTickerApiResponse: - endpoint = f"{self.url}/v2/snapshot/locale/global/markets/forex/tickers/{ticker}" - return self._handle_response("ForexCurrenciesSnapshotSingleTickerApiResponse", endpoint, query_params) - - def forex_currencies_snapshot_gainers_losers(self, direction, - **query_params) -> models.ForexCurrenciesSnapshotGainersLosersApiResponse: - endpoint = f"{self.url}/v2/snapshot/locale/global/markets/forex/{direction}" - return self._handle_response("ForexCurrenciesSnapshotGainersLosersApiResponse", endpoint, query_params) - - def forex_currencies_aggregates(self, ticker, multiplier, timespan, from_, to, - **query_params) -> models.CurrenciesAggregatesApiResponse: - endpoint = f"{self.url}/v2/aggs/ticker/{ticker}/range/{multiplier}/{timespan}/{from_}/{to}" - return self._handle_response("CurrenciesAggregatesApiResponse", endpoint, query_params) - - def crypto_crypto_exchanges(self, **query_params) -> models.CryptoCryptoExchangesApiResponse: - endpoint = f"{self.url}/v1/meta/crypto-exchanges" - return self._handle_response("CryptoCryptoExchangesApiResponse", endpoint, query_params) - - def crypto_last_trade_for_a_crypto_pair(self, from_, to, - **query_params) -> models.CryptoLastTradeForACryptoPairApiResponse: - endpoint = f"{self.url}/v1/last/crypto/{from_}/{to}" - return self._handle_response("CryptoLastTradeForACryptoPairApiResponse", endpoint, query_params) - - def crypto_daily_open_close(self, from_, to, date, **query_params) -> models.CryptoDailyOpenCloseApiResponse: - endpoint = f"{self.url}/v1/open-close/crypto/{from_}/{to}/{date}" - return self._handle_response("CryptoDailyOpenCloseApiResponse", endpoint, query_params) - - def crypto_aggregates(self, ticker, multiplier, timespan, from_, to, - **query_params) -> models.CurrenciesAggregatesApiResponse: - endpoint = f"{self.url}/v2/aggs/ticker/{ticker}/range/{multiplier}/{timespan}/{from_}/{to}" - return self._handle_response("CurrenciesAggregatesApiResponse", endpoint, query_params) - - def crypto_historic_crypto_trades(self, from_, to, date, - **query_params) -> models.CryptoHistoricCryptoTradesApiResponse: - endpoint = f"{self.url}/v1/historic/crypto/{from_}/{to}/{date}" - return self._handle_response("CryptoHistoricCryptoTradesApiResponse", endpoint, query_params) - - def crypto_grouped_daily(self, date, **query_params) -> models.CryptoGroupedDailyApiResponse: - endpoint = f"{self.url}/v2/aggs/grouped/locale/global/market/crypto/{date}" - return self._handle_response("CryptoGroupedDailyApiResponse", endpoint, query_params) - - def crypto_previous_close(self, ticker, **query_params) -> models.CryptoPreviousCloseApiResponse: - endpoint = f"{self.url}/v2/aggs/ticker/{ticker}/prev" - return self._handle_response("CryptoPreviousCloseApiResponse", endpoint, query_params) - - def crypto_snapshot_all_tickers(self, **query_params) -> models.CryptoSnapshotAllTickersApiResponse: - endpoint = f"{self.url}/v2/snapshot/locale/global/markets/crypto/tickers" - return self._handle_response("CryptoSnapshotAllTickersApiResponse", endpoint, query_params) - - def crypto_snapshot_single_ticker(self, ticker, **query_params) -> models.CryptoSnapshotSingleTickerApiResponse: - endpoint = f"{self.url}/v2/snapshot/locale/global/markets/crypto/tickers/{ticker}" - return self._handle_response("CryptoSnapshotSingleTickerApiResponse", endpoint, query_params) - - def crypto_snapshot_single_ticker_full_book(self, ticker, - **query_params) -> models.CryptoSnapshotSingleTickerFullBookApiResponse: - endpoint = f"{self.url}/v2/snapshot/locale/global/markets/crypto/tickers/{ticker}/book" - return self._handle_response("CryptoSnapshotSingleTickerFullBookApiResponse", endpoint, query_params) - - def crypto_snapshot_gainers_losers(self, direction, - **query_params) -> models.CryptoSnapshotGainersLosersApiResponse: - endpoint = f"{self.url}/v2/snapshot/locale/global/markets/crypto/{direction}" - return self._handle_response("CryptoSnapshotGainersLosersApiResponse", endpoint, query_params) diff --git a/polygon/rest/models/__init__.py b/polygon/rest/models/__init__.py index 8afea378..a912d6cc 100644 --- a/polygon/rest/models/__init__.py +++ b/polygon/rest/models/__init__.py @@ -1,223 +1,12 @@ -from .definitions import LastTrade -from .definitions import LastQuote -from .definitions import HistTrade -from .definitions import Quote -from .definitions import Aggregate -from .definitions import Company -from .definitions import CompanyV3 -from .definitions import Address -from .definitions import Symbol -from .definitions import SymbolV3 -from .definitions import Dividend -from .definitions import News -from .definitions import NewsV2 -from .definitions import Publisher -from .definitions import Earning -from .definitions import Financial -from .definitions import Exchange -from .definitions import Error -from .definitions import NotFound -from .definitions import Conflict -from .definitions import Unauthorized -from .definitions import MarketStatus -from .definitions import MarketHoliday -from .definitions import AnalystRatings -from .definitions import RatingSection -from .definitions import CryptoTick -from .definitions import CryptoTickJson -from .definitions import CryptoExchange -from .definitions import CryptoSnapshotTicker -from .definitions import CryptoSnapshotBookItem -from .definitions import CryptoSnapshotTickerBook -from .definitions import CryptoSnapshotAgg -from .definitions import Forex -from .definitions import LastForexTrade -from .definitions import LastForexQuote -from .definitions import ForexAggregate -from .definitions import ForexSnapshotTicker -from .definitions import ForexSnapshotAgg -from .definitions import Ticker -from .definitions import Split -from .definitions import Financials -from .definitions import Trade -from .definitions import StocksSnapshotTicker -from .definitions import StocksSnapshotBookItem -from .definitions import StocksSnapshotTickerBook -from .definitions import StocksV2Trade -from .definitions import StocksV2NBBO -from .definitions import StocksSnapshotAgg -from .definitions import StocksSnapshotQuote -from .definitions import Aggv2 -from .definitions import AggResponse -from .definitions import ReferenceTickersApiResponse -from .definitions import ReferenceTickersV3ApiResponse -from .definitions import ReferenceTickerTypesApiResponse -from .definitions import ReferenceTickerDetailsApiResponse -from .definitions import ReferenceTickerDetailsV3ApiResponse -from .definitions import ReferenceTickerNewsApiResponse -from .definitions import ReferenceTickerNewsV2ApiResponse -from .definitions import ReferenceMarketsApiResponse -from .definitions import ReferenceLocalesApiResponse -from .definitions import ReferenceStockSplitsApiResponse -from .definitions import ReferenceStockDividendsApiResponse -from .definitions import ReferenceStockFinancialsApiResponse -from .definitions import ReferenceMarketStatusApiResponse -from .definitions import ReferenceMarketHolidaysApiResponse -from .definitions import StocksEquitiesExchangesApiResponse -from .definitions import StocksEquitiesHistoricTradesApiResponse -from .definitions import HistoricTradesV2ApiResponse -from .definitions import StocksEquitiesHistoricQuotesApiResponse -from .definitions import HistoricNBboQuotesV2ApiResponse -from .definitions import StocksEquitiesLastTradeForASymbolApiResponse -from .definitions import StocksEquitiesLastQuoteForASymbolApiResponse -from .definitions import StocksEquitiesDailyOpenCloseApiResponse -from .definitions import StocksEquitiesConditionMappingsApiResponse -from .definitions import StocksEquitiesSnapshotAllTickersApiResponse -from .definitions import StocksEquitiesSnapshotSingleTickerApiResponse -from .definitions import StocksEquitiesSnapshotGainersLosersApiResponse -from .definitions import StocksEquitiesPreviousCloseApiResponse -from .definitions import StocksEquitiesAggregatesApiResponse -from .definitions import StocksEquitiesGroupedDailyApiResponse -from .definitions import ForexCurrenciesHistoricForexTicksApiResponse -from .definitions import ForexCurrenciesRealTimeCurrencyConversionApiResponse -from .definitions import ForexCurrenciesLastQuoteForACurrencyPairApiResponse -from. definitions import ForexCurrenciesGroupedDailyApiResponse -from .definitions import ForexCurrenciesPreviousCloseApiResponse -from .definitions import ForexCurrenciesSnapshotAllTickersApiResponse -from .definitions import ForexCurrenciesSnapshotSingleTickerApiResponse -from .definitions import ForexCurrenciesSnapshotGainersLosersApiResponse -from .definitions import CryptoCryptoExchangesApiResponse -from .definitions import CryptoLastTradeForACryptoPairApiResponse -from .definitions import CryptoDailyOpenCloseApiResponse -from .definitions import CryptoHistoricCryptoTradesApiResponse -from .definitions import CryptoGroupedDailyApiResponse -from .definitions import CryptoPreviousCloseApiResponse -from .definitions import CryptoSnapshotAllTickersApiResponse -from .definitions import CryptoSnapshotSingleTickerApiResponse -from .definitions import CryptoSnapshotSingleTickerFullBookApiResponse -from .definitions import CryptoSnapshotGainersLosersApiResponse -from .definitions import CurrenciesAggregatesApiResponse -from .definitions import StockSymbol -from .definitions import ConditionTypeMap -from .definitions import SymbolTypeMap -from .definitions import TickerSymbol +from .aggs import * +from .trades import * +from enum import Enum +class Sort(Enum): + ASC = 'asc' + DESC = 'desc' -import typing +class Order(Enum): + ASC = 'asc' + DESC = 'desc' -from .definitions import Definition - - -AnyDefinition = typing.TypeVar("AnyDefinition", bound=Definition) - -# noinspection SpellCheckingInspection -name_to_class: typing.Dict[str, typing.Callable[[], typing.Type[AnyDefinition]]] = { - "LastTrade": LastTrade, - "LastQuote": LastQuote, - "HistTrade": HistTrade, - "Quote": Quote, - "Aggregate": Aggregate, - "Company": Company, - "CompanyV3": CompanyV3, - "Address": Address, - "Symbol": Symbol, - "Dividend": Dividend, - "News": News, - "NewsV2": NewsV2, - "Publisher": Publisher, - "Earning": Earning, - "Financial": Financial, - "Exchange": Exchange, - "Error": Error, - "NotFound": NotFound, - "Conflict": Conflict, - "Unauthorized": Unauthorized, - "MarketStatus": MarketStatus, - "MarketHoliday": MarketHoliday, - "AnalystRatings": AnalystRatings, - "RatingSection": RatingSection, - "CryptoTick": CryptoTick, - "CryptoTickJson": CryptoTickJson, - "CryptoExchange": CryptoExchange, - "CryptoSnapshotTicker": CryptoSnapshotTicker, - "CryptoSnapshotBookItem": CryptoSnapshotBookItem, - "CryptoSnapshotTickerBook": CryptoSnapshotTickerBook, - "CryptoSnapshotAgg": CryptoSnapshotAgg, - "Forex": Forex, - "LastForexTrade": LastForexTrade, - "LastForexQuote": LastForexQuote, - "ForexAggregate": ForexAggregate, - "ForexSnapshotTicker": ForexSnapshotTicker, - "ForexSnapshotAgg": ForexSnapshotAgg, - "Ticker": Ticker, - "Split": Split, - "Financials": Financials, - "Trade": Trade, - "StocksSnapshotTicker": StocksSnapshotTicker, - "StocksSnapshotBookItem": StocksSnapshotBookItem, - "StocksSnapshotTickerBook": StocksSnapshotTickerBook, - "StocksV2Trade": StocksV2Trade, - "StocksV2NBBO": StocksV2NBBO, - "StocksSnapshotAgg": StocksSnapshotAgg, - "StocksSnapshotQuote": StocksSnapshotQuote, - "Aggv2": Aggv2, - "AggResponse": AggResponse, - "ReferenceTickersApiResponse": ReferenceTickersApiResponse, - "ReferenceTickersV3ApiResponse": ReferenceTickersV3ApiResponse, - "ReferenceTickerTypesApiResponse": ReferenceTickerTypesApiResponse, - "ReferenceTickerDetailsApiResponse": ReferenceTickerDetailsApiResponse, - "ReferenceTickerDetailsV3ApiResponse": ReferenceTickerDetailsV3ApiResponse, - "ReferenceTickerNewsApiResponse": ReferenceTickerNewsApiResponse, - "ReferenceTickerNewsV2ApiResponse": ReferenceTickerNewsV2ApiResponse, - "ReferenceMarketsApiResponse": ReferenceMarketsApiResponse, - "ReferenceLocalesApiResponse": ReferenceLocalesApiResponse, - "ReferenceStockSplitsApiResponse": ReferenceStockSplitsApiResponse, - "ReferenceStockDividendsApiResponse": ReferenceStockDividendsApiResponse, - "ReferenceStockFinancialsApiResponse": ReferenceStockFinancialsApiResponse, - "ReferenceMarketStatusApiResponse": ReferenceMarketStatusApiResponse, - "ReferenceMarketHolidaysApiResponse": ReferenceMarketHolidaysApiResponse, - "StocksEquitiesExchangesApiResponse": StocksEquitiesExchangesApiResponse, - "StocksEquitiesHistoricTradesApiResponse": StocksEquitiesHistoricTradesApiResponse, - "HistoricTradesV2ApiResponse": HistoricTradesV2ApiResponse, - "StocksEquitiesHistoricQuotesApiResponse": StocksEquitiesHistoricQuotesApiResponse, - "HistoricNBboQuotesV2ApiResponse": HistoricNBboQuotesV2ApiResponse, - "StocksEquitiesLastTradeForASymbolApiResponse": StocksEquitiesLastTradeForASymbolApiResponse, - "StocksEquitiesLastQuoteForASymbolApiResponse": StocksEquitiesLastQuoteForASymbolApiResponse, - "StocksEquitiesDailyOpenCloseApiResponse": StocksEquitiesDailyOpenCloseApiResponse, - "StocksEquitiesConditionMappingsApiResponse": StocksEquitiesConditionMappingsApiResponse, - "StocksEquitiesSnapshotAllTickersApiResponse": StocksEquitiesSnapshotAllTickersApiResponse, - "StocksEquitiesSnapshotSingleTickerApiResponse": StocksEquitiesSnapshotSingleTickerApiResponse, - "StocksEquitiesSnapshotGainersLosersApiResponse": StocksEquitiesSnapshotGainersLosersApiResponse, - "StocksEquitiesPreviousCloseApiResponse": StocksEquitiesPreviousCloseApiResponse, - "StocksEquitiesAggregatesApiResponse": StocksEquitiesAggregatesApiResponse, - "StocksEquitiesGroupedDailyApiResponse": StocksEquitiesGroupedDailyApiResponse, - "ForexCurrenciesHistoricForexTicksApiResponse": ForexCurrenciesHistoricForexTicksApiResponse, - "ForexCurrenciesRealTimeCurrencyConversionApiResponse": ForexCurrenciesRealTimeCurrencyConversionApiResponse, - "ForexCurrenciesLastQuoteForACurrencyPairApiResponse": ForexCurrenciesLastQuoteForACurrencyPairApiResponse, - "ForexCurrenciesGroupedDailyApiResponse": ForexCurrenciesGroupedDailyApiResponse, - "ForexCurrenciesPreviousCloseApiResponse": ForexCurrenciesPreviousCloseApiResponse, - "ForexCurrenciesSnapshotAllTickersApiResponse": ForexCurrenciesSnapshotAllTickersApiResponse, - "ForexCurrenciesSnapshotSingleTickerApiResponse": ForexCurrenciesSnapshotSingleTickerApiResponse, - "ForexCurrenciesSnapshotGainersLosersApiResponse": ForexCurrenciesSnapshotGainersLosersApiResponse, - "CryptoCryptoExchangesApiResponse": CryptoCryptoExchangesApiResponse, - "CryptoLastTradeForACryptoPairApiResponse": CryptoLastTradeForACryptoPairApiResponse, - "CryptoDailyOpenCloseApiResponse": CryptoDailyOpenCloseApiResponse, - "CryptoHistoricCryptoTradesApiResponse": CryptoHistoricCryptoTradesApiResponse, - "CryptoGroupedDailyApiResponse": CryptoGroupedDailyApiResponse, - "CryptoPreviousCloseApiResponse": CryptoPreviousCloseApiResponse, - "CryptoSnapshotAllTickersApiResponse": CryptoSnapshotAllTickersApiResponse, - "CryptoSnapshotSingleTickerApiResponse": CryptoSnapshotSingleTickerApiResponse, - "CryptoSnapshotSingleTickerFullBookApiResponse": CryptoSnapshotSingleTickerFullBookApiResponse, - "CryptoSnapshotGainersLosersApiResponse": CryptoSnapshotGainersLosersApiResponse, - "CurrenciesAggregatesApiResponse": CurrenciesAggregatesApiResponse, - -} - -# noinspection SpellCheckingInspection -name_to_type = { - "StockSymbol": StockSymbol, - "ConditionTypeMap": ConditionTypeMap, - "SymbolTypeMap": SymbolTypeMap, - "TickerSymbol": TickerSymbol, - -} \ No newline at end of file diff --git a/polygon/rest/models/aggs.py b/polygon/rest/models/aggs.py new file mode 100644 index 00000000..b303c21d --- /dev/null +++ b/polygon/rest/models/aggs.py @@ -0,0 +1,26 @@ +from dataclasses import dataclass + +@dataclass +class Agg: + open: float + high: float + low: float + close: float + volume: float + vwap: float + timestamp: int + transactions: int + + @staticmethod + def from_dict(d): + return Agg( + d['o'], + d['h'], + d['l'], + d['c'], + d['v'], + d['vw'], + d['t'], + d['n'] + ) + diff --git a/polygon/rest/models/definitions.py b/polygon/rest/models/definitions.py deleted file mode 100644 index c05b7cde..00000000 --- a/polygon/rest/models/definitions.py +++ /dev/null @@ -1,4180 +0,0 @@ -import keyword -from typing import List, Dict, Any - -from polygon.rest import models - - -class Definition: - _swagger_name_to_python: Dict[str, str] - _attribute_is_primitive: Dict[str, bool] - _attributes_to_types: Dict[str, Any] - - def unmarshal_json(self, input_json): - if isinstance(input_json, list): - list_attribute_name = list(self._swagger_name_to_python.values())[0] - if list_attribute_name in self._attributes_to_types: - list_type = self._attributes_to_types[list_attribute_name] - known_type = list_type.split("[")[1][:-1] - list_items = self._unmarshal_json_list(input_json, known_type) - else: - list_items = input_json - self.__setattr__(list_attribute_name, list_items) - return self - elif isinstance(input_json, dict): - self._unmarshal_json_object(input_json) - return self - elif isinstance(input_json, float) or isinstance(input_json, int): - return input_json - - @staticmethod - def _unmarshal_json_list(input_json, known_type): - items = [] - for item in input_json: - new_item = models.name_to_class[known_type]() - items.append(new_item._unmarshal_json_object(item)) - - return items - - def _unmarshal_json_object(self, input_json): - for key, value in input_json.items(): - if key in self._swagger_name_to_python: - attribute_name = self._swagger_name_to_python[key] - if not self._attribute_is_primitive[attribute_name]: - if attribute_name in self._attributes_to_types: - attribute_type = self._attributes_to_types[attribute_name] - if attribute_type in models.name_to_class: - model = models.name_to_class[attribute_type]() - value = model.unmarshal_json(input_json[key]) - else: - attribute_name = key + ('_' if keyword.iskeyword(key) else '') - - self.__setattr__(attribute_name, value) - return self - - -# noinspection SpellCheckingInspection -class LastTrade(Definition): - _swagger_name_to_python = { - "price": "price", - "size": "size", - "exchange": "exchange", - "cond1": "cond1", - "cond2": "cond2", - "cond3": "cond3", - "cond4": "cond4", - "timestamp": "timestamp", - - } - - _attribute_is_primitive = { - "price": True, - "size": True, - "exchange": True, - "cond1": True, - "cond2": True, - "cond3": True, - "cond4": True, - "timestamp": True, - - } - - _attributes_to_types = { - "price": "int", - "size": "int", - "exchange": "int", - "cond1": "int", - "cond2": "int", - "cond3": "int", - "cond4": "int", - "timestamp": "int", - - } - - def __init__(self): - self.price: int - self.size: int - self.exchange: int - self.cond1: int - self.cond2: int - self.cond3: int - self.cond4: int - self.timestamp: int - - -# noinspection SpellCheckingInspection -class LastQuote(Definition): - _swagger_name_to_python = { - "askprice": "askprice", - "asksize": "asksize", - "askexchange": "askexchange", - "bidprice": "bidprice", - "bidsize": "bidsize", - "bidexchange": "bidexchange", - "timestamp": "timestamp", - - } - - _attribute_is_primitive = { - "askprice": True, - "asksize": True, - "askexchange": True, - "bidprice": True, - "bidsize": True, - "bidexchange": True, - "timestamp": True, - - } - - _attributes_to_types = { - "askprice": "int", - "asksize": "int", - "askexchange": "int", - "bidprice": "int", - "bidsize": "int", - "bidexchange": "int", - "timestamp": "int", - - } - - def __init__(self): - self.askprice: int - self.asksize: int - self.askexchange: int - self.bidprice: int - self.bidsize: int - self.bidexchange: int - self.timestamp: int - - -# noinspection SpellCheckingInspection -class HistTrade(Definition): - _swagger_name_to_python = { - "condition1": "condition1", - "condition2": "condition2", - "condition3": "condition3", - "condition4": "condition4", - "exchange": "exchange", - "price": "price", - "size": "size", - "timestamp": "timestamp", - - } - - _attribute_is_primitive = { - "condition1": True, - "condition2": True, - "condition3": True, - "condition4": True, - "exchange": True, - "price": True, - "size": True, - "timestamp": True, - - } - - _attributes_to_types = { - "condition1": "int", - "condition2": "int", - "condition3": "int", - "condition4": "int", - "exchange": "str", - "price": "int", - "size": "int", - "timestamp": "str", - - } - - def __init__(self): - self.condition1: int - self.condition2: int - self.condition3: int - self.condition4: int - self.exchange: str - self.price: int - self.size: int - self.timestamp: str - - -# noinspection SpellCheckingInspection -class Quote(Definition): - _swagger_name_to_python = { - "c": "condition_of_this_quote", - "bE": "bid_exchange", - "aE": "ask_exchange", - "aP": "ask_price", - "bP": "bid_price", - "bS": "bid_size", - "aS": "ask_size", - "t": "timestamp_of_this_trade", - - } - - _attribute_is_primitive = { - "condition_of_this_quote": True, - "bid_exchange": True, - "ask_exchange": True, - "ask_price": True, - "bid_price": True, - "bid_size": True, - "ask_size": True, - "timestamp_of_this_trade": True, - - } - - _attributes_to_types = { - "condition_of_this_quote": "int", - "bid_exchange": "str", - "ask_exchange": "str", - "ask_price": "int", - "bid_price": "int", - "bid_size": "int", - "ask_size": "int", - "timestamp_of_this_trade": "int", - - } - - def __init__(self): - self.condition_of_this_quote: int - self.bid_exchange: str - self.ask_exchange: str - self.ask_price: int - self.bid_price: int - self.bid_size: int - self.ask_size: int - self.timestamp_of_this_trade: int - - -# noinspection SpellCheckingInspection -class Aggregate(Definition): - _swagger_name_to_python = { - "o": "open_price", - "c": "close_price", - "l": "low_price", - "h": "high_price", - "v": "total_volume_of_all_trades", - "k": "transactions", - "t": "timestamp_of_this_aggregation", - - } - - _attribute_is_primitive = { - "open_price": True, - "close_price": True, - "low_price": True, - "high_price": True, - "total_volume_of_all_trades": True, - "transactions": True, - "timestamp_of_this_aggregation": True, - - } - - _attributes_to_types = { - "open_price": "int", - "close_price": "int", - "low_price": "int", - "high_price": "int", - "total_volume_of_all_trades": "int", - "transactions": "int", - "timestamp_of_this_aggregation": "int", - - } - - def __init__(self): - self.open_price: int - self.close_price: int - self.low_price: int - self.high_price: int - self.total_volume_of_all_trades: int - self.transactions: int - self.timestamp_of_this_aggregation: int - - -# noinspection SpellCheckingInspection -class Company(Definition): - _swagger_name_to_python = { - "logo": "logo", - "exchange": "exchange", - "name": "name", - "symbol": "symbol", - "listdate": "listdate", - "cik": "cik", - "bloomberg": "bloomberg", - "figi": "figi", - "lei": "lei", - "sic": "sic", - "country": "country", - "industry": "industry", - "sector": "sector", - "marketcap": "marketcap", - "employees": "employees", - "phone": "phone", - "ceo": "ceo", - "url": "url", - "description": "description", - "similar": "similar", - "tags": "tags", - "updated": "updated", - - } - - _attribute_is_primitive = { - "logo": True, - "exchange": True, - "name": True, - "symbol": False, - "listdate": True, - "cik": True, - "bloomberg": True, - "figi": True, - "lei": True, - "sic": True, - "country": True, - "industry": True, - "sector": True, - "marketcap": True, - "employees": True, - "phone": True, - "ceo": True, - "url": True, - "description": True, - "similar": False, - "tags": False, - "updated": True, - - } - - _attributes_to_types = { - "logo": "str", - "exchange": "str", - "name": "str", - "symbol": "StockSymbol", - "listdate": "str", - "cik": "str", - "bloomberg": "str", - "figi": "str", - "lei": "str", - "sic": "float", - "country": "str", - "industry": "str", - "sector": "str", - "marketcap": "float", - "employees": "float", - "phone": "str", - "ceo": "str", - "url": "str", - "description": "str", - "similar": "List[StockSymbol]", - "tags": "List[str]", - "updated": "str", - - } - - def __init__(self): - self.logo: str - self.exchange: str - self.name: str - self.symbol: StockSymbol - self.listdate: str - self.cik: str - self.bloomberg: str - self.figi: str - self.lei: str - self.sic: float - self.country: str - self.industry: str - self.sector: str - self.marketcap: float - self.employees: float - self.phone: str - self.ceo: str - self.url: str - self.description: str - self.similar: List[StockSymbol] - self.tags: List[str] - self.updated: str - -class Address(Definition): - _swagger_name_to_python = { - "address1": "address1", - "city": "city", - "state": "state", - } - - _attributes_is_primitive = { - "address1": True, - "city": True, - "state": True, - } - - _attributes_to_types = { - "address1": "str", - "city": "str", - "state": "str", - } - - def __init__(self): - self.address1: str - self.city: str - self.state: str - - -# noinspection SpellCheckingInspection -class CompanyV3(Definition): - _swagger_name_to_python = { - "ticker": "ticker", - "name": "name", - "market": "market", - "locale": "locale", - "primary_exchange": "primary_exchange", - "type": "type", - "active": "active", - "currency_name": "currency_name", - "cik": "cik", - "composite_figi": "composite_figi", - "share_class_figi": "share_class_figi", - "last_updated_utc": "last_updated_utc", - "outstanding_shares": "outstanding_shares", - "market_cap": "market_cap", - "phone_number": "phone_number", - "address": "address", - "sic_code": "sic_code", - "sic_description": "sic_description", - } - - _attributes_is_primitive = { - "ticker": True, - "name": True, - "market": True, - "primary_exchange": True, - "type": True, - "active": True, - "currency_name": True, - "cik": True, - "composite_figi": True, - "share_class_figi": True, - "last_updated_utc": True, - "outstanding_shares": True, - "market_cap": True, - "phone_number": True, - "address": False, - "sic_code": True, - "sic_description": True, - } - - _attributes_to_types = { - "ticker": "str", - "name": "str", - "market": "str", - "primary_exchange": "str", - "type": "str", - "active": "bool", - "currency_name": "str", - "cik": "str", - "composite_figi": "str", - "share_class_figi": "str", - "last_updated_utc": "str", - "outstanding_shares": "int", - "market_cap": "int", - "phone_number": "str", - "address": "Address", - "sic_code": "str", - "sic_description": "str", - } - - def __init__(self): - self.ticker: str - self.name: str - self.market: str - self.primary_exchange: str - self.type: str - self.active: bool - self.currency_name: str - self.cik: str - self.composite_figi: str - self.share_class_figi: str - self.last_updated_utc: str - self.outstanding_shares: int - self.market_cap: int - self.phone_number: str - self.address: Address - self.sic_code: str - self.sic_description: str - -# noinspection SpellCheckingInspection -class Symbol(Definition): - _swagger_name_to_python = { - "symbol": "symbol", - "name": "name", - "type": "type", - "url": "url", - "updated": "updated", - "isOTC": "is___otc", - - } - - _attribute_is_primitive = { - "symbol": False, - "name": True, - "type": True, - "url": True, - "updated": True, - "is___otc": True, - - } - - _attributes_to_types = { - "symbol": "StockSymbol", - "name": "str", - "type": "str", - "url": "str", - "updated": "str", - "is___otc": "bool", - - } - - def __init__(self): - self.symbol: StockSymbol - self.name: str - self.type: str - self.url: str - self.updated: str - self.is___otc: bool - - -# noinspection SpellCheckingInspection -class SymbolV3(Definition): - _swagger_name_to_python = { - "ticker": "ticker", - "name": "name", - "market": "market", - "locale": "locale", - "primary_exchange": "primary_exchange", - "type": "type", - "active": "active", - "currency_name": "currency_name", - "cik": "cik", - "composite_figi": "composite_figi", - "share_class_figi": "share_class_figi", - "last_updated_utc": "last_updated_utc", - "delisted_utc": "delisted_utc", - } - - _attributes_is_primitive = { - "ticker": True, - "name": True, - "market": True, - "primary_exchange": True, - "type": True, - "active": True, - "currency_name": True, - "cik": True, - "composite_figi": True, - "share_class_figi": True, - "last_updated_utc": True, - "delisted_utc": True, - } - - _attributes_to_types = { - "ticker": "str", - "name": "str", - "market": "str", - "primary_exchange": "str", - "type": "str", - "active": "bool", - "currency_name": "str", - "cik": "str", - "composite_figi": "str", - "share_class_figi": "str", - "last_updated_utc": "str", - "delisted_utc": "str", - } - - def __init__(self): - self.ticker: str - self.name: str - self.market: str - self.primary_exchange: str - self.type: str - self.active: bool - self.currency_name: str - self.cik: str - self.composite_figi: str - self.share_class_figi: str - self.last_updated_utc: str - self.delisted_utc: str - -# noinspection SpellCheckingInspection -class Dividend(Definition): - _swagger_name_to_python = { - "symbol": "symbol", - "type": "type", - "exDate": "ex_date", - "paymentDate": "payment_date", - "recordDate": "record_date", - "declaredDate": "declared_date", - "amount": "amount", - "qualified": "qualified", - "flag": "flag", - - } - - _attribute_is_primitive = { - "symbol": False, - "type": True, - "ex_date": True, - "payment_date": True, - "record_date": True, - "declared_date": True, - "amount": True, - "qualified": True, - "flag": True, - - } - - _attributes_to_types = { - "symbol": "StockSymbol", - "type": "str", - "ex_date": "str", - "payment_date": "str", - "record_date": "str", - "declared_date": "str", - "amount": "float", - "qualified": "str", - "flag": "str", - - } - - def __init__(self): - self.symbol: StockSymbol - self.type: str - self.ex_date: str - self.payment_date: str - self.record_date: str - self.declared_date: str - self.amount: float - self.qualified: str - self.flag: str - - -# noinspection SpellCheckingInspection -class News(Definition): - _swagger_name_to_python = { - "symbols": "symbols", - "title": "title", - "url": "url", - "source": "source", - "summary": "summary", - "image": "image", - "timestamp": "timestamp", - "keywords": "keywords", - - } - - _attribute_is_primitive = { - "symbols": False, - "title": True, - "url": True, - "source": True, - "summary": True, - "image": True, - "timestamp": True, - "keywords": False, - - } - - _attributes_to_types = { - "symbols": "List[StockSymbol]", - "title": "str", - "url": "str", - "source": "str", - "summary": "str", - "image": "str", - "timestamp": "str", - "keywords": "List[str]", - - } - - def __init__(self): - self.symbols: List[StockSymbol] - self.title: str - self.url: str - self.source: str - self.summary: str - self.image: str - self.timestamp: str - self.keywords: List[str] - -class Publisher(Definition): - _swagger_name_to_python = { - "name": "name", - "logo_url": "logo_url", - "homepage_url": "homepage_url", - "favicon_url": "favicon_url", - } - - _attribute_is_primitive = { - "name": True, - "logo_url": True, - "homepage_url": True, - "favicon_url": True, - } - - _attributes_to_type = { - "name": "str", - "logo_url": "str", - "homepage_url": "str", - "favicon_url": "str", - } - - def __init__(self): - self.name: str - self.logo_url: str - self.homepage_url: str - self.favicon_url: str - - -# noinspection SpellCheckingInspection -class NewsV2(Definition): - _swagger_name_to_python = { - "id": "id", - "publisher": "publisher", - "title": "title", - "author": "author", - "published_utc": "published_utc", - "tickers": "tickers", - "amp_url": "amp_url", - "image_url": "image_url", - "description": "description", - "keywords": "keywords", - } - - _attribute_is_primitive = { - "id": True, - "publisher": False, - "title": True, - "author": True, - "published_utc": True, - "tickers": True, - "amp_url": True, - "image_url": True, - "description": True, - "keywords": True, - } - - _attributes_to_type = { - "id": "str", - "publisher": "Publisher", - "title": "str", - "author": "str", - "published_utc": "str", - "tickers": "List[str]", - "amp_url": "str", - "image_url": "str", - "description": "str", - "keywords": "str", - } - - def __init__(self): - self.id: str - self.publisher: Publisher - self.title: str - self.author: str - self.published_utc: str - self.tickers: List[str] - self.amp_url: str - self.image_url: str - self.description: str - self.keywords: str - -# noinspection SpellCheckingInspection -class Earning(Definition): - _swagger_name_to_python = { - "symbol": "symbol", - "EPSReportDate": "e___psrep_ortdate", - "EPSReportDateStr": "e___psrep_ort_datestr", - "fiscalPeriod": "fiscal_period", - "fiscalEndDate": "fiscal_en_ddate", - "actualEPS": "actual___eps", - "consensusEPS": "consensus___eps", - "estimatedEPS": "estimated___eps", - "announceTime": "announce_time", - "numberOfEstimates": "number_o_festimates", - "EPSSurpriseDollar": "e___pssurpr_isedollar", - "yearAgo": "year_ago", - "yearAgoChangePercent": "year_ag_ochan_gepercent", - "estimatedChangePercent": "estimated_chang_epercent", - - } - - _attribute_is_primitive = { - "symbol": True, - "e___psrep_ortdate": True, - "e___psrep_ort_datestr": True, - "fiscal_period": True, - "fiscal_en_ddate": True, - "actual___eps": True, - "consensus___eps": True, - "estimated___eps": True, - "announce_time": True, - "number_o_festimates": True, - "e___pssurpr_isedollar": True, - "year_ago": True, - "year_ag_ochan_gepercent": True, - "estimated_chang_epercent": True, - - } - - _attributes_to_types = { - "symbol": "str", - "e___psrep_ortdate": "str", - "e___psrep_ort_datestr": "str", - "fiscal_period": "str", - "fiscal_en_ddate": "str", - "actual___eps": "float", - "consensus___eps": "float", - "estimated___eps": "float", - "announce_time": "str", - "number_o_festimates": "float", - "e___pssurpr_isedollar": "float", - "year_ago": "float", - "year_ag_ochan_gepercent": "float", - "estimated_chang_epercent": "float", - - } - - def __init__(self): - self.symbol: str - self.e___psrep_ortdate: str - self.e___psrep_ort_datestr: str - self.fiscal_period: str - self.fiscal_en_ddate: str - self.actual___eps: float - self.consensus___eps: float - self.estimated___eps: float - self.announce_time: str - self.number_o_festimates: float - self.e___pssurpr_isedollar: float - self.year_ago: float - self.year_ag_ochan_gepercent: float - self.estimated_chang_epercent: float - - -# noinspection SpellCheckingInspection -class Financial(Definition): - _swagger_name_to_python = { - "symbol": "symbol", - "reportDate": "report_date", - "reportDateStr": "report_dat_estr", - "grossProfit": "gross_profit", - "costOfRevenue": "cost_o_frevenue", - "operatingRevenue": "operating_revenue", - "totalRevenue": "total_revenue", - "operatingIncome": "operating_income", - "netIncome": "net_income", - "researchAndDevelopment": "research_an_ddevelopment", - "operatingExpense": "operating_expense", - "currentAssets": "current_assets", - "totalAssets": "total_assets", - "totalLiabilities": "total_liabilities", - "currentCash": "current_cash", - "currentDebt": "current_debt", - "totalCash": "total_cash", - "totalDebt": "total_debt", - "shareholderEquity": "shareholder_equity", - "cashChange": "cash_change", - "cashFlow": "cash_flow", - "operatingGainsLosses": "operating_gain_slosses", - - } - - _attribute_is_primitive = { - "symbol": True, - "report_date": True, - "report_dat_estr": True, - "gross_profit": True, - "cost_o_frevenue": True, - "operating_revenue": True, - "total_revenue": True, - "operating_income": True, - "net_income": True, - "research_an_ddevelopment": True, - "operating_expense": True, - "current_assets": True, - "total_assets": True, - "total_liabilities": True, - "current_cash": True, - "current_debt": True, - "total_cash": True, - "total_debt": True, - "shareholder_equity": True, - "cash_change": True, - "cash_flow": True, - "operating_gain_slosses": True, - - } - - _attributes_to_types = { - "symbol": "str", - "report_date": "str", - "report_dat_estr": "str", - "gross_profit": "float", - "cost_o_frevenue": "float", - "operating_revenue": "float", - "total_revenue": "float", - "operating_income": "float", - "net_income": "float", - "research_an_ddevelopment": "float", - "operating_expense": "float", - "current_assets": "float", - "total_assets": "float", - "total_liabilities": "float", - "current_cash": "float", - "current_debt": "float", - "total_cash": "float", - "total_debt": "float", - "shareholder_equity": "float", - "cash_change": "float", - "cash_flow": "float", - "operating_gain_slosses": "float", - - } - - def __init__(self): - self.symbol: str - self.report_date: str - self.report_dat_estr: str - self.gross_profit: float - self.cost_o_frevenue: float - self.operating_revenue: float - self.total_revenue: float - self.operating_income: float - self.net_income: float - self.research_an_ddevelopment: float - self.operating_expense: float - self.current_assets: float - self.total_assets: float - self.total_liabilities: float - self.current_cash: float - self.current_debt: float - self.total_cash: float - self.total_debt: float - self.shareholder_equity: float - self.cash_change: float - self.cash_flow: float - self.operating_gain_slosses: float - - -# noinspection SpellCheckingInspection -class Exchange(Definition): - _swagger_name_to_python = { - "id": "i_d_of_the_exchange", - "type": "type", - "market": "market", - "mic": "mic", - "name": "name", - "tape": "tape", - - } - - _attribute_is_primitive = { - "i_d_of_the_exchange": True, - "type": True, - "market": True, - "mic": True, - "name": True, - "tape": True, - - } - - _attributes_to_types = { - "i_d_of_the_exchange": "float", - "type": "str", - "market": "str", - "mic": "str", - "name": "str", - "tape": "str", - - } - - def __init__(self): - self.i_d_of_the_exchange: float - self.type: str - self.market: str - self.mic: str - self.name: str - self.tape: str - - -# noinspection SpellCheckingInspection -class Error(Definition): - _swagger_name_to_python = { - "code": "code", - "message": "message", - "fields": "fields", - - } - - _attribute_is_primitive = { - "code": True, - "message": True, - "fields": True, - - } - - _attributes_to_types = { - "code": "int", - "message": "str", - "fields": "str", - - } - - def __init__(self): - self.code: int - self.message: str - self.fields: str - - -# noinspection SpellCheckingInspection -class NotFound(Definition): - _swagger_name_to_python = { - "message": "message", - - } - - _attribute_is_primitive = { - "message": True, - - } - - _attributes_to_types = { - "message": "str", - - } - - def __init__(self): - self.message: str - - -# noinspection SpellCheckingInspection -class Conflict(Definition): - _swagger_name_to_python = { - "message": "message", - - } - - _attribute_is_primitive = { - "message": True, - - } - - _attributes_to_types = { - "message": "str", - - } - - def __init__(self): - self.message: str - - -# noinspection SpellCheckingInspection -class Unauthorized(Definition): - _swagger_name_to_python = { - "message": "message", - - } - - _attribute_is_primitive = { - "message": True, - - } - - _attributes_to_types = { - "message": "str", - - } - - def __init__(self): - self.message: str - - -# noinspection SpellCheckingInspection -class MarketStatus(Definition): - _swagger_name_to_python = { - "market": "market", - "serverTime": "server_time", - "exchanges": "exchanges", - "currencies": "currencies", - - } - - _attribute_is_primitive = { - "market": True, - "server_time": True, - "exchanges": True, - "currencies": True, - - } - - _attributes_to_types = { - "market": "str", - "server_time": "str", - "exchanges": "Dict[str, str]", - "currencies": "Dict[str, str]", - - } - - def __init__(self): - self.market: str - self.server_time: str - self.exchanges: Dict[str, str] - self.currencies: Dict[str, str] - - -# noinspection SpellCheckingInspection -class MarketHoliday(Definition): - _swagger_name_to_python = { - "exchange": "exchange", - "name": "name", - "status": "status", - "date": "date", - "open": "open", - "close": "close", - - } - - _attribute_is_primitive = { - "exchange": True, - "name": True, - "status": True, - "date": True, - "open": True, - "close": True, - - } - - _attributes_to_types = { - "exchange": "str", - "name": "str", - "status": "str", - "date": "str", - "open": "str", - "close": "str", - - } - - def __init__(self): - self.exchange: str - self.name: str - self.status: str - self.date: str - self.open: str - self.close: str - - -# noinspection SpellCheckingInspection -class AnalystRatings(Definition): - _swagger_name_to_python = { - "symbol": "symbol", - "analysts": "analysts", - "change": "change", - "strongBuy": "strong_buy", - "buy": "buy", - "hold": "hold", - "sell": "sell", - "strongSell": "strong_sell", - "updated": "updated", - - } - - _attribute_is_primitive = { - "symbol": True, - "analysts": True, - "change": True, - "strong_buy": False, - "buy": False, - "hold": False, - "sell": False, - "strong_sell": False, - "updated": True, - - } - - _attributes_to_types = { - "symbol": "str", - "analysts": "float", - "change": "float", - "strong_buy": "RatingSection", - "buy": "RatingSection", - "hold": "RatingSection", - "sell": "RatingSection", - "strong_sell": "RatingSection", - "updated": "str", - - } - - def __init__(self): - self.symbol: str - self.analysts: float - self.change: float - self.strong_buy: RatingSection - self.buy: RatingSection - self.hold: RatingSection - self.sell: RatingSection - self.strong_sell: RatingSection - self.updated: str - - -# noinspection SpellCheckingInspection -class RatingSection(Definition): - _swagger_name_to_python = { - "current": "current", - "month1": "month1", - "month2": "month2", - "month3": "month3", - "month4": "month4", - "month5": "month5", - - } - - _attribute_is_primitive = { - "current": True, - "month1": True, - "month2": True, - "month3": True, - "month4": True, - "month5": True, - - } - - _attributes_to_types = { - "current": "float", - "month1": "float", - "month2": "float", - "month3": "float", - "month4": "float", - "month5": "float", - - } - - def __init__(self): - self.current: float - self.month1: float - self.month2: float - self.month3: float - self.month4: float - self.month5: float - - -# noinspection SpellCheckingInspection -class CryptoTick(Definition): - _swagger_name_to_python = { - "price": "price", - "size": "size", - "exchange": "exchange", - "conditions": "conditions", - "timestamp": "timestamp", - - } - - _attribute_is_primitive = { - "price": True, - "size": True, - "exchange": True, - "conditions": False, - "timestamp": True, - - } - - _attributes_to_types = { - "price": "int", - "size": "int", - "exchange": "int", - "conditions": "List[int]", - "timestamp": "int", - - } - - def __init__(self): - self.price: int - self.size: int - self.exchange: int - self.conditions: List[int] - self.timestamp: int - - -# noinspection SpellCheckingInspection -class CryptoTickJson(Definition): - _swagger_name_to_python = { - "p": "trade_price", - "s": "size_of_the_trade", - "x": "exchange_the_trade_occured_on", - "c": "c", - "t": "timestamp_of_this_trade", - - } - - _attribute_is_primitive = { - "trade_price": True, - "size_of_the_trade": True, - "exchange_the_trade_occured_on": True, - "c": False, - "timestamp_of_this_trade": True, - - } - - _attributes_to_types = { - "trade_price": "int", - "size_of_the_trade": "int", - "exchange_the_trade_occured_on": "int", - "c": "List[int]", - "timestamp_of_this_trade": "int", - - } - - def __init__(self): - self.trade_price: int - self.size_of_the_trade: int - self.exchange_the_trade_occured_on: int - self.c: List[int] - self.timestamp_of_this_trade: int - - -# noinspection SpellCheckingInspection -class CryptoExchange(Definition): - _swagger_name_to_python = { - "id": "i_d_of_the_exchange", - "type": "type", - "market": "market", - "name": "name", - "url": "url", - - } - - _attribute_is_primitive = { - "i_d_of_the_exchange": True, - "type": True, - "market": True, - "name": True, - "url": True, - - } - - _attributes_to_types = { - "i_d_of_the_exchange": "float", - "type": "str", - "market": "str", - "name": "str", - "url": "str", - - } - - def __init__(self): - self.i_d_of_the_exchange: float - self.type: str - self.market: str - self.name: str - self.url: str - - -# noinspection SpellCheckingInspection -class CryptoSnapshotTicker(Definition): - _swagger_name_to_python = { - "ticker": "ticker", - "day": "day", - "lastTrade": "last_trade", - "min": "min", - "prevDay": "prev_day", - "todaysChange": "todays_change", - "todaysChangePerc": "todays_chang_eperc", - "updated": "updated", - - } - - _attribute_is_primitive = { - "ticker": True, - "day": False, - "last_trade": False, - "min": False, - "prev_day": False, - "todays_change": True, - "todays_chang_eperc": True, - "updated": True, - - } - - _attributes_to_types = { - "ticker": "str", - "day": "CryptoSnapshotAgg", - "last_trade": "CryptoTickJson", - "min": "CryptoSnapshotAgg", - "prev_day": "CryptoSnapshotAgg", - "todays_change": "int", - "todays_chang_eperc": "int", - "updated": "int", - - } - - def __init__(self): - self.ticker: str - self.day: CryptoSnapshotAgg - self.last_trade: CryptoTickJson - self.min: CryptoSnapshotAgg - self.prev_day: CryptoSnapshotAgg - self.todays_change: int - self.todays_chang_eperc: int - self.updated: int - - -# noinspection SpellCheckingInspection -class CryptoSnapshotBookItem(Definition): - _swagger_name_to_python = { - "p": "price_of_this_book_level", - "x": "exchange_to_size_of_this_price_level", - - } - - _attribute_is_primitive = { - "price_of_this_book_level": True, - "exchange_to_size_of_this_price_level": True, - - } - - _attributes_to_types = { - "price_of_this_book_level": "int", - "exchange_to_size_of_this_price_level": "Dict[str, str]", - - } - - def __init__(self): - self.price_of_this_book_level: int - self.exchange_to_size_of_this_price_level: Dict[str, str] - - -# noinspection SpellCheckingInspection -class CryptoSnapshotTickerBook(Definition): - _swagger_name_to_python = { - "ticker": "ticker", - "bids": "bids", - "asks": "asks", - "bidCount": "bid_count", - "askCount": "ask_count", - "spread": "spread", - "updated": "updated", - - } - - _attribute_is_primitive = { - "ticker": True, - "bids": False, - "asks": False, - "bid_count": True, - "ask_count": True, - "spread": True, - "updated": True, - - } - - _attributes_to_types = { - "ticker": "str", - "bids": "List[CryptoSnapshotBookItem]", - "asks": "List[CryptoSnapshotBookItem]", - "bid_count": "int", - "ask_count": "int", - "spread": "int", - "updated": "int", - - } - - def __init__(self): - self.ticker: str - self.bids: List[CryptoSnapshotBookItem] - self.asks: List[CryptoSnapshotBookItem] - self.bid_count: int - self.ask_count: int - self.spread: int - self.updated: int - - -# noinspection SpellCheckingInspection -class CryptoSnapshotAgg(Definition): - _swagger_name_to_python = { - "c": "close_price", - "h": "high_price", - "l": "low_price", - "o": "open_price", - "v": "volume", - - } - - _attribute_is_primitive = { - "close_price": True, - "high_price": True, - "low_price": True, - "open_price": True, - "volume": True, - - } - - _attributes_to_types = { - "close_price": "int", - "high_price": "int", - "low_price": "int", - "open_price": "int", - "volume": "int", - - } - - def __init__(self): - self.close_price: int - self.high_price: int - self.low_price: int - self.open_price: int - self.volume: int - - -# noinspection SpellCheckingInspection -class Forex(Definition): - _swagger_name_to_python = { - "a": "ask_price", - "b": "bid_price", - "t": "timestamp_of_this_trade", - - } - - _attribute_is_primitive = { - "ask_price": True, - "bid_price": True, - "timestamp_of_this_trade": True, - - } - - _attributes_to_types = { - "ask_price": "int", - "bid_price": "int", - "timestamp_of_this_trade": "int", - - } - - def __init__(self): - self.ask_price: int - self.bid_price: int - self.timestamp_of_this_trade: int - - -# noinspection SpellCheckingInspection -class LastForexTrade(Definition): - _swagger_name_to_python = { - "price": "price", - "exchange": "exchange", - "timestamp": "timestamp", - - } - - _attribute_is_primitive = { - "price": True, - "exchange": True, - "timestamp": True, - - } - - _attributes_to_types = { - "price": "int", - "exchange": "int", - "timestamp": "int", - - } - - def __init__(self): - self.price: int - self.exchange: int - self.timestamp: int - - -# noinspection SpellCheckingInspection -class LastForexQuote(Definition): - _swagger_name_to_python = { - "ask": "ask", - "bid": "bid", - "exchange": "exchange", - "timestamp": "timestamp", - - } - - _attribute_is_primitive = { - "ask": True, - "bid": True, - "exchange": True, - "timestamp": True, - - } - - _attributes_to_types = { - "ask": "int", - "bid": "int", - "exchange": "int", - "timestamp": "int", - - } - - def __init__(self): - self.ask: int - self.bid: int - self.exchange: int - self.timestamp: int - - -# noinspection SpellCheckingInspection -class ForexAggregate(Definition): - _swagger_name_to_python = { - "o": "open_price", - "c": "close_price", - "l": "low_price", - "h": "high_price", - "v": "volume_of_all_trades", - "t": "timestamp_of_this_aggregation", - - } - - _attribute_is_primitive = { - "open_price": True, - "close_price": True, - "low_price": True, - "high_price": True, - "volume_of_all_trades": True, - "timestamp_of_this_aggregation": True, - - } - - _attributes_to_types = { - "open_price": "int", - "close_price": "int", - "low_price": "int", - "high_price": "int", - "volume_of_all_trades": "int", - "timestamp_of_this_aggregation": "int", - - } - - def __init__(self): - self.open_price: int - self.close_price: int - self.low_price: int - self.high_price: int - self.volume_of_all_trades: int - self.timestamp_of_this_aggregation: int - - -# noinspection SpellCheckingInspection -class ForexSnapshotTicker(Definition): - _swagger_name_to_python = { - "ticker": "ticker", - "day": "day", - "lastTrade": "last_trade", - "min": "min", - "prevDay": "prev_day", - "todaysChange": "todays_change", - "todaysChangePerc": "todays_chang_eperc", - "updated": "updated", - - } - - _attribute_is_primitive = { - "ticker": True, - "day": False, - "last_trade": False, - "min": False, - "prev_day": False, - "todays_change": True, - "todays_chang_eperc": True, - "updated": True, - - } - - _attributes_to_types = { - "ticker": "str", - "day": "ForexSnapshotAgg", - "last_trade": "Forex", - "min": "ForexSnapshotAgg", - "prev_day": "ForexSnapshotAgg", - "todays_change": "int", - "todays_chang_eperc": "int", - "updated": "int", - - } - - def __init__(self): - self.ticker: str - self.day: ForexSnapshotAgg - self.last_trade: Forex - self.min: ForexSnapshotAgg - self.prev_day: ForexSnapshotAgg - self.todays_change: int - self.todays_chang_eperc: int - self.updated: int - - -# noinspection SpellCheckingInspection -class ForexSnapshotAgg(Definition): - _swagger_name_to_python = { - "c": "close_price", - "h": "high_price", - "l": "low_price", - "o": "open_price", - "v": "volume", - - } - - _attribute_is_primitive = { - "close_price": True, - "high_price": True, - "low_price": True, - "open_price": True, - "volume": True, - - } - - _attributes_to_types = { - "close_price": "int", - "high_price": "int", - "low_price": "int", - "open_price": "int", - "volume": "int", - - } - - def __init__(self): - self.close_price: int - self.high_price: int - self.low_price: int - self.open_price: int - self.volume: int - - -# noinspection SpellCheckingInspection -class Ticker(Definition): - _swagger_name_to_python = { - "ticker": "ticker", - "name": "name", - "market": "market", - "locale": "locale", - "currency": "currency", - "active": "active", - "primaryExch": "primary_exch", - "url": "url", - "updated": "updated", - "attrs": "attrs", - "codes": "codes", - - } - - _attribute_is_primitive = { - "ticker": False, - "name": True, - "market": True, - "locale": True, - "currency": True, - "active": True, - "primary_exch": True, - "url": True, - "updated": True, - "attrs": True, - "codes": True, - - } - - _attributes_to_types = { - "ticker": "StockSymbol", - "name": "str", - "market": "str", - "locale": "str", - "currency": "str", - "active": "bool", - "primary_exch": "str", - "url": "str", - "updated": "str", - "attrs": "Dict[str, str]", - "codes": "Dict[str, str]", - - } - - def __init__(self): - self.ticker: StockSymbol - self.name: str - self.market: str - self.locale: str - self.currency: str - self.active: bool - self.primary_exch: str - self.url: str - self.updated: str - self.attrs: Dict[str, str] - self.codes: Dict[str, str] - - -# noinspection SpellCheckingInspection -class Split(Definition): - _swagger_name_to_python = { - "ticker": "ticker", - "exDate": "ex_date", - "paymentDate": "payment_date", - "recordDate": "record_date", - "declaredDate": "declared_date", - "ratio": "ratio", - "tofactor": "tofactor", - "forfactor": "forfactor", - - } - - _attribute_is_primitive = { - "ticker": False, - "ex_date": True, - "payment_date": True, - "record_date": True, - "declared_date": True, - "ratio": True, - "tofactor": True, - "forfactor": True, - - } - - _attributes_to_types = { - "ticker": "TickerSymbol", - "ex_date": "str", - "payment_date": "str", - "record_date": "str", - "declared_date": "str", - "ratio": "float", - "tofactor": "float", - "forfactor": "float", - - } - - def __init__(self): - self.ticker: TickerSymbol - self.ex_date: str - self.payment_date: str - self.record_date: str - self.declared_date: str - self.ratio: float - self.tofactor: float - self.forfactor: float - - -# noinspection SpellCheckingInspection -class Financials(Definition): - _swagger_name_to_python = { - "ticker": "ticker", - "period": "period", - "calendarDate": "calendar_date", - "reportPeriod": "report_period", - "updated": "updated", - "accumulatedOtherComprehensiveIncome": "accumulated_othe_rcomprehensi_veincome", - "assets": "assets", - "assetsAverage": "assets_average", - "assetsCurrent": "assets_current", - "assetTurnover": "asset_turnover", - "assetsNonCurrent": "assets_no_ncurrent", - "bookValuePerShare": "book_valu_ep_ershare", - "capitalExpenditure": "capital_expenditure", - "cashAndEquivalents": "cash_an_dequivalents", - "cashAndEquivalentsUSD": "cash_an_dequivalen___tsusd", - "costOfRevenue": "cost_o_frevenue", - "consolidatedIncome": "consolidated_income", - "currentRatio": "current_ratio", - "debtToEquityRatio": "debt_t_oequi_tyratio", - "debt": "debt", - "debtCurrent": "debt_current", - "debtNonCurrent": "debt_no_ncurrent", - "debtUSD": "debt___usd", - "deferredRevenue": "deferred_revenue", - "depreciationAmortizationAndAccretion": "depreciation_amortizatio_na_ndaccretion", - "deposits": "deposits", - "dividendYield": "dividend_yield", - "dividendsPerBasicCommonShare": "dividends_pe_rbas_iccom_monshare", - "earningBeforeInterestTaxes": "earning_befor_eintere_sttaxes", - "earningsBeforeInterestTaxesDepreciationAmortization": "earnings_befor_eintere_stta_xesdeprecia_tionamortization", - "EBITDAMargin": "e______bitdamargin", - "earningsBeforeInterestTaxesDepreciationAmortizationUSD": "earnings_befor_eintere_stta_xesdeprecia_tionamortiz___ationusd", - "earningBeforeInterestTaxesUSD": "earning_befor_eintere_stta___xesusd", - "earningsBeforeTax": "earnings_befor_etax", - "earningsPerBasicShare": "earnings_pe_rbas_icshare", - "earningsPerDilutedShare": "earnings_pe_rdilut_edshare", - "earningsPerBasicShareUSD": "earnings_pe_rbas_icsh___areusd", - "shareholdersEquity": "shareholders_equity", - "averageEquity": "average_equity", - "shareholdersEquityUSD": "shareholders_equit___yusd", - "enterpriseValue": "enterprise_value", - "enterpriseValueOverEBIT": "enterprise_valu_eov____erebit", - "enterpriseValueOverEBITDA": "enterprise_valu_eov______erebitda", - "freeCashFlow": "free_cas_hflow", - "freeCashFlowPerShare": "free_cas_hfl_ow_pershare", - "foreignCurrencyUSDExchangeRate": "foreign_currenc____yusdexc_hangerate", - "grossProfit": "gross_profit", - "grossMargin": "gross_margin", - "goodwillAndIntangibleAssets": "goodwill_an_dintangib_leassets", - "interestExpense": "interest_expense", - "investedCapital": "invested_capital", - "investedCapitalAverage": "invested_capita_laverage", - "inventory": "inventory", - "investments": "investments", - "investmentsCurrent": "investments_current", - "investmentsNonCurrent": "investments_no_ncurrent", - "totalLiabilities": "total_liabilities", - "currentLiabilities": "current_liabilities", - "liabilitiesNonCurrent": "liabilities_no_ncurrent", - "marketCapitalization": "market_capitalization", - "netCashFlow": "net_cas_hflow", - "netCashFlowBusinessAcquisitionsDisposals": "net_cas_hfl_owbusin_essacquisit_ionsdisposals", - "issuanceEquityShares": "issuance_equit_yshares", - "issuanceDebtSecurities": "issuance_deb_tsecurities", - "paymentDividendsOtherCashDistributions": "payment_dividend_soth_erc_ashdistributions", - "netCashFlowFromFinancing": "net_cas_hfl_owf_romfinancing", - "netCashFlowFromInvesting": "net_cas_hfl_owf_rominvesting", - "netCashFlowInvestmentAcquisitionsDisposals": "net_cas_hfl_owinvestm_entacquisit_ionsdisposals", - "netCashFlowFromOperations": "net_cas_hfl_owf_romoperations", - "effectOfExchangeRateChangesOnCash": "effect_o_fexchan_ger_atecha_n_gesoncash", - "netIncome": "net_income", - "netIncomeCommonStock": "net_incom_ecomm_onstock", - "netIncomeCommonStockUSD": "net_incom_ecomm_onst___ockusd", - "netLossIncomeFromDiscontinuedOperations": "net_los_sinco_mef_romdisconti_nuedoperations", - "netIncomeToNonControllingInterests": "net_incom_e_to_noncontrol_linginterests", - "profitMargin": "profit_margin", - "operatingExpenses": "operating_expenses", - "operatingIncome": "operating_income", - "tradeAndNonTradePayables": "trade_an_dn_ontr_adepayables", - "payoutRatio": "payout_ratio", - "priceToBookValue": "price_t_obo_okvalue", - "priceEarnings": "price_earnings", - "priceToEarningsRatio": "price_t_oearnin_gsratio", - "propertyPlantEquipmentNet": "property_plan_tequipme_ntnet", - "preferredDividendsIncomeStatementImpact": "preferred_dividend_sinco_mestatem_entimpact", - "sharePriceAdjustedClose": "share_pric_eadjust_edclose", - "priceSales": "price_sales", - "priceToSalesRatio": "price_t_osal_esratio", - "tradeAndNonTradeReceivables": "trade_an_dn_ontr_adereceivables", - "accumulatedRetainedEarningsDeficit": "accumulated_retaine_dearnin_gsdeficit", - "revenues": "revenues", - "revenuesUSD": "revenues___usd", - "researchAndDevelopmentExpense": "research_an_ddevelopme_ntexpense", - "returnOnAverageAssets": "return_o_navera_geassets", - "returnOnAverageEquity": "return_o_navera_geequity", - "returnOnInvestedCapital": "return_o_ninvest_edcapital", - "returnOnSales": "return_o_nsales", - "shareBasedCompensation": "share_base_dcompensation", - "sellingGeneralAndAdministrativeExpense": "selling_genera_la_ndadministrat_iveexpense", - "shareFactor": "share_factor", - "shares": "shares", - "weightedAverageShares": "weighted_averag_eshares", - "weightedAverageSharesDiluted": "weighted_averag_eshar_esdiluted", - "salesPerShare": "sales_pe_rshare", - "tangibleAssetValue": "tangible_asse_tvalue", - "taxAssets": "tax_assets", - "incomeTaxExpense": "income_ta_xexpense", - "taxLiabilities": "tax_liabilities", - "tangibleAssetsBookValuePerShare": "tangible_asset_sbo_okva_lu_epershare", - "workingCapital": "working_capital", - - } - - _attribute_is_primitive = { - "ticker": False, - "period": True, - "calendar_date": True, - "report_period": True, - "updated": True, - "accumulated_othe_rcomprehensi_veincome": True, - "assets": True, - "assets_average": True, - "assets_current": True, - "asset_turnover": True, - "assets_no_ncurrent": True, - "book_valu_ep_ershare": True, - "capital_expenditure": True, - "cash_an_dequivalents": True, - "cash_an_dequivalen___tsusd": True, - "cost_o_frevenue": True, - "consolidated_income": True, - "current_ratio": True, - "debt_t_oequi_tyratio": True, - "debt": True, - "debt_current": True, - "debt_no_ncurrent": True, - "debt___usd": True, - "deferred_revenue": True, - "depreciation_amortizatio_na_ndaccretion": True, - "deposits": True, - "dividend_yield": True, - "dividends_pe_rbas_iccom_monshare": True, - "earning_befor_eintere_sttaxes": True, - "earnings_befor_eintere_stta_xesdeprecia_tionamortization": True, - "e______bitdamargin": True, - "earnings_befor_eintere_stta_xesdeprecia_tionamortiz___ationusd": True, - "earning_befor_eintere_stta___xesusd": True, - "earnings_befor_etax": True, - "earnings_pe_rbas_icshare": True, - "earnings_pe_rdilut_edshare": True, - "earnings_pe_rbas_icsh___areusd": True, - "shareholders_equity": True, - "average_equity": True, - "shareholders_equit___yusd": True, - "enterprise_value": True, - "enterprise_valu_eov____erebit": True, - "enterprise_valu_eov______erebitda": True, - "free_cas_hflow": True, - "free_cas_hfl_ow_pershare": True, - "foreign_currenc____yusdexc_hangerate": True, - "gross_profit": True, - "gross_margin": True, - "goodwill_an_dintangib_leassets": True, - "interest_expense": True, - "invested_capital": True, - "invested_capita_laverage": True, - "inventory": True, - "investments": True, - "investments_current": True, - "investments_no_ncurrent": True, - "total_liabilities": True, - "current_liabilities": True, - "liabilities_no_ncurrent": True, - "market_capitalization": True, - "net_cas_hflow": True, - "net_cas_hfl_owbusin_essacquisit_ionsdisposals": True, - "issuance_equit_yshares": True, - "issuance_deb_tsecurities": True, - "payment_dividend_soth_erc_ashdistributions": True, - "net_cas_hfl_owf_romfinancing": True, - "net_cas_hfl_owf_rominvesting": True, - "net_cas_hfl_owinvestm_entacquisit_ionsdisposals": True, - "net_cas_hfl_owf_romoperations": True, - "effect_o_fexchan_ger_atecha_n_gesoncash": True, - "net_income": True, - "net_incom_ecomm_onstock": True, - "net_incom_ecomm_onst___ockusd": True, - "net_los_sinco_mef_romdisconti_nuedoperations": True, - "net_incom_e_to_noncontrol_linginterests": True, - "profit_margin": True, - "operating_expenses": True, - "operating_income": True, - "trade_an_dn_ontr_adepayables": True, - "payout_ratio": True, - "price_t_obo_okvalue": True, - "price_earnings": True, - "price_t_oearnin_gsratio": True, - "property_plan_tequipme_ntnet": True, - "preferred_dividend_sinco_mestatem_entimpact": True, - "share_pric_eadjust_edclose": True, - "price_sales": True, - "price_t_osal_esratio": True, - "trade_an_dn_ontr_adereceivables": True, - "accumulated_retaine_dearnin_gsdeficit": True, - "revenues": True, - "revenues___usd": True, - "research_an_ddevelopme_ntexpense": True, - "return_o_navera_geassets": True, - "return_o_navera_geequity": True, - "return_o_ninvest_edcapital": True, - "return_o_nsales": True, - "share_base_dcompensation": True, - "selling_genera_la_ndadministrat_iveexpense": True, - "share_factor": True, - "shares": True, - "weighted_averag_eshares": True, - "weighted_averag_eshar_esdiluted": True, - "sales_pe_rshare": True, - "tangible_asse_tvalue": True, - "tax_assets": True, - "income_ta_xexpense": True, - "tax_liabilities": True, - "tangible_asset_sbo_okva_lu_epershare": True, - "working_capital": True, - - } - - _attributes_to_types = { - "ticker": "TickerSymbol", - "period": "str", - "calendar_date": "str", - "report_period": "str", - "updated": "str", - "accumulated_othe_rcomprehensi_veincome": "int", - "assets": "int", - "assets_average": "int", - "assets_current": "int", - "asset_turnover": "int", - "assets_no_ncurrent": "int", - "book_valu_ep_ershare": "int", - "capital_expenditure": "int", - "cash_an_dequivalents": "int", - "cash_an_dequivalen___tsusd": "int", - "cost_o_frevenue": "int", - "consolidated_income": "int", - "current_ratio": "int", - "debt_t_oequi_tyratio": "int", - "debt": "int", - "debt_current": "int", - "debt_no_ncurrent": "int", - "debt___usd": "int", - "deferred_revenue": "int", - "depreciation_amortizatio_na_ndaccretion": "int", - "deposits": "int", - "dividend_yield": "int", - "dividends_pe_rbas_iccom_monshare": "int", - "earning_befor_eintere_sttaxes": "int", - "earnings_befor_eintere_stta_xesdeprecia_tionamortization": "int", - "e______bitdamargin": "int", - "earnings_befor_eintere_stta_xesdeprecia_tionamortiz___ationusd": "int", - "earning_befor_eintere_stta___xesusd": "int", - "earnings_befor_etax": "int", - "earnings_pe_rbas_icshare": "int", - "earnings_pe_rdilut_edshare": "int", - "earnings_pe_rbas_icsh___areusd": "int", - "shareholders_equity": "int", - "average_equity": "int", - "shareholders_equit___yusd": "int", - "enterprise_value": "int", - "enterprise_valu_eov____erebit": "int", - "enterprise_valu_eov______erebitda": "int", - "free_cas_hflow": "int", - "free_cas_hfl_ow_pershare": "int", - "foreign_currenc____yusdexc_hangerate": "int", - "gross_profit": "int", - "gross_margin": "int", - "goodwill_an_dintangib_leassets": "int", - "interest_expense": "int", - "invested_capital": "int", - "invested_capita_laverage": "int", - "inventory": "int", - "investments": "int", - "investments_current": "int", - "investments_no_ncurrent": "int", - "total_liabilities": "int", - "current_liabilities": "int", - "liabilities_no_ncurrent": "int", - "market_capitalization": "int", - "net_cas_hflow": "int", - "net_cas_hfl_owbusin_essacquisit_ionsdisposals": "int", - "issuance_equit_yshares": "int", - "issuance_deb_tsecurities": "int", - "payment_dividend_soth_erc_ashdistributions": "int", - "net_cas_hfl_owf_romfinancing": "int", - "net_cas_hfl_owf_rominvesting": "int", - "net_cas_hfl_owinvestm_entacquisit_ionsdisposals": "int", - "net_cas_hfl_owf_romoperations": "int", - "effect_o_fexchan_ger_atecha_n_gesoncash": "int", - "net_income": "int", - "net_incom_ecomm_onstock": "int", - "net_incom_ecomm_onst___ockusd": "int", - "net_los_sinco_mef_romdisconti_nuedoperations": "int", - "net_incom_e_to_noncontrol_linginterests": "int", - "profit_margin": "int", - "operating_expenses": "int", - "operating_income": "int", - "trade_an_dn_ontr_adepayables": "int", - "payout_ratio": "int", - "price_t_obo_okvalue": "int", - "price_earnings": "int", - "price_t_oearnin_gsratio": "int", - "property_plan_tequipme_ntnet": "int", - "preferred_dividend_sinco_mestatem_entimpact": "int", - "share_pric_eadjust_edclose": "int", - "price_sales": "int", - "price_t_osal_esratio": "int", - "trade_an_dn_ontr_adereceivables": "int", - "accumulated_retaine_dearnin_gsdeficit": "int", - "revenues": "int", - "revenues___usd": "int", - "research_an_ddevelopme_ntexpense": "int", - "return_o_navera_geassets": "int", - "return_o_navera_geequity": "int", - "return_o_ninvest_edcapital": "int", - "return_o_nsales": "int", - "share_base_dcompensation": "int", - "selling_genera_la_ndadministrat_iveexpense": "int", - "share_factor": "int", - "shares": "int", - "weighted_averag_eshares": "int", - "weighted_averag_eshar_esdiluted": "int", - "sales_pe_rshare": "int", - "tangible_asse_tvalue": "int", - "tax_assets": "int", - "income_ta_xexpense": "int", - "tax_liabilities": "int", - "tangible_asset_sbo_okva_lu_epershare": "int", - "working_capital": "int", - - } - - def __init__(self): - self.ticker: TickerSymbol - self.period: str - self.calendar_date: str - self.report_period: str - self.updated: str - self.accumulated_othe_rcomprehensi_veincome: int - self.assets: int - self.assets_average: int - self.assets_current: int - self.asset_turnover: int - self.assets_no_ncurrent: int - self.book_valu_ep_ershare: int - self.capital_expenditure: int - self.cash_an_dequivalents: int - self.cash_an_dequivalen___tsusd: int - self.cost_o_frevenue: int - self.consolidated_income: int - self.current_ratio: int - self.debt_t_oequi_tyratio: int - self.debt: int - self.debt_current: int - self.debt_no_ncurrent: int - self.debt___usd: int - self.deferred_revenue: int - self.depreciation_amortizatio_na_ndaccretion: int - self.deposits: int - self.dividend_yield: int - self.dividends_pe_rbas_iccom_monshare: int - self.earning_befor_eintere_sttaxes: int - self.earnings_befor_eintere_stta_xesdeprecia_tionamortization: int - self.e______bitdamargin: int - self.earnings_befor_eintere_stta_xesdeprecia_tionamortiz___ationusd: int - self.earning_befor_eintere_stta___xesusd: int - self.earnings_befor_etax: int - self.earnings_pe_rbas_icshare: int - self.earnings_pe_rdilut_edshare: int - self.earnings_pe_rbas_icsh___areusd: int - self.shareholders_equity: int - self.average_equity: int - self.shareholders_equit___yusd: int - self.enterprise_value: int - self.enterprise_valu_eov____erebit: int - self.enterprise_valu_eov______erebitda: int - self.free_cas_hflow: int - self.free_cas_hfl_ow_pershare: int - self.foreign_currenc____yusdexc_hangerate: int - self.gross_profit: int - self.gross_margin: int - self.goodwill_an_dintangib_leassets: int - self.interest_expense: int - self.invested_capital: int - self.invested_capita_laverage: int - self.inventory: int - self.investments: int - self.investments_current: int - self.investments_no_ncurrent: int - self.total_liabilities: int - self.current_liabilities: int - self.liabilities_no_ncurrent: int - self.market_capitalization: int - self.net_cas_hflow: int - self.net_cas_hfl_owbusin_essacquisit_ionsdisposals: int - self.issuance_equit_yshares: int - self.issuance_deb_tsecurities: int - self.payment_dividend_soth_erc_ashdistributions: int - self.net_cas_hfl_owf_romfinancing: int - self.net_cas_hfl_owf_rominvesting: int - self.net_cas_hfl_owinvestm_entacquisit_ionsdisposals: int - self.net_cas_hfl_owf_romoperations: int - self.effect_o_fexchan_ger_atecha_n_gesoncash: int - self.net_income: int - self.net_incom_ecomm_onstock: int - self.net_incom_ecomm_onst___ockusd: int - self.net_los_sinco_mef_romdisconti_nuedoperations: int - self.net_incom_e_to_noncontrol_linginterests: int - self.profit_margin: int - self.operating_expenses: int - self.operating_income: int - self.trade_an_dn_ontr_adepayables: int - self.payout_ratio: int - self.price_t_obo_okvalue: int - self.price_earnings: int - self.price_t_oearnin_gsratio: int - self.property_plan_tequipme_ntnet: int - self.preferred_dividend_sinco_mestatem_entimpact: int - self.share_pric_eadjust_edclose: int - self.price_sales: int - self.price_t_osal_esratio: int - self.trade_an_dn_ontr_adereceivables: int - self.accumulated_retaine_dearnin_gsdeficit: int - self.revenues: int - self.revenues___usd: int - self.research_an_ddevelopme_ntexpense: int - self.return_o_navera_geassets: int - self.return_o_navera_geequity: int - self.return_o_ninvest_edcapital: int - self.return_o_nsales: int - self.share_base_dcompensation: int - self.selling_genera_la_ndadministrat_iveexpense: int - self.share_factor: int - self.shares: int - self.weighted_averag_eshares: int - self.weighted_averag_eshar_esdiluted: int - self.sales_pe_rshare: int - self.tangible_asse_tvalue: int - self.tax_assets: int - self.income_ta_xexpense: int - self.tax_liabilities: int - self.tangible_asset_sbo_okva_lu_epershare: int - self.working_capital: int - - -# noinspection SpellCheckingInspection -class Trade(Definition): - _swagger_name_to_python = { - "c1": "condition_1_of_this_trade", - "c2": "condition_2_of_this_trade", - "c3": "condition_3_of_this_trade", - "c4": "condition_4_of_this_trade", - "e": "the_exchange_this_trade_happened_on", - "p": "price_of_the_trade", - "s": "size_of_the_trade", - "t": "timestamp_of_this_trade", - - } - - _attribute_is_primitive = { - "condition_1_of_this_trade": True, - "condition_2_of_this_trade": True, - "condition_3_of_this_trade": True, - "condition_4_of_this_trade": True, - "the_exchange_this_trade_happened_on": True, - "price_of_the_trade": True, - "size_of_the_trade": True, - "timestamp_of_this_trade": True, - - } - - _attributes_to_types = { - "condition_1_of_this_trade": "int", - "condition_2_of_this_trade": "int", - "condition_3_of_this_trade": "int", - "condition_4_of_this_trade": "int", - "the_exchange_this_trade_happened_on": "str", - "price_of_the_trade": "int", - "size_of_the_trade": "int", - "timestamp_of_this_trade": "int", - - } - - def __init__(self): - self.condition_1_of_this_trade: int - self.condition_2_of_this_trade: int - self.condition_3_of_this_trade: int - self.condition_4_of_this_trade: int - self.the_exchange_this_trade_happened_on: str - self.price_of_the_trade: int - self.size_of_the_trade: int - self.timestamp_of_this_trade: int - - -# noinspection SpellCheckingInspection -class StocksSnapshotTicker(Definition): - _swagger_name_to_python = { - "ticker": "ticker", - "day": "day", - "lastTrade": "last_trade", - "lastQuote": "last_quote", - "min": "min", - "prevDay": "prev_day", - "todaysChange": "todays_change", - "todaysChangePerc": "todays_chang_eperc", - "updated": "updated", - - } - - _attribute_is_primitive = { - "ticker": True, - "day": False, - "last_trade": False, - "last_quote": False, - "min": False, - "prev_day": False, - "todays_change": True, - "todays_chang_eperc": True, - "updated": True, - - } - - _attributes_to_types = { - "ticker": "str", - "day": "StocksSnapshotAgg", - "last_trade": "Trade", - "last_quote": "StocksSnapshotQuote", - "min": "StocksSnapshotAgg", - "prev_day": "StocksSnapshotAgg", - "todays_change": "int", - "todays_chang_eperc": "int", - "updated": "int", - - } - - def __init__(self): - self.ticker: str - self.day: StocksSnapshotAgg - self.last_trade: Trade - self.last_quote: StocksSnapshotQuote - self.min: StocksSnapshotAgg - self.prev_day: StocksSnapshotAgg - self.todays_change: int - self.todays_chang_eperc: int - self.updated: int - - -# noinspection SpellCheckingInspection -class StocksSnapshotBookItem(Definition): - _swagger_name_to_python = { - "p": "price_of_this_book_level", - "x": "exchange_to_size_of_this_price_level", - - } - - _attribute_is_primitive = { - "price_of_this_book_level": True, - "exchange_to_size_of_this_price_level": True, - - } - - _attributes_to_types = { - "price_of_this_book_level": "int", - "exchange_to_size_of_this_price_level": "Dict[str, str]", - - } - - def __init__(self): - self.price_of_this_book_level: int - self.exchange_to_size_of_this_price_level: Dict[str, str] - - -# noinspection SpellCheckingInspection -class StocksSnapshotTickerBook(Definition): - _swagger_name_to_python = { - "ticker": "ticker", - "bids": "bids", - "asks": "asks", - "bidCount": "bid_count", - "askCount": "ask_count", - "spread": "spread", - "updated": "updated", - - } - - _attribute_is_primitive = { - "ticker": True, - "bids": False, - "asks": False, - "bid_count": True, - "ask_count": True, - "spread": True, - "updated": True, - - } - - _attributes_to_types = { - "ticker": "str", - "bids": "List[StocksSnapshotBookItem]", - "asks": "List[StocksSnapshotBookItem]", - "bid_count": "int", - "ask_count": "int", - "spread": "int", - "updated": "int", - - } - - def __init__(self): - self.ticker: str - self.bids: List[StocksSnapshotBookItem] - self.asks: List[StocksSnapshotBookItem] - self.bid_count: int - self.ask_count: int - self.spread: int - self.updated: int - - -# noinspection SpellCheckingInspection -class StocksV2Trade(Definition): - _swagger_name_to_python = { - "T": "ticker_of_the_object", - "t": "nanosecond_accuracy_s__ip_unix_timestamp", - "y": "nanosecond_accuracy_participant_exchange_unix_timestamp", - "f": "nanosecond_accuracy_t__rf", - "q": "sequence_number", - "i": "trade_i_d", - "x": "exchange_i_d", - "s": "size_volume_of_the_trade", - "c": "c", - "p": "price_of_the_trade", - "z": "tape_where_trade_occured", - - } - - _attribute_is_primitive = { - "ticker_of_the_object": True, - "nanosecond_accuracy_s__ip_unix_timestamp": True, - "nanosecond_accuracy_participant_exchange_unix_timestamp": True, - "nanosecond_accuracy_t__rf": True, - "sequence_number": True, - "trade_i_d": True, - "exchange_i_d": True, - "size_volume_of_the_trade": True, - "c": False, - "price_of_the_trade": True, - "tape_where_trade_occured": True, - - } - - _attributes_to_types = { - "ticker_of_the_object": "str", - "nanosecond_accuracy_s__ip_unix_timestamp": "int", - "nanosecond_accuracy_participant_exchange_unix_timestamp": "int", - "nanosecond_accuracy_t__rf": "int", - "sequence_number": "int", - "trade_i_d": "str", - "exchange_i_d": "int", - "size_volume_of_the_trade": "int", - "c": "List[int]", - "price_of_the_trade": "int", - "tape_where_trade_occured": "int", - - } - - def __init__(self): - self.ticker_of_the_object: str - self.nanosecond_accuracy_s__ip_unix_timestamp: int - self.nanosecond_accuracy_participant_exchange_unix_timestamp: int - self.nanosecond_accuracy_t__rf: int - self.sequence_number: int - self.trade_i_d: str - self.exchange_i_d: int - self.size_volume_of_the_trade: int - self.c: List[int] - self.price_of_the_trade: int - self.tape_where_trade_occured: int - - -# noinspection SpellCheckingInspection -class StocksV2NBBO(Definition): - _swagger_name_to_python = { - "T": "ticker_of_the_object", - "t": "nanosecond_accuracy_s__ip_unix_timestamp", - "y": "nanosecond_accuracy_participant_exchange_unix_timestamp", - "f": "nanosecond_accuracy_t__rf", - "q": "sequence_number", - "c": "c", - "i": "i", - "p": "b__id_price", - "x": "b__id_exchange__id", - "s": "b__id_size", - "P": "a__sk_price", - "X": "a__sk_exchange__id", - "S": "a__sk_size", - "z": "tape_where_trade_occured", - - } - - _attribute_is_primitive = { - "ticker_of_the_object": True, - "nanosecond_accuracy_s__ip_unix_timestamp": True, - "nanosecond_accuracy_participant_exchange_unix_timestamp": True, - "nanosecond_accuracy_t__rf": True, - "sequence_number": True, - "c": False, - "i": False, - "b__id_price": True, - "b__id_exchange__id": True, - "b__id_size": True, - "a__sk_price": True, - "a__sk_exchange__id": True, - "a__sk_size": True, - "tape_where_trade_occured": True, - - } - - _attributes_to_types = { - "ticker_of_the_object": "str", - "nanosecond_accuracy_s__ip_unix_timestamp": "int", - "nanosecond_accuracy_participant_exchange_unix_timestamp": "int", - "nanosecond_accuracy_t__rf": "int", - "sequence_number": "int", - "c": "List[int]", - "i": "List[int]", - "b__id_price": "int", - "b__id_exchange__id": "int", - "b__id_size": "int", - "a__sk_price": "int", - "a__sk_exchange__id": "int", - "a__sk_size": "int", - "tape_where_trade_occured": "int", - - } - - def __init__(self): - self.ticker_of_the_object: str - self.nanosecond_accuracy_s__ip_unix_timestamp: int - self.nanosecond_accuracy_participant_exchange_unix_timestamp: int - self.nanosecond_accuracy_t__rf: int - self.sequence_number: int - self.c: List[int] - self.i: List[int] - self.b__id_price: int - self.b__id_exchange__id: int - self.b__id_size: int - self.a__sk_price: int - self.a__sk_exchange__id: int - self.a__sk_size: int - self.tape_where_trade_occured: int - - -# noinspection SpellCheckingInspection -class StocksSnapshotAgg(Definition): - _swagger_name_to_python = { - "c": "close_price", - "h": "high_price", - "l": "low_price", - "o": "open_price", - "v": "volume", - - } - - _attribute_is_primitive = { - "close_price": True, - "high_price": True, - "low_price": True, - "open_price": True, - "volume": True, - - } - - _attributes_to_types = { - "close_price": "int", - "high_price": "int", - "low_price": "int", - "open_price": "int", - "volume": "int", - - } - - def __init__(self): - self.close_price: int - self.high_price: int - self.low_price: int - self.open_price: int - self.volume: int - - -# noinspection SpellCheckingInspection -class StocksSnapshotQuote(Definition): - _swagger_name_to_python = { - "p": "bid_price", - "s": "bid_size_in_lots", - "P": "ask_price", - "S": "ask_size_in_lots", - "t": "last_updated_timestamp", - - } - - _attribute_is_primitive = { - "bid_price": True, - "bid_size_in_lots": True, - "ask_price": True, - "ask_size_in_lots": True, - "last_updated_timestamp": True, - - } - - _attributes_to_types = { - "bid_price": "int", - "bid_size_in_lots": "int", - "ask_price": "int", - "ask_size_in_lots": "int", - "last_updated_timestamp": "int", - - } - - def __init__(self): - self.bid_price: int - self.bid_size_in_lots: int - self.ask_price: int - self.ask_size_in_lots: int - self.last_updated_timestamp: int - - -# noinspection SpellCheckingInspection -class Aggv2(Definition): - _swagger_name_to_python = { - "T": "ticker_symbol", - "v": "volume", - "o": "open", - "c": "close", - "h": "high", - "l": "low", - "t": "unix_msec_timestamp", - "n": "number_of_items_in_aggregate_window", - - } - - _attribute_is_primitive = { - "ticker_symbol": True, - "volume": True, - "open": True, - "close": True, - "high": True, - "low": True, - "unix_msec_timestamp": True, - "number_of_items_in_aggregate_window": True, - - } - - _attributes_to_types = { - "ticker_symbol": "str", - "volume": "int", - "open": "int", - "close": "int", - "high": "int", - "low": "int", - "unix_msec_timestamp": "float", - "number_of_items_in_aggregate_window": "float", - - } - - def __init__(self): - self.ticker_symbol: str - self.volume: int - self.open: int - self.close: int - self.high: int - self.low: int - self.unix_msec_timestamp: float - self.number_of_items_in_aggregate_window: float - - -# noinspection SpellCheckingInspection -class AggResponse(Definition): - _swagger_name_to_python = { - "ticker": "ticker", - "status": "status", - "adjusted": "adjusted", - "queryCount": "query_count", - "resultsCount": "results_count", - "results": "results", - - } - - _attribute_is_primitive = { - "ticker": True, - "status": True, - "adjusted": True, - "query_count": True, - "results_count": True, - "results": False, - - } - - _attributes_to_types = { - "ticker": "str", - "status": "str", - "adjusted": "bool", - "query_count": "float", - "results_count": "float", - "results": "List[Aggv2]", - - } - - def __init__(self): - self.ticker: str - self.status: str - self.adjusted: bool - self.query_count: float - self.results_count: float - self.results: List[Aggv2] - - -# noinspection SpellCheckingInspection -class ReferenceTickersApiResponse(Definition): - _swagger_name_to_python = { - "symbol": "symbol", - - } - - _attribute_is_primitive = { - "symbol": False, - - } - - _attributes_to_types = { - "symbol": "List[Symbol]", - - } - - def __init__(self): - self.symbol: List[Symbol] - - -# noinspection SpellCheckingInspection -class ReferenceTickersV3ApiResponse(Definition): - _swagger_name_to_python = { - "results": "results", - "status": "status", - "count": "count", - "next_url": "next_url", - } - - _attribute_is_primitive = { - "results": False, - "status": True, - "count": True, - "next_url": True, - } - - _attributes_to_types = { - "results": "List[SymbolV3]", - "status": "str", - "count": "float", - "next_url": "str", - } - - def __init__(self): - self.results: List[SymbolV3] - self.status: str - self.count: float - self.next_url: str - - -# noinspection SpellCheckingInspection -class ReferenceTickerTypesApiResponse(Definition): - _swagger_name_to_python = { - "status": "status", - "results": "results", - - } - - _attribute_is_primitive = { - "status": True, - "results": True, - - } - - _attributes_to_types = { - "status": "str", - "results": "Dict[str, str]", - - } - - def __init__(self): - self.status: str - self.results: Dict[str, str] - - -# noinspection SpellCheckingInspection -class ReferenceTickerDetailsApiResponse(Definition): - _swagger_name_to_python = { - "company": "company", - - } - - _attribute_is_primitive = { - "company": False, - - } - - _attributes_to_types = { - "company": "Company", - - } - - def __init__(self): - self.company: Company - - -# noinspection SpellCheckingInspection -class ReferenceTickerDetailsV3ApiResponse(Definition): - _swagger_name_to_python = { - "results": "results", - "status": "status", - "count": "count", - } - - _attribute_is_primitive = { - "results": False, - "status": True, - "count": True, - } - - _attributes_to_types = { - "results": "List[CompanyV3]", - "status": "str", - "count": "float", - } - - def __init__(self): - self.results: List[CompanyV3] - self.status: str - self.count: float - - -# noinspection SpellCheckingInspection -class ReferenceTickerNewsApiResponse(Definition): - _swagger_name_to_python = { - "news": "news", - - } - - _attribute_is_primitive = { - "news": False, - - } - - _attributes_to_types = { - "news": "List[News]", - - } - - def __init__(self): - self.news: List[News] - - -# noinspection SpellCheckingInspection -class ReferenceTickerNewsV2ApiResponse(Definition): - _swagger_name_to_python = { - "results": "results", - "next_url": "next_url", - "status": "status", - "count": "count", - } - - _attribute_is_primitive = { - "results": False, - "next_url": True, - "status": True, - "count": True, - } - - _attributes_to_types = { - "results": "List[NewsV2]", - "next_url": "str", - "status": "str", - "count": "float", - } - - def __init__(self): - self.results: List[NewsV2] - self.next_url: str - self.status: str - self.count: float - - -# noinspection SpellCheckingInspection -class ReferenceMarketsApiResponse(Definition): - _swagger_name_to_python = { - "status": "status", - "results": "results", - - } - - _attribute_is_primitive = { - "status": True, - "results": False, - - } - - _attributes_to_types = { - "status": "str", - "results": "List[Dict[str, str]]", - - } - - def __init__(self): - self.status: str - self.results: List[Dict[str, str]] - - -# noinspection SpellCheckingInspection -class ReferenceLocalesApiResponse(Definition): - _swagger_name_to_python = { - "status": "status", - "results": "results", - - } - - _attribute_is_primitive = { - "status": True, - "results": False, - - } - - _attributes_to_types = { - "status": "str", - "results": "List[Dict[str, str]]", - - } - - def __init__(self): - self.status: str - self.results: List[Dict[str, str]] - - -# noinspection SpellCheckingInspection -class ReferenceStockSplitsApiResponse(Definition): - _swagger_name_to_python = { - "status": "status", - "count": "count", - "results": "results", - - } - - _attribute_is_primitive = { - "status": True, - "count": True, - "results": False, - - } - - _attributes_to_types = { - "status": "str", - "count": "float", - "results": "List[Split]", - - } - - def __init__(self): - self.status: str - self.count: float - self.results: List[Split] - - -# noinspection SpellCheckingInspection -class ReferenceStockDividendsApiResponse(Definition): - _swagger_name_to_python = { - "status": "status", - "count": "count", - "results": "results", - - } - - _attribute_is_primitive = { - "status": True, - "count": True, - "results": False, - - } - - _attributes_to_types = { - "status": "str", - "count": "float", - "results": "List[Dividend]", - - } - - def __init__(self): - self.status: str - self.count: float - self.results: List[Dividend] - - -# noinspection SpellCheckingInspection -class ReferenceStockFinancialsApiResponse(Definition): - _swagger_name_to_python = { - "status": "status", - "count": "count", - "results": "results", - - } - - _attribute_is_primitive = { - "status": True, - "count": True, - "results": False, - - } - - _attributes_to_types = { - "status": "str", - "count": "float", - "results": "List[Financials]", - - } - - def __init__(self): - self.status: str - self.count: float - self.results: List[Financials] - - -# noinspection SpellCheckingInspection -class ReferenceMarketStatusApiResponse(Definition): - _swagger_name_to_python = { - "marketstatus": "marketstatus", - - } - - _attribute_is_primitive = { - "marketstatus": False, - - } - - _attributes_to_types = { - "marketstatus": "MarketStatus", - - } - - def __init__(self): - self.marketstatus: MarketStatus - - -# noinspection SpellCheckingInspection -class ReferenceMarketHolidaysApiResponse(Definition): - _swagger_name_to_python = { - "marketholiday": "marketholiday", - - } - - _attribute_is_primitive = { - "marketholiday": False, - - } - - _attributes_to_types = { - "marketholiday": "List[MarketHoliday]", - - } - - def __init__(self): - self.marketholiday: List[MarketHoliday] - - -# noinspection SpellCheckingInspection -class StocksEquitiesExchangesApiResponse(Definition): - _swagger_name_to_python = { - "exchange": "exchange", - - } - - _attribute_is_primitive = { - "exchange": False, - - } - - _attributes_to_types = { - "exchange": "List[Exchange]", - - } - - def __init__(self): - self.exchange: List[Exchange] - - -# noinspection SpellCheckingInspection -class StocksEquitiesHistoricTradesApiResponse(Definition): - _swagger_name_to_python = { - "day": "day", - "map": "map", - "msLatency": "ms_latency", - "status": "status", - "symbol": "symbol", - "ticks": "ticks", - - } - - _attribute_is_primitive = { - "day": True, - "map": True, - "ms_latency": True, - "status": True, - "symbol": True, - "ticks": False, - - } - - _attributes_to_types = { - "day": "str", - "map": "Dict[str, str]", - "ms_latency": "int", - "status": "str", - "symbol": "str", - "ticks": "List[Trade]", - - } - - def __init__(self): - self.day: str - self.map: Dict[str, str] - self.ms_latency: int - self.status: str - self.symbol: str - self.ticks: List[Trade] - - -# noinspection SpellCheckingInspection -class HistoricTradesV2ApiResponse(Definition): - _swagger_name_to_python = { - "results_count": "results_count", - "db_latency": "db_latency", - "success": "success", - "ticker": "ticker", - "results": "results", - - } - - _attribute_is_primitive = { - "results_count": True, - "db_latency": True, - "success": True, - "ticker": True, - "results": False, - - } - - _attributes_to_types = { - "results_count": "int", - "db_latency": "int", - "success": "bool", - "ticker": "str", - "results": "List[StocksV2Trade]", - - } - - def __init__(self): - self.results_count: int - self.db_latency: int - self.success: bool - self.ticker: str - self.results: List[StocksV2Trade] - - -# noinspection SpellCheckingInspection -class StocksEquitiesHistoricQuotesApiResponse(Definition): - _swagger_name_to_python = { - "day": "day", - "map": "map", - "msLatency": "ms_latency", - "status": "status", - "symbol": "symbol", - "ticks": "ticks", - - } - - _attribute_is_primitive = { - "day": True, - "map": True, - "ms_latency": True, - "status": True, - "symbol": True, - "ticks": False, - - } - - _attributes_to_types = { - "day": "str", - "map": "Dict[str, str]", - "ms_latency": "int", - "status": "str", - "symbol": "str", - "ticks": "List[Quote]", - - } - - def __init__(self): - self.day: str - self.map: Dict[str, str] - self.ms_latency: int - self.status: str - self.symbol: str - self.ticks: List[Quote] - - -# noinspection SpellCheckingInspection -class HistoricNBboQuotesV2ApiResponse(Definition): - _swagger_name_to_python = { - "results_count": "results_count", - "db_latency": "db_latency", - "success": "success", - "ticker": "ticker", - "results": "results", - - } - - _attribute_is_primitive = { - "results_count": True, - "db_latency": True, - "success": True, - "ticker": True, - "results": False, - - } - - _attributes_to_types = { - "results_count": "int", - "db_latency": "int", - "success": "bool", - "ticker": "str", - "results": "List[StocksV2NBBO]", - - } - - def __init__(self): - self.results_count: int - self.db_latency: int - self.success: bool - self.ticker: str - self.results: List[StocksV2NBBO] - - -# noinspection SpellCheckingInspection -class StocksEquitiesLastTradeForASymbolApiResponse(Definition): - _swagger_name_to_python = { - "status": "status", - "symbol": "symbol", - "last": "last", - - } - - _attribute_is_primitive = { - "status": True, - "symbol": True, - "last": False, - - } - - _attributes_to_types = { - "status": "str", - "symbol": "str", - "last": "LastTrade", - - } - - def __init__(self): - self.status: str - self.symbol: str - self.last: LastTrade - - -# noinspection SpellCheckingInspection -class StocksEquitiesLastQuoteForASymbolApiResponse(Definition): - _swagger_name_to_python = { - "status": "status", - "symbol": "symbol", - "last": "last", - - } - - _attribute_is_primitive = { - "status": True, - "symbol": True, - "last": False, - - } - - _attributes_to_types = { - "status": "str", - "symbol": "str", - "last": "LastQuote", - - } - - def __init__(self): - self.status: str - self.symbol: str - self.last: LastQuote - - -# noinspection SpellCheckingInspection -class StocksEquitiesDailyOpenCloseApiResponse(Definition): - _swagger_name_to_python = { - "from": "from_", - "symbol": "symbol", - "open": "open", - "high": "high", - "low": "low", - "close": "close", - "volume": "volume", - "afterHours": "after_hours", - "preMarket": "pre_market", - } - - _attribute_is_primitive = { - "from_": True, - "symbol": True, - "open": True, - "high": True, - "low": True, - "close": True, - "volume": True, - "after_hours": True, - "pre_market": True, - } - - _attributes_to_types = { - "from_": "str", - "symbol": "str", - "open": "float", - "high": "float", - "low": "float", - "close": "float", - "volume": "float", - "after_hours": "float", - "pre_market": "float", - } - - def __init__(self): - self.from_: str - self.symbol: str - self.open: float - self.high: float - self.low: float - self.close: float - self.volume: float - self.after_hours: float - self.pre_market: float - - -# noinspection SpellCheckingInspection -class StocksEquitiesConditionMappingsApiResponse(Definition): - _swagger_name_to_python = { - "conditiontypemap": "conditiontypemap", - - } - - _attribute_is_primitive = { - "conditiontypemap": False, - - } - - _attributes_to_types = { - "conditiontypemap": "ConditionTypeMap", - - } - - def __init__(self): - self.conditiontypemap: ConditionTypeMap - - -# noinspection SpellCheckingInspection -class StocksEquitiesSnapshotAllTickersApiResponse(Definition): - _swagger_name_to_python = { - "status": "status", - "tickers": "tickers", - - } - - _attribute_is_primitive = { - "status": True, - "tickers": False, - - } - - _attributes_to_types = { - "status": "str", - "tickers": "List[StocksSnapshotTicker]", - - } - - def __init__(self): - self.status: str - self.tickers: List[StocksSnapshotTicker] - - -# noinspection SpellCheckingInspection -class StocksEquitiesSnapshotSingleTickerApiResponse(Definition): - _swagger_name_to_python = { - "status": "status", - "ticker": "ticker", - - } - - _attribute_is_primitive = { - "status": True, - "ticker": False, - - } - - _attributes_to_types = { - "status": "str", - "ticker": "StocksSnapshotTicker", - - } - - def __init__(self): - self.status: str - self.ticker: StocksSnapshotTicker - - -# noinspection SpellCheckingInspection -class StocksEquitiesSnapshotGainersLosersApiResponse(Definition): - _swagger_name_to_python = { - "status": "status", - "tickers": "tickers", - - } - - _attribute_is_primitive = { - "status": True, - "tickers": False, - - } - - _attributes_to_types = { - "status": "str", - "tickers": "List[StocksSnapshotTicker]", - - } - - def __init__(self): - self.status: str - self.tickers: List[StocksSnapshotTicker] - - -# noinspection SpellCheckingInspection -class StocksEquitiesPreviousCloseApiResponse(Definition): - _swagger_name_to_python = { - "aggresponse": "aggresponse", - - } - - _attribute_is_primitive = { - "aggresponse": False, - - } - - _attributes_to_types = { - "aggresponse": "AggResponse", - - } - - def __init__(self): - self.aggresponse: AggResponse - - -# noinspection SpellCheckingInspection -class StocksEquitiesAggregatesApiResponse(Definition): - _swagger_name_to_python = { - "aggresponse": "aggresponse", - - } - - _attribute_is_primitive = { - "aggresponse": False, - - } - - _attributes_to_types = { - "aggresponse": "AggResponse", - - } - - def __init__(self): - self.aggresponse: AggResponse - - -# noinspection SpellCheckingInspection -class StocksEquitiesGroupedDailyApiResponse(Definition): - _swagger_name_to_python = { - "aggresponse": "aggresponse", - - } - - _attribute_is_primitive = { - "aggresponse": False, - - } - - _attributes_to_types = { - "aggresponse": "AggResponse", - - } - - def __init__(self): - self.aggresponse: AggResponse - - -# noinspection SpellCheckingInspection -class CurrenciesAggregatesApiResponse(Definition): - _swagger_name_to_python = { - "aggresponse": "aggresponse", - - } - - _attribute_is_primitive = { - "aggresponse": False, - - } - - _attributes_to_types = { - "aggresponse": "AggResponse", - - } - - def __init__(self): - self.aggresponse: AggResponse - -# noinspection SpellCheckingInspection -class ForexCurrenciesHistoricForexTicksApiResponse(Definition): - _swagger_name_to_python = { - "day": "day", - "map": "map", - "msLatency": "ms_latency", - "status": "status", - "pair": "pair", - "ticks": "ticks", - - } - - _attribute_is_primitive = { - "day": True, - "map": True, - "ms_latency": True, - "status": True, - "pair": True, - "ticks": False, - - } - - _attributes_to_types = { - "day": "str", - "map": "Dict[str, str]", - "ms_latency": "int", - "status": "str", - "pair": "str", - "ticks": "List[Forex]", - - } - - def __init__(self): - self.day: str - self.map: Dict[str, str] - self.ms_latency: int - self.status: str - self.pair: str - self.ticks: List[Forex] - - -# noinspection SpellCheckingInspection -class ForexCurrenciesRealTimeCurrencyConversionApiResponse(Definition): - _swagger_name_to_python = { - "status": "status", - "from": "from_", - "to": "to_currency_symbol", - "initialAmount": "initial_amount", - "converted": "converted", - "lastTrade": "last_trade", - "symbol": "symbol", - - } - - _attribute_is_primitive = { - "status": True, - "from_": True, - "to_currency_symbol": True, - "initial_amount": True, - "converted": True, - "last_trade": False, - "symbol": True, - - } - - _attributes_to_types = { - "status": "str", - "from_": "str", - "to_currency_symbol": "str", - "initial_amount": "float", - "converted": "float", - "last_trade": "LastForexTrade", - "symbol": "str", - - } - - def __init__(self): - self.status: str - self.from_: str - self.to_currency_symbol: str - self.initial_amount: float - self.converted: float - self.last_trade: LastForexTrade - self.symbol: str - - -# noinspection SpellCheckingInspection -class ForexCurrenciesLastQuoteForACurrencyPairApiResponse(Definition): - _swagger_name_to_python = { - "status": "status", - "symbol": "symbol", - "last": "last", - - } - - _attribute_is_primitive = { - "status": True, - "symbol": True, - "last": False, - - } - - _attributes_to_types = { - "status": "str", - "symbol": "str", - "last": "LastForexQuote", - - } - - def __init__(self): - self.status: str - self.symbol: str - self.last: LastForexQuote - - -# noinspection SpellCheckingInspection -class ForexCurrenciesGroupedDailyApiResponse(Definition): - _swagger_name_to_python = { - "status": "status", - "adjusted": "adjusted", - "queryCount": "queryCount", - "resultsCount": "resultsCount", - "results": "results", - } - - _attribute_is_primitive = { - "status": True, - "adjusted": True, - "queryCount": True, - "resultsCount": True, - "results": False, - } - - _attributes_to_types = { - "status": "str", - "adjusted": "bool", - "queryCount": "int", - "resultsCount": "int", - "results": "List[Aggv2]" - } - - def __init__(self): - self.status: str - self.adjusted: bool - self.queryCount: int - self.resultsCount: int - self.results: List[Aggv2] - - -# noinspection SpellCheckingInspection -class ForexCurrenciesPreviousCloseApiResponse(Definition): - _swagger_name_to_python = { - "ticker": "ticker", - "status": "status", - "adjusted": "adjusted", - "queryCount": "queryCount", - "resultsCount": "resultsCount", - "results": "results", - } - - _attribute_is_primitive = { - "ticker": True, - "status": True, - "adjusted": True, - "queryCount": True, - "resultsCount": True, - "results": False, - } - - _attributes_to_types = { - "ticker": "str", - "status": "str", - "adjusted": "bool", - "queryCount": "int", - "resultsCount": "int", - "results": "List[Aggv2]" - } - - def __init__(self): - self.ticker: str - self.status: str - self.adjusted: bool - self.queryCount: int - self.resultsCount: int - self.results: List[Aggv2] - - -# noinspection SpellCheckingInspection -class ForexCurrenciesSnapshotAllTickersApiResponse(Definition): - _swagger_name_to_python = { - "status": "status", - "tickers": "tickers", - - } - - _attribute_is_primitive = { - "status": True, - "tickers": False, - - } - - _attributes_to_types = { - "status": "str", - "tickers": "List[ForexSnapshotTicker]", - - } - - def __init__(self): - self.status: str - self.tickers: List[ForexSnapshotTicker] - - -# noinspection SpellCheckingInspection -class ForexCurrenciesSnapshotSingleTickerApiResponse(Definition): - _swagger_name_to_python = { - "status": "status", - "ticker": "ticker", - } - - _attribute_is_primitive = { - "status": True, - "ticker": False, - } - - _attributes_to_types = { - "status": "str", - "ticker": "ForexSnapshotTicker", - } - - def __init__(self): - self.status: str - self.ticker: ForexSnapshotTicker - - -# noinspection SpellCheckingInspection -class ForexCurrenciesSnapshotGainersLosersApiResponse(Definition): - _swagger_name_to_python = { - "status": "status", - "tickers": "tickers", - - } - - _attribute_is_primitive = { - "status": True, - "tickers": False, - - } - - _attributes_to_types = { - "status": "str", - "tickers": "List[ForexSnapshotTicker]", - - } - - def __init__(self): - self.status: str - self.tickers: List[ForexSnapshotTicker] - - -# noinspection SpellCheckingInspection -class CryptoCryptoExchangesApiResponse(Definition): - _swagger_name_to_python = { - "cryptoexchange": "cryptoexchange", - - } - - _attribute_is_primitive = { - "cryptoexchange": False, - - } - - _attributes_to_types = { - "cryptoexchange": "List[CryptoExchange]", - - } - - def __init__(self): - self.cryptoexchange: List[CryptoExchange] - - -# noinspection SpellCheckingInspection -class CryptoLastTradeForACryptoPairApiResponse(Definition): - _swagger_name_to_python = { - "status": "status", - "symbol": "symbol", - "last": "last", - "lastAverage": "last_average", - - } - - _attribute_is_primitive = { - "status": True, - "symbol": True, - "last": False, - "last_average": True, - - } - - _attributes_to_types = { - "status": "str", - "symbol": "str", - "last": "CryptoTick", - "last_average": "Dict[str, str]", - - } - - def __init__(self): - self.status: str - self.symbol: str - self.last: CryptoTick - self.last_average: Dict[str, str] - - -# noinspection SpellCheckingInspection -class CryptoDailyOpenCloseApiResponse(Definition): - _swagger_name_to_python = { - "symbol": "symbol", - "isUTC": "is___utc", - "day": "day", - "open": "open", - "close": "close", - "openTrades": "open_trades", - "closingTrades": "closing_trades", - - } - - _attribute_is_primitive = { - "symbol": True, - "is___utc": True, - "day": True, - "open": True, - "close": True, - "open_trades": False, - "closing_trades": False, - - } - - _attributes_to_types = { - "symbol": "str", - "is___utc": "bool", - "day": "str", - "open": "int", - "close": "int", - "open_trades": "List[CryptoTickJson]", - "closing_trades": "List[CryptoTickJson]", - - } - - def __init__(self): - self.symbol: str - self.is___utc: bool - self.day: str - self.open: int - self.close: int - self.open_trades: List[CryptoTickJson] - self.closing_trades: List[CryptoTickJson] - - -# noinspection SpellCheckingInspection -class CryptoHistoricCryptoTradesApiResponse(Definition): - _swagger_name_to_python = { - "day": "day", - "map": "map", - "msLatency": "ms_latency", - "status": "status", - "symbol": "symbol", - "ticks": "ticks", - - } - - _attribute_is_primitive = { - "day": True, - "map": True, - "ms_latency": True, - "status": True, - "symbol": True, - "ticks": False, - - } - - _attributes_to_types = { - "day": "str", - "map": "Dict[str, str]", - "ms_latency": "int", - "status": "str", - "symbol": "str", - "ticks": "List[CryptoTickJson]", - - } - - def __init__(self): - self.day: str - self.map: Dict[str, str] - self.ms_latency: int - self.status: str - self.symbol: str - self.ticks: List[CryptoTickJson] - - -# noinspection SpellCheckingInspection -class CryptoGroupedDailyApiResponse(Definition): - _swagger_name_to_python = { - "status": "status", - "adjusted": "adjusted", - "queryCount": "queryCount", - "resultsCount": "resultsCount", - "results": "results", - } - - _attribute_is_primitive = { - "status": True, - "adjusted": True, - "queryCount": True, - "resultsCount": True, - "results": False, - } - - _attributes_to_types = { - "status": "str", - "adjusted": "bool", - "queryCount": "int", - "resultsCount": "int", - "results": "List[Aggv2]" - } - - def __init__(self): - self.status: str - self.adjusted: bool - self.queryCount: int - self.resultsCount: int - self.results: List[Aggv2] - - -# noinspection SpellCheckingInspection -class CryptoPreviousCloseApiResponse(Definition): - _swagger_name_to_python = { - "ticker": "ticker", - "status": "status", - "adjusted": "adjusted", - "queryCount": "queryCount", - "resultsCount": "resultsCount", - "results": "results", - } - - _attribute_is_primitive = { - "ticker": True, - "status": True, - "adjusted": True, - "queryCount": True, - "resultsCount": True, - "results": False, - } - - _attributes_to_types = { - "ticker": "str", - "status": "str", - "adjusted": "bool", - "queryCount": "int", - "resultsCount": "int", - "results": "List[Aggv2]" - } - - def __init__(self): - self.ticker: str - self.status: str - self.adjusted: bool - self.queryCount: int - self.resultsCount: int - self.results: List[Aggv2] - -# noinspection SpellCheckingInspection -class CryptoSnapshotAllTickersApiResponse(Definition): - _swagger_name_to_python = { - "status": "status", - "tickers": "tickers", - - } - - _attribute_is_primitive = { - "status": True, - "tickers": False, - - } - - _attributes_to_types = { - "status": "str", - "tickers": "List[CryptoSnapshotTicker]", - - } - - def __init__(self): - self.status: str - self.tickers: List[CryptoSnapshotTicker] - - -# noinspection SpellCheckingInspection -class CryptoSnapshotSingleTickerApiResponse(Definition): - _swagger_name_to_python = { - "status": "status", - "ticker": "ticker", - - } - - _attribute_is_primitive = { - "status": True, - "ticker": False, - - } - - _attributes_to_types = { - "status": "str", - "ticker": "CryptoSnapshotTicker", - - } - - def __init__(self): - self.status: str - self.ticker: CryptoSnapshotTicker - - -# noinspection SpellCheckingInspection -class CryptoSnapshotSingleTickerFullBookApiResponse(Definition): - _swagger_name_to_python = { - "status": "status", - "data": "data", - - } - - _attribute_is_primitive = { - "status": True, - "data": False, - - } - - _attributes_to_types = { - "status": "str", - "data": "CryptoSnapshotTickerBook", - - } - - def __init__(self): - self.status: str - self.data: CryptoSnapshotTickerBook - - -# noinspection SpellCheckingInspection -class CryptoSnapshotGainersLosersApiResponse(Definition): - _swagger_name_to_python = { - "status": "status", - "tickers": "tickers", - - } - - _attribute_is_primitive = { - "status": True, - "tickers": False, - - } - - _attributes_to_types = { - "status": "str", - "tickers": "List[CryptoSnapshotTicker]", - - } - - def __init__(self): - self.status: str - self.tickers: List[CryptoSnapshotTicker] - - -StockSymbol = str -ConditionTypeMap = Dict[str, str] -SymbolTypeMap = Dict[str, str] -TickerSymbol = str diff --git a/polygon/rest/models/trades.py b/polygon/rest/models/trades.py new file mode 100644 index 00000000..a68991e7 --- /dev/null +++ b/polygon/rest/models/trades.py @@ -0,0 +1,23 @@ +from typing import Optional, List +from dataclasses import dataclass + +@dataclass +class Trade: + "Trade contains trade data for a specified ticker symbol." + conditions: Optional[List[int]] = None + correction: Optional[int] = None + exchange: Optional[int] = None + id: Optional[str] = None + participant_timestamp: Optional[int] = None + price: Optional[float] = None + sequence_number: Optional[int] = None + sip_timestamp: Optional[int] = None + size: Optional[float] = None + tape: Optional[int] = None + trf_id: Optional[int] = None + trf_timestamp: Optional[int] = None + + @staticmethod + def from_dict(d): + return Trade(**d) + diff --git a/polygon/rest/models/unmarshal.py b/polygon/rest/models/unmarshal.py deleted file mode 100644 index 720fe7c0..00000000 --- a/polygon/rest/models/unmarshal.py +++ /dev/null @@ -1,9 +0,0 @@ -from typing import Type - -from polygon.rest import models - - -def unmarshal_json(response_type, resp_json) -> Type[models.AnyDefinition]: - obj = models.name_to_class[response_type]() - obj.unmarshal_json(resp_json) - return obj diff --git a/polygon/rest/trades.py b/polygon/rest/trades.py new file mode 100644 index 00000000..55a36b23 --- /dev/null +++ b/polygon/rest/trades.py @@ -0,0 +1,41 @@ +from .base import BaseClient +from typing import Optional, Any, Dict, Union +from .models import Trade, Sort, Order + +# https://polygon.io/docs/stocks +class TradesClient(BaseClient): + def list_trades(self, + ticker: str, + timestamp: Optional[str]=None, + timestamp_lt: Optional[str]=None, + timestamp_lte: Optional[str]=None, + timestamp_gt: Optional[str]=None, + timestamp_gte: Optional[str]=None, + limit: Optional[int] = None, + sort: Optional[Union[str, Sort]] = None, + order: Optional[Union[str, Order]] = None, + params: Optional[Dict[str, Any]]=None, + raw: bool=False + ): + """ + Get trades for a ticker symbol in a given time range. + + :param ticker: The ticker symbol. + :param timestamp: Either a date with the format YYYY-MM-DD or a nanosecond timestamp. + :param timestamp_lt: Timestamp less than + :param timestamp_lte: Timestamp less than or equal to + :param timestamp_gt: Timestamp greater than + :param timestamp_gte: Timestamp greater than or equal to + :param limit: Limits the number of base aggregates queried to create the aggregate results. Max 50000 and Default 5000. Read more about how limit is used to calculate aggregate results in our article on Aggregate Data API Improvements. + :param sort: Sort the results by timestamp. asc will return results in ascending order (oldest at the top), desc will return results in descending order (newest at the top).The end of the aggregate time window. + :param order: Order results based on the sort field + :param params: Any additional query params + :param raw: Return raw object instead of results object + :return: List of aggregates + :rtype: List[Agg] + """ + url = f"/v3/trades/{ticker}" + + return self._paginate(path=url, params=self._get_params(self.list_trades, locals()), raw=raw, deserializer=Trade.from_dict) + + diff --git a/rest-example.py b/rest-example.py index a517db12..9e96f222 100644 --- a/rest-example.py +++ b/rest-example.py @@ -1,28 +1,13 @@ -import datetime - from polygon import RESTClient +from polygon.rest.models import Sort +c = RESTClient() -def ts_to_datetime(ts) -> str: - return datetime.datetime.fromtimestamp(ts / 1000.0).strftime('%Y-%m-%d %H:%M') - - -def main(): - key = "your api key" - - # RESTClient can be used as a context manager to facilitate closing the underlying http session - # https://requests.readthedocs.io/en/master/user/advanced/#session-objects - with RESTClient(key) as client: - from_ = "2019-01-01" - to = "2019-02-01" - resp = client.stocks_equities_aggregates("AAPL", 1, "minute", from_, to, unadjusted=False) - - print(f"Minute aggregates for {resp.ticker} between {from_} and {to}.") - - for result in resp.results: - dt = ts_to_datetime(result["t"]) - print(f"{dt}\n\tO: {result['o']}\n\tH: {result['h']}\n\tL: {result['l']}\n\tC: {result['c']} ") +aggs = c.get_aggs("AAPL", 1, "day", "2005-04-01", "2005-04-04") +print(aggs) +trades = [] +for t in c.list_trades("AAA", timestamp="2022-04-20", limit=5, sort=Sort.ASC): + trades.append(t) +print(trades) -if __name__ == '__main__': - main() \ No newline at end of file From a254183dc65b6a4563a97ee1fc1bb40aea5bde3f Mon Sep 17 00:00:00 2001 From: mcdayoub <38268139+mcdayoub@users.noreply.github.com> Date: Mon, 25 Apr 2022 14:52:32 -0400 Subject: [PATCH 2/4] started aggs --- polygon/rest/aggs.py | 20 +++++++++++++++++- polygon/rest/models/aggs.py | 42 ++++++++++++++++++++++++++++++------- 2 files changed, 53 insertions(+), 9 deletions(-) diff --git a/polygon/rest/aggs.py b/polygon/rest/aggs.py index b345d0e1..6920ce48 100644 --- a/polygon/rest/aggs.py +++ b/polygon/rest/aggs.py @@ -1,6 +1,7 @@ +from email.headerregistry import Group from .base import BaseClient from typing import Optional, Any, Dict, List, Union -from .models import Agg, Sort +from .models import Agg, GroupedDailyAgg, Sort # https://polygon.io/docs/stocks class AggsClient(BaseClient): @@ -37,3 +38,20 @@ def get_aggs(self, return self._get(path=url, params=self._get_params(self.get_aggs, locals()), resultKey="results", deserializer=Agg.from_dict, raw=raw) + def get_grouped_daily_aggs(self, + date: str, + adjusted: Optional[bool]=None, + raw: bool=False, + params: Optional[Dict[str, Any]]=None, + ) -> List[GroupedDailyAgg]: + """ + Get the daily open, high, low, and close (OHLC) for the entire market. + + :param date: The beginning date for the aggregate window. + :param adjusted: Whether or not the results are adjusted for splits. By default, results are adjusted. Set this to false to get results that are NOT adjusted for splits. + :return: List of aggregates + :rtype: List[Agg] + """ + url = f"/v2/aggs/grouped/locale/us/market/stocks/{date}" + + return self._get(path=url, params=self._get_params(self.get_grouped_daily_aggs, locals()), resultKey="results", deserializer=GroupedDailyAgg.from_dict, raw=raw) diff --git a/polygon/rest/models/aggs.py b/polygon/rest/models/aggs.py index b303c21d..43d82611 100644 --- a/polygon/rest/models/aggs.py +++ b/polygon/rest/models/aggs.py @@ -1,4 +1,5 @@ from dataclasses import dataclass +from typing import Optional @dataclass class Agg: @@ -14,13 +15,38 @@ class Agg: @staticmethod def from_dict(d): return Agg( - d['o'], - d['h'], - d['l'], - d['c'], - d['v'], - d['vw'], - d['t'], - d['n'] + d.get('o', None), + d.get('h', None), + d.get('l', None), + d.get('c', None), + d.get('v', None), + d.get('vw', None), + d.get('t', None), + d.get('n', None) ) +@dataclass +class GroupedDailyAgg: + ticker: str + open: float + high: float + low: float + close: float + volume: float + vwap: Optional[float] + timestamp: int + transactions: Optional[int] + + @staticmethod + def from_dict(d): + return GroupedDailyAgg( + d.get('T', None), + d.get('o', None), + d.get('h', None), + d.get('l', None), + d.get('c', None), + d.get('v', None), + d.get('vw', None), + d.get('t', None), + d.get('n', None) + ) From ad640cd0b7a9b87354b0a01a506b9a30d15a1d0b Mon Sep 17 00:00:00 2001 From: mcdayoub <38268139+mcdayoub@users.noreply.github.com> Date: Tue, 26 Apr 2022 15:53:49 -0400 Subject: [PATCH 3/4] other endpoints --- polygon/rest/aggs.py | 78 +++++++++++++++++++++++++++++-------- polygon/rest/base.py | 7 ++++ polygon/rest/models/aggs.py | 55 ++++++++++++++++++++++++++ 3 files changed, 123 insertions(+), 17 deletions(-) diff --git a/polygon/rest/aggs.py b/polygon/rest/aggs.py index 6920ce48..dd9c520f 100644 --- a/polygon/rest/aggs.py +++ b/polygon/rest/aggs.py @@ -1,7 +1,7 @@ from email.headerregistry import Group from .base import BaseClient from typing import Optional, Any, Dict, List, Union -from .models import Agg, GroupedDailyAgg, Sort +from .models import Agg, GroupedDailyAgg, DailyOpenCloseAgg, PreviousCloseAgg, Sort # https://polygon.io/docs/stocks class AggsClient(BaseClient): @@ -39,19 +39,63 @@ def get_aggs(self, return self._get(path=url, params=self._get_params(self.get_aggs, locals()), resultKey="results", deserializer=Agg.from_dict, raw=raw) def get_grouped_daily_aggs(self, - date: str, - adjusted: Optional[bool]=None, - raw: bool=False, - params: Optional[Dict[str, Any]]=None, - ) -> List[GroupedDailyAgg]: - """ - Get the daily open, high, low, and close (OHLC) for the entire market. - - :param date: The beginning date for the aggregate window. - :param adjusted: Whether or not the results are adjusted for splits. By default, results are adjusted. Set this to false to get results that are NOT adjusted for splits. - :return: List of aggregates - :rtype: List[Agg] - """ - url = f"/v2/aggs/grouped/locale/us/market/stocks/{date}" - - return self._get(path=url, params=self._get_params(self.get_grouped_daily_aggs, locals()), resultKey="results", deserializer=GroupedDailyAgg.from_dict, raw=raw) + date: str, + adjusted: Optional[bool]=None, + params: Optional[Dict[str, Any]]=None, + raw: bool=False, + ) -> List[GroupedDailyAgg]: + """ + Get the daily open, high, low, and close (OHLC) for the entire market. + + :param date: The beginning date for the aggregate window. + :param adjusted: Whether or not the results are adjusted for splits. By default, results are adjusted. Set this to false to get results that are NOT adjusted for splits. + :param params: Any additional query params + :param raw: Return raw object instead of results object + :return: List of grouped daily aggregates + :rtype: List[GroupedDailyAgg] + """ + url = f"/v2/aggs/grouped/locale/us/market/stocks/{date}" + + return self._get(path=url, params=self._get_params(self.get_grouped_daily_aggs, locals()), resultKey="results", deserializer=GroupedDailyAgg.from_dict, raw=raw) + + def get_daily_open_close_agg(self, + ticker: str, + date: str, + adjusted: Optional[bool]=None, + params: Optional[Dict[str, Any]]=None, + raw: bool=False, + ) -> DailyOpenCloseAgg: + """ + Get the open, close and afterhours prices of a stock symbol on a certain date. + + :param ticker: The exchange symbol that this item is traded under. + :param date: The beginning date for the aggregate window. + :param adjusted: Whether or not the results are adjusted for splits. By default, results are adjusted. Set this to false to get results that are NOT adjusted for splits. + :param params: Any additional query params + :param raw: Return raw object instead of results object + :return: Daily open close aggregate + :rtype: DailyOpenCloseAgg + """ + url = f"/v1/open-close/{ticker}/{date}" + + return self._get(path=url, params=self._get_params(self.get_daily_open_close_agg, locals()), deserializer=DailyOpenCloseAgg.from_dict, raw=raw) + + def get_previous_close_agg(self, + ticker: str, + adjusted: Optional[bool]=None, + params: Optional[Dict[str, Any]]=None, + raw: bool=False, + ) -> PreviousCloseAgg: + """ + Get the previous day's open, high, low, and close (OHLC) for the specified stock ticker. + + :param ticker: The ticker symbol of the stock/equity. + :param adjusted: Whether or not the results are adjusted for splits. By default, results are adjusted. Set this to false to get results that are NOT adjusted for splits. + :param params: Any additional query params + :param raw: Return raw object instead of results object + :return: Previous close aggregate + :rtype: PreviousCloseAgg + """ + url = f"/v2/aggs/ticker/{ticker}/prev" + + return self._get(path=url, params=self._get_params(self.get_previous_close_agg, locals()), resultKey="results", deserializer=PreviousCloseAgg.from_dict, raw=raw) diff --git a/polygon/rest/base.py b/polygon/rest/base.py index 2cbd985d..7f17bdaa 100644 --- a/polygon/rest/base.py +++ b/polygon/rest/base.py @@ -48,8 +48,15 @@ def _get(self, path: str, params: Optional[dict] = None, resultKey: Optional[str obj = self._decode(resp) + print("type1", type(obj)) + if resultKey: obj = obj[resultKey] + else: + # If the resultKey does not exist, still need to put the results in a list + obj_list = [] + obj_list.append(obj) + obj = obj_list if deserializer: obj = [deserializer(o) for o in obj] diff --git a/polygon/rest/models/aggs.py b/polygon/rest/models/aggs.py index 43d82611..65ee8bdd 100644 --- a/polygon/rest/models/aggs.py +++ b/polygon/rest/models/aggs.py @@ -1,3 +1,4 @@ +import json from dataclasses import dataclass from typing import Optional @@ -50,3 +51,57 @@ def from_dict(d): d.get('t', None), d.get('n', None) ) + +@dataclass +class DailyOpenCloseAgg: + after_hours: Optional[float] + close: float + from_: str + high: float + low: float + open: float + pre_market: float + status: Optional[str] + symbol: str + volume: float + + @staticmethod + def from_dict(d): + print(type(d)) + return DailyOpenCloseAgg( + d.get('afterHours', None), + d.get('close', None), + d.get('from', None), + d.get('high', None), + d.get('low', None), + d.get('open', None), + d.get('preMarket', None), + d.get('status', None), + d.get('symbol', None), + d.get('volume', None) + ) + +@dataclass +class PreviousCloseAgg: + ticker: str + close: float + high: float + low: float + open: float + timestamp: float + volume: float + vwap: Optional[float] + + @staticmethod + def from_dict(d): + return PreviousCloseAgg( + d.get('T', None), + d.get('c', None), + d.get('h', None), + d.get('l', None), + d.get('o', None), + d.get('t', None), + d.get('v', None), + d.get('vw', None), + ) + From 04730474c5c589dd03b13df7b4cc90d3e07ad5ae Mon Sep 17 00:00:00 2001 From: mcdayoub <38268139+mcdayoub@users.noreply.github.com> Date: Tue, 26 Apr 2022 15:57:14 -0400 Subject: [PATCH 4/4] remove prints --- polygon/rest/base.py | 2 -- polygon/rest/models/aggs.py | 1 - 2 files changed, 3 deletions(-) diff --git a/polygon/rest/base.py b/polygon/rest/base.py index 7f17bdaa..8e48d64e 100644 --- a/polygon/rest/base.py +++ b/polygon/rest/base.py @@ -48,8 +48,6 @@ def _get(self, path: str, params: Optional[dict] = None, resultKey: Optional[str obj = self._decode(resp) - print("type1", type(obj)) - if resultKey: obj = obj[resultKey] else: diff --git a/polygon/rest/models/aggs.py b/polygon/rest/models/aggs.py index 65ee8bdd..5a46c358 100644 --- a/polygon/rest/models/aggs.py +++ b/polygon/rest/models/aggs.py @@ -67,7 +67,6 @@ class DailyOpenCloseAgg: @staticmethod def from_dict(d): - print(type(d)) return DailyOpenCloseAgg( d.get('afterHours', None), d.get('close', None),