Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
79be2e6
Created using Colab
rixprakash Sep 12, 2024
a854f32
Created using Colab
rixprakash Sep 12, 2024
cdd7767
Created using Colab
rixprakash Sep 14, 2024
06f3428
Created using Colab
rixprakash Sep 14, 2024
3148a89
Created using Colab
rixprakash Sep 14, 2024
33f7dc3
Created using Colab
rixprakash Sep 14, 2024
1b6dd78
Created using Colab
rixprakash Sep 15, 2024
cebd120
Add files via upload
rixprakash Sep 19, 2024
da81a7d
Merge branch 'fourfeatherz:main' into main
rixprakash Sep 19, 2024
178d55b
Delete Labs_Pandas_and_CSV_Hands_On.ipynb
rixprakash Sep 19, 2024
742b4cd
Created using Colab
rixprakash Sep 19, 2024
e1d60c2
Created using Colab
rixprakash Sep 21, 2024
d43163d
Add files via upload
rixprakash Sep 21, 2024
08de27c
Delete nuf7jw_accbasketballhw.ipynb
rixprakash Sep 21, 2024
bfadc7a
Created using Colab
rixprakash Sep 21, 2024
685c0c1
Created using Colab
rixprakash Sep 22, 2024
0bd63f1
Created using Colab
rixprakash Sep 22, 2024
ef4a0da
Merge branch 'fourfeatherz:main' into main
rixprakash Sep 24, 2024
f46726b
Merge branch 'fourfeatherz:main' into main
rixprakash Sep 26, 2024
0f2c222
Created using Colab
rixprakash Sep 26, 2024
e33c02b
Created using Colab
rixprakash Sep 26, 2024
5275780
Created using Colab
rixprakash Sep 26, 2024
944fdde
Created using Colab
rixprakash Oct 1, 2024
bbcf6dc
Merge branch 'fourfeatherz:main' into main
rixprakash Oct 3, 2024
0bfb431
Created using Colab
rixprakash Oct 3, 2024
173b708
Created using Colab
rixprakash Oct 5, 2024
c280f4d
Created using Colab
rixprakash Oct 6, 2024
bb835eb
Created using Colab
rixprakash Oct 6, 2024
aeff2fd
Created using Colab
rixprakash Oct 8, 2024
4c99a5d
Merge branch 'fourfeatherz:main' into main
rixprakash Oct 17, 2024
8ad7ab2
Created using Colab
rixprakash Oct 17, 2024
911e6fe
Add files via upload
rixprakash Oct 17, 2024
3c33e29
Delete Crime_Data.csv
rixprakash Oct 17, 2024
34cecdb
Create file
rixprakash Oct 17, 2024
a1dff62
Add files via upload
rixprakash Oct 17, 2024
68adb4e
Delete dataproject1/file
rixprakash Oct 17, 2024
5b68800
Created using Colab
rixprakash Oct 17, 2024
955d43e
Created using Colab
rixprakash Oct 17, 2024
55881ae
Add files via upload
rixprakash Oct 18, 2024
786a593
Created using Colab
rixprakash Oct 18, 2024
dcced4f
Created using Colab
rixprakash Oct 20, 2024
9f75b86
Created using Colab
rixprakash Oct 20, 2024
eb253e1
Created using Colab
rixprakash Oct 21, 2024
3292d48
Created using Colab
rixprakash Oct 21, 2024
dab7326
Rename project1.ipynb to dataproject1/project1.ipynb
rixprakash Oct 21, 2024
9e3e51d
Add files via upload
rixprakash Oct 21, 2024
448e1a6
Created using Colab
rixprakash Oct 21, 2024
61ed58f
Created using Colab
rixprakash Oct 21, 2024
ec7ae80
Created using Colab
rixprakash Nov 26, 2024
b371d61
Created using Colab
rixprakash Nov 26, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
172 changes: 149 additions & 23 deletions Labs/Universities_and_Stock_API_Workshop.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"colab_type": "text"
},
"source": [
"<a href=\"https://colab.research.google.com/github/fourfeatherz/DS2002F24/blob/main/Labs/Universities_and_Stock_API_Workshop.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
"<a href=\"https://colab.research.google.com/github/rixprakash/DS2002F24/blob/main/Labs/Universities_and_Stock_API_Workshop.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
]
},
{
Expand All @@ -33,7 +33,7 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": null,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
Expand Down Expand Up @@ -81,7 +81,7 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": null,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
Expand Down Expand Up @@ -130,7 +130,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": null,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
Expand Down Expand Up @@ -621,7 +621,7 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": null,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
Expand Down Expand Up @@ -691,7 +691,7 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": null,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
Expand Down Expand Up @@ -736,7 +736,7 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": null,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
Expand Down Expand Up @@ -797,7 +797,7 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": null,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
Expand Down Expand Up @@ -873,7 +873,7 @@
"id": "80xOdsHQ2SzU"
},
"id": "80xOdsHQ2SzU",
"execution_count": null,
"execution_count": 1,
"outputs": []
},
{
Expand All @@ -883,32 +883,84 @@
"stock=input()"
],
"metadata": {
"id": "qdoW9lbM2Wes"
"id": "qdoW9lbM2Wes",
"colab": {
"base_uri": "https://localhost:8080/"
},
"outputId": "88b9c5f9-3302-4768-8671-360c22a0dcd1"
},
"id": "qdoW9lbM2Wes",
"execution_count": null,
"outputs": []
"execution_count": 40,
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"aaple,msft,spy\n"
]
}
]
},
{
"cell_type": "code",
"source": [
"print(\"The Stock we will research is:\" + stock)"
],
"metadata": {
"id": "Jb5ddkbl2YWF"
"id": "Jb5ddkbl2YWF",
"colab": {
"base_uri": "https://localhost:8080/"
},
"outputId": "dc2ac3bd-2ebc-465c-d48d-13efaceda542"
},
"id": "Jb5ddkbl2YWF",
"execution_count": null,
"outputs": []
"execution_count": 33,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"The Stock we will research is:apple,msft\n"
]
}
]
},
{
"cell_type": "code",
"source": [
"stocks = stock.split(\",\")\n",
"stocks"
],
"metadata": {
"id": "Y_YIXh7pZIio",
"outputId": "b4d1b6ad-a0e2-45d0-f575-cafb3a78b50b",
"colab": {
"base_uri": "https://localhost:8080/"
}
},
"id": "Y_YIXh7pZIio",
"execution_count": 35,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"['apple', 'msft']"
]
},
"metadata": {},
"execution_count": 35
}
]
},
{
"cell_type": "code",
"source": [
"apikey=\"yourkey\"\n",
"apikey=\"maeundD0dq1ZlJPU0OQHCXorzXNtNtJ2TOqRKOi9\"\n",
"\n",
"url = \"https://yfapi.net/v6/finance/quote\"\n",
"\n",
"querystring = {\"symbols\":stock}\n",
"querystring = {\"symbols\":stocks}\n",
"\n",
"headers = {\n",
" 'x-api-key': apikey\n",
Expand All @@ -919,11 +971,23 @@
"print(response.text)"
],
"metadata": {
"id": "pFKgjZlO2atU"
"id": "pFKgjZlO2atU",
"colab": {
"base_uri": "https://localhost:8080/"
},
"outputId": "6325c8f8-063d-424f-dedb-da90d1cd9c2b"
},
"id": "pFKgjZlO2atU",
"execution_count": null,
"outputs": []
"execution_count": 26,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"{\"quoteResponse\":{\"result\":[{\"language\":\"en-US\",\"region\":\"US\",\"quoteType\":\"EQUITY\",\"typeDisp\":\"Equity\",\"quoteSourceName\":\"Nasdaq Real Time Price\",\"triggerable\":true,\"customPriceAlertConfidence\":\"HIGH\",\"currency\":\"USD\",\"marketState\":\"REGULAR\",\"exchange\":\"NMS\",\"shortName\":\"Microsoft Corporation\",\"longName\":\"Microsoft Corporation\",\"messageBoardId\":\"finmb_21835\",\"exchangeTimezoneName\":\"America/New_York\",\"exchangeTimezoneShortName\":\"EDT\",\"gmtOffSetMilliseconds\":-14400000,\"market\":\"us_market\",\"esgPopulated\":false,\"regularMarketChangePercent\":-0.5698133,\"regularMarketPrice\":429.648,\"hasPrePostMarketData\":true,\"firstTradeDateMilliseconds\":511108200000,\"priceHint\":2,\"regularMarketChange\":-2.461975,\"regularMarketTime\":1727371833,\"regularMarketDayHigh\":435.24,\"regularMarketDayRange\":\"429.13 - 435.24\",\"regularMarketDayLow\":429.13,\"regularMarketVolume\":6643764,\"regularMarketPreviousClose\":432.11,\"bid\":429.5,\"ask\":429.8,\"bidSize\":1,\"askSize\":1,\"fullExchangeName\":\"NasdaqGS\",\"financialCurrency\":\"USD\",\"regularMarketOpen\":435.085,\"averageDailyVolume3Month\":20098431,\"averageDailyVolume10Day\":20725370,\"fiftyTwoWeekLowChange\":120.198,\"fiftyTwoWeekLowChangePercent\":0.3884246,\"fiftyTwoWeekRange\":\"309.45 - 468.35\",\"fiftyTwoWeekHighChange\":-38.701996,\"fiftyTwoWeekHighChangePercent\":-0.08263477,\"fiftyTwoWeekLow\":309.45,\"fiftyTwoWeekHigh\":468.35,\"fiftyTwoWeekChangePercent\":37.772606,\"dividendDate\":1733961600,\"earningsTimestamp\":1722369600,\"earningsTimestampStart\":1729594740,\"earningsTimestampEnd\":1730116800,\"earningsCallTimestampStart\":1722375000,\"earningsCallTimestampEnd\":1722375000,\"isEarningsDateEstimate\":true,\"trailingAnnualDividendRate\":3.0,\"trailingPE\":36.410847,\"dividendRate\":3.32,\"trailingAnnualDividendYield\":0.006942677,\"dividendYield\":0.77,\"epsTrailingTwelveMonths\":11.8,\"epsForward\":15.22,\"epsCurrentYear\":13.08,\"priceEpsCurrentYear\":32.847706,\"sharesOutstanding\":7433039872,\"bookValue\":36.115,\"fiftyDayAverage\":420.4014,\"fiftyDayAverageChange\":9.246613,\"fiftyDayAverageChangePercent\":0.021994723,\"twoHundredDayAverage\":414.8203,\"twoHundredDayAverageChange\":14.827698,\"twoHundredDayAverageChangePercent\":0.03574487,\"marketCap\":3193590775808,\"forwardPE\":28.229172,\"priceToBook\":11.896663,\"sourceInterval\":15,\"exchangeDataDelayedBy\":0,\"averageAnalystRating\":\"1.7 - Buy\",\"tradeable\":false,\"cryptoTradeable\":false,\"displayName\":\"Microsoft\",\"symbol\":\"MSFT\"}],\"error\":null}}\n"
]
}
]
},
{
"cell_type": "code",
Expand All @@ -933,11 +997,23 @@
"print(stock_json['quoteResponse']['result'][0][\"longName\"] + \" Price:$\" + str(stock_json['quoteResponse']['result'][0][\"regularMarketPrice\"]))"
],
"metadata": {
"id": "SVJqBY7y2eSs"
"id": "SVJqBY7y2eSs",
"colab": {
"base_uri": "https://localhost:8080/"
},
"outputId": "f38b07fe-2b87-457c-d06f-2c474432a84b"
},
"id": "SVJqBY7y2eSs",
"execution_count": null,
"outputs": []
"execution_count": 38,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"Microsoft Corporation Price:$429.62\n"
]
}
]
},
{
"cell_type": "markdown",
Expand All @@ -948,6 +1024,56 @@
"id": "9sqZZPI12leh"
},
"id": "9sqZZPI12leh"
},
{
"cell_type": "code",
"source": [
"import requests\n",
"\n",
"apikey = \"maeundD0dq1ZlJPU0OQHCXorzXNtNtJ2TOqRKOi9\"\n",
"\n",
"user_input = input(\"Enter stock symbols separated by commas:\")\n",
"stocks = user_input.split(\",\")\n",
"stock_symbols = \",\".join(stocks)\n",
"\n",
"url = \"https://yfapi.net/v6/finance/quote\"\n",
"\n",
"querystring = {\"symbols\": stock_symbols}\n",
"\n",
"headers = {\n",
" 'x-api-key': apikey\n",
"}\n",
"\n",
"response = requests.request(\"GET\", url, headers=headers, params=querystring)\n",
"stock_json = response.json()\n",
"\n",
"for stock in stock_json['quoteResponse']['result']:\n",
" stock_name = stock.get(\"longName\", \"N/A\") #n/a if stock name isn't there\n",
" stock_price = stock.get(\"regularMarketPrice\", \"N/A\") #n/a for when price isn't available\n",
" print(f\"{stock_name} Price: ${stock_price}\")\n",
"\n"
],
"metadata": {
"id": "c7HPrPYTaXbF",
"outputId": "9e0b0320-e409-4aa1-9ff5-193ce32df1b7",
"colab": {
"base_uri": "https://localhost:8080/"
}
},
"id": "c7HPrPYTaXbF",
"execution_count": 46,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"Enter stock symbols separated by commas:meta,aapl,msft\n",
"Meta Platforms, Inc. Price: $564.352\n",
"Apple Inc. Price: $227.44\n",
"Microsoft Corporation Price: $429.95\n"
]
}
]
}
],
"metadata": {
Expand Down
Loading