Common Usage Examples

The iex-examples repository provides a number of detailed examples of iexfinance usage. Basic examples are also provided below.

Using iexfinance to access data from IEX is quite easy. The most commonly-used endpoints are the Stocks endpoints, which allow access to various information regarding equities, including quotes, historical prices, dividends, and much more.

The iexfinance codebase and documentation are structured in a way that emulates much of the IEX Cloud Documentation for readability and ease of use.

These modules provide classes and functions to execute queries to IEX Cloud.

Account

See also

Account

Stocks

See also

For more information, see Stocks.

Real-time Quotes

To obtain real-time quotes for one or more symbols, use the get_price method of the Stock object:

In [1]: from iexfinance.stocks import Stock

In [2]: tsla = Stock('TSLA')

In [3]: tsla.get_price()
Out[3]: 
        TSLA
TSLA  228.25

or for multiple symbols, use a list or list-like object (Tuple, Pandas Series, etc.):

In [4]: batch = Stock(["TSLA", "AAPL"])

In [5]: batch.get_price()
Out[5]: 
        AAPL    TSLA
TSLA  201.29  233.07
AAPL  201.29  233.07

Historical Data

It’s possible to obtain historical data the get_historical_data and get_historical_intraday.

Daily

To obtain daily historical price data for one or more symbols, use the get_historical_data function. This will return a daily time-series of the ticker requested over the desired date range (start and end passed as datetime.datetime objects):

In [6]: from datetime import datetime

In [7]: from iexfinance.stocks import get_historical_data

In [8]: start = datetime(2017, 1, 1)

In [9]: end = datetime(2018, 1, 1)

In [10]: df = get_historical_data("TSLA", start, end)

For Pandas DataFrame output formatting, pass output_format:

In [11]: df = get_historical_data("TSLA", start, end, output_format='pandas')

Minutely (Intraday)

To obtain historical intraday data, use get_historical_intraday as follows. Pass an optional date to specify a date within three months prior to the current day (default is current date):

In [12]: from datetime import datetime

In [13]: from iexfinance.stocks import get_historical_intraday

In [14]: date = datetime(2019, 5, 10)

In [15]: get_historical_intraday("AAPL", date)
Out[15]: 
                     average  changeOverTime    close        date     high  \
