From 05a76e5a9af5b6a9123ac574c66d623027d51c73 Mon Sep 17 00:00:00 2001 From: Zach Coriarty Date: Mon, 10 Jan 2022 15:51:17 -0500 Subject: [PATCH] alphavantage links added --- JupyterNotebooks/Alphavantage.ipynb | 438 +++++----------------------- Source/Alphavantage.rst | 66 ++++- 2 files changed, 119 insertions(+), 385 deletions(-) diff --git a/JupyterNotebooks/Alphavantage.ipynb b/JupyterNotebooks/Alphavantage.ipynb index 7abd8aa..af3d799 100644 --- a/JupyterNotebooks/Alphavantage.ipynb +++ b/JupyterNotebooks/Alphavantage.ipynb @@ -73,6 +73,13 @@ "key = \"AAUUBAYEDCI353AC\"" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Historic Stock Price and Volume" + ] + }, { "cell_type": "code", "execution_count": 27, @@ -244,7 +251,18 @@ } ], "source": [ - "data" + "data = {\n", + " \"function\": \"DIGITAL_CURRENCY_DAILY\", # WEEKLY, MONTHLY possible\n", + " \"symbol\": \"ETH\",\n", + " \"market\": 'CNY',\n", + " \"apikey\": key\n", + " }\n", + "r = requests.get(url, params=data)\n", + "data = r.json()\n", + "crypto_df = pd.DataFrame(data['Time Series (Digital Currency Daily)']).T.reset_index()\n", + "crypto_df = crypto_df.rename(columns={\"index\": \"Date\"})\n", + "crypto_df['Date'] = pd.to_datetime(crypto_df['Date'])\n", + "crypto_df " ] }, { @@ -367,7 +385,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "### Live Updates" + "### Realtime Data" ] }, { @@ -1236,6 +1254,24 @@ "data = r.json()\n" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "data = {\n", + " \"function\": \"CURRENCY_EXCHANGE_RATE\", # WEEKLY, MONTHLY possible\n", + " \"from_currency\": \"ETH\",\n", + " \"to_currency\": 'USD',\n", + " \"apikey\": key\n", + " }\n", + "r = requests.get(url, params=data)\n", + "data = r.json()\n", + "crypto_df = pd.DataFrame(data['Realtime Currency Exchange Rate'], index=[0]).T\n", + "crypto_df" + ] + }, { "cell_type": "markdown", "metadata": {}, @@ -2314,377 +2350,21 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "### Historic Data" + "### Treasury Yield" ] }, { "cell_type": "code", - "execution_count": 60, - "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", - "
Date1a. open (CNY)1b. open (USD)2a. high (CNY)2b. high (USD)3a. low (CNY)3b. low (USD)4a. close (CNY)4b. close (USD)5. volume6. market cap (USD)
02021-12-2725883.315472004063.5700000025990.961712004080.4700000025780.127952004047.3700000025954.400208004074.7300000014823.9076000014823.90760000
12021-12-2626079.435456004094.3600000026147.208000004105.0000000025478.400000004000.0000000025883.251776004063.56000000189309.25500000189309.25500000
22021-12-2525773.630960004046.3500000026356.831536004137.9100000025597.001952004018.6200000026082.429168004094.83000000208126.88050000208126.88050000
32021-12-2426188.037136004111.4100000026337.276864004134.8400000025587.766032004017.1700000025773.694656004046.36000000230833.16610000230833.16610000
42021-12-2325347.886896003979.5100000026433.840000004150.0000000024798.317808003893.2300000026188.037136004111.41000000380207.81660000380207.81660000
....................................
9952019-04-071054.55097600165.560000001117.41892800175.430000001044.99657600164.060000001109.64801600174.21000000465507.52497000465507.52497000
9962019-04-061049.96486400164.840000001100.47579200172.770000001014.04032000159.200000001054.16880000165.50000000528168.33297000528168.33297000
9972019-04-051002.12916800157.330000001069.00996800167.83000000993.27542400155.940000001049.51899200164.77000000516070.34553000516070.34553000
9982019-04-041018.88121600159.960000001044.61440000164.00000000973.27488000152.800000001002.32025600157.36000000686080.95248000686080.95248000
9992019-04-031039.90089600163.260000001132.57857600177.81000000950.53540800149.230000001018.88121600159.960000001345344.538450001345344.53845000
\n", - "

1000 rows × 11 columns

\n", - "
" - ], - "text/plain": [ - " Date 1a. open (CNY) 1b. open (USD) 2a. high (CNY) 2b. high (USD) \\\n", - "0 2021-12-27 25883.31547200 4063.57000000 25990.96171200 4080.47000000 \n", - "1 2021-12-26 26079.43545600 4094.36000000 26147.20800000 4105.00000000 \n", - "2 2021-12-25 25773.63096000 4046.35000000 26356.83153600 4137.91000000 \n", - "3 2021-12-24 26188.03713600 4111.41000000 26337.27686400 4134.84000000 \n", - "4 2021-12-23 25347.88689600 3979.51000000 26433.84000000 4150.00000000 \n", - ".. ... ... ... ... ... \n", - "995 2019-04-07 1054.55097600 165.56000000 1117.41892800 175.43000000 \n", - "996 2019-04-06 1049.96486400 164.84000000 1100.47579200 172.77000000 \n", - "997 2019-04-05 1002.12916800 157.33000000 1069.00996800 167.83000000 \n", - "998 2019-04-04 1018.88121600 159.96000000 1044.61440000 164.00000000 \n", - "999 2019-04-03 1039.90089600 163.26000000 1132.57857600 177.81000000 \n", - "\n", - " 3a. low (CNY) 3b. low (USD) 4a. close (CNY) 4b. close (USD) \\\n", - "0 25780.12795200 4047.37000000 25954.40020800 4074.73000000 \n", - "1 25478.40000000 4000.00000000 25883.25177600 4063.56000000 \n", - "2 25597.00195200 4018.62000000 26082.42916800 4094.83000000 \n", - "3 25587.76603200 4017.17000000 25773.69465600 4046.36000000 \n", - "4 24798.31780800 3893.23000000 26188.03713600 4111.41000000 \n", - ".. ... ... ... ... \n", - "995 1044.99657600 164.06000000 1109.64801600 174.21000000 \n", - "996 1014.04032000 159.20000000 1054.16880000 165.50000000 \n", - "997 993.27542400 155.94000000 1049.51899200 164.77000000 \n", - "998 973.27488000 152.80000000 1002.32025600 157.36000000 \n", - "999 950.53540800 149.23000000 1018.88121600 159.96000000 \n", - "\n", - " 5. volume 6. market cap (USD) \n", - "0 14823.90760000 14823.90760000 \n", - "1 189309.25500000 189309.25500000 \n", - "2 208126.88050000 208126.88050000 \n", - "3 230833.16610000 230833.16610000 \n", - "4 380207.81660000 380207.81660000 \n", - ".. ... ... \n", - "995 465507.52497000 465507.52497000 \n", - "996 528168.33297000 528168.33297000 \n", - "997 516070.34553000 516070.34553000 \n", - "998 686080.95248000 686080.95248000 \n", - "999 1345344.53845000 1345344.53845000 \n", - "\n", - "[1000 rows x 11 columns]" - ] - }, - "execution_count": 60, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "data = {\n", - " \"function\": \"DIGITAL_CURRENCY_DAILY\", # WEEKLY, MONTHLY possible\n", - " \"symbol\": \"ETH\",\n", - " \"market\": 'CNY',\n", - " \"apikey\": key\n", - " }\n", - "r = requests.get(url, params=data)\n", - "data = r.json()\n", - "crypto_df = pd.DataFrame(data['Time Series (Digital Currency Daily)']).T.reset_index()\n", - "crypto_df = crypto_df.rename(columns={\"index\": \"Date\"})\n", - "crypto_df['Date'] = pd.to_datetime(crypto_df['Date'])\n", - "crypto_df\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Exchange Rates\n" - ] - }, - { - "cell_type": "code", - "execution_count": 98, + "execution_count": null, "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", - "
0
1. From_Currency CodeETH
2. From_Currency NameEthereum
3. To_Currency CodeUSD
4. To_Currency NameUnited States Dollar
5. Exchange Rate4095.02000000
6. Last Refreshed2021-12-27 18:57:01
7. Time ZoneUTC
8. Bid Price4095.29000000
9. Ask Price4095.30000000
\n", - "
" - ], - "text/plain": [ - " 0\n", - "1. From_Currency Code ETH\n", - "2. From_Currency Name Ethereum\n", - "3. To_Currency Code USD\n", - "4. To_Currency Name United States Dollar\n", - "5. Exchange Rate 4095.02000000\n", - "6. Last Refreshed 2021-12-27 18:57:01\n", - "7. Time Zone UTC\n", - "8. Bid Price 4095.29000000\n", - "9. Ask Price 4095.30000000" - ] - }, - "execution_count": 98, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ - "data = {\n", - " \"function\": \"CURRENCY_EXCHANGE_RATE\", # WEEKLY, MONTHLY possible\n", - " \"from_currency\": \"ETH\",\n", - " \"to_currency\": 'USD',\n", + "treasury_yield = {\n", + " \"function\": \"TREASURY_YIELD\",\n", + " \"interval\": \"weekly\", # daily, monthly\n", + " \"maturity\": \"3month\", # OPTIONAL 5year, 10year, 30year\n", " \"apikey\": key\n", - " }\n", - "r = requests.get(url, params=data)\n", - "data = r.json()\n", - "crypto_df = pd.DataFrame(data['Realtime Currency Exchange Rate'], index=[0]).T\n", - "crypto_df" + "}" ] }, { @@ -2806,12 +2486,7 @@ " \"interval\": \"annual\", # quarterly\n", " \"apikey\": key\n", "}\n", - "treasury_yield = {\n", - " \"function\": \"TREASURY_YIELD\",\n", - " \"interval\": \"weekly\", # daily, monthly\n", - " \"maturity\": \"3month\", # OPTIONAL 5year, 10year, 30year\n", - " \"apikey\": key\n", - "}\n", + "\n", "federal_funds_rate = {\n", " \"function\": \"FEDERAL_FUNDS_RATE\",\n", " \"interval\": \"weekly\", # daily, monthly\n", @@ -2842,6 +2517,25 @@ "crypto_df" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Financials" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "document = 'INCOME_STATEMENT' # BALANCE_SHEET, CASH_FLOW\n", + "url = 'https://www.alphavantage.co/query?function='+document+'&symbol=IBM&apikey=demo'\n", + "r = requests.get(url)\n", + "data = r.json()" + ] + }, { "cell_type": "markdown", "metadata": {}, diff --git a/Source/Alphavantage.rst b/Source/Alphavantage.rst index 145daa9..c8eba71 100644 --- a/Source/Alphavantage.rst +++ b/Source/Alphavantage.rst @@ -21,17 +21,17 @@ Fetching the data - `5. Many Stocks <#5>`_ - `6. Finanical Indices <#6>`_ - `7. Currencies <#7>`_ -- `8. Crypto <#8>`_ -- `9. Mutual Funds <#9>`_ -- `10. Treasury <#10>`_ -- `11. Stock Fundamentals <#11>`_ -- `12. Financials <#12>`_ -- `13. Put Call Options <#13>`_ -- `14. Stream Real Time Data <#14>`_ -- `15. Economic Indicators <#15>`_ -- `16. Technical Indicators <#16>`_ - -.. code:: ipython3 +- `8. Crypto <#8>`_ +- `9. Mutual Funds <#9>`_ +- `10. Treasury <#10>`_ +- `11. Stock Fundamentals <#11>`_ +- `12. Financials <#12>`_ +- `13. Put Call Options <#13>`_ +- `14. Stream Real Time Data <#14>`_ +- `15. Economic Indicators <#15>`_ +- `16. Technical Indicators <#16>`_ + +.. code-block:: ipython3 from alpha_vantage.timeseries import TimeSeries import pandas as pd @@ -42,6 +42,10 @@ Fetching the data Historical Price and Volume for 1 Stock --------------------------------------- +Link to the `historic price and volume of one stock`_ JupyterNB cell. + +.. _historic price and volume of one stock: Source/Alphavantage.ipynb#Historic-Stock-Price-and-Volume + .. code:: ipython3 data = { @@ -77,6 +81,9 @@ Adding Time Periods Frequency Setting ----------------- +Link to the `intraday data`_ JupyterNB cell. + +.. _intraday data: Source/Alphavantage.ipynb#Intraday-Data .. code:: ipython3 @@ -96,6 +103,9 @@ Frequency Setting Stock Split and dividends ------------------------- +Link to the `dividends`_ JupyterNB cell. + +.. _dividends: Source/Alphavantage.ipynb#Dividends .. code:: ipython3 @@ -108,6 +118,9 @@ Stock Split and dividends Financial Indices ----------------- +Link to the `financial indices`_ JupyterNB cell. + +.. _Financial Indices: Source/Alphavantage.ipynb#Indices .. code:: ipython3 @@ -120,6 +133,9 @@ Financial Indices Currencies --------------- +Link to the `currency exchange`_ JupyterNB cell. + +.. _Currency Exchange: Source/Alphavantage.ipynb#Currency-Exchange .. code:: ipython3 @@ -131,8 +147,11 @@ Currencies r = requests.get(url) data = r.json() -Crypto ---------------- +Cryptocurrencies +---------------- +Link to the `cryptocurrencies`_ JupyterNB cell. + +.. _Cryptocurrencies: Source/Alphavantage.ipynb#Cryptocurrencies .. code:: ipython3 @@ -146,6 +165,9 @@ Crypto Mutual Funds --------------- +Link to the `mutual funds`_ JupyterNB cell. + +.. _Mutual Funds: Source/Alphavantage.ipynb#Mutual-Funds .. code:: ipython3 @@ -159,6 +181,9 @@ Mutual Funds Treasury Rates --------------- +Link to the `treasury yield`_ JupyterNB cell. + +.. _Treasury Yield: Source/Alphavantage.ipynb#Treasury-Yield .. code:: ipython3 @@ -171,6 +196,9 @@ Treasury Rates Stock Fundamentals ------------------ +Link to the `intraday data`_ JupyterNB cell. + +.. _intraday data: Source/Alphavantage.ipynb#Intraday-Data .. code:: ipython3 @@ -181,6 +209,9 @@ Stock Fundamentals Import Financials ----------------- +Link to the `financials`_ JupyterNB cell. + +.. _Financials: Source/Alphavantage.ipynb#Financials .. code:: ipython3 @@ -191,6 +222,9 @@ Import Financials Stream Realtime Data -------------------- +Link to the `realtime data`_ JupyterNB cell. + +.. _Realtime Data: Source/Alphavantage.ipynb#Realtime-Data .. code:: ipython3 @@ -214,6 +248,9 @@ Stream Realtime Data Economic Indicators ------------------- +Link to the `economic indicators`_ JupyterNB cell. + +.. _Economic Indicators: Source/Alphavantage.ipynb#Economic-Indicators .. code:: ipython3 @@ -258,6 +295,9 @@ Economic Indicators Technical Indicators -------------------- +Link to the `technical indicators`_ JupyterNB cell. + +.. _Technical Indicators: Source/Alphavantage.ipynb#Technical-Indicators .. code:: ipython3