Pyex Documentation Release 0.5.0

Pyex Documentation Release 0.5.0

pyEX Documentation Release 0.5.0 Tim Paine Mar 28, 2021 Contents 1 Referral 3 2 Getting Started 5 2.1 Install...................................................5 2.2 Demos + Docs..............................................5 2.3 Overview.................................................5 2.4 Improvements over native API, other libraries, etc...........................7 2.5 Other enhancements...........................................7 2.6 Demo...................................................7 2.7 Rules Engine...............................................7 2.8 Methods.................................................8 2.9 Data....................................................8 2.10 Development...............................................9 2.11 License..................................................9 Python Module Index 567 Index 569 i ii pyEX Documentation, Release 0.5.0 Python interface to IEX Cloud Build Status Coverage License PyPI Docs Contents 1 pyEX Documentation, Release 0.5.0 2 Contents CHAPTER 1 Referral Please subscribe to IEX Cloud using my referral code. 3 pyEX Documentation, Release 0.5.0 4 Chapter 1. Referral CHAPTER 2 Getting Started 2.1 Install Install from pip pip install pyEX of from source python setup.py install 2.1.1 Extensions • pyEX[async]: asyncio integration for streaming APIs • pyEX[studies]: Technical indicators and other calculations 2.2 Demos + Docs • Demo Notebook - IEX Cloud • Streaming Notebook - IEX Cloud • Read The Docs! 2.3 Overview pyEX supports the IEX Cloud api through 2 interfaces. The first is a simple function call, passing in the api version and token as arguments 5 pyEX Documentation, Release 0.5.0 In[1]: import pyEX as p In[2]: p.chart? Signature: p.chart(symbol, timeframe='1m', date=None, token='', version='', filter='') Docstring: Historical price/volume data, daily and intraday https://iexcloud.io/docs/api/#historical-prices Data Schedule 1d: -9:30-4pm ET Mon-Fri on regular market trading days -9:30-1pm ET on early close trading days All others: -Prior trading day available after 4am ET Tue-Sat Args: symbol(str); Ticker to request timeframe(str); Timeframe to request e.g. 1m date(datetime): date, if requesting intraday token(str); Access token version(str); API version filter(str); filters: https://iexcloud.io/docs/api/#filter-results Returns: dict: result For most calls, there is a convenience method that returns a dataframe as well: In[5]:[_ for _ in dir(p) if _.endswith('DF')] Out[5]: ['advancedStatsDF', 'auctionDF', 'balanceSheetDF', 'batchDF', 'bookDF', 'bulkBatchDF', 'bulkMinuteBarsDF', 'calendarDF', ... Since the token rarely changes, we have a Client object for convenience: In[6]: p.Client? Init signature: p.Client(api_token=None, version='v1', api_limit=5) Docstring: IEX Cloud Client Client has access to all methods provided as standalone, but in an authenticated way Args: api_token(str): api token(can pickup from IEX_TOKEN environment variable) version(str): api version to use(defaults to v1) set version to 'sandbox' to run against the IEX sandbox api_limit(int): cache calls in this interval File: ~/Programs/projects/iex/pyEX/pyEX/client.py Type: type Subclasses: The client will automatically pick up the API key from the environment variable IEX_TOKEN, or it can be passed as 6 Chapter 2. Getting Started pyEX Documentation, Release 0.5.0 an argument. To use the IEX Cloud test environment, simple set version='sandbox'. In[8]:c= p.Client(version='sandbox') In[9]: c.chartDF('AAPL').head() Out[9]: open close high low volume uOpen uClose uHigh uLow ,! uVolume change changePercent label changeOverTime date 2019-11-27 271.31 274.04 277.09 268.75 16994433 267.69 271.99 271.82 266.32 ,!168117470.000.0000 Nov 270.000000 2019-11-29 271.30 272.19 280.00 279.20 12135259 270.90 275.02 270.00 267.10 ,!11927464 -0.60 -0.2255 Nov 29 -0.002232 2019-12-02 279.96 265.23 276.41 267.93 23831255 279.97 266.80 281.32 269.29 ,!24607845 -3.20 -1.1646 Dec2 -0.013820 2019-12-03 261.54 271.05 259.96 262.09 30331487 259.87 271.34 269.02 260.71 ,!30518449 -4.93 -1.8450 Dec3 -0.032745 2019-12-04 272.81 273.56 271.26 267.06 17109161 267.30 262.82 274.99 270.83 ,!172305172.390.8955 Dec4 -0.023411 2.4 Improvements over native API, other libraries, etc • pyEX will transparently cache requests according to the refresh interval as defined on the IEX Cloud website (and in the docstrings), to avoid wasting credits. It can also cache to disk, or integrate with your own custom caching scheme. • pyEX fully implements the streaming APIs 2.5 Other enhancements • pyEX-studies: pyEX integration with TA-Lib and other libraries, for technical analysis and other metrics on top of the IEX data • pyEX-caching: persistent, queryable caching for pyEX function calls. Minimize your spend and maximize your performance • pyEX-zipline: Zipline integration for IEX data 2.6 Demo 2.7 Rules Engine pyEX implements methods for interacting with the Rules Engine. rule={ 'conditions': [['changePercent','>',500], ['latestPrice','>',100000]], 'outputs': [{'frequency': 60, (continues on next page) 2.4. Improvements over native API, other libraries, etc 7 pyEX Documentation, Release 0.5.0 (continued from previous page) 'method':'email', 'to':'your_email@domain' }] } c.createRule(rule,'MyTestRule','AAPL','all') # returns {"id": <ruleID>, "weight": ,!2} c.rules() # list all rules c.ruleInfo("<ruleID>") c.ruleOutput("<ruleID>") c.pauseRule("<ruleID>") c.resumeRule("<ruleID>") c.deleteRule("<ruleID>") We also provide helper classes in python for constructing rules such that they abide by the rules schema (dictated in the schema() helper function) 2.8 Methods • schema • lookup • create • pause • resume • edit • rule (get info) • rules (list all) • output 2.9 Data pyEX provides wrappers around both static and SSE streaming data. For most static data endpoints, we provide both JSON and DataFrame return functions. For market data endpoints, we provide async wrappers as well using aiohttp (to install the dependencies, pip install pyEX[async]). DataFrame functions will have the suffix DF, and async functions will have the suffix Async. SSE streaming data can either be used with callbacks: newsSSE('AAPL', on_data=my_function_todo_on_data) or via async generators (after installing pyEX[async]): async for data in newsSSE('AAPL'): 8 Chapter 2. Getting Started pyEX Documentation, Release 0.5.0 2.9.1 Full API Please see the readthedocs for a full API spec. Implemented methods are provided in CATALOG.md. All methods share a common naming convention. If the API method is called technicals, there will be technicals and technicalsDF methods on the client. Additionally, most methods are provided in a scope, e.g. wti is avail- able as client.wti and client.commodities.wti, analystDays from Wall Street Horizon is available as client.premium.analystDays, etc. 2.10 Development See CONTRIBUTING.md for guidelines. 2.11 License This software is licensed under the Apache 2.0 license. See the LICENSE and AUTHORS files for details. 2.11.1 API Documentation 2.10. Development 9 pyEX Documentation, Release 0.5.0 Client class pyEX.Client(api_token=None, version=’v1’, api_limit=5) IEX Cloud Client Client has access to all methods provided as standalone, but in an authenticated way Parameters • api_token (str) – api token (can pickup from IEX_TOKEN environment variable) • version (str) – api version to use (defaults to v1) set version to ‘sandbox’ to run against the IEX sandbox • api_limit (int) – cache calls in this interval acos(symbol, timeframe=’6m’, col=’close’) This will return a dataframe of Vector Trigonometric ACos for the given symbol across the given timeframe Parameters • client (pyEX.Client)– • symbol (string)– • timeframe (string)– • col (string)– Returns result Return type DataFrame ad(symbol, timeframe=’6m’, highcol=’high’, lowcol=’low’, closecol=’close’, volumecol=’volume’) This will return a dataframe of Chaikin A/D Line for the given symbol across the given timeframe Parameters • client (pyEX.Client) – Client • symbol (string) – Ticker • timeframe (string) – timeframe to use, for pyEX.chart • highcol (string) – column to use to calculate • lowcol (string) – column to use to calculate • closecol (string) – column to use to calculate • volumecol (string) – column to use to calculate Returns result Return type DataFrame add(symbol, timeframe=’6m’, col1=’open’, col2=’close’) This will return a dataframe of Vector Arithmetic Add for the given symbol across the given timeframe Parameters • client (pyEX.Client)– • symbol (string)– • timeframe (string)– • col1 (string)– 10 Chapter 2. Getting Started pyEX Documentation, Release 0.5.0 • col2 (string)– Returns result Return type DataFrame adosc(symbol, timeframe=’6m’, highcol=’high’, lowcol=’low’, closecol=’close’, volumecol=’volume’, fastperiod=3, slowperiod=10) This will return a dataframe of Chaikin A/D Oscillator for the given symbol across the given timeframe Parameters • client (pyEX.Client) – Client • symbol (string) – Ticker • timeframe (string) – timeframe to use, for pyEX.chart • highcol (string) – column to use to calculate • lowcol (string) – column to use to calculate • closecol (string) – column to use to calculate • volumecol (string) – column to use to calculate • fastperiod (int) – fast period to calculate across • slowperiod (int) – slow period to calculate across Returns result Return type DataFrame advancedStats(token=”, version=’stable’, filter=”, format=’json’) Returns everything in key stats plus additional advanced stats such as EBITDA, ratios, key financial data, and more. https://iexcloud.io/docs/api/#advanced-stats

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    578 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us