2019-05-10 09:30:00  205.239        0.000000  205.343  2019-05-10  202.908   
2019-05-10 09:31:00  201.268        0.002565  203.000  2019-05-10  204.570   
2019-05-10 09:32:00  202.198        0.001320  198.630  2019-05-10  203.810   
2019-05-10 09:33:00  204.935        0.003448  200.150  2019-05-10  202.960   
2019-05-10 09:34:00  205.314        0.002427  198.880  2019-05-10  204.050   
2019-05-10 09:35:00  204.880       -0.000874  200.613  2019-05-10  200.840   
2019-05-10 09:36:00  198.489       -0.000265  202.080  2019-05-10  198.110   
2019-05-10 09:37:00  205.023        0.000224  207.210  2019-05-10  204.980   
2019-05-10 09:38:00  200.070        0.001804  201.700  2019-05-10  205.200   
2019-05-10 09:39:00  204.638        0.003332  202.220  2019-05-10  203.990   
2019-05-10 09:40:00  203.600        0.004336  206.300  2019-05-10  206.140   
2019-05-10 09:41:00  199.272        0.004635  198.990  2019-05-10  200.400   
2019-05-10 09:42:00  204.453        0.004492  202.700  2019-05-10  203.230   
2019-05-10 09:43:00  204.603        0.003769  207.200  2019-05-10  202.120   
2019-05-10 09:44:00  201.092        0.002057  202.230  2019-05-10  204.250   
2019-05-10 09:45:00  207.567        0.002658  206.400  2019-05-10  201.000   
2019-05-10 09:46:00  203.415        0.003392  202.010  2019-05-10  208.260   
2019-05-10 09:47:00  203.120        0.003347  205.900  2019-05-10  200.103   
2019-05-10 09:48:00  206.538        0.003373  202.600  2019-05-10  200.300   
2019-05-10 09:49:00  201.742        0.002569  201.260  2019-05-10  207.050   
2019-05-10 09:50:00  206.671        0.000663  203.600  2019-05-10  204.870   
2019-05-10 09:51:00  206.084       -0.000876  202.540  2019-05-10  201.400   
2019-05-10 09:52:00  204.077       -0.001077  201.570  2019-05-10  206.890   
2019-05-10 09:53:00  199.233       -0.001110  199.110  2019-05-10  204.760   
2019-05-10 09:54:00  198.540       -0.001974  201.800  2019-05-10  203.530   
2019-05-10 09:55:00  205.614       -0.002022  199.610  2019-05-10  198.259   
2019-05-10 09:56:00  204.729       -0.002272  198.890  2019-05-10  200.270   
2019-05-10 09:57:00  207.074       -0.001352  197.810  2019-05-10  201.900   
2019-05-10 09:58:00  206.463       -0.000940  206.605  2019-05-10  198.463   
2019-05-10 09:59:00  205.417       -0.001342  202.860  2019-05-10  201.997   
...                      ...             ...      ...         ...      ...   
2019-05-10 15:30:00  205.875        0.000948  201.870  2019-05-10  201.850   
2019-05-10 15:31:00  206.845        0.000487  202.800  2019-05-10  201.490   
2019-05-10 15:32:00  201.249        0.000730  200.900  2019-05-10  201.510   
2019-05-10 15:33:00  201.318        0.000510  204.570  2019-05-10  205.300   
2019-05-10 15:34:00  198.612       -0.000858  201.090  2019-05-10  202.900   
2019-05-10 15:35:00  200.923       -0.002972  206.880  2019-05-10  205.740   
2019-05-10 15:36:00  199.323       -0.003365  198.030  2019-05-10  199.590   
2019-05-10 15:37:00  198.273       -0.003830  203.800  2019-05-10  200.020   
2019-05-10 15:38:00  198.237       -0.003631  206.840  2019-05-10  200.180   
2019-05-10 15:39:00  198.778       -0.004597  198.220  2019-05-10  204.010   
2019-05-10 15:40:00  198.117       -0.005868  206.220  2019-05-10  206.150   
2019-05-10 15:41:00  205.246       -0.006152  202.200  2019-05-10  196.900   
2019-05-10 15:42:00  202.419       -0.005575  204.950  2019-05-10  202.240   
2019-05-10 15:43:00  201.636       -0.006447  200.590  2019-05-10  201.400   
2019-05-10 15:44:00  202.766       -0.005658  197.450  2019-05-10  198.160   
2019-05-10 15:45:00  206.192       -0.004745  199.740  2019-05-10  205.960   
2019-05-10 15:46:00  198.292       -0.004163  199.450  2019-05-10  201.190   
2019-05-10 15:47:00  201.706       -0.003875  205.730  2019-05-10  201.280   
2019-05-10 15:48:00  200.818       -0.005662  201.270  2019-05-10  205.030   
2019-05-10 15:49:00  198.298       -0.006690  203.760  2019-05-10  198.880   
2019-05-10 15:50:00  205.852       -0.005963  205.070  2019-05-10  198.100   
2019-05-10 15:51:00  205.592       -0.006518  204.200  2019-05-10  201.970   
2019-05-10 15:52:00  198.718       -0.006521  198.200  2019-05-10  200.630   
2019-05-10 15:53:00  205.725       -0.006009  203.690  2019-05-10  199.310   
2019-05-10 15:54:00  198.699       -0.006285  199.900  2019-05-10  199.870   
2019-05-10 15:55:00  197.100       -0.005309  205.280  2019-05-10  198.266   
2019-05-10 15:56:00  199.258       -0.005066  206.480  2019-05-10  199.000   
2019-05-10 15:57:00  199.621       -0.005616  202.790  2019-05-10  198.670   
2019-05-10 15:58:00  206.580       -0.005596  201.000  2019-05-10  199.300   
2019-05-10 15:59:00  202.175       -0.003757  199.000  2019-05-10  200.880   

                        label      low  marketAverage  marketChangeOverTime  \
