polygon

A Complete Python Wrapper for Polygon.io APIs. Including Stocks, Options, Streaming, Forex & Crypto, References API and more...

https://github.com/pssolanki111/polygon

Science Score: 26.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (15.0%) to scientific vocabulary

Keywords

api-wrapper asyncio automated-trading finance financial-data polygon polygon-io python python3 trading
Last synced: 6 months ago · JSON representation

Repository

A Complete Python Wrapper for Polygon.io APIs. Including Stocks, Options, Streaming, Forex & Crypto, References API and more...

Basic Info
Statistics
  • Stars: 114
  • Watchers: 4
  • Forks: 24
  • Open Issues: 0
  • Releases: 0
Topics
api-wrapper asyncio automated-trading finance financial-data polygon polygon-io python python3 trading
Created over 4 years ago · Last pushed 7 months ago
Metadata Files
Readme Changelog License

README.md

polygon: A Complete Polygon.io API Wrapper

Discord Downloads Documentation Status pypi CodeFactor ff fd Licenses gh

what is polygon

polygon is a Complete Python Wrapper for Polygon.io APIs. It offers simple and elegant programmatic access over each endpoint. Functionalities include but not limited to:

  • Stocks, Index and Options data
  • Forex and Crypto data
  • Real time Websocket streaming (both callback and async based)
  • Technical Indicators (SMA, EMA, RSI, MACD)
  • Market Info, News, Holidays, Schedules, Tickers, Conditions, Dividends, Splits
  • Async support for REST endpoints
  • Built In stream reconnection functionality (Experimental, async streamer only)
  • Full builtin Pagination support (with internal merging of responses)
  • Bulk data download functions: bulk OCHLV aggregates bars, bulk ticker details etc.
  • Extensive Option Symbology supporting 6 option symbol formats

and a lot more...

How Do I Use polygon

The complete description of everything you need to know is available in the Documentation which has answers to any question you might have with example uses included wherever needed. Docs are a must-read for most people.

  • For examples to get started with, see the examples
  • For an advanced use case example code involving redis queue and postgresql database, check out
  • MarketMakerLite/polygon
  • The lib is also officially supported by the popular TA library pandas-ta as an underlying data source instead of the default yfinance. See relevant docs to know how to use
  • To see an advanced use case of downloading ALL OCHLV data for ALL tickers for 20+ years and write it to a timescale enabled postgresql database efficiently, see This Script by MML.
  • The documentation also contain TONS of sample code snippets wherever necessary.

Quick Setup Guide With Examples

Before you do anything, you'll need to have a polygon account and get your API key. Visit Your Dashboard to get yours.

Next, you'd need to install polygon

shell pip install polygon

and You're good to Go!

Here are a few quick usage examples.

Getting a Stock's Previous Day OCHLV

```python import polygon

apikey = 'YOURKEY'

stocksclient = polygon.StocksClient(apikey)

previousclose = stocksclient.getpreviousclose('AMD')

print(previous_close) ```

An Async Example for REST endpoints - Previous Close

```python import polygon import asyncio

async def main(): apikey = 'YOURKEY'

stocks_client = polygon.StocksClient(api_key, True)

previous_close = await stocks_client.get_previous_close('AMD')
await stocks_client.close()  # Recommended to close the httpx session when it's not needed. 
print(previous_close)

if name == 'main': asyncio.run(main()) ```

A Streaming Example (Callback Based)

```python import polygon from polygon.enums import StreamCluster

def myownmessage_handler(ws, msg): print(f'msg received: {msg}')

def main(): apikey = 'YOURKEY'

stream_client = polygon.StreamClient(api_key, StreamCluster.STOCKS, on_message=my_own_message_handler)
stream_client.start_stream_thread()
stream_client.subscribe_stock_trades(['AMD', 'NVDA'])

if name == 'main': main() ```

An Async Streaming Example

```python import asyncio import polygon from polygon.enums import StreamCluster

async def stocktradeshandler(msg): # it is possible to create one common message handler for different services. print(f'msg received: {msg}')

async def main(): apikey = 'YOURKEY'

stream_client = polygon.AsyncStreamClient(api_key, StreamCluster.STOCKS)

await stream_client.subscribe_stock_trades(['AMD', 'NVDA'], stock_trades_handler)

while 1:
    await stream_client.handle_messages()  # the lib provides auto reconnect functionality. See docs for info

if name == 'main': asyncio.run(main())

``` This only scratches the surface of the library.

