OnurKerimoglu commited on
Commit
96e657b
·
1 Parent(s): cc15f2b

introduced nb/finance_metric_providers.ipynb

Browse files
notebooks/finance_metric_providers.ipynb ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "code",
5
+ "execution_count": null,
6
+ "metadata": {},
7
+ "outputs": [],
8
+ "source": [
9
+ "import datetime as dt\n",
10
+ "import yfinance as yf\n",
11
+ "\n",
12
+ "ticker = 'TSLA'\n",
13
+ "period_start = dt.datetime.now() - dt.timedelta(weeks=12)\n",
14
+ "data = yf.download(\n",
15
+ " ticker,\n",
16
+ " start=period_start,\n",
17
+ " end=dt.datetime.now(),\n",
18
+ " interval='1d'\n",
19
+ ")\n",
20
+ "df= data.copy()\n",
21
+ "if len(df.columns[0]) > 1:\n",
22
+ " df.columns = [i[0] for i in df.columns]\n",
23
+ "data.reset_index(inplace=True)\n",
24
+ "data.Date = data.Date.astype(str)"
25
+ ]
26
+ },
27
+ {
28
+ "cell_type": "code",
29
+ "execution_count": null,
30
+ "metadata": {},
31
+ "outputs": [],
32
+ "source": [
33
+ "import os\n",
34
+ "import requests\n",
35
+ "# function = 'TIME_SERIES_INTRADAY'\n",
36
+ "function = 'INCOME_STATEMENT'\n",
37
+ "ticker = 'IBM'\n",
38
+ "av_api_key = os.environ.get(\"ALPHAVANTAGE_API_KEY\")\n",
39
+ "# url = f'https://www.alphavantage.co/query?function={function}&symbol={ticker}&interval=5min&apikey={av_api_key}'\n",
40
+ "url = (\n",
41
+ " f\"https://www.alphavantage.co/query?function={function}&\"\n",
42
+ " f\"symbol={ticker}&\"\n",
43
+ " f\"interval=5min&\"\n",
44
+ " f\"apikey={av_api_key}\"\n",
45
+ ")\n",
46
+ "r = requests.get(url)\n",
47
+ "data = r.json()\n",
48
+ "\n",
49
+ "print(data)"
50
+ ]
51
+ }
52
+ ],
53
+ "metadata": {
54
+ "kernelspec": {
55
+ "display_name": "finagents_py311",
56
+ "language": "python",
57
+ "name": "python3"
58
+ },
59
+ "language_info": {
60
+ "codemirror_mode": {
61
+ "name": "ipython",
62
+ "version": 3
63
+ },
64
+ "file_extension": ".py",
65
+ "mimetype": "text/x-python",
66
+ "name": "python",
67
+ "nbconvert_exporter": "python",
68
+ "pygments_lexer": "ipython3",
69
+ "version": "3.11.1"
70
+ }
71
+ },
72
+ "nbformat": 4,
73
+ "nbformat_minor": 2
74
+ }