2019-05-10 09:30:00  09:30 AM  200.190        204.549              0.000000   
2019-05-10 09:31:00  09:31 AM  200.860        202.510              0.002975   
2019-05-10 09:32:00  09:32 AM  207.200        202.058              0.002232   
2019-05-10 09:33:00  09:33 AM  200.050        203.457              0.004449   
2019-05-10 09:34:00  09:34 AM  205.750        203.227              0.003704   
2019-05-10 09:35:00  09:35 AM  198.600        205.187              0.000611   
2019-05-10 09:36:00  09:36 AM  205.500        203.998              0.000695   
2019-05-10 09:37:00  09:37 AM  201.380        199.905              0.001418   
2019-05-10 09:38:00  09:38 AM  202.050        198.444              0.003402   
2019-05-10 09:39:00  09:39 AM  207.689        200.794              0.004296   
2019-05-10 09:40:00  09:40 AM  205.750        200.653              0.005577   
2019-05-10 09:41:00  09:41 AM  207.660        202.753              0.005716   
2019-05-10 09:42:00  09:42 AM  203.610        202.552              0.005627   
2019-05-10 09:43:00  09:43 AM  207.280        206.543              0.005055   
2019-05-10 09:44:00  09:44 AM  202.160        206.391              0.003333   
2019-05-10 09:45:00  09:45 AM  199.600        206.564              0.003806   
2019-05-10 09:46:00  09:46 AM  203.940        200.602              0.004576   
2019-05-10 09:47:00  09:47 AM  202.320        205.810              0.004309   
2019-05-10 09:48:00  09:48 AM  207.170        203.902              0.004429   
2019-05-10 09:49:00  09:49 AM  198.820        208.033              0.003446   
2019-05-10 09:50:00  09:50 AM  205.000        207.131              0.001811   
2019-05-10 09:51:00  09:51 AM  203.570        201.860              0.000203   
2019-05-10 09:52:00  09:52 AM  204.813        206.942              0.000026   
2019-05-10 09:53:00  09:53 AM  201.840        198.317             -0.000260   
2019-05-10 09:54:00  09:54 AM  204.890        200.799             -0.001000   
2019-05-10 09:55:00  09:55 AM  202.542        199.661             -0.000786   
2019-05-10 09:56:00  09:56 AM  198.200        200.120             -0.001202   
2019-05-10 09:57:00  09:57 AM  202.580        204.097             -0.000342   
2019-05-10 09:58:00  09:58 AM  199.200        199.740             -0.000015   
2019-05-10 09:59:00  09:59 AM  206.880        204.549             -0.000147   
...                       ...      ...            ...                   ...   
2019-05-10 15:30:00   3:30 PM  203.270        207.089              0.002119   
2019-05-10 15:31:00   3:31 PM  205.600        207.032              0.001634   
2019-05-10 15:32:00   3:32 PM  205.000        206.342              0.001554   
2019-05-10 15:33:00   3:33 PM  203.340        205.506              0.001627   
2019-05-10 15:34:00   3:34 PM  203.900        200.768              0.000079   
2019-05-10 15:35:00   3:35 PM  197.460        199.341             -0.001963   
2019-05-10 15:36:00   3:36 PM  202.480        198.523             -0.002294   
2019-05-10 15:37:00   3:37 PM  198.200        203.595             -0.002805   
2019-05-10 15:38:00   3:38 PM  197.940        203.952             -0.002502   
2019-05-10 15:39:00   3:39 PM  201.460        206.760             -0.003351   
2019-05-10 15:40:00   3:40 PM  204.550        197.660             -0.004637   
2019-05-10 15:41:00   3:41 PM  198.310        204.066             -0.005030   
2019-05-10 15:42:00   3:42 PM  200.160        199.242             -0.004485   
2019-05-10 15:43:00   3:43 PM  196.860        206.076             -0.005445   
2019-05-10 15:44:00   3:44 PM  201.580        205.971             -0.004040   
2019-05-10 15:45:00   3:45 PM  205.330        201.388             -0.003676   
2019-05-10 15:46:00   3:46 PM  205.720        205.750             -0.003222   
2019-05-10 15:47:00   3:47 PM  200.360        201.950             -0.002529   
2019-05-10 15:48:00   3:48 PM  200.530        199.977             -0.004337   
2019-05-10 15:49:00   3:49 PM  202.700        205.072             -0.005508   
2019-05-10 15:50:00   3:50 PM  204.430        205.588             -0.004902   
2019-05-10 15:51:00   3:51 PM  205.760        204.695             -0.005560   
2019-05-10 15:52:00   3:52 PM  201.550        199.983             -0.005434   
2019-05-10 15:53:00   3:53 PM  205.230        200.548             -0.004944   
2019-05-10 15:54:00   3:54 PM  198.270        206.049             -0.005032   
2019-05-10 15:55:00   3:55 PM  204.480        203.976             -0.004300   
2019-05-10 15:56:00   3:56 PM  201.910        206.100             -0.003932   
2019-05-10 15:57:00   3:57 PM  198.030        199.477             -0.004448   
2019-05-10 15:58:00   3:58 PM  198.040        202.463             -0.004335   
2019-05-10 15:59:00   3:59 PM  200.970        199.978             -0.002639   

                     marketClose  marketHigh  marketLow  marketNotional  \
2019-05-10 09:30:00      201.412     199.170    200.120    1.318723e+08   
2019-05-10 09:31:00      198.000     202.360    207.200    4.039109e+07   
2019-05-10 09:32:00      200.910     203.761    207.450    3.878891e+07   
2019-05-10 09:33:00      201.940     200.800    200.180    3.855812e+07   
2019-05-10 09:34:00      203.534     199.130    207.070    2.713843e+07   
2019-05-10 09:35:00      200.058     206.700    204.670    4.687891e+07   
2019-05-10 09:36:00      200.623     206.950    204.095    2.177548e+07   
2019-05-10 09:37:00      200.069     200.080    205.590    2.623677e+07   
2019-05-10 09:38:00      202.190     199.508    199.939    3.072288e+07   
2019-05-10 09:39:00      207.290     202.830    200.050    2.155480e+07   
2019-05-10 09:40:00      203.080     202.150    200.000    2.090204e+07   
2019-05-10 09:41:00      202.470     199.870    202.400    1.927954e+07   
2019-05-10 09:42:00      208.100     206.080    204.450    1.901843e+07   
2019-05-10 09:43:00      203.800     202.200    200.826    2.264884e+07   
2019-05-10 09:44:00      206.510     199.570    204.170    1.871288e+07   
2019-05-10 09:45:00      206.210     207.800    200.460    1.866965e+07   
2019-05-10 09:46:00      201.370     205.250    204.800    1.589890e+07   
2019-05-10 09:47:00      202.620     207.220    202.581    1.288411e+07   
2019-05-10 09:48:00      201.710     202.337    200.270    1.225313e+07   
2019-05-10 09:49:00      200.680     201.762    205.040    1.597337e+07   
2019-05-10 09:50:00      205.480     207.800    206.370    2.769234e+07   
2019-05-10 09:51:00      206.920     203.600    202.220    2.174955e+07   
2019-05-10 09:52:00      198.650     204.800    201.190    1.239951e+07   
2019-05-10 09:53:00      203.900     207.630    204.200    2.871896e+07   
2019-05-10 09:54:00      200.330     206.250    204.730    1.771830e+07   
2019-05-10 09:55:00      204.250     201.670    204.430    2.234796e+07   
2019-05-10 09:56:00      197.800     197.970    207.030    2.366918e+07   
2019-05-10 09:57:00      206.890     199.640    204.660    2.561592e+07   
2019-05-10 09:58:00      200.907     201.210    203.850    2.323213e+07   
2019-05-10 09:59:00      207.200     204.880    200.950    1.690132e+07   
...                          ...         ...        ...             ...   
2019-05-10 15:30:00      204.000     198.610    199.840    3.252642e+07   
2019-05-10 15:31:00      204.060     205.360    200.460    1.964017e+07   
2019-05-10 15:32:00      205.520     205.280    206.832    1.714839e+07   
2019-05-10 15:33:00      206.460     201.820    204.450    1.721577e+07   
2019-05-10 15:34:00      199.300     200.950    206.670    2.742127e+07   
2019-05-10 15:35:00      199.380     199.470    203.320    2.390232e+07   
2019-05-10 15:36:00      206.060     199.500    201.160    1.979215e+07   
2019-05-10 15:37:00      198.123     201.890    204.930    1.861976e+07   
2019-05-10 15:38:00      199.350     199.600    199.510    1.009904e+07   
2019-05-10 15:39:00      203.460     206.760    202.960    1.888501e+07   
2019-05-10 15:40:00      204.093     206.540    204.870    2.114221e+07   
2019-05-10 15:41:00      200.600     203.170    203.360    2.547636e+07   
2019-05-10 15:42:00      200.380     203.370    201.160    1.335028e+07   
2019-05-10 15:43:00      204.455     198.800    201.240    1.162194e+07   
2019-05-10 15:44:00      206.710     201.330    205.793    1.609622e+07   
2019-05-10 15:45:00      204.169     197.600    199.580    1.696449e+07   
2019-05-10 15:46:00      202.180     203.910    206.757    1.644303e+07   
2019-05-10 15:47:00      206.510     199.110    203.600    1.685901e+07   
2019-05-10 15:48:00      202.470     199.580    205.750    2.238961e+07   
2019-05-10 15:49:00      203.070     202.740    199.360    2.243540e+07   
2019-05-10 15:50:00      202.268     203.350    204.550    1.813275e+07   
2019-05-10 15:51:00      196.824     204.430    205.022    1.574421e+07   
2019-05-10 15:52:00      198.410     205.708    201.650    1.597782e+07   
2019-05-10 15:53:00      206.133     201.770    203.430    2.196822e+07   
2019-05-10 15:54:00      201.200     202.540    199.857    3.539445e+07   
2019-05-10 15:55:00      197.710     201.540    200.720    2.953320e+07   
2019-05-10 15:56:00      205.450     197.220    205.990    2.454914e+07   
2019-05-10 15:57:00      200.740     200.150    200.250    2.048456e+07   
2019-05-10 15:58:00      197.950     201.150    204.240    2.548295e+07   
2019-05-10 15:59:00      206.800     201.100    198.340    7.685399e+07   

                     marketNumberOfTrades  marketOpen  marketVolume  \