See the Documentation to start using the library with its full functionalities.

Latest development source code of the library can be found on the development branch

What if I need help?

We have a helpful & vibrant community in our Discord Server. Join in to ask a question, share your ideas or observations or to just chat with interesting people, or maybe just for lurking :eyes:

See Getting Help or you can also start a quick discussion

Quick Links for Speed Runners

What else?

  • Bug reports, suggestions and pull requests are always welcome.
  • See Contributing if you wish to contribute.
  • Read This before raising a bug.
  • CHANGELOG for the project is available within the same repository
  • polygon is released under the MIT License

Made with Passion & Python by P S Solanki

Owner

  • Name: P S Solanki
  • Login: pssolanki111
  • Kind: user
  • Location: Jaipur, Rajasthan, India.
  • Company: @MyFunded

Senior Software Engineer @ MFF | Co-Founder at Reroutes.io

GitHub Events

Total
  • Issues event: 6
  • Watch event: 27
  • Issue comment event: 8
  • Push event: 2
  • Pull request review comment event: 1
  • Pull request review event: 4
  • Pull request event: 4
  • Fork event: 4
Last Year
  • Issues event: 6
  • Watch event: 27
  • Issue comment event: 8
  • Push event: 2
  • Pull request review comment event: 1
  • Pull request review event: 4
  • Pull request event: 4
  • Fork event: 4

Committers

Last synced: over 1 year ago

All Time
  • Total Commits: 221
  • Total Committers: 5
  • Avg Commits per committer: 44.2
  • Development Distribution Score (DDS): 0.09
Past Year
  • Commits: 17
  • Committers: 2
  • Avg Commits per committer: 8.5
  • Development Distribution Score (DDS): 0.294
Top Committers
Name Email Commits
P S Solanki p****s@g****m 201
P S Solanki p****i@p****m 12
MuradGitHub g****b@n****g 5
riri r****i@q****m 2
Michael Astashkevich a****a 1
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 8
  • Total pull requests: 7
  • Average time to close issues: 3 months
  • Average time to close pull requests: 7 days
  • Total issue authors: 8
  • Total pull request authors: 7
  • Average comments per issue: 2.5
  • Average comments per pull request: 1.57
  • Merged pull requests: 4
  • Bot issues: 0
  • Bot pull requests: 1
Past Year
  • Issues: 1
  • Pull requests: 0
  • Average time to close issues: 14 days
  • Average time to close pull requests: N/A
  • Issue authors: 1
  • Pull request authors: 0
  • Average comments per issue: 5.0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • yarimiz (1)
  • RedstonedLife (1)
  • greko6 (1)
  • ecamaj (1)
  • svmlfin (1)
  • timotheecour (1)
  • hoangvictor (1)
  • C0deX00 (1)
Pull Request Authors
  • edzme (2)
  • sadtriyo100jt (2)
  • asmisha (1)
  • vitteloil (1)
  • deepsource-autofix[bot] (1)
  • Chacoon3 (1)
  • MuradGitHub (1)
  • yarimiz (1)
  • RedstonedLife (1)
  • pssolanki111 (1)
Top Labels
Issue Labels
Potential Bug (5) question (1) bug (1)
Pull Request Labels
code_style (1) enhancement (1)

Packages

  • Total packages: 1
  • Total downloads:
    • pypi 9,271 last-month
  • Total docker downloads: 8
  • Total dependent packages: 15
  • Total dependent repositories: 7
  • Total versions: 37
  • Total maintainers: 1
pypi.org: polygon

A Complete Python Wrapper for Polygon.io APIs.

  • Versions: 37
  • Dependent Packages: 15
  • Dependent Repositories: 7
  • Downloads: 9,271 Last month
  • Docker Downloads: 8
Rankings
Dependent packages count: 0.7%
Downloads: 3.0%
Docker downloads count: 4.1%
Dependent repos count: 5.5%
Average: 5.6%
Stargazers count: 9.2%
Forks count: 10.9%
Maintainers (1)
Last synced: 6 months ago

Dependencies

requirements.txt pypi
  • asynctest *
  • httpx *
  • orjson *
  • pytz *
  • requests *
  • sphinx *
  • sphinx_rtd_theme *
  • uvloop *
  • websocket-client *
  • websockets *
setup.py pypi
  • httpx *
  • requests *
  • websocket-client *
  • websockets *