{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import pynasdaq as nas;\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Stock" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Current price of a stock" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "symbol AMZN\n", "company Amazon.com, Inc. Common Stock\n", "lastSalePrice 1806.33\n", "dtype: object" ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "nas.currentPrice(\"AMZN\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Stock summary quote" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "symbol IBM\n", "company International Business Machines Corporation Co...\n", "lastSalePrice $142.45\n", "volume 367,370\n", "MarketCap 126,192,916,684\n", "dtype: object" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "nas.stockSummaryQuote(\"IBM\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Historical stock prices" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
highlowopenclosevolumedateTimevalue
0134.59132.9539133.04133.763,011,99308/16/2019133.76
1136.33134.88134.88135.043,165,43608/19/2019135.04
2135.28132.81135.241333,018,93408/20/2019133
3135.94133.8134.96134.252,806,77408/21/2019134.25
4135.68133.81134.69134.322,695,00908/22/2019134.32
5134.26128.83133.63129.574,818,75908/23/2019129.57
6131.3129.16131.05129.992,836,83708/26/2019129.99
7131.6961130.31131.2131.174,728,39208/27/2019131.17
8132.89130.04130.44132.762,720,36208/28/2019132.76
9135.69134.04134.18134.882,972,84208/29/2019134.88
10136.07134.3627135.58135.532,960,59408/30/2019135.53
11134.9013133.3301134.85134.12,828,24209/03/2019134.1
12136.43135.15135.71136.322,262,08109/04/2019136.32
13141.695138.05138.3140.975,012,91409/05/2019140.97
14141.525140.46141.52140.572,577,20009/06/2019140.57
15143.02140.46140.59142.64,226,94409/09/2019142.6
16145.46142.96143145.054,979,74109/10/2019145.05
17145.12142.7051144.85143.63,869,73109/11/2019143.6
18144.04141.88144.03143.622,505,43209/12/2019143.62
19144.65143.26144.32143.672,206,61209/13/2019143.67
\n", "
" ], "text/plain": [ " high low open close volume dateTime value\n", "0 134.59 132.9539 133.04 133.76 3,011,993 08/16/2019 133.76\n", "1 136.33 134.88 134.88 135.04 3,165,436 08/19/2019 135.04\n", "2 135.28 132.81 135.24 133 3,018,934 08/20/2019 133\n", "3 135.94 133.8 134.96 134.25 2,806,774 08/21/2019 134.25\n", "4 135.68 133.81 134.69 134.32 2,695,009 08/22/2019 134.32\n", "5 134.26 128.83 133.63 129.57 4,818,759 08/23/2019 129.57\n", "6 131.3 129.16 131.05 129.99 2,836,837 08/26/2019 129.99\n", "7 131.6961 130.31 131.2 131.17 4,728,392 08/27/2019 131.17\n", "8 132.89 130.04 130.44 132.76 2,720,362 08/28/2019 132.76\n", "9 135.69 134.04 134.18 134.88 2,972,842 08/29/2019 134.88\n", "10 136.07 134.3627 135.58 135.53 2,960,594 08/30/2019 135.53\n", "11 134.9013 133.3301 134.85 134.1 2,828,242 09/03/2019 134.1\n", "12 136.43 135.15 135.71 136.32 2,262,081 09/04/2019 136.32\n", "13 141.695 138.05 138.3 140.97 5,012,914 09/05/2019 140.97\n", "14 141.525 140.46 141.52 140.57 2,577,200 09/06/2019 140.57\n", "15 143.02 140.46 140.59 142.6 4,226,944 09/09/2019 142.6\n", "16 145.46 142.96 143 145.05 4,979,741 09/10/2019 145.05\n", "17 145.12 142.7051 144.85 143.6 3,869,731 09/11/2019 143.6\n", "18 144.04 141.88 144.03 143.62 2,505,432 09/12/2019 143.62\n", "19 144.65 143.26 144.32 143.67 2,206,612 09/13/2019 143.67" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "nas.historicalStockQuote('ibm',fromdate='2019-08-16',todate='2019-09-16')\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Batch quotes" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
companyNamelastSalePricenetChangepercentageChangedeltaIndicatorlastTradeTimestampvolume
symbol
AAPLApple Inc. Common Stock$219.77+1.020.47%upDATA AS OF Sep 16, 2019 3:20 PM ET7,322,583
GOOGAlphabet Inc. Class C Capital Stock$1,231.29-8.270.67%downDATA AS OF Sep 16, 2019 3:20 PM ET270,146
FBFacebook, Inc. Class A Common Stock$186.13-1.0650.57%downDATA AS OF Sep 16, 2019 3:20 PM ET2,593,937
IBMInternational Business Machines Corporation Co...$142.45-1.220.85%downDATA AS OF Sep 16, 2019 3:20 PM ET367,370
\n", "
" ], "text/plain": [ " companyName lastSalePrice \\\n", "symbol \n", "AAPL Apple Inc. Common Stock $219.77 \n", "GOOG Alphabet Inc. Class C Capital Stock $1,231.29 \n", "FB Facebook, Inc. Class A Common Stock $186.13 \n", "IBM International Business Machines Corporation Co... $142.45 \n", "\n", " netChange percentageChange deltaIndicator \\\n", "symbol \n", "AAPL +1.02 0.47% up \n", "GOOG -8.27 0.67% down \n", "FB -1.065 0.57% down \n", "IBM -1.22 0.85% down \n", "\n", " lastTradeTimestamp volume \n", "symbol \n", "AAPL DATA AS OF Sep 16, 2019 3:20 PM ET 7,322,583 \n", "GOOG DATA AS OF Sep 16, 2019 3:20 PM ET 270,146 \n", "FB DATA AS OF Sep 16, 2019 3:20 PM ET 2,593,937 \n", "IBM DATA AS OF Sep 16, 2019 3:20 PM ET 367,370 " ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "nas.batchQuotes(['AAPL','GOOG',\"FB\",\"IBM\"])" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Dividend" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Dividend calendar for a given date " ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
companyNamesymboldividend_Ex_Datepayment_Daterecord_Datedividend_Rateindicated_Annual_Dividendannouncement_Date
0Altra Industrial Motion Corp.AIMC09/17/201910/02/201909/18/20190.1700.68007/22/2019
1Brookfield Real Assets Income Fund Inc.RA09/17/201909/26/201909/18/20190.1992.58707/05/2019
2Briggs & Stratton CorporationBGG09/17/201910/02/201909/18/20190.0500.20001/01/1900
3Brookfield Global Listed Infrastructure Income...INF09/17/201909/26/201909/18/20190.0821.06207/05/2019
4Cohen & Steers Closed-End Opportunity Fund, Inc.FOF09/17/201909/30/201909/18/20190.0871.13106/11/2019
\n", "
" ], "text/plain": [ " companyName symbol dividend_Ex_Date \\\n", "0 Altra Industrial Motion Corp. AIMC 09/17/2019 \n", "1 Brookfield Real Assets Income Fund Inc. RA 09/17/2019 \n", "2 Briggs & Stratton Corporation BGG 09/17/2019 \n", "3 Brookfield Global Listed Infrastructure Income... INF 09/17/2019 \n", "4 Cohen & Steers Closed-End Opportunity Fund, Inc. FOF 09/17/2019 \n", "\n", " payment_Date record_Date dividend_Rate indicated_Annual_Dividend \\\n", "0 10/02/2019 09/18/2019 0.170 0.680 \n", "1 09/26/2019 09/18/2019 0.199 2.587 \n", "2 10/02/2019 09/18/2019 0.050 0.200 \n", "3 09/26/2019 09/18/2019 0.082 1.062 \n", "4 09/30/2019 09/18/2019 0.087 1.131 \n", "\n", " announcement_Date \n", "0 07/22/2019 \n", "1 07/05/2019 \n", "2 01/01/1900 \n", "3 07/05/2019 \n", "4 06/11/2019 " ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "nas.dividendCalendar(date=\"2019-09-17\").head()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Dividend history for a company given the symbol" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
exOrEffDatetypeamountdeclarationDaterecordDatepaymentDate
008/09/2019Cash$0.7707/30/201908/12/201908/15/2019
105/10/2019Cash$0.7704/30/201905/13/201905/16/2019
202/08/2019Cash$0.7301/29/201902/11/201902/14/2019
311/08/2018Cash$0.7311/01/201811/12/201811/15/2018
408/10/2018Cash$0.7307/31/201808/13/201808/16/2018
\n", "
" ], "text/plain": [ " exOrEffDate type amount declarationDate recordDate paymentDate\n", "0 08/09/2019 Cash $0.77 07/30/2019 08/12/2019 08/15/2019\n", "1 05/10/2019 Cash $0.77 04/30/2019 05/13/2019 05/16/2019\n", "2 02/08/2019 Cash $0.73 01/29/2019 02/11/2019 02/14/2019\n", "3 11/08/2018 Cash $0.73 11/01/2018 11/12/2018 11/15/2018\n", "4 08/10/2018 Cash $0.73 07/31/2018 08/13/2018 08/16/2018" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "nas.dividendHistory(\"AAPL\").head()" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.7.1" } }, "nbformat": 4, "nbformat_minor": 2 }