2019-05-10 09:30:00                  1568     203.701        668040   
2019-05-10 09:31:00                  1133     205.200        206543   
2019-05-10 09:32:00                  1043     205.478        191466   
2019-05-10 09:33:00                  1051     206.246        191261   
2019-05-10 09:34:00                   923     200.040        137697   
2019-05-10 09:35:00                  1286     207.800        229312   
2019-05-10 09:36:00                   555     202.601        111169   
2019-05-10 09:37:00                   691     198.910        134472   
2019-05-10 09:38:00                   762     207.080        156171   
2019-05-10 09:39:00                   727     204.690        104948   
2019-05-10 09:40:00                   649     206.670        106709   
2019-05-10 09:41:00                   516     206.610         97017   
2019-05-10 09:42:00                   489     202.050         97658   
2019-05-10 09:43:00                   643     203.200        117375   
2019-05-10 09:44:00                   628     204.080         98465   
2019-05-10 09:45:00                   598     199.540         96511   
2019-05-10 09:46:00                   470     201.510         81318   
2019-05-10 09:47:00                   408     207.900         63802   
2019-05-10 09:48:00                   412     206.190         61512   
2019-05-10 09:49:00                   461     207.050         80047   
2019-05-10 09:50:00                   777     206.190        139373   
2019-05-10 09:51:00                   637     202.182        108794   
2019-05-10 09:52:00                   391     205.509         62672   
2019-05-10 09:53:00                   679     201.020        141843   
2019-05-10 09:54:00                   523     205.800         92777   
2019-05-10 09:55:00                   648     202.240        115700   
2019-05-10 09:56:00                   663     199.300        121544   
2019-05-10 09:57:00                   780     197.600        131407   
2019-05-10 09:58:00                   588     205.050        115054   
2019-05-10 09:59:00                   507     202.810         87896   
...                                   ...         ...           ...   
2019-05-10 15:30:00                   959     204.320        164390   
2019-05-10 15:31:00                   629     200.690         99740   
2019-05-10 15:32:00                   512     199.873         84979   
2019-05-10 15:33:00                   529     207.960         85900   
2019-05-10 15:34:00                   758     204.630        136066   
2019-05-10 15:35:00                   620     204.820        121154   
2019-05-10 15:36:00                   590     202.740        101918   
2019-05-10 15:37:00                   596     202.450         94058   
2019-05-10 15:38:00                   351     201.550         51627   
2019-05-10 15:39:00                   462     199.820         92760   
2019-05-10 15:40:00                   696     204.620        107252   
2019-05-10 15:41:00                   493     199.000        129661   
2019-05-10 15:42:00                   399     205.844         65474   
2019-05-10 15:43:00                   378     202.390         61092   
2019-05-10 15:44:00                   453     197.950         81140   
2019-05-10 15:45:00                   412     200.420         88334   
2019-05-10 15:46:00                   348     206.369         80344   
2019-05-10 15:47:00                   453     204.319         86617   
2019-05-10 15:48:00                   742     206.080        114646   
2019-05-10 15:49:00                   680     200.050        113916   
2019-05-10 15:50:00                   534     200.280         95333   
2019-05-10 15:51:00                   483     203.900         77548   
2019-05-10 15:52:00                   554     200.330         84325   
2019-05-10 15:53:00                   691     200.540        107196   
2019-05-10 15:54:00                  1385     203.060        186366   
2019-05-10 15:55:00                   995     206.100        153961   
2019-05-10 15:56:00                   905     197.687        124558   
2019-05-10 15:57:00                   698     204.220        102719   
2019-05-10 15:58:00                   809     200.990        125054   
2019-05-10 15:59:00                  2371     204.843        391004   

                        notional  numberOfTrades     open  volume  
