diff --git a/.polygon/rest.json b/.polygon/rest.json index f4e5fcb9..fe330dce 100644 --- a/.polygon/rest.json +++ b/.polygon/rest.json @@ -7007,7 +7007,7 @@ "operationId": "EMA", "parameters": [ { - "description": "The ticker symbol for which to get exponential moving average (EMA) data.", + "description": "Specify a case-sensitive ticker symbol for which to get exponential moving average (EMA) data. For example, AAPL represents Apple Inc.", "example": "AAPL", "in": "path", "name": "stockTicker", @@ -8757,7 +8757,7 @@ "operationId": "MACD", "parameters": [ { - "description": "The ticker symbol for which to get MACD data.", + "description": "Specify a case-sensitive ticker symbol for which to get moving average convergence/divergence (MACD) data. For example, AAPL represents Apple Inc.", "example": "AAPL", "in": "path", "name": "stockTicker", @@ -10375,7 +10375,7 @@ "operationId": "RSI", "parameters": [ { - "description": "The ticker symbol for which to get relative strength index (RSI) data.", + "description": "Specify a case-sensitive ticker symbol for which to get relative strength index (RSI) data. For example, AAPL represents Apple Inc.", "example": "AAPL", "in": "path", "name": "stockTicker", @@ -12015,7 +12015,7 @@ "operationId": "SMA", "parameters": [ { - "description": "The ticker symbol for which to get simple moving average (SMA) data.", + "description": "Specify a case-sensitive ticker symbol for which to get simple moving average (SMA) data. For example, AAPL represents Apple Inc.", "example": "AAPL", "in": "path", "name": "stockTicker", @@ -24822,7 +24822,7 @@ "type": "string" }, "mic": { - "description": "The Market Identifer Code of this exchange (see ISO 10383).", + "description": "The Market Identifier Code of this exchange (see ISO 10383).", "example": "XASE", "type": "string" }, @@ -25536,7 +25536,7 @@ "operationId": "ListStockSplits", "parameters": [ { - "description": "Return the stock splits that contain this ticker.", + "description": "Specify a case-sensitive ticker symbol. For example, AAPL represents Apple Inc.", "in": "query", "name": "ticker", "schema": { @@ -25570,7 +25570,7 @@ } }, { - "description": "Search by ticker.", + "description": "Range by ticker.", "in": "query", "name": "ticker.gte", "schema": { @@ -25578,7 +25578,7 @@ } }, { - "description": "Search by ticker.", + "description": "Range by ticker.", "in": "query", "name": "ticker.gt", "schema": { @@ -25586,7 +25586,7 @@ } }, { - "description": "Search by ticker.", + "description": "Range by ticker.", "in": "query", "name": "ticker.lte", "schema": { @@ -25594,7 +25594,7 @@ } }, { - "description": "Search by ticker.", + "description": "Range by ticker.", "in": "query", "name": "ticker.lt", "schema": { @@ -25602,7 +25602,7 @@ } }, { - "description": "Search by execution_date.", + "description": "Range by execution_date.", "in": "query", "name": "execution_date.gte", "schema": { @@ -25611,7 +25611,7 @@ } }, { - "description": "Search by execution_date.", + "description": "Range by execution_date.", "in": "query", "name": "execution_date.gt", "schema": { @@ -25620,7 +25620,7 @@ } }, { - "description": "Search by execution_date.", + "description": "Range by execution_date.", "in": "query", "name": "execution_date.lte", "schema": { @@ -25629,7 +25629,7 @@ } }, { - "description": "Search by execution_date.", + "description": "Range by execution_date.", "in": "query", "name": "execution_date.lt", "schema": { @@ -28339,7 +28339,7 @@ }, { "description": "The option contract identifier.", - "example": "O:EVRI240119C00002500", + "example": "O:EVRI240920P00012500", "in": "path", "name": "optionContract", "required": true, diff --git a/.polygon/websocket.json b/.polygon/websocket.json index 67db5785..85245e63 100644 --- a/.polygon/websocket.json +++ b/.polygon/websocket.json @@ -539,11 +539,11 @@ }, "s": { "type": "integer", - "description": "The timestamp of the starting tick for this aggregate window in Unix Milliseconds." + "description": "The start timestamp of this aggregate window in Unix Milliseconds." }, "e": { "type": "integer", - "description": "The timestamp of the ending tick for this aggregate window in Unix Milliseconds." + "description": "The end timestamp of this aggregate window in Unix Milliseconds." }, "otc": { "type": "boolean", @@ -686,11 +686,11 @@ }, "s": { "type": "integer", - "description": "The timestamp of the starting tick for this aggregate window in Unix Milliseconds." + "description": "The start timestamp of this aggregate window in Unix Milliseconds." }, "e": { "type": "integer", - "description": "The timestamp of the ending tick for this aggregate window in Unix Milliseconds." + "description": "The end timestamp of this aggregate window in Unix Milliseconds." }, "otc": { "type": "boolean", @@ -1104,11 +1104,11 @@ }, "s": { "type": "integer", - "description": "The timestamp of the starting tick for this aggregate window in Unix Milliseconds." + "description": "The start timestamp of this aggregate window in Unix Milliseconds." }, "e": { "type": "integer", - "description": "The timestamp of the ending tick for this aggregate window in Unix Milliseconds." + "description": "The end timestamp of this aggregate window in Unix Milliseconds." } } }, @@ -1513,11 +1513,11 @@ }, "s": { "type": "integer", - "description": "The timestamp of the starting tick for this aggregate window in Unix Milliseconds." + "description": "The start timestamp of this aggregate window in Unix Milliseconds." }, "e": { "type": "integer", - "description": "The timestamp of the ending tick for this aggregate window in Unix Milliseconds." + "description": "The end timestamp of this aggregate window in Unix Milliseconds." } } }, @@ -1656,11 +1656,11 @@ }, "s": { "type": "integer", - "description": "The timestamp of the starting tick for this aggregate window in Unix Milliseconds." + "description": "The start timestamp of this aggregate window in Unix Milliseconds." }, "e": { "type": "integer", - "description": "The timestamp of the ending tick for this aggregate window in Unix Milliseconds." + "description": "The end timestamp of this aggregate window in Unix Milliseconds." } } }, @@ -1870,11 +1870,11 @@ }, "s": { "type": "integer", - "description": "The timestamp of the starting tick for this aggregate window in Unix Milliseconds." + "description": "The start timestamp of this aggregate window in Unix Milliseconds." }, "e": { "type": "integer", - "description": "The timestamp of the ending tick for this aggregate window in Unix Milliseconds." + "description": "The end timestamp of this aggregate window in Unix Milliseconds." } } }, @@ -2148,11 +2148,11 @@ }, "s": { "type": "integer", - "description": "The start time for this aggregate window in Unix Milliseconds." + "description": "The start timestamp of this aggregate window in Unix Milliseconds." }, "e": { "type": "integer", - "description": "The end time for this aggregate window in Unix Milliseconds." + "description": "The end timestamp of this aggregate window in Unix Milliseconds." } } }, @@ -2248,11 +2248,11 @@ }, "s": { "type": "integer", - "description": "The start time for this aggregate window in Unix Milliseconds." + "description": "The start timestamp of this aggregate window in Unix Milliseconds." }, "e": { "type": "integer", - "description": "The end time for this aggregate window in Unix Milliseconds." + "description": "The end timestamp of this aggregate window in Unix Milliseconds." } } }, @@ -2440,11 +2440,11 @@ }, "s": { "type": "integer", - "description": "The timestamp of the starting tick for this aggregate window in Unix Milliseconds." + "description": "The start timestamp of this aggregate window in Unix Milliseconds." }, "e": { "type": "integer", - "description": "The timestamp of the ending tick for this aggregate window in Unix Milliseconds." + "description": "The end timestamp of this aggregate window in Unix Milliseconds." } } }, @@ -2805,7 +2805,7 @@ }, "b": { "type": "array", - "description": "An array of bid prices with a maximum depth of 100.", + "description": "An array of bid prices, where each entry contains two elements: the first is the bid price, and the second is the size, with a maximum depth of 100.", "items": { "type": "array", "description": "An array where the first item is bid price and the second item is size.", @@ -2817,7 +2817,7 @@ }, "a": { "type": "array", - "description": "An array of ask prices with a maximum depth of 100.", + "description": "An array of ask prices, where each entry contains two elements: the first is the ask price, and the second is the size, with a maximum depth of 100.", "items": { "type": "array", "description": "An array where the first item is ask price and the second item is size.", @@ -2950,11 +2950,11 @@ }, "s": { "type": "integer", - "description": "The start time for this aggregate window in Unix Milliseconds." + "description": "The start timestamp of this aggregate window in Unix Milliseconds." }, "e": { "type": "integer", - "description": "The end time for this aggregate window in Unix Milliseconds." + "description": "The end timestamp of this aggregate window in Unix Milliseconds." }, "vw": { "type": "number", @@ -3062,11 +3062,11 @@ }, "s": { "type": "integer", - "description": "The start time for this aggregate window in Unix Milliseconds." + "description": "The start timestamp of this aggregate window in Unix Milliseconds." }, "e": { "type": "integer", - "description": "The end time for this aggregate window in Unix Milliseconds." + "description": "The end timestamp of this aggregate window in Unix Milliseconds." }, "vw": { "type": "number", @@ -3266,11 +3266,11 @@ }, "s": { "type": "integer", - "description": "The timestamp of the starting tick for this aggregate window in Unix Milliseconds." + "description": "The start timestamp of this aggregate window in Unix Milliseconds." }, "e": { "type": "integer", - "description": "The timestamp of the ending tick for this aggregate window in Unix Milliseconds." + "description": "The end timestamp of this aggregate window in Unix Milliseconds." } } }, @@ -3448,11 +3448,11 @@ }, "s": { "type": "integer", - "description": "The timestamp of the starting index for this aggregate window in Unix Milliseconds." + "description": "The start timestamp of this aggregate window in Unix Milliseconds." }, "e": { "type": "integer", - "description": "The timestamp of the ending index for this aggregate window in Unix Milliseconds." + "description": "The end timestamp of this aggregate window in Unix Milliseconds." } } }, @@ -3564,11 +3564,11 @@ }, "s": { "type": "integer", - "description": "The timestamp of the starting index for this aggregate window in Unix Milliseconds." + "description": "The start timestamp of this aggregate window in Unix Milliseconds." }, "e": { "type": "integer", - "description": "The timestamp of the ending index for this aggregate window in Unix Milliseconds." + "description": "The end timestamp of this aggregate window in Unix Milliseconds." } } }, @@ -3919,11 +3919,11 @@ }, "AggsStartTime": { "type": "integer", - "description": "The start time for this aggregate window in Unix Milliseconds." + "description": "The start timestamp of this aggregate window in Unix Milliseconds." }, "AggsEndTime": { "type": "integer", - "description": "The end time for this aggregate window in Unix Milliseconds." + "description": "The end timestamp of this aggregate window in Unix Milliseconds." }, "StockTradeEvent": { "type": "object", @@ -4109,11 +4109,11 @@ }, "s": { "type": "integer", - "description": "The timestamp of the starting tick for this aggregate window in Unix Milliseconds." + "description": "The start timestamp of this aggregate window in Unix Milliseconds." }, "e": { "type": "integer", - "description": "The timestamp of the ending tick for this aggregate window in Unix Milliseconds." + "description": "The end timestamp of this aggregate window in Unix Milliseconds." }, "otc": { "type": "boolean", @@ -4182,11 +4182,11 @@ }, "s": { "type": "integer", - "description": "The timestamp of the starting tick for this aggregate window in Unix Milliseconds." + "description": "The start timestamp of this aggregate window in Unix Milliseconds." }, "e": { "type": "integer", - "description": "The timestamp of the ending tick for this aggregate window in Unix Milliseconds." + "description": "The end timestamp of this aggregate window in Unix Milliseconds." }, "otc": { "type": "boolean", @@ -4267,11 +4267,11 @@ }, "s": { "type": "integer", - "description": "The timestamp of the starting tick for this aggregate window in Unix Milliseconds." + "description": "The start timestamp of this aggregate window in Unix Milliseconds." }, "e": { "type": "integer", - "description": "The timestamp of the ending tick for this aggregate window in Unix Milliseconds." + "description": "The end timestamp of this aggregate window in Unix Milliseconds." }, "otc": { "type": "boolean", @@ -4547,11 +4547,11 @@ }, "s": { "type": "integer", - "description": "The timestamp of the starting tick for this aggregate window in Unix Milliseconds." + "description": "The start timestamp of this aggregate window in Unix Milliseconds." }, "e": { "type": "integer", - "description": "The timestamp of the ending tick for this aggregate window in Unix Milliseconds." + "description": "The end timestamp of this aggregate window in Unix Milliseconds." } } }, @@ -4616,11 +4616,11 @@ }, "s": { "type": "integer", - "description": "The timestamp of the starting tick for this aggregate window in Unix Milliseconds." + "description": "The start timestamp of this aggregate window in Unix Milliseconds." }, "e": { "type": "integer", - "description": "The timestamp of the ending tick for this aggregate window in Unix Milliseconds." + "description": "The end timestamp of this aggregate window in Unix Milliseconds." } } }, @@ -4697,11 +4697,11 @@ }, "s": { "type": "integer", - "description": "The timestamp of the starting tick for this aggregate window in Unix Milliseconds." + "description": "The start timestamp of this aggregate window in Unix Milliseconds." }, "e": { "type": "integer", - "description": "The timestamp of the ending tick for this aggregate window in Unix Milliseconds." + "description": "The end timestamp of this aggregate window in Unix Milliseconds." } } }, @@ -4837,11 +4837,11 @@ }, "s": { "type": "integer", - "description": "The start time for this aggregate window in Unix Milliseconds." + "description": "The start timestamp of this aggregate window in Unix Milliseconds." }, "e": { "type": "integer", - "description": "The end time for this aggregate window in Unix Milliseconds." + "description": "The end timestamp of this aggregate window in Unix Milliseconds." } } }, @@ -4885,11 +4885,11 @@ }, "s": { "type": "integer", - "description": "The start time for this aggregate window in Unix Milliseconds." + "description": "The start timestamp of this aggregate window in Unix Milliseconds." }, "e": { "type": "integer", - "description": "The end time for this aggregate window in Unix Milliseconds." + "description": "The end timestamp of this aggregate window in Unix Milliseconds." } } }, @@ -5031,11 +5031,11 @@ }, "s": { "type": "integer", - "description": "The start time for this aggregate window in Unix Milliseconds." + "description": "The start timestamp of this aggregate window in Unix Milliseconds." }, "e": { "type": "integer", - "description": "The end time for this aggregate window in Unix Milliseconds." + "description": "The end timestamp of this aggregate window in Unix Milliseconds." }, "vw": { "type": "number", @@ -5088,11 +5088,11 @@ }, "s": { "type": "integer", - "description": "The start time for this aggregate window in Unix Milliseconds." + "description": "The start timestamp of this aggregate window in Unix Milliseconds." }, "e": { "type": "integer", - "description": "The end time for this aggregate window in Unix Milliseconds." + "description": "The end timestamp of this aggregate window in Unix Milliseconds." }, "vw": { "type": "number", @@ -5121,7 +5121,7 @@ }, "b": { "type": "array", - "description": "An array of bid prices with a maximum depth of 100.", + "description": "An array of bid prices, where each entry contains two elements: the first is the bid price, and the second is the size, with a maximum depth of 100.", "items": { "type": "array", "description": "An array where the first item is bid price and the second item is size.", @@ -5133,7 +5133,7 @@ }, "a": { "type": "array", - "description": "An array of ask prices with a maximum depth of 100.", + "description": "An array of ask prices, where each entry contains two elements: the first is the ask price, and the second is the size, with a maximum depth of 100.", "items": { "type": "array", "description": "An array where the first item is ask price and the second item is size.", @@ -5206,11 +5206,11 @@ }, "s": { "type": "integer", - "description": "The timestamp of the starting index for this aggregate window in Unix Milliseconds." + "description": "The start timestamp of this aggregate window in Unix Milliseconds." }, "e": { "type": "integer", - "description": "The timestamp of the ending index for this aggregate window in Unix Milliseconds." + "description": "The end timestamp of this aggregate window in Unix Milliseconds." } } }, @@ -5253,11 +5253,11 @@ }, "s": { "type": "integer", - "description": "The timestamp of the starting index for this aggregate window in Unix Milliseconds." + "description": "The start timestamp of this aggregate window in Unix Milliseconds." }, "e": { "type": "integer", - "description": "The timestamp of the ending index for this aggregate window in Unix Milliseconds." + "description": "The end timestamp of this aggregate window in Unix Milliseconds." } } }, @@ -5312,11 +5312,11 @@ }, "s": { "type": "integer", - "description": "The timestamp of the starting index for this aggregate window in Unix Milliseconds." + "description": "The start timestamp of this aggregate window in Unix Milliseconds." }, "e": { "type": "integer", - "description": "The timestamp of the ending index for this aggregate window in Unix Milliseconds." + "description": "The end timestamp of this aggregate window in Unix Milliseconds." } } }, @@ -5412,11 +5412,11 @@ }, "s": { "type": "integer", - "description": "The timestamp of the starting tick for this aggregate window in Unix Milliseconds." + "description": "The start timestamp of this aggregate window in Unix Milliseconds." }, "e": { "type": "integer", - "description": "The timestamp of the ending tick for this aggregate window in Unix Milliseconds." + "description": "The end timestamp of this aggregate window in Unix Milliseconds." } } }, diff --git a/README.md b/README.md index ae63afb0..81494a78 100644 --- a/README.md +++ b/README.md @@ -5,18 +5,27 @@ Welcome to the official Python client library for the [Polygon](https://polygon.io/) REST and WebSocket API. To get started, please see the [Getting Started](https://polygon.io/docs/stocks/getting-started) section in our documentation, view the [examples](./examples/) directory for code snippets, or the [blog post](https://polygon.io/blog/polygon-io-with-python-for-stock-market-data/) with video tutorials to learn more. +## Prerequisites + +Before installing the Polygon Python client, ensure your environment has Python 3.8 or higher. While most Python environments come with setuptools installed, it is a dependency for this library. In the rare case it's not already present, you can install setuptools using pip: + +``` +pip install setuptools +``` + ## Install Please use pip to install or update to the latest stable version. ``` pip install -U polygon-api-client ``` -Requires Python >= 3.8. ## Getting started To get started, please see the [Getting Started](https://polygon-api-client.readthedocs.io/en/latest/Getting-Started.html) section in our docs, view the [examples](./examples) directory for code snippets, or view the [blog post with videos](https://polygon.io/blog/polygon-io-with-python-for-stock-market-data/) to learn more. +The free tier of our API comes with usage limitations, potentially leading to rate limit errors if these are exceeded. For uninterrupted access and to support larger data requirements, we recommend reviewing our [subscription plans](https://polygon.io/pricing), which are tailored for a wide range of needs from development to high-demand applications. Refer to our pricing page for detailed information on limits and features to ensure a seamless experience, especially for real-time data processing. + ## REST API Client Import the RESTClient. ```python diff --git a/examples/tools/async_websocket_rest_handler/async_websocket_rest_handler.py b/examples/tools/async_websocket_rest_handler/async_websocket_rest_handler.py new file mode 100644 index 00000000..d60a257c --- /dev/null +++ b/examples/tools/async_websocket_rest_handler/async_websocket_rest_handler.py @@ -0,0 +1,109 @@ +import asyncio +import logging +import os +import re +from concurrent.futures import ThreadPoolExecutor +from typing import Optional, Union +from polygon import RESTClient, WebSocketClient +from polygon.websocket.models import Market, Feed + + +class ApiCallHandler: + def __init__(self): + self.api_call_queue = asyncio.Queue() + self.executor = ThreadPoolExecutor() # Thread pool for running synchronous code + self.client = RESTClient() # Assumes POLYGON_API_KEY is set in the environment + + async def enqueue_api_call(self, options_ticker): + await self.api_call_queue.put(options_ticker) + + async def start_processing_api_calls(self): + while True: + options_ticker = await self.api_call_queue.get() + try: + # TODO: + # Here, you can process the rest api requets as needed + # Example: Get the options contract for this + contract = await asyncio.get_running_loop().run_in_executor( + self.executor, self.get_options_contract, options_ticker + ) + print(contract) # Or process the contract data as needed + except Exception as e: + logging.error(f"Error processing API call for {options_ticker}: {e}") + finally: + self.api_call_queue.task_done() + + def get_options_contract(self, options_ticker): + return self.client.get_options_contract(options_ticker) + + +class MessageHandler: + def __init__(self, api_call_handler): + self.handler_queue = asyncio.Queue() + self.api_call_handler = api_call_handler + + async def add(self, message_response: Optional[Union[str, bytes]]) -> None: + await self.handler_queue.put(message_response) + + async def start_handling(self) -> None: + while True: + message_response = await self.handler_queue.get() + logging.info(f"Received message: {message_response}") + try: + # TODO: + # Here, you can process the websocket messages as needed + # Example: Extract ticker symbol and enqueue REST API call + # to get the options contract for this trade (non-blocking) + for trade in message_response: + ticker = self.extract_symbol(trade.symbol) + if ticker == "NVDA": + asyncio.create_task( + self.api_call_handler.enqueue_api_call(trade.symbol) + ) + except Exception as e: + logging.error(f"Error handling message: {e}") + finally: + self.handler_queue.task_done() + + def extract_symbol(self, input_string): + match = re.search(r"O:([A-Z]+)", input_string) + if match: + return match.group(1) + else: + return None + + +class MyClient: + def __init__(self, feed, market, subscriptions): + api_key = os.getenv("POLYGON_API_KEY") + self.polygon_websocket_client = WebSocketClient( + api_key=api_key, + feed=feed, + market=market, + verbose=True, + subscriptions=subscriptions, + ) + self.api_call_handler = ApiCallHandler() + self.message_handler = MessageHandler(self.api_call_handler) + + async def start_event_stream(self): + try: + await asyncio.gather( + self.polygon_websocket_client.connect(self.message_handler.add), + self.message_handler.start_handling(), + self.api_call_handler.start_processing_api_calls(), + ) + except Exception as e: + logging.error(f"Error in event stream: {e}") + + +async def main(): + logging.basicConfig(level=logging.INFO) + my_client = MyClient( + feed=Feed.RealTime, market=Market.Options, subscriptions=["T.*"] + ) + await my_client.start_event_stream() + + +# Entry point for the asyncio program +asyncio.run(main()) diff --git a/examples/tools/async_websocket_rest_handler/readme.md b/examples/tools/async_websocket_rest_handler/readme.md new file mode 100644 index 00000000..a4482ff3 --- /dev/null +++ b/examples/tools/async_websocket_rest_handler/readme.md @@ -0,0 +1,16 @@ +# Pattern for Non-Blocking WebSocket and REST Calls in Python + +This script demonstrates a non-blocking pattern for handling WebSocket streams and REST API calls in Python using asyncio. It focuses on efficient, concurrent processing of real-time financial data and asynchronous fetching of additional information, ensuring that real-time data streams are managed without delays or blockages. The tutorial provides both theoretical insights and a practical, adaptable example, ideal for applications in financial data processing and similar real-time data handling scenarios. + +Please see the [tutorial](https://polygon.io/blog/pattern-for-non-blocking-websocket-and-rest-calls-in-python) for more details. + +### Prerequisites + +- Python 3.x +- Polygon.io account and Options API key + +### Running the Example + +``` +python3 async_websocket_rest_handler.py +``` \ No newline at end of file diff --git a/examples/tools/docker/Dockerfile b/examples/tools/docker/Dockerfile new file mode 100644 index 00000000..253c1fc1 --- /dev/null +++ b/examples/tools/docker/Dockerfile @@ -0,0 +1,19 @@ +# Use an official Python runtime as a parent image +FROM python:3.8-slim + +# Set the working directory in the container +WORKDIR /usr/src/app + +# Copy the current directory contents into the container at /usr/src/app +COPY . . + +# Install any needed packages specified in requirements.txt +RUN pip install --no-cache-dir polygon-api-client + +# Set the environment variable for the Polygon API key +# Note: Replace "" with your actual API key or use Docker's --env flag when running the container to set it dynamically +# Warning: Not recommended for production or shared environments +ENV POLYGON_API_KEY= + +# Run the script when the container launches +CMD ["python", "./app.py"] diff --git a/examples/tools/docker/app.py b/examples/tools/docker/app.py new file mode 100644 index 00000000..8e5c0223 --- /dev/null +++ b/examples/tools/docker/app.py @@ -0,0 +1,20 @@ +from polygon import RESTClient + +# docs +# https://polygon.io/docs/stocks/get_v2_aggs_ticker__stocksticker__range__multiplier___timespan___from___to +# https://polygon-api-client.readthedocs.io/en/latest/Aggs.html#polygon.RESTClient.list_aggs + +client = RESTClient() # POLYGON_API_KEY environment variable is used + +aggs = [] +for a in client.list_aggs( + "AAPL", + 1, + "hour", + "2024-01-30", + "2024-01-30", + limit=50000, +): + aggs.append(a) + +print(aggs) diff --git a/examples/tools/docker/readme.md b/examples/tools/docker/readme.md new file mode 100644 index 00000000..776fd70c --- /dev/null +++ b/examples/tools/docker/readme.md @@ -0,0 +1,41 @@ +# Dockerized Python Application with Polygon API Client + +This Docker setup provides a ready-to-use environment for running Python scripts that utilize the `polygon-api-client` for financial data processing. It encapsulates the Python environment and the `polygon-api-client` library in a Docker container, making it easy to deploy and run the application consistently across any system with Docker installed. This approach is particularly useful for developers looking to integrate Polygon's financial data APIs into their applications without worrying about environment inconsistencies. + +### Prerequisites + +- [Docker](https://www.docker.com/) installed on your machine +- [Polygon.io](https://polygon.io/) account and API key + +### Setup and Configuration + +1. Clone the repository or download the Dockerfile and your Python script into a directory. +2. Use Docker's `--env` flag when running the container to set the `POLYGON_API_KEY` environment variable dynamically, or replace `` in the Dockerfile with your Polygon API key (not recommended for production or shared environments). +3. Ensure your Python script (e.g., `app.py`) is in the same directory as the Dockerfile. + +### Building the Docker Image + +Any modifications to the Python script will require rebuilding the Docker image to reflect the changes in the containerized environment. Use the docker build command each time your script is updated to ensure the latest version is used in your Docker container. + +Navigate to the directory containing your Dockerfile and execute the following command to build your Docker image: + +``` +docker build -t polygon-client-app . +``` + +This command creates a Docker image named `polygon-client-app` based on the instructions in your Dockerfile. + +### Running the Docker Container + +Run your Docker container using the following command: + +``` +docker run --env POLYGON_API_KEY="" polygon-client-app +``` + +Replace `` with your actual Polygon API key. This command starts a Docker container based on the `polygon-client-app` image, sets the `POLYGON_API_KEY` environment variable to your provided API key, and runs your Python script inside the container. + +### Additional Notes + +- The Docker setup provided here is a very basic example. Depending on your specific requirements, you might need to customize the Dockerfile, such as adding volume mounts for persistent data or exposing ports for network communication. +- For more details on using the Polygon API and the `polygon-api-client` library, please refer to the [Polygon documentation](https://polygon.io/docs), the [polygon-io/client-python](https://github.com/polygon-io/client-python) repo, or the [polygon-api-client documentation](https://polygon-api-client.readthedocs.io/en/latest/). \ No newline at end of file diff --git a/poetry.lock b/poetry.lock index 994c656c..c4d4dd8f 100644 --- a/poetry.lock +++ b/poetry.lock @@ -90,13 +90,13 @@ uvloop = ["uvloop (>=0.15.2)"] [[package]] name = "certifi" -version = "2023.11.17" +version = "2024.2.2" description = "Python package for providing Mozilla's CA Bundle." optional = false python-versions = ">=3.6" files = [ - {file = "certifi-2023.11.17-py3-none-any.whl", hash = "sha256:e036ab49d5b79556f99cfc2d9320b34cfbe5be05c5871b51de9329f0603b0474"}, - {file = "certifi-2023.11.17.tar.gz", hash = "sha256:9b469f3a900bf28dc19b8cfbf8019bf47f7fdd1a65a1d4ffb98fc14166beb4d1"}, + {file = "certifi-2024.2.2-py3-none-any.whl", hash = "sha256:dc383c07b76109f368f6106eee2b593b04a011ea4d55f652c6ca24a754d1cdd1"}, + {file = "certifi-2024.2.2.tar.gz", hash = "sha256:0569859f95fc761b18b45ef421b1290a0f65f147e92a1e5eb3e635f9a5e4e66f"}, ] [[package]] @@ -224,14 +224,14 @@ docs = ["furo", "jaraco.packaging (>=9)", "jaraco.tidelift (>=1.4)", "rst.linker testing = ["flake8 (<5)", "pytest (>=6)", "pytest-black (>=0.3.7)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=1.3)", "pytest-flake8", "pytest-mypy (>=0.9.1)"] [[package]] -name = "Jinja2" -version = "3.1.2" +name = "jinja2" +version = "3.1.3" description = "A very fast and expressive template engine." optional = false python-versions = ">=3.7" files = [ - {file = "Jinja2-3.1.2-py3-none-any.whl", hash = "sha256:6088930bfe239f0e6710546ab9c19c9ef35e29792895fed6e6e31a023a182a61"}, - {file = "Jinja2-3.1.2.tar.gz", hash = "sha256:31351a702a408a9e7595a8fc6150fc3f43bb6bf7e319770cbc0db9df9437e852"}, + {file = "Jinja2-3.1.3-py3-none-any.whl", hash = "sha256:7d6d50dd97d52cbc355597bd845fabfbac3f551e1f99619e39a35ce8c370b5fa"}, + {file = "Jinja2-3.1.3.tar.gz", hash = "sha256:ac8bd6544d4bb2c9792bf3a159e80bba8fda7f07e81bc3aed565432d5925ba90"}, ] [package.dependencies] @@ -312,38 +312,38 @@ files = [ [[package]] name = "mypy" -version = "1.8.0" +version = "1.9.0" description = "Optional static typing for Python" optional = false python-versions = ">=3.8" files = [ - {file = "mypy-1.8.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:485a8942f671120f76afffff70f259e1cd0f0cfe08f81c05d8816d958d4577d3"}, - {file = "mypy-1.8.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:df9824ac11deaf007443e7ed2a4a26bebff98d2bc43c6da21b2b64185da011c4"}, - {file = "mypy-1.8.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:2afecd6354bbfb6e0160f4e4ad9ba6e4e003b767dd80d85516e71f2e955ab50d"}, - {file = "mypy-1.8.0-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:8963b83d53ee733a6e4196954502b33567ad07dfd74851f32be18eb932fb1cb9"}, - {file = "mypy-1.8.0-cp310-cp310-win_amd64.whl", hash = "sha256:e46f44b54ebddbeedbd3d5b289a893219065ef805d95094d16a0af6630f5d410"}, - {file = "mypy-1.8.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:855fe27b80375e5c5878492f0729540db47b186509c98dae341254c8f45f42ae"}, - {file = "mypy-1.8.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:4c886c6cce2d070bd7df4ec4a05a13ee20c0aa60cb587e8d1265b6c03cf91da3"}, - {file = "mypy-1.8.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d19c413b3c07cbecf1f991e2221746b0d2a9410b59cb3f4fb9557f0365a1a817"}, - {file = "mypy-1.8.0-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:9261ed810972061388918c83c3f5cd46079d875026ba97380f3e3978a72f503d"}, - {file = "mypy-1.8.0-cp311-cp311-win_amd64.whl", hash = "sha256:51720c776d148bad2372ca21ca29256ed483aa9a4cdefefcef49006dff2a6835"}, - {file = "mypy-1.8.0-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:52825b01f5c4c1c4eb0db253ec09c7aa17e1a7304d247c48b6f3599ef40db8bd"}, - {file = "mypy-1.8.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:f5ac9a4eeb1ec0f1ccdc6f326bcdb464de5f80eb07fb38b5ddd7b0de6bc61e55"}, - {file = "mypy-1.8.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:afe3fe972c645b4632c563d3f3eff1cdca2fa058f730df2b93a35e3b0c538218"}, - {file = "mypy-1.8.0-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:42c6680d256ab35637ef88891c6bd02514ccb7e1122133ac96055ff458f93fc3"}, - {file = "mypy-1.8.0-cp312-cp312-win_amd64.whl", hash = "sha256:720a5ca70e136b675af3af63db533c1c8c9181314d207568bbe79051f122669e"}, - {file = "mypy-1.8.0-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:028cf9f2cae89e202d7b6593cd98db6759379f17a319b5faf4f9978d7084cdc6"}, - {file = "mypy-1.8.0-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:4e6d97288757e1ddba10dd9549ac27982e3e74a49d8d0179fc14d4365c7add66"}, - {file = "mypy-1.8.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:7f1478736fcebb90f97e40aff11a5f253af890c845ee0c850fe80aa060a267c6"}, - {file = "mypy-1.8.0-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:42419861b43e6962a649068a61f4a4839205a3ef525b858377a960b9e2de6e0d"}, - {file = "mypy-1.8.0-cp38-cp38-win_amd64.whl", hash = "sha256:2b5b6c721bd4aabaadead3a5e6fa85c11c6c795e0c81a7215776ef8afc66de02"}, - {file = "mypy-1.8.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:5c1538c38584029352878a0466f03a8ee7547d7bd9f641f57a0f3017a7c905b8"}, - {file = "mypy-1.8.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:4ef4be7baf08a203170f29e89d79064463b7fc7a0908b9d0d5114e8009c3a259"}, - {file = "mypy-1.8.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:7178def594014aa6c35a8ff411cf37d682f428b3b5617ca79029d8ae72f5402b"}, - {file = "mypy-1.8.0-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:ab3c84fa13c04aeeeabb2a7f67a25ef5d77ac9d6486ff33ded762ef353aa5592"}, - {file = "mypy-1.8.0-cp39-cp39-win_amd64.whl", hash = "sha256:99b00bc72855812a60d253420d8a2eae839b0afa4938f09f4d2aa9bb4654263a"}, - {file = "mypy-1.8.0-py3-none-any.whl", hash = "sha256:538fd81bb5e430cc1381a443971c0475582ff9f434c16cd46d2c66763ce85d9d"}, - {file = "mypy-1.8.0.tar.gz", hash = "sha256:6ff8b244d7085a0b425b56d327b480c3b29cafbd2eff27316a004f9a7391ae07"}, + {file = "mypy-1.9.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:f8a67616990062232ee4c3952f41c779afac41405806042a8126fe96e098419f"}, + {file = "mypy-1.9.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:d357423fa57a489e8c47b7c85dfb96698caba13d66e086b412298a1a0ea3b0ed"}, + {file = "mypy-1.9.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:49c87c15aed320de9b438ae7b00c1ac91cd393c1b854c2ce538e2a72d55df150"}, + {file = "mypy-1.9.0-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:48533cdd345c3c2e5ef48ba3b0d3880b257b423e7995dada04248725c6f77374"}, + {file = "mypy-1.9.0-cp310-cp310-win_amd64.whl", hash = "sha256:4d3dbd346cfec7cb98e6cbb6e0f3c23618af826316188d587d1c1bc34f0ede03"}, + {file = "mypy-1.9.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:653265f9a2784db65bfca694d1edd23093ce49740b2244cde583aeb134c008f3"}, + {file = "mypy-1.9.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:3a3c007ff3ee90f69cf0a15cbcdf0995749569b86b6d2f327af01fd1b8aee9dc"}, + {file = "mypy-1.9.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:2418488264eb41f69cc64a69a745fad4a8f86649af4b1041a4c64ee61fc61129"}, + {file = "mypy-1.9.0-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:68edad3dc7d70f2f17ae4c6c1b9471a56138ca22722487eebacfd1eb5321d612"}, + {file = "mypy-1.9.0-cp311-cp311-win_amd64.whl", hash = "sha256:85ca5fcc24f0b4aeedc1d02f93707bccc04733f21d41c88334c5482219b1ccb3"}, + {file = "mypy-1.9.0-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:aceb1db093b04db5cd390821464504111b8ec3e351eb85afd1433490163d60cd"}, + {file = "mypy-1.9.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:0235391f1c6f6ce487b23b9dbd1327b4ec33bb93934aa986efe8a9563d9349e6"}, + {file = "mypy-1.9.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d4d5ddc13421ba3e2e082a6c2d74c2ddb3979c39b582dacd53dd5d9431237185"}, + {file = "mypy-1.9.0-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:190da1ee69b427d7efa8aa0d5e5ccd67a4fb04038c380237a0d96829cb157913"}, + {file = "mypy-1.9.0-cp312-cp312-win_amd64.whl", hash = "sha256:fe28657de3bfec596bbeef01cb219833ad9d38dd5393fc649f4b366840baefe6"}, + {file = "mypy-1.9.0-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:e54396d70be04b34f31d2edf3362c1edd023246c82f1730bbf8768c28db5361b"}, + {file = "mypy-1.9.0-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:5e6061f44f2313b94f920e91b204ec600982961e07a17e0f6cd83371cb23f5c2"}, + {file = "mypy-1.9.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:81a10926e5473c5fc3da8abb04119a1f5811a236dc3a38d92015cb1e6ba4cb9e"}, + {file = "mypy-1.9.0-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:b685154e22e4e9199fc95f298661deea28aaede5ae16ccc8cbb1045e716b3e04"}, + {file = "mypy-1.9.0-cp38-cp38-win_amd64.whl", hash = "sha256:5d741d3fc7c4da608764073089e5f58ef6352bedc223ff58f2f038c2c4698a89"}, + {file = "mypy-1.9.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:587ce887f75dd9700252a3abbc9c97bbe165a4a630597845c61279cf32dfbf02"}, + {file = "mypy-1.9.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:f88566144752999351725ac623471661c9d1cd8caa0134ff98cceeea181789f4"}, + {file = "mypy-1.9.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:61758fabd58ce4b0720ae1e2fea5cfd4431591d6d590b197775329264f86311d"}, + {file = "mypy-1.9.0-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:e49499be624dead83927e70c756970a0bc8240e9f769389cdf5714b0784ca6bf"}, + {file = "mypy-1.9.0-cp39-cp39-win_amd64.whl", hash = "sha256:571741dc4194b4f82d344b15e8837e8c5fcc462d66d076748142327626a1b6e9"}, + {file = "mypy-1.9.0-py3-none-any.whl", hash = "sha256:a260627a570559181a9ea5de61ac6297aa5af202f06fd7ab093ce74e7181e43e"}, + {file = "mypy-1.9.0.tar.gz", hash = "sha256:3cc5da0127e6a478cddd906068496a97a7618a21ce9b54bde5bf7e539c7af974"}, ] [package.dependencies] @@ -384,61 +384,61 @@ six = ">=1.8.0" [[package]] name = "orjson" -version = "3.9.10" +version = "3.9.15" description = "Fast, correct Python JSON library supporting dataclasses, datetimes, and numpy" optional = false python-versions = ">=3.8" files = [ - {file = "orjson-3.9.10-cp310-cp310-macosx_10_15_x86_64.macosx_11_0_arm64.macosx_10_15_universal2.whl", hash = "sha256:c18a4da2f50050a03d1da5317388ef84a16013302a5281d6f64e4a3f406aabc4"}, - {file = "orjson-3.9.10-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:5148bab4d71f58948c7c39d12b14a9005b6ab35a0bdf317a8ade9a9e4d9d0bd5"}, - {file = "orjson-3.9.10-cp310-cp310-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:4cf7837c3b11a2dfb589f8530b3cff2bd0307ace4c301e8997e95c7468c1378e"}, - {file = "orjson-3.9.10-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:c62b6fa2961a1dcc51ebe88771be5319a93fd89bd247c9ddf732bc250507bc2b"}, - {file = "orjson-3.9.10-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:deeb3922a7a804755bbe6b5be9b312e746137a03600f488290318936c1a2d4dc"}, - {file = "orjson-3.9.10-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:1234dc92d011d3554d929b6cf058ac4a24d188d97be5e04355f1b9223e98bbe9"}, - {file = "orjson-3.9.10-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:06ad5543217e0e46fd7ab7ea45d506c76f878b87b1b4e369006bdb01acc05a83"}, - {file = "orjson-3.9.10-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:4fd72fab7bddce46c6826994ce1e7de145ae1e9e106ebb8eb9ce1393ca01444d"}, - {file = "orjson-3.9.10-cp310-none-win32.whl", hash = "sha256:b5b7d4a44cc0e6ff98da5d56cde794385bdd212a86563ac321ca64d7f80c80d1"}, - {file = "orjson-3.9.10-cp310-none-win_amd64.whl", hash = "sha256:61804231099214e2f84998316f3238c4c2c4aaec302df12b21a64d72e2a135c7"}, - {file = "orjson-3.9.10-cp311-cp311-macosx_10_15_x86_64.macosx_11_0_arm64.macosx_10_15_universal2.whl", hash = "sha256:cff7570d492bcf4b64cc862a6e2fb77edd5e5748ad715f487628f102815165e9"}, - {file = "orjson-3.9.10-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:ed8bc367f725dfc5cabeed1ae079d00369900231fbb5a5280cf0736c30e2adf7"}, - {file = "orjson-3.9.10-cp311-cp311-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:c812312847867b6335cfb264772f2a7e85b3b502d3a6b0586aa35e1858528ab1"}, - {file = "orjson-3.9.10-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:9edd2856611e5050004f4722922b7b1cd6268da34102667bd49d2a2b18bafb81"}, - {file = "orjson-3.9.10-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:674eb520f02422546c40401f4efaf8207b5e29e420c17051cddf6c02783ff5ca"}, - {file = "orjson-3.9.10-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:1d0dc4310da8b5f6415949bd5ef937e60aeb0eb6b16f95041b5e43e6200821fb"}, - {file = "orjson-3.9.10-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:e99c625b8c95d7741fe057585176b1b8783d46ed4b8932cf98ee145c4facf499"}, - {file = "orjson-3.9.10-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:ec6f18f96b47299c11203edfbdc34e1b69085070d9a3d1f302810cc23ad36bf3"}, - {file = "orjson-3.9.10-cp311-none-win32.whl", hash = "sha256:ce0a29c28dfb8eccd0f16219360530bc3cfdf6bf70ca384dacd36e6c650ef8e8"}, - {file = "orjson-3.9.10-cp311-none-win_amd64.whl", hash = "sha256:cf80b550092cc480a0cbd0750e8189247ff45457e5a023305f7ef1bcec811616"}, - {file = "orjson-3.9.10-cp312-cp312-macosx_10_15_x86_64.macosx_11_0_arm64.macosx_10_15_universal2.whl", hash = "sha256:602a8001bdf60e1a7d544be29c82560a7b49319a0b31d62586548835bbe2c862"}, - {file = "orjson-3.9.10-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:f295efcd47b6124b01255d1491f9e46f17ef40d3d7eabf7364099e463fb45f0f"}, - {file = "orjson-3.9.10-cp312-cp312-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:92af0d00091e744587221e79f68d617b432425a7e59328ca4c496f774a356071"}, - {file = "orjson-3.9.10-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:c5a02360e73e7208a872bf65a7554c9f15df5fe063dc047f79738998b0506a14"}, - {file = "orjson-3.9.10-cp312-cp312-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:858379cbb08d84fe7583231077d9a36a1a20eb72f8c9076a45df8b083724ad1d"}, - {file = "orjson-3.9.10-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:666c6fdcaac1f13eb982b649e1c311c08d7097cbda24f32612dae43648d8db8d"}, - {file = "orjson-3.9.10-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:3fb205ab52a2e30354640780ce4587157a9563a68c9beaf52153e1cea9aa0921"}, - {file = "orjson-3.9.10-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:7ec960b1b942ee3c69323b8721df2a3ce28ff40e7ca47873ae35bfafeb4555ca"}, - {file = "orjson-3.9.10-cp312-none-win_amd64.whl", hash = "sha256:3e892621434392199efb54e69edfff9f699f6cc36dd9553c5bf796058b14b20d"}, - {file = "orjson-3.9.10-cp38-cp38-macosx_10_15_x86_64.macosx_11_0_arm64.macosx_10_15_universal2.whl", hash = "sha256:8b9ba0ccd5a7f4219e67fbbe25e6b4a46ceef783c42af7dbc1da548eb28b6531"}, - {file = "orjson-3.9.10-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:2e2ecd1d349e62e3960695214f40939bbfdcaeaaa62ccc638f8e651cf0970e5f"}, - {file = "orjson-3.9.10-cp38-cp38-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:7f433be3b3f4c66016d5a20e5b4444ef833a1f802ced13a2d852c637f69729c1"}, - {file = "orjson-3.9.10-cp38-cp38-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:4689270c35d4bb3102e103ac43c3f0b76b169760aff8bcf2d401a3e0e58cdb7f"}, - {file = "orjson-3.9.10-cp38-cp38-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:4bd176f528a8151a6efc5359b853ba3cc0e82d4cd1fab9c1300c5d957dc8f48c"}, - {file = "orjson-3.9.10-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:3a2ce5ea4f71681623f04e2b7dadede3c7435dfb5e5e2d1d0ec25b35530e277b"}, - {file = "orjson-3.9.10-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:49f8ad582da6e8d2cf663c4ba5bf9f83cc052570a3a767487fec6af839b0e777"}, - {file = "orjson-3.9.10-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:2a11b4b1a8415f105d989876a19b173f6cdc89ca13855ccc67c18efbd7cbd1f8"}, - {file = "orjson-3.9.10-cp38-none-win32.whl", hash = "sha256:a353bf1f565ed27ba71a419b2cd3db9d6151da426b61b289b6ba1422a702e643"}, - {file = "orjson-3.9.10-cp38-none-win_amd64.whl", hash = "sha256:e28a50b5be854e18d54f75ef1bb13e1abf4bc650ab9d635e4258c58e71eb6ad5"}, - {file = "orjson-3.9.10-cp39-cp39-macosx_10_15_x86_64.macosx_11_0_arm64.macosx_10_15_universal2.whl", hash = "sha256:ee5926746232f627a3be1cc175b2cfad24d0170d520361f4ce3fa2fd83f09e1d"}, - {file = "orjson-3.9.10-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:0a73160e823151f33cdc05fe2cea557c5ef12fdf276ce29bb4f1c571c8368a60"}, - {file = "orjson-3.9.10-cp39-cp39-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:c338ed69ad0b8f8f8920c13f529889fe0771abbb46550013e3c3d01e5174deef"}, - {file = "orjson-3.9.10-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:5869e8e130e99687d9e4be835116c4ebd83ca92e52e55810962446d841aba8de"}, - {file = "orjson-3.9.10-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:d2c1e559d96a7f94a4f581e2a32d6d610df5840881a8cba8f25e446f4d792df3"}, - {file = "orjson-3.9.10-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:81a3a3a72c9811b56adf8bcc829b010163bb2fc308877e50e9910c9357e78521"}, - {file = "orjson-3.9.10-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:7f8fb7f5ecf4f6355683ac6881fd64b5bb2b8a60e3ccde6ff799e48791d8f864"}, - {file = "orjson-3.9.10-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:c943b35ecdf7123b2d81d225397efddf0bce2e81db2f3ae633ead38e85cd5ade"}, - {file = "orjson-3.9.10-cp39-none-win32.whl", hash = "sha256:fb0b361d73f6b8eeceba47cd37070b5e6c9de5beaeaa63a1cb35c7e1a73ef088"}, - {file = "orjson-3.9.10-cp39-none-win_amd64.whl", hash = "sha256:b90f340cb6397ec7a854157fac03f0c82b744abdd1c0941a024c3c29d1340aff"}, - {file = "orjson-3.9.10.tar.gz", hash = "sha256:9ebbdbd6a046c304b1845e96fbcc5559cd296b4dfd3ad2509e33c4d9ce07d6a1"}, + {file = "orjson-3.9.15-cp310-cp310-macosx_10_15_x86_64.macosx_11_0_arm64.macosx_10_15_universal2.whl", hash = "sha256:d61f7ce4727a9fa7680cd6f3986b0e2c732639f46a5e0156e550e35258aa313a"}, + {file = "orjson-3.9.15-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:4feeb41882e8aa17634b589533baafdceb387e01e117b1ec65534ec724023d04"}, + {file = "orjson-3.9.15-cp310-cp310-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:fbbeb3c9b2edb5fd044b2a070f127a0ac456ffd079cb82746fc84af01ef021a4"}, + {file = "orjson-3.9.15-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:b66bcc5670e8a6b78f0313bcb74774c8291f6f8aeef10fe70e910b8040f3ab75"}, + {file = "orjson-3.9.15-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:2973474811db7b35c30248d1129c64fd2bdf40d57d84beed2a9a379a6f57d0ab"}, + {file = "orjson-3.9.15-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:9fe41b6f72f52d3da4db524c8653e46243c8c92df826ab5ffaece2dba9cccd58"}, + {file = "orjson-3.9.15-cp310-cp310-musllinux_1_2_aarch64.whl", hash = "sha256:4228aace81781cc9d05a3ec3a6d2673a1ad0d8725b4e915f1089803e9efd2b99"}, + {file = "orjson-3.9.15-cp310-cp310-musllinux_1_2_x86_64.whl", hash = "sha256:6f7b65bfaf69493c73423ce9db66cfe9138b2f9ef62897486417a8fcb0a92bfe"}, + {file = "orjson-3.9.15-cp310-none-win32.whl", hash = "sha256:2d99e3c4c13a7b0fb3792cc04c2829c9db07838fb6973e578b85c1745e7d0ce7"}, + {file = "orjson-3.9.15-cp310-none-win_amd64.whl", hash = "sha256:b725da33e6e58e4a5d27958568484aa766e825e93aa20c26c91168be58e08cbb"}, + {file = "orjson-3.9.15-cp311-cp311-macosx_10_15_x86_64.macosx_11_0_arm64.macosx_10_15_universal2.whl", hash = "sha256:c8e8fe01e435005d4421f183038fc70ca85d2c1e490f51fb972db92af6e047c2"}, + {file = "orjson-3.9.15-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:87f1097acb569dde17f246faa268759a71a2cb8c96dd392cd25c668b104cad2f"}, + {file = "orjson-3.9.15-cp311-cp311-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:ff0f9913d82e1d1fadbd976424c316fbc4d9c525c81d047bbdd16bd27dd98cfc"}, + {file = "orjson-3.9.15-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:8055ec598605b0077e29652ccfe9372247474375e0e3f5775c91d9434e12d6b1"}, + {file = "orjson-3.9.15-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:d6768a327ea1ba44c9114dba5fdda4a214bdb70129065cd0807eb5f010bfcbb5"}, + {file = "orjson-3.9.15-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:12365576039b1a5a47df01aadb353b68223da413e2e7f98c02403061aad34bde"}, + {file = "orjson-3.9.15-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:71c6b009d431b3839d7c14c3af86788b3cfac41e969e3e1c22f8a6ea13139404"}, + {file = "orjson-3.9.15-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:e18668f1bd39e69b7fed19fa7cd1cd110a121ec25439328b5c89934e6d30d357"}, + {file = "orjson-3.9.15-cp311-none-win32.whl", hash = "sha256:62482873e0289cf7313461009bf62ac8b2e54bc6f00c6fabcde785709231a5d7"}, + {file = "orjson-3.9.15-cp311-none-win_amd64.whl", hash = "sha256:b3d336ed75d17c7b1af233a6561cf421dee41d9204aa3cfcc6c9c65cd5bb69a8"}, + {file = "orjson-3.9.15-cp312-cp312-macosx_10_15_x86_64.macosx_11_0_arm64.macosx_10_15_universal2.whl", hash = "sha256:82425dd5c7bd3adfe4e94c78e27e2fa02971750c2b7ffba648b0f5d5cc016a73"}, + {file = "orjson-3.9.15-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:2c51378d4a8255b2e7c1e5cc430644f0939539deddfa77f6fac7b56a9784160a"}, + {file = "orjson-3.9.15-cp312-cp312-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:6ae4e06be04dc00618247c4ae3f7c3e561d5bc19ab6941427f6d3722a0875ef7"}, + {file = "orjson-3.9.15-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:bcef128f970bb63ecf9a65f7beafd9b55e3aaf0efc271a4154050fc15cdb386e"}, + {file = "orjson-3.9.15-cp312-cp312-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:b72758f3ffc36ca566ba98a8e7f4f373b6c17c646ff8ad9b21ad10c29186f00d"}, + {file = "orjson-3.9.15-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:10c57bc7b946cf2efa67ac55766e41764b66d40cbd9489041e637c1304400494"}, + {file = "orjson-3.9.15-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:946c3a1ef25338e78107fba746f299f926db408d34553b4754e90a7de1d44068"}, + {file = "orjson-3.9.15-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:2f256d03957075fcb5923410058982aea85455d035607486ccb847f095442bda"}, + {file = "orjson-3.9.15-cp312-none-win_amd64.whl", hash = "sha256:5bb399e1b49db120653a31463b4a7b27cf2fbfe60469546baf681d1b39f4edf2"}, + {file = "orjson-3.9.15-cp38-cp38-macosx_10_15_x86_64.macosx_11_0_arm64.macosx_10_15_universal2.whl", hash = "sha256:b17f0f14a9c0ba55ff6279a922d1932e24b13fc218a3e968ecdbf791b3682b25"}, + {file = "orjson-3.9.15-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:7f6cbd8e6e446fb7e4ed5bac4661a29e43f38aeecbf60c4b900b825a353276a1"}, + {file = "orjson-3.9.15-cp38-cp38-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:76bc6356d07c1d9f4b782813094d0caf1703b729d876ab6a676f3aaa9a47e37c"}, + {file = "orjson-3.9.15-cp38-cp38-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:fdfa97090e2d6f73dced247a2f2d8004ac6449df6568f30e7fa1a045767c69a6"}, + {file = "orjson-3.9.15-cp38-cp38-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:7413070a3e927e4207d00bd65f42d1b780fb0d32d7b1d951f6dc6ade318e1b5a"}, + {file = "orjson-3.9.15-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:9cf1596680ac1f01839dba32d496136bdd5d8ffb858c280fa82bbfeb173bdd40"}, + {file = "orjson-3.9.15-cp38-cp38-musllinux_1_2_aarch64.whl", hash = "sha256:809d653c155e2cc4fd39ad69c08fdff7f4016c355ae4b88905219d3579e31eb7"}, + {file = "orjson-3.9.15-cp38-cp38-musllinux_1_2_x86_64.whl", hash = "sha256:920fa5a0c5175ab14b9c78f6f820b75804fb4984423ee4c4f1e6d748f8b22bc1"}, + {file = "orjson-3.9.15-cp38-none-win32.whl", hash = "sha256:2b5c0f532905e60cf22a511120e3719b85d9c25d0e1c2a8abb20c4dede3b05a5"}, + {file = "orjson-3.9.15-cp38-none-win_amd64.whl", hash = "sha256:67384f588f7f8daf040114337d34a5188346e3fae6c38b6a19a2fe8c663a2f9b"}, + {file = "orjson-3.9.15-cp39-cp39-macosx_10_15_x86_64.macosx_11_0_arm64.macosx_10_15_universal2.whl", hash = "sha256:6fc2fe4647927070df3d93f561d7e588a38865ea0040027662e3e541d592811e"}, + {file = "orjson-3.9.15-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:34cbcd216e7af5270f2ffa63a963346845eb71e174ea530867b7443892d77180"}, + {file = "orjson-3.9.15-cp39-cp39-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:f541587f5c558abd93cb0de491ce99a9ef8d1ae29dd6ab4dbb5a13281ae04cbd"}, + {file = "orjson-3.9.15-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:92255879280ef9c3c0bcb327c5a1b8ed694c290d61a6a532458264f887f052cb"}, + {file = "orjson-3.9.15-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:05a1f57fb601c426635fcae9ddbe90dfc1ed42245eb4c75e4960440cac667262"}, + {file = "orjson-3.9.15-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:ede0bde16cc6e9b96633df1631fbcd66491d1063667f260a4f2386a098393790"}, + {file = "orjson-3.9.15-cp39-cp39-musllinux_1_2_aarch64.whl", hash = "sha256:e88b97ef13910e5f87bcbc4dd7979a7de9ba8702b54d3204ac587e83639c0c2b"}, + {file = "orjson-3.9.15-cp39-cp39-musllinux_1_2_x86_64.whl", hash = "sha256:57d5d8cf9c27f7ef6bc56a5925c7fbc76b61288ab674eb352c26ac780caa5b10"}, + {file = "orjson-3.9.15-cp39-none-win32.whl", hash = "sha256:001f4eb0ecd8e9ebd295722d0cbedf0748680fb9998d3993abaed2f40587257a"}, + {file = "orjson-3.9.15-cp39-none-win_amd64.whl", hash = "sha256:ea0b183a5fe6b2b45f3b854b0d19c4e932d6f5934ae1f723b07cf9560edd4ec7"}, + {file = "orjson-3.9.15.tar.gz", hash = "sha256:95cae920959d772f30ab36d3b25f83bb0f3be671e986c72ce22f8fa700dae061"}, ] [[package]] @@ -491,13 +491,13 @@ test = ["appdirs (==1.4.4)", "pytest (>=7.2)", "pytest-cov (>=4)", "pytest-mock [[package]] name = "pook" -version = "1.4.0" +version = "1.4.3" description = "HTTP traffic mocking and expectations made easy" optional = false python-versions = ">=3.8" files = [ - {file = "pook-1.4.0-py3-none-any.whl", hash = "sha256:1b47fcc75a8a063fc977ee55c7360a0f70bcf3ac0de9be584c8ec09cb127da49"}, - {file = "pook-1.4.0.tar.gz", hash = "sha256:9261e576e7fe9e9df22f77ffe630560dc6297945382cb4ab9d9c1bb33ddfc62b"}, + {file = "pook-1.4.3-py3-none-any.whl", hash = "sha256:4683a8a9d11fb56901ae15001a5bfb76a1bb960b1a841de1f0ca11c8c2d9eef8"}, + {file = "pook-1.4.3.tar.gz", hash = "sha256:61dbd9f6f9bf4d0bbab4abdf382bf7e8fbaae8561c5de3cd444e7c4be67df651"}, ] [package.dependencies] @@ -641,22 +641,22 @@ test = ["cython", "filelock", "html5lib", "pytest (>=4.6)"] [[package]] name = "sphinx-autodoc-typehints" -version = "1.25.2" +version = "2.0.0" description = "Type hints (PEP 484) support for the Sphinx autodoc extension" optional = false python-versions = ">=3.8" files = [ - {file = "sphinx_autodoc_typehints-1.25.2-py3-none-any.whl", hash = "sha256:5ed05017d23ad4b937eab3bee9fae9ab0dd63f0b42aa360031f1fad47e47f673"}, - {file = "sphinx_autodoc_typehints-1.25.2.tar.gz", hash = "sha256:3cabc2537e17989b2f92e64a399425c4c8bf561ed73f087bc7414a5003616a50"}, + {file = "sphinx_autodoc_typehints-2.0.0-py3-none-any.whl", hash = "sha256:12c0e161f6fe191c2cdfd8fa3caea271f5387d9fbc67ebcd6f4f1f24ce880993"}, + {file = "sphinx_autodoc_typehints-2.0.0.tar.gz", hash = "sha256:7f2cdac2e70fd9787926b6e9e541cd4ded1e838d2b46fda2a1bb0a75ec5b7f3a"}, ] [package.dependencies] sphinx = ">=7.1.2" [package.extras] -docs = ["furo (>=2023.7.26)", "sphinx (>=7.1.2)"] +docs = ["furo (>=2023.9.10)"] numpy = ["nptyping (>=2.5)"] -testing = ["covdefaults (>=2.3)", "coverage (>=7.3)", "diff-cover (>=7.7)", "pytest (>=7.4)", "pytest-cov (>=4.1)", "sphobjinv (>=2.3.1)", "typing-extensions (>=4.7.1)"] +testing = ["covdefaults (>=2.3)", "coverage (>=7.3.2)", "diff-cover (>=8.0.1)", "pytest (>=7.4.3)", "pytest-cov (>=4.1)", "sphobjinv (>=2.3.1)", "typing-extensions (>=4.8)"] [[package]] name = "sphinx-rtd-theme" @@ -804,13 +804,13 @@ files = [ [[package]] name = "types-setuptools" -version = "69.0.0.0" +version = "69.2.0.20240317" description = "Typing stubs for setuptools" optional = false -python-versions = ">=3.7" +python-versions = ">=3.8" files = [ - {file = "types-setuptools-69.0.0.0.tar.gz", hash = "sha256:b0a06219f628c6527b2f8ce770a4f47550e00d3e8c3ad83e2dc31bc6e6eda95d"}, - {file = "types_setuptools-69.0.0.0-py3-none-any.whl", hash = "sha256:8c86195bae2ad81e6dea900a570fe9d64a59dbce2b11cc63c046b03246ea77bf"}, + {file = "types-setuptools-69.2.0.20240317.tar.gz", hash = "sha256:b607c4c48842ef3ee49dc0c7fe9c1bad75700b071e1018bb4d7e3ac492d47048"}, + {file = "types_setuptools-69.2.0.20240317-py3-none-any.whl", hash = "sha256:cf91ff7c87ab7bf0625c3f0d4d90427c9da68561f3b0feab77977aaf0bbf7531"}, ] [[package]] @@ -961,4 +961,4 @@ testing = ["flake8 (<5)", "func-timeout", "jaraco.functools", "jaraco.itertools" [metadata] lock-version = "2.0" python-versions = "^3.8" -content-hash = "a365fadab022b55a06bc1fe6b7ef8a6253066ae7cb4fa0a458bf63ea9a5c9d6d" +content-hash = "4411fb69fca534e61c7af60386dc101effb9666f13f3b85a0f148414e0c4cf79" diff --git a/polygon/rest/base.py b/polygon/rest/base.py index dcddb8a8..3e65c06c 100644 --- a/polygon/rest/base.py +++ b/polygon/rest/base.py @@ -1,5 +1,6 @@ import certifi import json +import ssl import urllib3 import inspect from urllib3.util.retry import Retry @@ -66,13 +67,16 @@ def __init__( backoff_factor=0.1, # [0.0s, 0.2s, 0.4s, 0.8s, 1.6s, ...] ) + # global cache ssl context and use (vs on each init of pool manager) + ssl_context = ssl.create_default_context() + ssl_context.load_verify_locations(certifi.where()) + # https://urllib3.readthedocs.io/en/stable/reference/urllib3.poolmanager.html # https://urllib3.readthedocs.io/en/stable/reference/urllib3.connectionpool.html#urllib3.HTTPConnectionPool self.client = urllib3.PoolManager( num_pools=num_pools, headers=self.headers, # default headers sent with each request. - ca_certs=certifi.where(), - cert_reqs="CERT_REQUIRED", + ssl_context=ssl_context, retries=retry_strategy, # use the customized Retry instance ) diff --git a/pyproject.toml b/pyproject.toml index ecc9b5e9..b69d67ba 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -27,20 +27,20 @@ packages = [ python = "^3.8" urllib3 = "^1.26.9,<2.0" websockets = ">=10.3,<13.0" -certifi = ">=2022.5.18,<2024.0.0" +certifi = ">=2022.5.18,<2025.0.0" [tool.poetry.dev-dependencies] black = "^23.12.1" -mypy = "^1.8" +mypy = "^1.9" types-urllib3 = "^1.26.25" Sphinx = "^7.1.2" sphinx-rtd-theme = "^2.0.0" # keep this in sync with docs/requirements.txt for readthedocs.org -sphinx-autodoc-typehints = "^1.25.2" +sphinx-autodoc-typehints = "^2.0.0" types-certifi = "^2021.10.8" -types-setuptools = "^69.0.0" -pook = "^1.4.0" -orjson = "^3.9.10" +types-setuptools = "^69.2.0" +pook = "^1.4.3" +orjson = "^3.9.15" [build-system] requires = ["poetry-core>=1.0.0"] pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy