From 53b665b83f55efe1eadc79f4fa99b30d4804bf8d Mon Sep 17 00:00:00 2001 From: Zach Coriarty Date: Thu, 30 Dec 2021 14:43:44 -0500 Subject: [PATCH] Adjusted FA, quandl; added IEX, stooq --- JupyterNotebooks/FundamentalAnalysis.ipynb | 367 ++++++- JupyterNotebooks/iex.ipynb | 1105 ++++++++++++++++++++ JupyterNotebooks/quandl.ipynb | 9 + JupyterNotebooks/stooq.ipynb | 209 ++++ 4 files changed, 1682 insertions(+), 8 deletions(-) create mode 100644 JupyterNotebooks/iex.ipynb create mode 100644 JupyterNotebooks/stooq.ipynb diff --git a/JupyterNotebooks/FundamentalAnalysis.ipynb b/JupyterNotebooks/FundamentalAnalysis.ipynb index 68bcf27..8281447 100644 --- a/JupyterNotebooks/FundamentalAnalysis.ipynb +++ b/JupyterNotebooks/FundamentalAnalysis.ipynb @@ -2,21 +2,304 @@ "cells": [ { "cell_type": "code", - "execution_count": null, + "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "import FundamentalAnalysis as fa\n", + "import financedatabase as fd\n", "import pandas as pd\n", "ticker = \"TSLA\"\n", - "api_key = \"api key\"\n" + "api_key = \"7b95034d43c6ccb530b841102ac7bc8f\"\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "The below command lists all options available to be queried" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 19, "metadata": {}, - "outputs": [], + "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", + "
0
0AAVE
1ABBC
2ACH
3ACT
4ADA
......
346ZIL
347ZNN
348ZRX
349ZVC
350ZYN
\n", + "

351 rows × 1 columns

\n", + "
" + ], + "text/plain": [ + " 0\n", + "0 AAVE\n", + "1 ABBC\n", + "2 ACH\n", + "3 ACT\n", + "4 ADA\n", + ".. ...\n", + "346 ZIL\n", + "347 ZNN\n", + "348 ZRX\n", + "349 ZVC\n", + "350 ZYN\n", + "\n", + "[351 rows x 1 columns]" + ] + }, + "execution_count": 19, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# Options: 'cryptocurrencies', 'currencies', 'equities', 'etfs' or 'funds'\n", + "options = fd.show_options('cryptocurrencies', equities_selection=None, country=None, sector=None, industry=None)\n", + "options = pd.DataFrame(options)\n", + "options" + ] + }, + { + "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", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
namepriceexchangeexchangeShortNametype
symbol
000001.SZPing An Bank Co., Ltd.16.82ShenzhenSHZstock
000002.SZChina Vanke Co., Ltd.19.12ShenzhenSHZstock
000004.SZShenzhen GuoHua Network Security Technology Co...19.60ShenzhenSHZstock
000005.SZShenzhen Fountain Corporation2.29ShenzhenSHZstock
000006.SZShenzhen Zhenye (Group) Co.,Ltd.4.38ShenzhenSHZstock
..................
ZYT.LZytronic plc170.00LSELSEstock
ZYXIZynex, Inc.10.34Nasdaq Capital MarketNASDAQstock
ZZLLZZLL Information Technology, Inc.0.23Other OTCMUTUAL_FUNDstock
ZZZ.TOSleep Country Canada Holdings Inc.37.73TorontoTSXstock
ZZZD.TOBMO Tactical Dividend ETF Fund ETF28.27TorontoTSXetf
\n", + "

33459 rows × 5 columns

\n", + "
" + ], + "text/plain": [ + " name price \\\n", + "symbol \n", + "000001.SZ Ping An Bank Co., Ltd. 16.82 \n", + "000002.SZ China Vanke Co., Ltd. 19.12 \n", + "000004.SZ Shenzhen GuoHua Network Security Technology Co... 19.60 \n", + "000005.SZ Shenzhen Fountain Corporation 2.29 \n", + "000006.SZ Shenzhen Zhenye (Group) Co.,Ltd. 4.38 \n", + "... ... ... \n", + "ZYT.L Zytronic plc 170.00 \n", + "ZYXI Zynex, Inc. 10.34 \n", + "ZZLL ZZLL Information Technology, Inc. 0.23 \n", + "ZZZ.TO Sleep Country Canada Holdings Inc. 37.73 \n", + "ZZZD.TO BMO Tactical Dividend ETF Fund ETF 28.27 \n", + "\n", + " exchange exchangeShortName type \n", + "symbol \n", + "000001.SZ Shenzhen SHZ stock \n", + "000002.SZ Shenzhen SHZ stock \n", + "000004.SZ Shenzhen SHZ stock \n", + "000005.SZ Shenzhen SHZ stock \n", + "000006.SZ Shenzhen SHZ stock \n", + "... ... ... ... \n", + "ZYT.L LSE LSE stock \n", + "ZYXI Nasdaq Capital Market NASDAQ stock \n", + "ZZLL Other OTC MUTUAL_FUND stock \n", + "ZZZ.TO Toronto TSX stock \n", + "ZZZD.TO Toronto TSX etf \n", + "\n", + "[33459 rows x 5 columns]" + ] + }, + "execution_count": 6, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "# Show the available companies\n", "companies = fa.available_companies(api_key)\n", @@ -35,9 +318,48 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 5, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
\n", + "
" + ], + "text/plain": [ + "Empty DataFrame\n", + "Columns: []\n", + "Index: []" + ] + }, + "execution_count": 5, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "# Company Profile\n", "profile = fa.profile(ticker, api_key)\n", @@ -57,9 +379,24 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 4, "metadata": {}, - "outputs": [], + "outputs": [ + { + "ename": "KeyError", + "evalue": "\"None of ['date'] are in the columns\"", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mKeyError\u001b[0m Traceback (most recent call last)", + "\u001b[0;32m/var/folders/pk/ntxqk62j0_jb9d_f4plbpzv80000gn/T/ipykernel_24051/1997791733.py\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[0;31m# Analysts Recommendation/Ratings\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 2\u001b[0;31m \u001b[0mratings\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mfa\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mrating\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'ADA'\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mapi_key\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 3\u001b[0m \u001b[0mratings\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m~/Desktop/FinAILabDatasets/venv/lib/python3.8/site-packages/FundamentalAnalysis/details.py\u001b[0m in \u001b[0;36mrating\u001b[0;34m(ticker, api_key)\u001b[0m\n\u001b[1;32m 189\u001b[0m \u001b[0;32mdel\u001b[0m \u001b[0mvalue\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m'symbol'\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 190\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 191\u001b[0;31m \u001b[0mdata_formatted\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mpd\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mDataFrame\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mdata_json\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mset_index\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'date'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 192\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 193\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mdata_formatted\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m~/Desktop/FinAILabDatasets/venv/lib/python3.8/site-packages/pandas/util/_decorators.py\u001b[0m in \u001b[0;36mwrapper\u001b[0;34m(*args, **kwargs)\u001b[0m\n\u001b[1;32m 309\u001b[0m \u001b[0mstacklevel\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mstacklevel\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 310\u001b[0m )\n\u001b[0;32m--> 311\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0mfunc\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m*\u001b[0m\u001b[0margs\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mkwargs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 312\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 313\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mwrapper\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m~/Desktop/FinAILabDatasets/venv/lib/python3.8/site-packages/pandas/core/frame.py\u001b[0m in \u001b[0;36mset_index\u001b[0;34m(self, keys, drop, append, inplace, verify_integrity)\u001b[0m\n\u001b[1;32m 5449\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 5450\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mmissing\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 5451\u001b[0;31m \u001b[0;32mraise\u001b[0m \u001b[0mKeyError\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34mf\"None of {missing} are in the columns\"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 5452\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 5453\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0minplace\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;31mKeyError\u001b[0m: \"None of ['date'] are in the columns\"" + ] + } + ], "source": [ "# Analysts Recommendation/Ratings\n", "ratings = fa.rating(ticker, api_key)\n", @@ -211,6 +548,20 @@ "# Detailed stock data\n", "stock_data_detailed = fa.stock_data_detailed(ticker, api_key, begin=\"2000-01-01\", end=\"2020-01-01\")" ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Cryptocurrencites" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] } ], "metadata": { diff --git a/JupyterNotebooks/iex.ipynb b/JupyterNotebooks/iex.ipynb new file mode 100644 index 0000000..87860f3 --- /dev/null +++ b/JupyterNotebooks/iex.ipynb @@ -0,0 +1,1105 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 25, + "metadata": {}, + "outputs": [], + "source": [ + "import pandas as pd\n", + "import pyEX as p \n", + "import requests\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "The following command shows all functions available, all of which follow the same structure as the examples below\n", + "- Some require a premium substription" + ] + }, + { + "cell_type": "code", + "execution_count": 31, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "['accountingQualityAndRiskMatrixAuditAnalyticsDF',\n", + " 'advancedStatsDF',\n", + " 'analystDaysWallStreetHorizonDF',\n", + " 'analystRecommendationsDF',\n", + " 'balanceSheetDF',\n", + " 'batchDF',\n", + " 'boardOfDirectorsMeetingWallStreetHorizonDF',\n", + " 'bonusIssueDF',\n", + " 'bookDF',\n", + " 'bulkBatchDF',\n", + " 'bulkMinuteBarsDF',\n", + " 'businessUpdatesWallStreetHorizonDF',\n", + " 'buybacksWallStreetHorizonDF',\n", + " 'calendarDF',\n", + " 'cam1ExtractAlphaDF',\n", + " 'capitalMarketsDayWallStreetHorizonDF',\n", + " 'cashFlowDF',\n", + " 'ceoCompensationDF',\n", + " 'chartDF',\n", + " 'collectionsDF',\n", + " 'companyDF',\n", + " 'companyTravelWallStreetHorizonDF',\n", + " 'convertFXDF',\n", + " 'corporateActionsDF',\n", + " 'cryptoBookDF',\n", + " 'cryptoPriceDF',\n", + " 'cryptoQuoteDF',\n", + " 'cryptoSymbolsDF',\n", + " 'dailyDF',\n", + " 'delayedQuoteDF',\n", + " 'directorAndOfficerChangesAuditAnalyticsDF',\n", + " 'directoryDF',\n", + " 'distributionDF',\n", + " 'dividendsBasicDF',\n", + " 'dividendsDF',\n", + " 'earningsDF',\n", + " 'earningsTodayDF',\n", + " 'esgCFPBComplaintsExtractAlphaDF',\n", + " 'esgCPSCRecallsExtractAlphaDF',\n", + " 'esgDOLVisaApplicationsExtractAlphaDF',\n", + " 'esgEPAEnforcementsExtractAlphaDF',\n", + " 'esgEPAMilestonesExtractAlphaDF',\n", + " 'esgFECIndividualCampaingContributionsExtractAlphaDF',\n", + " 'esgOSHAInspectionsExtractAlphaDF',\n", + " 'esgSenateLobbyingExtractAlphaDF',\n", + " 'esgUSASpendingExtractAlphaDF',\n", + " 'esgUSPTOPatentApplicationsExtractAlphaDF',\n", + " 'esgUSPTOPatentGrantsExtractAlphaDF',\n", + " 'estimatesDF',\n", + " 'exchangesDF',\n", + " 'fdaAdvisoryCommitteeMeetingsWallStreetHorizonDF',\n", + " 'figiDF',\n", + " 'filingDueDatesWallStreetHorizonDF',\n", + " 'financialsDF',\n", + " 'fiscalQuarterEndWallStreetHorizonDF',\n", + " 'fiveDayMLReturnRankingBrainDF',\n", + " 'forumWallStreetHorizonDF',\n", + " 'fundOwnershipDF',\n", + " 'fundamentalsDF',\n", + " 'fxSymbolsDF',\n", + " 'generalConferenceWallStreetHorizonDF',\n", + " 'historicalFXDF',\n", + " 'holidaysDF',\n", + " 'holidaysWallStreetHorizonDF',\n", + " 'iexAuctionDF',\n", + " 'iexBookDF',\n", + " 'iexDeepDF',\n", + " 'iexHistDF',\n", + " 'iexLastDF',\n", + " 'iexOfficialPriceDF',\n", + " 'iexOpHaltStatusDF',\n", + " 'iexSecurityEventDF',\n", + " 'iexSsrStatusDF',\n", + " 'iexSymbolsDF',\n", + " 'iexSystemEventDF',\n", + " 'iexTopsDF',\n", + " 'iexTradeBreakDF',\n", + " 'iexTradesDF',\n", + " 'iexTradingStatusDF',\n", + " 'incomeStatementDF',\n", + " 'indexChangesWallStreetHorizonDF',\n", + " 'insiderRosterDF',\n", + " 'insiderSummaryDF',\n", + " 'insiderTransactionsDF',\n", + " 'institutionalOwnershipDF',\n", + " 'internationalExchangesDF',\n", + " 'internationalSymbolsDF',\n", + " 'intradayDF',\n", + " 'ipoTodayDF',\n", + " 'ipoUpcomingDF',\n", + " 'iposWallStreetHorizonDF',\n", + " 'isinLookupDF',\n", + " 'kScoreChinaKavoutDF',\n", + " 'kScoreKavoutDF',\n", + " 'keyStatsDF',\n", + " 'languageMetricsOnCompanyFilingsAllBrainDF',\n", + " 'languageMetricsOnCompanyFilingsBrainDF',\n", + " 'languageMetricsOnCompanyFilingsDifferenceAllBrainDF',\n", + " 'languageMetricsOnCompanyFilingsDifferenceBrainDF',\n", + " 'largestTradesDF',\n", + " 'latestFXDF',\n", + " 'legalActionsWallStreetHorizonDF',\n", + " 'listDF',\n", + " 'marketNewsDF',\n", + " 'marketOhlcDF',\n", + " 'marketPreviousDF',\n", + " 'marketShortInterestDF',\n", + " 'marketVolumeDF',\n", + " 'marketYesterdayDF',\n", + " 'marketsDF',\n", + " 'mergersAndAcquisitionsWallStreetHorizonDF',\n", + " 'metadataDF',\n", + " 'mutualFundSymbolsDF',\n", + " 'newsDF',\n", + " 'nextDayExtDateDF',\n", + " 'nonTimelyFilingsFraudFactorsDF',\n", + " 'ohlcDF',\n", + " 'optionsDF',\n", + " 'optionsSymbolsDF',\n", + " 'otcSymbolsDF',\n", + " 'peersDF',\n", + " 'pointsDF',\n", + " 'previousDF',\n", + " 'priceDF',\n", + " 'priceDynamicsPrecisionAlphaDF',\n", + " 'priceTargetDF',\n", + " 'productEventsWallStreetHorizonDF',\n", + " 'queryMetadataDF',\n", + " 'quoteDF',\n", + " 'recentDF',\n", + " 'recordsDF',\n", + " 'refDividendsDF',\n", + " 'relevantDF',\n", + " 'researchAndDevelopmentDaysWallStreetHorizonDF',\n", + " 'returnOfCapitalDF',\n", + " 'rightToPurchaseDF',\n", + " 'rightsIssueDF',\n", + " 'sameStoreSalesWallStreetHorizonDF',\n", + " 'searchDF',\n", + " 'secondaryOfferingsWallStreetHorizonDF',\n", + " 'sectorPerformanceDF',\n", + " 'sectorsDF',\n", + " 'securityReclassificationDF',\n", + " 'securitySwapDF',\n", + " 'seminarsWallStreetHorizonDF',\n", + " 'sentimentDF',\n", + " 'sevenDaySentimentBrainDF',\n", + " 'shareholderMeetingsWallStreetHorizonDF',\n", + " 'shortInterestDF',\n", + " 'similarityIndexFraudFactorsDF',\n", + " 'socialSentimentStockTwitsDF',\n", + " 'spinoffDF',\n", + " 'splitsDF',\n", + " 'spreadDF',\n", + " 'statsDF',\n", + " 'statusDF',\n", + " 'stockSplitsDF',\n", + " 'summaryDF',\n", + " 'summitMeetingsWallStreetHorizonDF',\n", + " 'symbolsDF',\n", + " 'tacticalModel1ExtractAlphaDF',\n", + " 'tagsDF',\n", + " 'technicalsDF',\n", + " 'tenDayMLReturnRankingBrainDF',\n", + " 'thirtyDaySentimentBrainDF',\n", + " 'threeDayMLReturnRankingBrainDF',\n", + " 'thresholdDF',\n", + " 'timeSeriesDF',\n", + " 'timeSeriesInventoryDF',\n", + " 'tradeShowsWallStreetHorizonDF',\n", + " 'twentyOneDayMLReturnRankingBrainDF',\n", + " 'twoDayMLReturnRankingBrainDF',\n", + " 'upcomingDividendsDF',\n", + " 'upcomingEarningsDF',\n", + " 'upcomingEventsDF',\n", + " 'upcomingIPOsDF',\n", + " 'upcomingSplitsDF',\n", + " 'usageDF',\n", + " 'volumeByVenueDF',\n", + " 'witchingHoursWallStreetHorizonDF',\n", + " 'workshopsWallStreetHorizonDF',\n", + " 'yesterdayDF']" + ] + }, + "execution_count": 31, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "[_ for _ in dir(p) if _.endswith('DF')]" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": {}, + "outputs": [], + "source": [ + "api_token = 'pk_d0e1e3f4d972458da439782f34c5f5a2'\n", + "conn = p.Client(api_token=api_token, version='stable')\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Realtime Data" + ] + }, + { + "cell_type": "code", + "execution_count": 27, + "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", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
value
avgTotalVolume5967872
calculationPricetops
change0.32
changePercent0.00338
closeNone
closeSourceofficial
closeTimeNone
companyNameGeneral Electric Co.
currencyUSD
delayedPriceNone
delayedPriceTimeNone
extendedChangeNone
extendedChangePercentNone
extendedPriceNone
extendedPriceTimeNone
highNone
highSource15 minute delayed price
highTime1640891366896
iexAskPrice95.08
iexAskSize150
iexBidPrice93
iexBidSize100
iexClose95.11
iexCloseTime1640892232700
iexLastUpdated1640892232700
iexMarketPercent0.030712
iexOpen94.585
iexOpenTime1640874602325
iexRealtimePrice95.11
iexRealtimeSize25
iexVolume64564
lastTradeTime1640892232700
latestPrice95.11
latestSourceIEX real time price
latestTime2:23:52 PM
latestUpdate1640892232700
latestVolumeNone
lowNone
lowSourceIEX real time price
lowTime1640874603118
marketCap104443822244
oddLotDelayedPriceNone
oddLotDelayedPriceTimeNone
openNone
openTimeNone
openSourceofficial
peRatio-251.61
previousClose94.79
previousVolume3490524
primaryExchangeNEW YORK STOCK EXCHANGE INC.
symbolGE
volumeNone
week52High116.06
week52Low82.94
ytdChange0.103949
isUSMarketOpenTrue
\n", + "
" + ], + "text/plain": [ + " value\n", + "avgTotalVolume 5967872\n", + "calculationPrice tops\n", + "change 0.32\n", + "changePercent 0.00338\n", + "close None\n", + "closeSource official\n", + "closeTime None\n", + "companyName General Electric Co.\n", + "currency USD\n", + "delayedPrice None\n", + "delayedPriceTime None\n", + "extendedChange None\n", + "extendedChangePercent None\n", + "extendedPrice None\n", + "extendedPriceTime None\n", + "high None\n", + "highSource 15 minute delayed price\n", + "highTime 1640891366896\n", + "iexAskPrice 95.08\n", + "iexAskSize 150\n", + "iexBidPrice 93\n", + "iexBidSize 100\n", + "iexClose 95.11\n", + "iexCloseTime 1640892232700\n", + "iexLastUpdated 1640892232700\n", + "iexMarketPercent 0.030712\n", + "iexOpen 94.585\n", + "iexOpenTime 1640874602325\n", + "iexRealtimePrice 95.11\n", + "iexRealtimeSize 25\n", + "iexVolume 64564\n", + "lastTradeTime 1640892232700\n", + "latestPrice 95.11\n", + "latestSource IEX real time price\n", + "latestTime 2:23:52 PM\n", + "latestUpdate 1640892232700\n", + "latestVolume None\n", + "low None\n", + "lowSource IEX real time price\n", + "lowTime 1640874603118\n", + "marketCap 104443822244\n", + "oddLotDelayedPrice None\n", + "oddLotDelayedPriceTime None\n", + "open None\n", + "openTime None\n", + "openSource official\n", + "peRatio -251.61\n", + "previousClose 94.79\n", + "previousVolume 3490524\n", + "primaryExchange NEW YORK STOCK EXCHANGE INC.\n", + "symbol GE\n", + "volume None\n", + "week52High 116.06\n", + "week52Low 82.94\n", + "ytdChange 0.103949\n", + "isUSMarketOpen True" + ] + }, + "execution_count": 27, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "ticker = 'GE'\n", + "\n", + "real_time = conn.quote(ticker)\n", + "real_time = pd.DataFrame(real_time, index = ['value']).T\n", + "real_time" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Historical Prices" + ] + }, + { + "cell_type": "code", + "execution_count": 19, + "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", + "
closehighlowopensymbolvolumeidkeysubkeyupdated...uLowuVolumefOpenfClosefHighfLowfVolumelabelchangechangePercent
date
2021-12-2994.7995.4894.4495.00GE3490524HISTORICAL_PRICESGE2021-12-30 02:53:41...94.44349052495.0094.7995.4894.443490524Dec 29, 210.000.0000
2021-12-2895.3096.0894.2494.43GE4054839HISTORICAL_PRICESGE2021-12-29 03:38:27...94.24405483994.4395.3096.0894.244054839Dec 28, 210.510.0054
2021-12-2794.6294.6793.4593.63GE3429798HISTORICAL_PRICESGE2021-12-28 02:55:28...93.45342979893.6394.6294.6793.453429798Dec 27, 21-0.68-0.0071
\n", + "

3 rows × 25 columns

\n", + "
" + ], + "text/plain": [ + " close high low open symbol volume id key \\\n", + "date \n", + "2021-12-29 94.79 95.48 94.44 95.00 GE 3490524 HISTORICAL_PRICES GE \n", + "2021-12-28 95.30 96.08 94.24 94.43 GE 4054839 HISTORICAL_PRICES GE \n", + "2021-12-27 94.62 94.67 93.45 93.63 GE 3429798 HISTORICAL_PRICES GE \n", + "\n", + " subkey updated ... uLow uVolume fOpen fClose \\\n", + "date ... \n", + "2021-12-29 2021-12-30 02:53:41 ... 94.44 3490524 95.00 94.79 \n", + "2021-12-28 2021-12-29 03:38:27 ... 94.24 4054839 94.43 95.30 \n", + "2021-12-27 2021-12-28 02:55:28 ... 93.45 3429798 93.63 94.62 \n", + "\n", + " fHigh fLow fVolume label change changePercent \n", + "date \n", + "2021-12-29 95.48 94.44 3490524 Dec 29, 21 0.00 0.0000 \n", + "2021-12-28 96.08 94.24 4054839 Dec 28, 21 0.51 0.0054 \n", + "2021-12-27 94.67 93.45 3429798 Dec 27, 21 -0.68 -0.0071 \n", + "\n", + "[3 rows x 25 columns]" + ] + }, + "execution_count": 19, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "timeframe = '5d' # up to 15 years, or minute-by-minute for the last 30 days\n", + "history = conn.chartDF(ticker, timeframe=timeframe)\n", + "history" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### News" + ] + }, + { + "cell_type": "code", + "execution_count": 23, + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/Users/zacharycoriarty/Desktop/FinAILabDatasets/venv/lib/python3.8/site-packages/pyEX/common/checks.py:475: FutureWarning: casting datetime64[ns] values to int64 with .astype(...) is deprecated and will raise in a future version. Use .view(...) instead.\n", + " df[rcol] = pd.to_datetime(df[rcol].astype(int), unit=\"ms\")\n" + ] + }, + { + "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", + "
headlinesourceurlsummaryrelatedimagelanghasPaywall
datetime
2021-12-24 11:56:41General Electric (NYSE:GE) Shares Sold by Allw...Dakota Financial Newshttps://cloud.iexapis.com/v1/news/article/IXIU...Allworth Financial LP cut its stake in General...GE,GNE-FP,GEOO34-BS,FUNDhttps://cloud.iexapis.com/v1/news/image/IXIUmh...enFalse
2021-12-24 02:56:57Interview with Shahab Qader CEO & VP Commerci...Business Recorderhttps://cloud.iexapis.com/v1/news/article/18DJ...We dont need imported fuel for power if we ful...GE,GNE-FP,GEOO34-BS,RSKIAhttps://cloud.iexapis.com/v1/news/image/18DJZK...enFalse
2021-12-23 16:20:45Ironwood Financial llc Decreases Stock Positio...Dakota Financial Newshttps://cloud.iexapis.com/v1/news/article/BJtp...Ironwood Financial llc reduced its position in...GE,GNE-FP,GEOO34-BS,FUNDhttps://cloud.iexapis.com/v1/news/image/BJtpxo...enFalse
2021-12-23 15:45:00Thinking about trading options or stock in Gen...Kwhen Financehttps://cloud.iexapis.com/v1/news/article/2a6c...GE,QDEL,JD,CROX,XOMhttps://cloud.iexapis.com/v1/news/image/2a6ccp...enFalse
2021-12-23 11:01:48ANALYSIS-How 2021 became the year of ESG inves...Devdiscoursehttps://cloud.iexapis.com/v1/news/article/1zFm...Inflows in European ESG funds dropped in 2021,...UNP,UNPA,XOM,GE,GNE-FP,GEOO34-BShttps://cloud.iexapis.com/v1/news/image/1zFmG7...enFalse
2021-12-22 21:40:00Top 10 Themes For 2022: Part 1Zero Hedgehttps://cloud.iexapis.com/v1/news/article/3Mif...Top 10 Themes For 2022: Part 1 In its comprehe...GE,GNE-FP,GEOO34-BS,IBM,IBM-LN,JNJ,AMZN,GOOG,G...https://cloud.iexapis.com/v1/news/image/3MifE0...enFalse
2021-12-22 16:44:12GE Digital Inks Deal to Buy Opus One; Shares GainSmarter Analysthttps://cloud.iexapis.com/v1/news/article/1zF0...This article was originally published on TipRa...GE,GNE-FP,GEOO34-BShttps://cloud.iexapis.com/v1/news/image/1zF0Le...enFalse
2021-12-22 14:49:00Global Point of Entry Water Treatment Systems ...Business Wirehttps://cloud.iexapis.com/v1/news/article/40bF...DUBLIN--(BUSINESS WIRE)--The \"Global Point of ...GE,GNE-FP,GEOO34-BS,DD,6D81-GY,6D81-GH,6D81-GF...https://cloud.iexapis.com/v1/news/image/40bFpJ...enFalse
2021-12-22 14:04:43B. Metzler seel. Sohn & Co. Holding AG Reduces...Dakota Financial Newshttps://cloud.iexapis.com/v1/news/article/S2jq...B. Metzler seel. Sohn & Co. Holding AG lessene...GE,GNE-FP,GEOO34-BShttps://cloud.iexapis.com/v1/news/image/S2jqwf...enFalse
2021-12-22 13:30:49General Electric Company Consensus Indicates ...DirectorsTalkhttps://cloud.iexapis.com/v1/news/article/3MMo...General Electric Company found using ticker (G...GE,GNE-FP,GEOO34-BS,RSKIAhttps://cloud.iexapis.com/v1/news/image/3MMoen...enFalse
\n", + "
" + ], + "text/plain": [ + " headline \\\n", + "datetime \n", + "2021-12-24 11:56:41 General Electric (NYSE:GE) Shares Sold by Allw... \n", + "2021-12-24 02:56:57 Interview with Shahab Qader CEO & VP Commerci... \n", + "2021-12-23 16:20:45 Ironwood Financial llc Decreases Stock Positio... \n", + "2021-12-23 15:45:00 Thinking about trading options or stock in Gen... \n", + "2021-12-23 11:01:48 ANALYSIS-How 2021 became the year of ESG inves... \n", + "2021-12-22 21:40:00 Top 10 Themes For 2022: Part 1 \n", + "2021-12-22 16:44:12 GE Digital Inks Deal to Buy Opus One; Shares Gain \n", + "2021-12-22 14:49:00 Global Point of Entry Water Treatment Systems ... \n", + "2021-12-22 14:04:43 B. Metzler seel. Sohn & Co. Holding AG Reduces... \n", + "2021-12-22 13:30:49 General Electric Company Consensus Indicates ... \n", + "\n", + " source \\\n", + "datetime \n", + "2021-12-24 11:56:41 Dakota Financial News \n", + "2021-12-24 02:56:57 Business Recorder \n", + "2021-12-23 16:20:45 Dakota Financial News \n", + "2021-12-23 15:45:00 Kwhen Finance \n", + "2021-12-23 11:01:48 Devdiscourse \n", + "2021-12-22 21:40:00 Zero Hedge \n", + "2021-12-22 16:44:12 Smarter Analyst \n", + "2021-12-22 14:49:00 Business Wire \n", + "2021-12-22 14:04:43 Dakota Financial News \n", + "2021-12-22 13:30:49 DirectorsTalk \n", + "\n", + " url \\\n", + "datetime \n", + "2021-12-24 11:56:41 https://cloud.iexapis.com/v1/news/article/IXIU... \n", + "2021-12-24 02:56:57 https://cloud.iexapis.com/v1/news/article/18DJ... \n", + "2021-12-23 16:20:45 https://cloud.iexapis.com/v1/news/article/BJtp... \n", + "2021-12-23 15:45:00 https://cloud.iexapis.com/v1/news/article/2a6c... \n", + "2021-12-23 11:01:48 https://cloud.iexapis.com/v1/news/article/1zFm... \n", + "2021-12-22 21:40:00 https://cloud.iexapis.com/v1/news/article/3Mif... \n", + "2021-12-22 16:44:12 https://cloud.iexapis.com/v1/news/article/1zF0... \n", + "2021-12-22 14:49:00 https://cloud.iexapis.com/v1/news/article/40bF... \n", + "2021-12-22 14:04:43 https://cloud.iexapis.com/v1/news/article/S2jq... \n", + "2021-12-22 13:30:49 https://cloud.iexapis.com/v1/news/article/3MMo... \n", + "\n", + " summary \\\n", + "datetime \n", + "2021-12-24 11:56:41 Allworth Financial LP cut its stake in General... \n", + "2021-12-24 02:56:57 We dont need imported fuel for power if we ful... \n", + "2021-12-23 16:20:45 Ironwood Financial llc reduced its position in... \n", + "2021-12-23 15:45:00 \n", + "2021-12-23 11:01:48 Inflows in European ESG funds dropped in 2021,... \n", + "2021-12-22 21:40:00 Top 10 Themes For 2022: Part 1 In its comprehe... \n", + "2021-12-22 16:44:12 This article was originally published on TipRa... \n", + "2021-12-22 14:49:00 DUBLIN--(BUSINESS WIRE)--The \"Global Point of ... \n", + "2021-12-22 14:04:43 B. Metzler seel. Sohn & Co. Holding AG lessene... \n", + "2021-12-22 13:30:49 General Electric Company found using ticker (G... \n", + "\n", + " related \\\n", + "datetime \n", + "2021-12-24 11:56:41 GE,GNE-FP,GEOO34-BS,FUND \n", + "2021-12-24 02:56:57 GE,GNE-FP,GEOO34-BS,RSKIA \n", + "2021-12-23 16:20:45 GE,GNE-FP,GEOO34-BS,FUND \n", + "2021-12-23 15:45:00 GE,QDEL,JD,CROX,XOM \n", + "2021-12-23 11:01:48 UNP,UNPA,XOM,GE,GNE-FP,GEOO34-BS \n", + "2021-12-22 21:40:00 GE,GNE-FP,GEOO34-BS,IBM,IBM-LN,JNJ,AMZN,GOOG,G... \n", + "2021-12-22 16:44:12 GE,GNE-FP,GEOO34-BS \n", + "2021-12-22 14:49:00 GE,GNE-FP,GEOO34-BS,DD,6D81-GY,6D81-GH,6D81-GF... \n", + "2021-12-22 14:04:43 GE,GNE-FP,GEOO34-BS \n", + "2021-12-22 13:30:49 GE,GNE-FP,GEOO34-BS,RSKIA \n", + "\n", + " image lang \\\n", + "datetime \n", + "2021-12-24 11:56:41 https://cloud.iexapis.com/v1/news/image/IXIUmh... en \n", + "2021-12-24 02:56:57 https://cloud.iexapis.com/v1/news/image/18DJZK... en \n", + "2021-12-23 16:20:45 https://cloud.iexapis.com/v1/news/image/BJtpxo... en \n", + "2021-12-23 15:45:00 https://cloud.iexapis.com/v1/news/image/2a6ccp... en \n", + "2021-12-23 11:01:48 https://cloud.iexapis.com/v1/news/image/1zFmG7... en \n", + "2021-12-22 21:40:00 https://cloud.iexapis.com/v1/news/image/3MifE0... en \n", + "2021-12-22 16:44:12 https://cloud.iexapis.com/v1/news/image/1zF0Le... en \n", + "2021-12-22 14:49:00 https://cloud.iexapis.com/v1/news/image/40bFpJ... en \n", + "2021-12-22 14:04:43 https://cloud.iexapis.com/v1/news/image/S2jqwf... en \n", + "2021-12-22 13:30:49 https://cloud.iexapis.com/v1/news/image/3MMoen... en \n", + "\n", + " hasPaywall \n", + "datetime \n", + "2021-12-24 11:56:41 False \n", + "2021-12-24 02:56:57 False \n", + "2021-12-23 16:20:45 False \n", + "2021-12-23 15:45:00 False \n", + "2021-12-23 11:01:48 False \n", + "2021-12-22 21:40:00 False \n", + "2021-12-22 16:44:12 False \n", + "2021-12-22 14:49:00 False \n", + "2021-12-22 14:04:43 False \n", + "2021-12-22 13:30:49 False " + ] + }, + "execution_count": 23, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "news = conn.newsDF(ticker, count=10)\n", + "news" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Dividends" + ] + }, + { + "cell_type": "code", + "execution_count": 21, + "metadata": {}, + "outputs": [ + { + "ename": "PyEXception", + "evalue": "('Response 402 - ', 'The requested data is not available to free tier accounts. Please upgrade for access to this data.')", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mPyEXception\u001b[0m Traceback (most recent call last)", + "\u001b[0;32m/var/folders/pk/ntxqk62j0_jb9d_f4plbpzv80000gn/T/ipykernel_26906/2456159225.py\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[0mtimeframe\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m'6m'\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 2\u001b[0;31m \u001b[0mdividends\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mconn\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mdividendsDF\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mticker\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", + "\u001b[0;32m~/Desktop/FinAILabDatasets/venv/lib/python3.8/site-packages/pyEX/client.py\u001b[0m in \u001b[0;36mbind\u001b[0;34m(self, *args, **kwargs)\u001b[0m\n\u001b[1;32m 1760\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0mmeth\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1761\u001b[0m \u001b[0;32mraise\u001b[0m \u001b[0mPyEXception\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"Must provide method!\"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 1762\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0mmeth\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mtoken\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_token\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mversion\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_version\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m*\u001b[0m\u001b[0margs\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mkwargs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 1763\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1764\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0maccount\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m*\u001b[0m\u001b[0margs\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mkwargs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m~/Desktop/FinAILabDatasets/venv/lib/python3.8/site-packages/pyEX/stocks/corporateActions.py\u001b[0m in \u001b[0;36mdividendsDF\u001b[0;34m(*args, **kwargs)\u001b[0m\n\u001b[1;32m 161\u001b[0m \u001b[0;34m@\u001b[0m\u001b[0mwraps\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mdividends\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 162\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0mdividendsDF\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m*\u001b[0m\u001b[0margs\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mkwargs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 163\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0mpd\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mDataFrame\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mdividends\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m*\u001b[0m\u001b[0margs\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mkwargs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 164\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 165\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m~/Desktop/FinAILabDatasets/venv/lib/python3.8/site-packages/pyEX/stocks/corporateActions.py\u001b[0m in \u001b[0;36mdividends\u001b[0;34m(symbol, refid, token, version, filter, format, **timeseries_kwargs)\u001b[0m\n\u001b[1;32m 147\u001b[0m \u001b[0msymbol\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0m_quoteSymbols\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0msymbol\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 148\u001b[0m \u001b[0m_timeseriesWrapper\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mtimeseries_kwargs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 149\u001b[0;31m return timeSeries(\n\u001b[0m\u001b[1;32m 150\u001b[0m \u001b[0mid\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m\"advanced_dividends\"\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 151\u001b[0m \u001b[0mkey\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0msymbol\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m~/Desktop/FinAILabDatasets/venv/lib/python3.8/site-packages/pyEX/stocks/timeseries.py\u001b[0m in \u001b[0;36mtimeSeries\u001b[0;34m(id, key, subkey, range, calendar, limit, subattribute, dateField, from_, to_, on, last, first, token, version, filter, format, **extra_params)\u001b[0m\n\u001b[1;32m 164\u001b[0m \u001b[0mbase_url\u001b[0m \u001b[0;34m+=\u001b[0m \u001b[0;34m\"&\"\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mjoin\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"{}={}\"\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mformat\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mk\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mv\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;32mfor\u001b[0m \u001b[0mk\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mv\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mextra_params\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mitems\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 165\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 166\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0m_get\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mbase_url\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mtoken\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mtoken\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mversion\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mversion\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mfilter\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mfilter\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mformat\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mformat\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 167\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 168\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m~/Desktop/FinAILabDatasets/venv/lib/python3.8/site-packages/pyEX/common/urls.py\u001b[0m in \u001b[0;36m_get\u001b[0;34m(url, token, version, filter, format)\u001b[0m\n\u001b[1;32m 51\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mversion\u001b[0m \u001b[0;34m==\u001b[0m \u001b[0;34m\"sandbox\"\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 52\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0m_getIEXCloudSandbox\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0murl\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mtoken\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mversion\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mfilter\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mformat\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 53\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0m_getIEXCloud\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0murl\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mtoken\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mversion\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mfilter\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mformat\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 54\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0m_getOrig\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0murl\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 55\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m~/Desktop/FinAILabDatasets/venv/lib/python3.8/site-packages/pyEX/common/urls.py\u001b[0m in \u001b[0;36m_getIEXCloud\u001b[0;34m(url, token, version, filter, format)\u001b[0m\n\u001b[1;32m 122\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0m_getIEXCloud\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0murl\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mtoken\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m\"\"\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mversion\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m\"stable\"\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mfilter\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m\"\"\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mformat\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m\"json\"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 123\u001b[0m \u001b[0;34m\"\"\"for iex cloud\"\"\"\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 124\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0m_getIEXCloudBase\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0m_URL_PREFIX_CLOUD\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0murl\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mtoken\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mversion\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mfilter\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mformat\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 125\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 126\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m~/Desktop/FinAILabDatasets/venv/lib/python3.8/site-packages/pyEX/common/urls.py\u001b[0m in \u001b[0;36m_getIEXCloudBase\u001b[0;34m(base_url, url, token, version, filter, format)\u001b[0m\n\u001b[1;32m 117\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mresp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mcontent\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 118\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mresp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mtext\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 119\u001b[0;31m \u001b[0;32mraise\u001b[0m \u001b[0mPyEXception\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"Response %d - \"\u001b[0m \u001b[0;34m%\u001b[0m \u001b[0mresp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mstatus_code\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mresp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mtext\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 120\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 121\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;31mPyEXception\u001b[0m: ('Response 402 - ', 'The requested data is not available to free tier accounts. Please upgrade for access to this data.')" + ] + } + ], + "source": [ + "timeframe = '6m'\n", + "dividends = conn.dividendsDF(ticker)\n", + "dividends" + ] + } + ], + "metadata": { + "interpreter": { + "hash": "366707ea24bdd07af2745ddffc3e5dd8201944abddf6c7f0911e7ecd4d105ee5" + }, + "kernelspec": { + "display_name": "Python 3.8.9 64-bit ('venv': venv)", + "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.8.9" + }, + "orig_nbformat": 4 + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/JupyterNotebooks/quandl.ipynb b/JupyterNotebooks/quandl.ipynb index 4049e96..e83d239 100644 --- a/JupyterNotebooks/quandl.ipynb +++ b/JupyterNotebooks/quandl.ipynb @@ -1,5 +1,14 @@ { "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Quandl\n", + " Website to find Datasets: https://data.nasdaq.com/search\n", + "- Identifier is found under usage -> python -> examples and can then be put in the desiered functions, as shown below" + ] + }, { "cell_type": "code", "execution_count": 35, diff --git a/JupyterNotebooks/stooq.ipynb b/JupyterNotebooks/stooq.ipynb new file mode 100644 index 0000000..2361a35 --- /dev/null +++ b/JupyterNotebooks/stooq.ipynb @@ -0,0 +1,209 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 2, + "metadata": {}, + "outputs": [], + "source": [ + "import pandas as pd\n", + "import numpy as np\n", + "import pandas_datareader.data as web\n", + "from datetime import datetime" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "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", + "
OpenHighLowCloseVolume
Date
2019-12-3171.4210072.3420071.3190072.33500102490623
2019-12-3071.3050072.1030070.2600071.81200146380989
2019-12-2771.7150072.4150070.9740071.38800148545967
2019-12-2670.1640071.4340070.1350071.4160094722440
2019-12-2470.1320070.1810069.6930070.0270049198965
..................
1990-01-080.287230.290920.283190.29092118470824
1990-01-050.289050.292680.283190.28905143826725
1990-01-040.292680.296650.285040.28781258365560
1990-01-030.290920.290920.287230.28723242598119
1990-01-020.269790.287230.267930.28504213676036
\n", + "

7558 rows × 5 columns

\n", + "
" + ], + "text/plain": [ + " Open High Low Close Volume\n", + "Date \n", + "2019-12-31 71.42100 72.34200 71.31900 72.33500 102490623\n", + "2019-12-30 71.30500 72.10300 70.26000 71.81200 146380989\n", + "2019-12-27 71.71500 72.41500 70.97400 71.38800 148545967\n", + "2019-12-26 70.16400 71.43400 70.13500 71.41600 94722440\n", + "2019-12-24 70.13200 70.18100 69.69300 70.02700 49198965\n", + "... ... ... ... ... ...\n", + "1990-01-08 0.28723 0.29092 0.28319 0.29092 118470824\n", + "1990-01-05 0.28905 0.29268 0.28319 0.28905 143826725\n", + "1990-01-04 0.29268 0.29665 0.28504 0.28781 258365560\n", + "1990-01-03 0.29092 0.29092 0.28723 0.28723 242598119\n", + "1990-01-02 0.26979 0.28723 0.26793 0.28504 213676036\n", + "\n", + "[7558 rows x 5 columns]" + ] + }, + "execution_count": 3, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# adjust the variables below\n", + "ticker = 'AAPL'\n", + "start = datetime(1990,1,1)\n", + "end = datetime(2020,1,1)\n", + "\n", + "df = web.DataReader(ticker, 'stooq', start, end)\n", + "df" + ] + } + ], + "metadata": { + "interpreter": { + "hash": "366707ea24bdd07af2745ddffc3e5dd8201944abddf6c7f0911e7ecd4d105ee5" + }, + "kernelspec": { + "display_name": "Python 3.8.9 64-bit ('venv': venv)", + "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.8.9" + }, + "orig_nbformat": 4 + }, + "nbformat": 4, + "nbformat_minor": 2 +}