2019-05-10 09:30:00  5104524.696             144  202.302   26412  
2019-05-10 09:31:00  2013281.906              72  205.605   10176  
2019-05-10 09:32:00  2250170.614              61  200.280   11861  
2019-05-10 09:33:00  3517190.530             124  207.789   17639  
2019-05-10 09:34:00  2533609.090              83  202.080   12669  
2019-05-10 09:35:00  3007259.388             109  200.890   15148  
2019-05-10 09:36:00  1022947.380              34  207.320    5112  
2019-05-10 09:37:00  1242106.660              51  198.200    6056  
2019-05-10 09:38:00  1023009.020              37  201.620    5058  
2019-05-10 09:39:00   622764.828              40  200.680    3209  
2019-05-10 09:40:00   474805.581              30  206.180    2376  
2019-05-10 09:41:00   384651.970              22  206.530    1945  
2019-05-10 09:42:00   763777.260              41  200.610    3872  
2019-05-10 09:43:00   434229.222              24  206.000    2178  
2019-05-10 09:44:00   583137.030              39  198.480    2992  
2019-05-10 09:45:00   516049.450              24  199.679    2681  
2019-05-10 09:46:00   718461.790              38  206.776    3738  
2019-05-10 09:47:00   328193.350              21  199.230    1656  
2019-05-10 09:48:00   403332.198              24  202.120    2012  
2019-05-10 09:49:00   407767.160              24  206.640    2019  
2019-05-10 09:50:00  1394017.800              55  200.030    7102  
2019-05-10 09:51:00  1628546.000              57  204.560    8279  
2019-05-10 09:52:00   753665.040              33  198.550    3754  
2019-05-10 09:53:00  3055387.996              74  205.490   15470  
2019-05-10 09:54:00  2438514.760              55  204.410   12283  
2019-05-10 09:55:00  3093468.771              56  202.170   16007  
2019-05-10 09:56:00   643501.380              37  200.780    3213  
2019-05-10 09:57:00   551769.710              28  197.840    2736  
2019-05-10 09:58:00  1281990.856              41  206.250    6282  
2019-05-10 09:59:00   774133.610              36  200.920    3833  
...                          ...             ...      ...     ...  
2019-05-10 15:30:00   714094.080              47  205.220    3611  
2019-05-10 15:31:00   575148.250              32  205.600    2958  
2019-05-10 15:32:00   886393.470              49  199.330    4487  
2019-05-10 15:33:00   755012.470              45  200.200    3833  
2019-05-10 15:34:00  1037510.510              43  204.760    5236  
2019-05-10 15:35:00   597320.910              36  202.230    3021  
2019-05-10 15:36:00   598519.000              35  197.400    3064  
2019-05-10 15:37:00   789488.990              46  197.590    3936  
2019-05-10 15:38:00   858782.900              55  198.660    4320  
2019-05-10 15:39:00   499634.420              30  199.480    2526  
2019-05-10 15:40:00   983311.210              56  204.779    5144  
2019-05-10 15:41:00   531707.470              32  205.020    2784  
2019-05-10 15:42:00   655926.900              35  198.690    3326  
2019-05-10 15:43:00   647463.550              38  205.410    3276  
2019-05-10 15:44:00   610853.750              37  205.370    3194  
2019-05-10 15:45:00   505248.310              34  205.650    2643  
2019-05-10 15:46:00   422632.360              24  200.100    2119  
2019-05-10 15:47:00   714067.160              47  201.350    3743  
2019-05-10 15:48:00  1115881.510              51  206.040    5821  
2019-05-10 15:49:00   871335.830              46  200.520    4367  
2019-05-10 15:50:00   429144.120              28  205.740    2209  
2019-05-10 15:51:00   480801.189              29  199.430    2447  
2019-05-10 15:52:00   547808.710              29  201.130    2735  
2019-05-10 15:53:00   640935.467              41  202.710    3357  
2019-05-10 15:54:00  1346637.290              82  205.290    6950  
2019-05-10 15:55:00   586598.930              37  202.510    3038  
2019-05-10 15:56:00  1589261.618              85  198.230    7816  
2019-05-10 15:57:00   955727.700              47  201.350    4709  
2019-05-10 15:58:00  1313594.800              70  199.276    6711  
2019-05-10 15:59:00  3734232.550             176  197.500   18603  

[390 rows x 20 columns]

or for a pandas.DataFrame indexed by each minute:

In [16]: get_historical_intraday("AAPL", output_format='pandas').head()
Out[16]: 
                     average  changeOverTime   close        date     high  \
2019-06-19 09:30:00  205.786        0.000000  202.02  2019-06-19  199.882   
2019-06-19 09:31:00  207.078       -0.000363  204.27  2019-06-19  207.320   
2019-06-19 09:32:00  202.870       -0.001597  199.33  2019-06-19  204.220   
2019-06-19 09:33:00  207.700       -0.001036  201.58  2019-06-19  201.560   
2019-06-19 09:34:00  203.162       -0.002645  202.55  2019-06-19  200.060   

                        label     low  marketAverage  marketChangeOverTime  \
2019-06-19 09:30:00  09:30 AM  200.94        204.961              0.000000   
2019-06-19 09:31:00  09:31 AM  208.79        203.802             -0.000810   
2019-06-19 09:32:00  09:32 AM  206.41        207.774             -0.002212   
2019-06-19 09:33:00  09:33 AM  201.08        202.070             -0.001860   
2019-06-19 09:34:00  09:34 AM  200.94        204.383             -0.002941   

                     marketClose  marketHigh  marketLow  marketNotional  \
2019-06-19 09:30:00      201.300     199.880     199.29    1.069649e+08   
2019-06-19 09:31:00      202.699     209.370     205.87    2.036946e+07   
2019-06-19 09:32:00      204.841     200.125     200.32    2.060970e+07   
2019-06-19 09:33:00      203.382     206.600     201.77    2.162062e+07   
2019-06-19 09:34:00      201.686     207.749     200.03    1.549091e+07   

                     marketNumberOfTrades  marketOpen  marketVolume  \
2019-06-19 09:30:00                  1363     207.890        551399   
2019-06-19 09:31:00                   465     209.374        106604   
2019-06-19 09:32:00                   551     205.304        103564   
2019-06-19 09:33:00                   475     205.930        106890   
2019-06-19 09:34:00                   380     201.400         78291   

                        notional  numberOfTrades     open  volume  
2019-06-19 09:30:00  1507602.390              62  208.933    7777  
2019-06-19 09:31:00   145198.000               6  204.060     723  
2019-06-19 09:32:00   287256.003              18  204.807    1491  
2019-06-19 09:33:00   334950.940              21  201.070    1674  
2019-06-19 09:34:00   158568.500               7  201.163     811  

Endpoints

The Stock object can obtain each of these endpoints. Requests for single symbols will return the exact results from that endpoint as shown in the IEX API documentation (see below). Requests for multiple symbols will return a symbol-indexed dictionary of the endpoint requested.

Endpoint Method examples get_quote(), get_volume_by_venue()

In [17]: from iexfinance.stocks import Stock

In [18]: aapl = Stock("AAPL")

In [19]: aapl.get_previous_day_prices()
Out[19]: 
                      AAPL
change                   0
changeOverTime           0
changePercent            0
close               199.97
date            2019-06-18
high                201.78
low                  202.9
open                203.64
symbol                AAPL
uClose              202.17
uHigh               202.54
uLow                 202.1
uOpen               203.28
uVolume           27167925
volume            27770023

For a detailed list of the endpoint methods, see here.

Fields

To obtain individual fields from an endpoint, select Field Methods are also provided.

Examples get_open(), get_name()

Single Symbol

In [20]: aapl = Stock("AAPL")

In [21]: aapl.get_open()
Out[21]: 
        AAPL
open  203.91

In [22]: aapl.get_price()
Out[22]: 
        AAPL
AAPL  202.98

Multiple Symbols

In [23]: b = Stock(["AAPL", "TSLA"])

In [24]: b.get_open()
Out[24]: 
        AAPL    TSLA
open  205.82  227.49

For a detailed list of these functions, see here.

Endpoint-Specific Parameters

Top-level parameters may be passed to the Stock function, including output_format and request parameters (such as retry_count, and pause) - the latter of which will be used should any queries made by the object fail. These parameters are passed keyword arguments, and are entirely optional.

Certain endpoints (such as quote and chart), however, allow customizable parameters. To specify one of these parameters, merely pass it to an endpoint method as a keyword argument.

In [25]: aapl = Stock("AAPL", output_format='pandas')

In [26]: aapl.get_quote(displayPercent=True).loc["ytdChange"]
Out[26]: 
AAPL    25.9646
Name: ytdChange, dtype: object

Note

The output_format from the initial call to the Stock function will be used (if the output format has not been change through change_output_format since) and cannot be changed through calls to endpoint methods. See Stocks for more information.

Reference Data

See also

Reference Data

Investor’s Exchange Data

API System Metadata

Caching

iexfinance supports the caching of HTTP requests to IEX using the requests-cache package.

See also

Caching Queries