mirror of
https://github.com/norandom/trading_analysis.git
synced 2024-11-01 05:25:13 +00:00
1209 lines
219 KiB
Plaintext
1209 lines
219 KiB
Plaintext
|
{
|
|||
|
"cells": [
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"id": "5ec09a1980f583e",
|
|||
|
"metadata": {
|
|||
|
"collapsed": false
|
|||
|
},
|
|||
|
"source": [
|
|||
|
"# Yahoo Finance Data DL\n",
|
|||
|
"\n",
|
|||
|
"* Download historical data for analysis (raw)"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"id": "4e7c6353ee2365ed",
|
|||
|
"metadata": {
|
|||
|
"collapsed": false
|
|||
|
},
|
|||
|
"source": [
|
|||
|
"## Install deps"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"execution_count": 32,
|
|||
|
"id": "initial_id",
|
|||
|
"metadata": {
|
|||
|
"ExecuteTime": {
|
|||
|
"end_time": "2024-03-09T12:57:50.171570Z",
|
|||
|
"start_time": "2024-03-09T12:57:46.685081Z"
|
|||
|
},
|
|||
|
"collapsed": true
|
|||
|
},
|
|||
|
"outputs": [
|
|||
|
{
|
|||
|
"name": "stdout",
|
|||
|
"output_type": "stream",
|
|||
|
"text": [
|
|||
|
"Requirement already satisfied: yfinance==0.2.37 in /home/marius/miniconda3/envs/lang_chain/lib/python3.11/site-packages (from yfinance[optional]==0.2.37) (0.2.37)\r\n",
|
|||
|
"Requirement already satisfied: pandas>=1.3.0 in /home/marius/miniconda3/envs/lang_chain/lib/python3.11/site-packages (from yfinance==0.2.37->yfinance[optional]==0.2.37) (2.2.1)\r\n",
|
|||
|
"Requirement already satisfied: numpy>=1.16.5 in /home/marius/miniconda3/envs/lang_chain/lib/python3.11/site-packages (from yfinance==0.2.37->yfinance[optional]==0.2.37) (1.26.4)\r\n",
|
|||
|
"Requirement already satisfied: requests>=2.31 in /home/marius/miniconda3/envs/lang_chain/lib/python3.11/site-packages (from yfinance==0.2.37->yfinance[optional]==0.2.37) (2.31.0)\r\n",
|
|||
|
"Requirement already satisfied: multitasking>=0.0.7 in /home/marius/miniconda3/envs/lang_chain/lib/python3.11/site-packages (from yfinance==0.2.37->yfinance[optional]==0.2.37) (0.0.11)\r\n",
|
|||
|
"Requirement already satisfied: lxml>=4.9.1 in /home/marius/miniconda3/envs/lang_chain/lib/python3.11/site-packages (from yfinance==0.2.37->yfinance[optional]==0.2.37) (5.1.0)\r\n",
|
|||
|
"Requirement already satisfied: appdirs>=1.4.4 in /home/marius/miniconda3/envs/lang_chain/lib/python3.11/site-packages (from yfinance==0.2.37->yfinance[optional]==0.2.37) (1.4.4)\r\n",
|
|||
|
"Requirement already satisfied: pytz>=2022.5 in /home/marius/miniconda3/envs/lang_chain/lib/python3.11/site-packages (from yfinance==0.2.37->yfinance[optional]==0.2.37) (2024.1)\r\n",
|
|||
|
"Requirement already satisfied: frozendict>=2.3.4 in /home/marius/miniconda3/envs/lang_chain/lib/python3.11/site-packages (from yfinance==0.2.37->yfinance[optional]==0.2.37) (2.4.0)\r\n",
|
|||
|
"Requirement already satisfied: peewee>=3.16.2 in /home/marius/miniconda3/envs/lang_chain/lib/python3.11/site-packages (from yfinance==0.2.37->yfinance[optional]==0.2.37) (3.17.1)\r\n",
|
|||
|
"Requirement already satisfied: beautifulsoup4>=4.11.1 in /home/marius/miniconda3/envs/lang_chain/lib/python3.11/site-packages (from yfinance==0.2.37->yfinance[optional]==0.2.37) (4.12.3)\r\n",
|
|||
|
"Requirement already satisfied: html5lib>=1.1 in /home/marius/miniconda3/envs/lang_chain/lib/python3.11/site-packages (from yfinance==0.2.37->yfinance[optional]==0.2.37) (1.1)\r\n",
|
|||
|
"\u001b[33mWARNING: yfinance 0.2.37 does not provide the extra 'optional'\u001b[0m\u001b[33m\r\n",
|
|||
|
"\u001b[0mRequirement already satisfied: soupsieve>1.2 in /home/marius/miniconda3/envs/lang_chain/lib/python3.11/site-packages (from beautifulsoup4>=4.11.1->yfinance==0.2.37->yfinance[optional]==0.2.37) (2.5)\r\n",
|
|||
|
"Requirement already satisfied: six>=1.9 in /home/marius/miniconda3/envs/lang_chain/lib/python3.11/site-packages (from html5lib>=1.1->yfinance==0.2.37->yfinance[optional]==0.2.37) (1.16.0)\r\n",
|
|||
|
"Requirement already satisfied: webencodings in /home/marius/miniconda3/envs/lang_chain/lib/python3.11/site-packages (from html5lib>=1.1->yfinance==0.2.37->yfinance[optional]==0.2.37) (0.5.1)\r\n",
|
|||
|
"Requirement already satisfied: python-dateutil>=2.8.2 in /home/marius/miniconda3/envs/lang_chain/lib/python3.11/site-packages (from pandas>=1.3.0->yfinance==0.2.37->yfinance[optional]==0.2.37) (2.9.0)\r\n",
|
|||
|
"Requirement already satisfied: tzdata>=2022.7 in /home/marius/miniconda3/envs/lang_chain/lib/python3.11/site-packages (from pandas>=1.3.0->yfinance==0.2.37->yfinance[optional]==0.2.37) (2024.1)\r\n",
|
|||
|
"Requirement already satisfied: charset-normalizer<4,>=2 in /home/marius/miniconda3/envs/lang_chain/lib/python3.11/site-packages (from requests>=2.31->yfinance==0.2.37->yfinance[optional]==0.2.37) (3.3.2)\r\n",
|
|||
|
"Requirement already satisfied: idna<4,>=2.5 in /home/marius/miniconda3/envs/lang_chain/lib/python3.11/site-packages (from requests>=2.31->yfinance==0.2.37->yfinance[optional]==0.2.37) (3.6)\r\n",
|
|||
|
"Requirement already satisfied: urllib3<3,>=1.21.1 in /home/marius/miniconda3/envs/lang_chain/lib/python3.11/site-packages (from requests>=2.31->yfinance==0.2.37->yfinance[optional]==0.2.37) (2.2.1)\r\n",
|
|||
|
"Requirement already satisfied: certifi>=2017.4.17 in /home/marius/miniconda3/envs/lang_chain/lib/python3.11/site-packages (from requests>=2.31->yfinance==0.2.37->yfinance[optional]==0.2.37) (2024.2.2)\r\n",
|
|||
|
"Note: you may need to restart the kernel to use updated packages.\n"
|
|||
|
]
|
|||
|
}
|
|||
|
],
|
|||
|
"source": [
|
|||
|
"%pip install \"yfinance[optional]\"==\"0.2.37\""
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"id": "48b1ebb620c74042",
|
|||
|
"metadata": {
|
|||
|
"collapsed": false
|
|||
|
},
|
|||
|
"source": [
|
|||
|
"## DL\n",
|
|||
|
"\n",
|
|||
|
"* HG=F - Copper"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"execution_count": 33,
|
|||
|
"id": "7d72d656bb3bef8d",
|
|||
|
"metadata": {
|
|||
|
"ExecuteTime": {
|
|||
|
"end_time": "2024-03-09T12:57:52.729521Z",
|
|||
|
"start_time": "2024-03-09T12:57:52.705820Z"
|
|||
|
},
|
|||
|
"collapsed": false
|
|||
|
},
|
|||
|
"outputs": [],
|
|||
|
"source": [
|
|||
|
"import yfinance as yf\n",
|
|||
|
"\n",
|
|||
|
"hg_f = yf.Ticker(\"HG=F\")"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"execution_count": 34,
|
|||
|
"id": "cd6f3f72c56be9a1",
|
|||
|
"metadata": {
|
|||
|
"ExecuteTime": {
|
|||
|
"end_time": "2024-03-09T12:57:54.067233Z",
|
|||
|
"start_time": "2024-03-09T12:57:53.991242Z"
|
|||
|
},
|
|||
|
"collapsed": false
|
|||
|
},
|
|||
|
"outputs": [
|
|||
|
{
|
|||
|
"data": {
|
|||
|
"text/plain": [
|
|||
|
"{'maxAge': 86400,\n",
|
|||
|
" 'priceHint': 4,\n",
|
|||
|
" 'previousClose': 3.926,\n",
|
|||
|
" 'open': 3.9255,\n",
|
|||
|
" 'dayLow': 3.8815,\n",
|
|||
|
" 'dayHigh': 3.9465,\n",
|
|||
|
" 'regularMarketPreviousClose': 3.926,\n",
|
|||
|
" 'regularMarketOpen': 3.9255,\n",
|
|||
|
" 'regularMarketDayLow': 3.8815,\n",
|
|||
|
" 'regularMarketDayHigh': 3.9465,\n",
|
|||
|
" 'volume': 80624,\n",
|
|||
|
" 'regularMarketVolume': 80624,\n",
|
|||
|
" 'averageVolume': 1088,\n",
|
|||
|
" 'averageVolume10days': 4041,\n",
|
|||
|
" 'averageDailyVolume10Day': 4041,\n",
|
|||
|
" 'bid': 3.8905,\n",
|
|||
|
" 'ask': 3.8915,\n",
|
|||
|
" 'bidSize': 800,\n",
|
|||
|
" 'askSize': 1200,\n",
|
|||
|
" 'expireDate': 1716940800,\n",
|
|||
|
" 'openInterest': 126184,\n",
|
|||
|
" 'fiftyTwoWeekLow': 3.53,\n",
|
|||
|
" 'fiftyTwoWeekHigh': 4.1895,\n",
|
|||
|
" 'fiftyDayAverage': 3.81898,\n",
|
|||
|
" 'twoHundredDayAverage': 3.7641976,\n",
|
|||
|
" 'currency': 'USD',\n",
|
|||
|
" 'exchange': 'CMX',\n",
|
|||
|
" 'quoteType': 'FUTURE',\n",
|
|||
|
" 'symbol': 'HGK24.CMX',\n",
|
|||
|
" 'underlyingSymbol': 'HG=F',\n",
|
|||
|
" 'shortName': 'Copper May 24',\n",
|
|||
|
" 'firstTradeDateEpochUtc': 967608000,\n",
|
|||
|
" 'timeZoneFullName': 'America/New_York',\n",
|
|||
|
" 'timeZoneShortName': 'EST',\n",
|
|||
|
" 'uuid': '02846b86-92eb-33ab-a801-f9b43107619f',\n",
|
|||
|
" 'gmtOffSetMilliseconds': -18000000,\n",
|
|||
|
" 'trailingPegRatio': None}"
|
|||
|
]
|
|||
|
},
|
|||
|
"execution_count": 34,
|
|||
|
"metadata": {},
|
|||
|
"output_type": "execute_result"
|
|||
|
}
|
|||
|
],
|
|||
|
"source": [
|
|||
|
"# get all stock info\n",
|
|||
|
"hg_f.info"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"execution_count": 43,
|
|||
|
"id": "89fddac643750762",
|
|||
|
"metadata": {
|
|||
|
"ExecuteTime": {
|
|||
|
"end_time": "2024-03-09T13:09:14.698670Z",
|
|||
|
"start_time": "2024-03-09T13:09:14.621937Z"
|
|||
|
},
|
|||
|
"collapsed": false
|
|||
|
},
|
|||
|
"outputs": [
|
|||
|
{
|
|||
|
"data": {
|
|||
|
"text/html": [
|
|||
|
"<div>\n",
|
|||
|
"<style scoped>\n",
|
|||
|
" .dataframe tbody tr th:only-of-type {\n",
|
|||
|
" vertical-align: middle;\n",
|
|||
|
" }\n",
|
|||
|
"\n",
|
|||
|
" .dataframe tbody tr th {\n",
|
|||
|
" vertical-align: top;\n",
|
|||
|
" }\n",
|
|||
|
"\n",
|
|||
|
" .dataframe thead th {\n",
|
|||
|
" text-align: right;\n",
|
|||
|
" }\n",
|
|||
|
"</style>\n",
|
|||
|
"<table border=\"1\" class=\"dataframe\">\n",
|
|||
|
" <thead>\n",
|
|||
|
" <tr style=\"text-align: right;\">\n",
|
|||
|
" <th></th>\n",
|
|||
|
" <th>Open</th>\n",
|
|||
|
" <th>High</th>\n",
|
|||
|
" <th>Low</th>\n",
|
|||
|
" <th>Close</th>\n",
|
|||
|
" <th>Volume</th>\n",
|
|||
|
" <th>Dividends</th>\n",
|
|||
|
" <th>Stock Splits</th>\n",
|
|||
|
" </tr>\n",
|
|||
|
" <tr>\n",
|
|||
|
" <th>Date</th>\n",
|
|||
|
" <th></th>\n",
|
|||
|
" <th></th>\n",
|
|||
|
" <th></th>\n",
|
|||
|
" <th></th>\n",
|
|||
|
" <th></th>\n",
|
|||
|
" <th></th>\n",
|
|||
|
" <th></th>\n",
|
|||
|
" </tr>\n",
|
|||
|
" </thead>\n",
|
|||
|
" <tbody>\n",
|
|||
|
" <tr>\n",
|
|||
|
" <th>2023-03-09 00:00:00-05:00</th>\n",
|
|||
|
" <td>4.0465</td>\n",
|
|||
|
" <td>4.0565</td>\n",
|
|||
|
" <td>4.0300</td>\n",
|
|||
|
" <td>4.0545</td>\n",
|
|||
|
" <td>584</td>\n",
|
|||
|
" <td>NaN</td>\n",
|
|||
|
" <td>NaN</td>\n",
|
|||
|
" </tr>\n",
|
|||
|
" <tr>\n",
|
|||
|
" <th>2023-03-10 00:00:00-05:00</th>\n",
|
|||
|
" <td>4.0120</td>\n",
|
|||
|
" <td>4.0675</td>\n",
|
|||
|
" <td>3.9900</td>\n",
|
|||
|
" <td>4.0455</td>\n",
|
|||
|
" <td>591</td>\n",
|
|||
|
" <td>NaN</td>\n",
|
|||
|
" <td>NaN</td>\n",
|
|||
|
" </tr>\n",
|
|||
|
" <tr>\n",
|
|||
|
" <th>2023-03-13 00:00:00-04:00</th>\n",
|
|||
|
" <td>4.0230</td>\n",
|
|||
|
" <td>4.0800</td>\n",
|
|||
|
" <td>3.9460</td>\n",
|
|||
|
" <td>4.0695</td>\n",
|
|||
|
" <td>842</td>\n",
|
|||
|
" <td>NaN</td>\n",
|
|||
|
" <td>NaN</td>\n",
|
|||
|
" </tr>\n",
|
|||
|
" <tr>\n",
|
|||
|
" <th>2023-03-14 00:00:00-04:00</th>\n",
|
|||
|
" <td>4.0395</td>\n",
|
|||
|
" <td>4.0620</td>\n",
|
|||
|
" <td>4.0010</td>\n",
|
|||
|
" <td>4.0105</td>\n",
|
|||
|
" <td>923</td>\n",
|
|||
|
" <td>NaN</td>\n",
|
|||
|
" <td>NaN</td>\n",
|
|||
|
" </tr>\n",
|
|||
|
" <tr>\n",
|
|||
|
" <th>2023-03-15 00:00:00-04:00</th>\n",
|
|||
|
" <td>4.0210</td>\n",
|
|||
|
" <td>4.0210</td>\n",
|
|||
|
" <td>3.8565</td>\n",
|
|||
|
" <td>3.8565</td>\n",
|
|||
|
" <td>875</td>\n",
|
|||
|
" <td>NaN</td>\n",
|
|||
|
" <td>NaN</td>\n",
|
|||
|
" </tr>\n",
|
|||
|
" <tr>\n",
|
|||
|
" <th>...</th>\n",
|
|||
|
" <td>...</td>\n",
|
|||
|
" <td>...</td>\n",
|
|||
|
" <td>...</td>\n",
|
|||
|
" <td>...</td>\n",
|
|||
|
" <td>...</td>\n",
|
|||
|
" <td>...</td>\n",
|
|||
|
" <td>...</td>\n",
|
|||
|
" </tr>\n",
|
|||
|
" <tr>\n",
|
|||
|
" <th>2024-03-04 00:00:00-05:00</th>\n",
|
|||
|
" <td>3.8450</td>\n",
|
|||
|
" <td>3.8815</td>\n",
|
|||
|
" <td>3.8435</td>\n",
|
|||
|
" <td>3.8520</td>\n",
|
|||
|
" <td>1136</td>\n",
|
|||
|
" <td>NaN</td>\n",
|
|||
|
" <td>NaN</td>\n",
|
|||
|
" </tr>\n",
|
|||
|
" <tr>\n",
|
|||
|
" <th>2024-03-05 00:00:00-05:00</th>\n",
|
|||
|
" <td>3.8465</td>\n",
|
|||
|
" <td>3.8630</td>\n",
|
|||
|
" <td>3.8380</td>\n",
|
|||
|
" <td>3.8440</td>\n",
|
|||
|
" <td>929</td>\n",
|
|||
|
" <td>NaN</td>\n",
|
|||
|
" <td>NaN</td>\n",
|
|||
|
" </tr>\n",
|
|||
|
" <tr>\n",
|
|||
|
" <th>2024-03-06 00:00:00-05:00</th>\n",
|
|||
|
" <td>3.8400</td>\n",
|
|||
|
" <td>3.8915</td>\n",
|
|||
|
" <td>3.8375</td>\n",
|
|||
|
" <td>3.8705</td>\n",
|
|||
|
" <td>987</td>\n",
|
|||
|
" <td>NaN</td>\n",
|
|||
|
" <td>NaN</td>\n",
|
|||
|
" </tr>\n",
|
|||
|
" <tr>\n",
|
|||
|
" <th>2024-03-07 00:00:00-05:00</th>\n",
|
|||
|
" <td>3.8740</td>\n",
|
|||
|
" <td>3.9310</td>\n",
|
|||
|
" <td>3.8740</td>\n",
|
|||
|
" <td>3.9195</td>\n",
|
|||
|
" <td>1243</td>\n",
|
|||
|
" <td>NaN</td>\n",
|
|||
|
" <td>NaN</td>\n",
|
|||
|
" </tr>\n",
|
|||
|
" <tr>\n",
|
|||
|
" <th>2024-03-08 00:00:00-05:00</th>\n",
|
|||
|
" <td>3.9175</td>\n",
|
|||
|
" <td>3.9320</td>\n",
|
|||
|
" <td>3.8780</td>\n",
|
|||
|
" <td>3.8850</td>\n",
|
|||
|
" <td>1243</td>\n",
|
|||
|
" <td>NaN</td>\n",
|
|||
|
" <td>NaN</td>\n",
|
|||
|
" </tr>\n",
|
|||
|
" </tbody>\n",
|
|||
|
"</table>\n",
|
|||
|
"<p>252 rows × 7 columns</p>\n",
|
|||
|
"</div>"
|
|||
|
],
|
|||
|
"text/plain": [
|
|||
|
" Open High Low Close Volume Dividends \\\n",
|
|||
|
"Date \n",
|
|||
|
"2023-03-09 00:00:00-05:00 4.0465 4.0565 4.0300 4.0545 584 NaN \n",
|
|||
|
"2023-03-10 00:00:00-05:00 4.0120 4.0675 3.9900 4.0455 591 NaN \n",
|
|||
|
"2023-03-13 00:00:00-04:00 4.0230 4.0800 3.9460 4.0695 842 NaN \n",
|
|||
|
"2023-03-14 00:00:00-04:00 4.0395 4.0620 4.0010 4.0105 923 NaN \n",
|
|||
|
"2023-03-15 00:00:00-04:00 4.0210 4.0210 3.8565 3.8565 875 NaN \n",
|
|||
|
"... ... ... ... ... ... ... \n",
|
|||
|
"2024-03-04 00:00:00-05:00 3.8450 3.8815 3.8435 3.8520 1136 NaN \n",
|
|||
|
"2024-03-05 00:00:00-05:00 3.8465 3.8630 3.8380 3.8440 929 NaN \n",
|
|||
|
"2024-03-06 00:00:00-05:00 3.8400 3.8915 3.8375 3.8705 987 NaN \n",
|
|||
|
"2024-03-07 00:00:00-05:00 3.8740 3.9310 3.8740 3.9195 1243 NaN \n",
|
|||
|
"2024-03-08 00:00:00-05:00 3.9175 3.9320 3.8780 3.8850 1243 NaN \n",
|
|||
|
"\n",
|
|||
|
" Stock Splits \n",
|
|||
|
"Date \n",
|
|||
|
"2023-03-09 00:00:00-05:00 NaN \n",
|
|||
|
"2023-03-10 00:00:00-05:00 NaN \n",
|
|||
|
"2023-03-13 00:00:00-04:00 NaN \n",
|
|||
|
"2023-03-14 00:00:00-04:00 NaN \n",
|
|||
|
"2023-03-15 00:00:00-04:00 NaN \n",
|
|||
|
"... ... \n",
|
|||
|
"2024-03-04 00:00:00-05:00 NaN \n",
|
|||
|
"2024-03-05 00:00:00-05:00 NaN \n",
|
|||
|
"2024-03-06 00:00:00-05:00 NaN \n",
|
|||
|
"2024-03-07 00:00:00-05:00 NaN \n",
|
|||
|
"2024-03-08 00:00:00-05:00 NaN \n",
|
|||
|
"\n",
|
|||
|
"[252 rows x 7 columns]"
|
|||
|
]
|
|||
|
},
|
|||
|
"execution_count": 43,
|
|||
|
"metadata": {},
|
|||
|
"output_type": "execute_result"
|
|||
|
}
|
|||
|
],
|
|||
|
"source": [
|
|||
|
"import pandas as pd\n",
|
|||
|
"import numpy as np\n",
|
|||
|
"\n",
|
|||
|
"# get historical market data\n",
|
|||
|
"hist = hg_f.history(period=\"1y\")\n",
|
|||
|
"\n",
|
|||
|
"# Replace 0 values with NaN in specific columns\n",
|
|||
|
"hist.replace({'Volume': {0: pd.NA}, 'Open': {0: pd.NA}}, inplace=True)\n",
|
|||
|
"hist.replace(0, np.nan, inplace=True) # Replace 0 with NaN\n",
|
|||
|
"\n",
|
|||
|
"# Drop rows with NaN values in these specific columns\n",
|
|||
|
"hist.dropna(subset=['Volume', 'Open'], inplace=True)\n",
|
|||
|
"\n",
|
|||
|
"hist\n"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"execution_count": 45,
|
|||
|
"id": "1593cdb6a096c786",
|
|||
|
"metadata": {
|
|||
|
"ExecuteTime": {
|
|||
|
"end_time": "2024-03-09T13:09:57.377149Z",
|
|||
|
"start_time": "2024-03-09T13:09:57.083539Z"
|
|||
|
},
|
|||
|
"collapsed": false
|
|||
|
},
|
|||
|
"outputs": [
|
|||
|
{
|
|||
|
"data": {
|
|||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAmwAAAHqCAYAAAC5lBJ9AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjguMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/H5lhTAAAACXBIWXM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mJiNGvWLOdz4WI2m03Dhg3TBx98oEaNGslut2vJkiWSpBdffFG33XabKleurKCgIDVt2jTfS74X9jF//nw1bNhQQUFBio+P1/bt2yVJs2bNUr169RQYGKjWrVtzTx+QD86wAaXIZ599pujoaLVo0SLf9S1btlR0dLS++OKLPOv69Omj6OhoTZ48WevWrdOrr76qkydP6r333nPOmTRpkp555hn16dNHf/vb33Ts2DG99tpratmypTZv3qwKFSo45548eVKdO3dWr1691KdPH3388cd68skndeONN6pLly5uP7bs7Gz98ssvqly5ssv4nDlzdPbsWQ0ZMkR2u12VKlVSbm5unu23bdumFi1ayN/fX0OGDFF0dLT27t2rzz77TJMmTZIkHTlyRLfeeqszYFStWlWLFy/W4MGDlZGRoREjRhSqzt9//z3PeHp6+hW3PXr0qDp27KiqVatqzJgxqlChgg4cOKAFCxZIkqpWraqkpCT9/e9/V8+ePdWrVy9JUlxcnCRp+fLl6tKli+rWrauEhAT98ccfeu2113T77bdr06ZNio6OliRt3rxZnTt3VmRkpBITE5WTk6MJEybkCfkXrFy5Uv/+9781bNgwValSxbmfV155RXfddZf69++vc+fOad68ebr77rv1+eefq2vXri77+Prrr/Xpp59q6NChkqTJkyfrzjvv1BNPPKGZM2fq0Ucf1cmTJzV16lQNGjRIK1euvGK/gGuKBaBUOHXqlCXJ6t69+2Xn3XXXXZYkKyMjw7Isyxo/frwlybrrrrtc5j366KOWJGvr1q2WZVnWgQMHLD8/P2vSpEku87Zv326VLVvWZbxVq1aWJOu9995zjjkcDisiIsLq3bv3FR9L7dq1rY4dO1rHjh2zjh07Zm3dutXq27evJcl67LHHLMuyrP3791uSrNDQUOvo0aMu219YN2fOHOdYy5YtrZCQEOvgwYMuc3Nzc51/Hjx4sBUZGWn9/vvvLnP69u1rhYWFWVlZWVesW9Jlf+bPn++cP2fOHEuStX//fsuyLGvhwoWWJOv7778v8BjHjh2zJFnjx4/Ps65JkyZWeHi4dfz4cefY1q1brTJlylgDBgxwjnXr1s0KDg62fvvtN+fY7t27rb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RZlurUqaMGDRpctcdwNVz4CJMdO3YUOKdq1aoKCQlRTk5OoYLi1XTrrbfq1ltv1aRJk5ScnKz+/ftr3rx5+tvf/pbv2Svp/GfPSdKuXbvyrPvpp59UpUoVlStXToGBgQoMDNSePXvyzMtvrCCffPKJAgMDlZKS4nL2b86cOYXeB4DC4x42oBT5xz/+oaCgID388MM6fvy4y7oTJ07okUceUXBwsP7xj3/k2XbGjBkuy6+99pokOe9r6tWrl/z8/JSYmJjn7IdlWXmOZ5KqVauqZcuWeuedd3To0CGXdRcei5+fn3r37q1PPvkk32B37Nixq17nyZMn8/S2SZMmkuS85BgcHCxJOnXqlMu8yMhINWnSRO+++67Luh07dmjp0qW64447JJ1/nO3bt9eiRYuUmprqnLdnzx4tXry40LX6+fnJZrMpJyfHOXbgwAEtWrSo0PsAUHicYQNKkfr16+vdd99V//79deONN+b5poPff/9dH374oWJiYvJsu3//ft11113q3Lmz1q5dq/fff1/9+vVT48aNJZ0/wzZx4kSNHTt
|
|||
|
"text/plain": [
|
|||
|
"<Figure size 1200x500 with 1 Axes>"
|
|||
|
]
|
|||
|
},
|
|||
|
"metadata": {},
|
|||
|
"output_type": "display_data"
|
|||
|
}
|
|||
|
],
|
|||
|
"source": [
|
|||
|
"import matplotlib.pyplot as plt\n",
|
|||
|
"# Assuming 'data' is your DataFrame\n",
|
|||
|
"plt.figure(figsize=(12, 5))\n",
|
|||
|
"\n",
|
|||
|
"\n",
|
|||
|
"\n",
|
|||
|
"# Plotting Open\n",
|
|||
|
"plt.subplot(1, 2, 2)\n",
|
|||
|
"hist['Open'].hist(bins=20)\n",
|
|||
|
"plt.title('Open Price Histogram')\n",
|
|||
|
"plt.xlabel('Open Price')\n",
|
|||
|
"plt.ylabel('Frequency')\n",
|
|||
|
"\n",
|
|||
|
"plt.tight_layout()\n",
|
|||
|
"plt.show()"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"execution_count": 48,
|
|||
|
"id": "b4055c5600389958",
|
|||
|
"metadata": {
|
|||
|
"ExecuteTime": {
|
|||
|
"end_time": "2024-03-09T13:12:19.024137Z",
|
|||
|
"start_time": "2024-03-09T13:12:18.618590Z"
|
|||
|
},
|
|||
|
"collapsed": false
|
|||
|
},
|
|||
|
"outputs": [
|
|||
|
{
|
|||
|
"data": {
|
|||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAA04AAAIICAYAAABZ1r5EAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjguMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/H5lhTAAAACXBIWXMAAA9hAAAPYQGoP6dpAADhtElEQVR4nOzdd3wb9f0/8Ndpy0PeI7GdOLGdRQYZJGSzEkKY/VJWgQClBQq08KOlbdrSAoWGFiizpaEEKGW1UKAFAiGBBEggZG+SOMOx4xFvy9Ye9/vj7nPasiRr6/18PHgQy2fprJOle997fDie53kQQgghhBBCCAlIlugdIIQQQgghhJBkR4ETIYQQQgghhAyCAidCCCGEEEIIGQQFToQQQgghhBAyCAqcCCGEEEIIIWQQFDgRQgghhBBCyCAocCKEEEIIIYSQQVDgRAghhBBCCCGDoMCJEEIIIYQQQgZBgRMhhJCk1dDQAI7j8PLLLyd6V9JGdXU1brzxxkTvBiGEpBwKnAghJInt378f1113HSoqKqBWqzF8+HBce+212L9/f6J3LSTV1dXgOE76r7S0FPPnz8e7776b6F0blM1mw9NPP40zzjgDubm5yMnJwRlnnIGnn34aNpst0bsn2bBhg8dzHOw/QgghkeN4nucTvROEEEJ8vfPOO7jmmmtQWFiIm2++GaNGjUJDQwNWrVqFrq4uvPnmm/jOd76T6N0Mqrq6GgUFBfjpT38KAGhpacHKlStx7NgxPPfcc7jtttuC/jzP87BYLFAqlZDL5fHYZQCAwWDAhRdeiM8//xwXXXQRlixZAplMho8//hj/+9//sHDhQnz44YfIzs6O2z4FcurUKaxdu9bjtuXLlyMnJwe//vWvPW6/7rrrYLFYIJPJoFQq47mbhBCS8ihwIoSQJHT06FFMnjwZI0aMwBdffIGSkhLpe52dnZg/fz6ampqwZ88ejB49OoF7Glx1dTUmTpyIDz74QLqtra0NtbW1qKiowKFDh/z+nN1uh9PphEqliteuerj11lvx/PPP45lnnsGdd97p8b2//OUvuPPOO3Hbbbfhueeei9s+8TwPs9kMrVY76LYTJ05EcXExNmzYEPsdI4SQDEGleoQQkoQeffRRGI1GPP/88x5BEwAUFxdj5cqVMBgM+NOf/iTdfv/994PjOBw8eBBXXnkldDodioqKcNddd8FsNvs8xquvvorp06dDq9WisLAQV199NZqamjy2OeusszBx4kQcOHAAZ599NrKyslBRUeHxuOEqLy/H+PHjcfz4cQCuPqbHHnsMTz75JGpqaqBWq3HgwIGAPU7sdywpKYFWq8XYsWN9sivNzc34/ve/j7KyMqjVapx22ml48cUXB92/kydPYtWqVTjnnHN8giYAuOOOO3D22WfjhRdewMmTJwEIgcrZZ5/ts63T6URFRQW++93vetz25JNP4rTTToNGo0FZWRluvfVW9PT0ePxsdXU1LrroIqxZswYzZsyAVqvFypUrB93/wXj3OL388svgOA4bN27ET37yE5SUlCA/Px+33norrFYrent7sWzZMhQUFKCgoAA///nP4X3NNdTfiRBCUhkFToQQkoTef/99VFdXY/78+X6/v2DBAlRXV+PDDz/0+d6VV14Js9mMFStWYOnSpXj66adxyy23eGzz8MMPY9myZairq8Of//xn3H333fj000+xYMEC9Pb2emzb09ODJUuWYMqUKXj88ccxbtw4/OIXv8BHH30U0e9ms9nQ1NSEoqIij9tfeuklPPPMM7jlllvw+OOPo7Cw0O/P79mzB7NmzcJnn32GH/7wh3jqqadw2WWX4f3335e2OXXqFM4880ysW7cOd955J5566inU1tbi5ptvxpNPPhl0/z766CM4HA4sW7Ys4DbLli2D3W7Hxx9/DAC46qqr8MUXX6Ctrc1ju40bN6KlpQVXX321dNutt96Ke++9F3PnzsVTTz2Fm266Ca+99hrOP/98n96pQ4cO4ZprrsGiRYvw1FNP4fTTTw+670Px4x//GPX19XjggQdwySWX4Pn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6+vR19eH0tLSkPYrlOckWrwD0by8PABAVVWVz+3uvUvh/k6EEJKqKHAihJAkk5eXh2HDhg0amOzZswcVFRXQ6XRBt/MOepxOJziOw0cffeR3xHdOTo7H14HGgPMhDmUtLi7GeeedN+h2oUyLC4XT6QQgjN6+4YYb/G4zefLkgD8/fvx4AMLzG6iniB2bCRMmSLddddVVWL58Od566y3cfffd+Pe//428vDwsWbLEY99KS0vx2muv+b1f74xbtJ6TUAQ6zv5udz/24f5OhBCSqihwIoSQJHTRRRfh73//OzZu3Ih58+b5fP/LL79EQ0MDbr31Vp/v1dfXe2Qqjhw5AqfTierqagBCBorneYwaNQpjxoyJ2e8QC2z0+r59+wJuU1JSgtzcXDgcjpACNm8XXHAB5HI5/vnPfwYcEPHKK69AoVB4BEWjRo3CzJkz8a9//Qt33nkn3nnnHVx22WVQq9XSNjU1NVi3bh3mzp0b16AoltLxdyKEEH+ox4kQQpLQvffeC61Wi1tvvRVdXV0e3+vu7sZtt92GrKws3HvvvT4/+5e//MXj62eeeQaAEBAAwP/93/9BLpfjgQce8Mka8Tzv83jJpKSkBAsWLMCLL76IxsZGj++x30Uul+Pyyy/Hf/7zH78BVkdHR9DHqKqqwk033YR169b5Xafpb3/7Gz777DPcfPPNqKys9PjeVVddhc2bN+PFF19EZ2enR5keIEw8dDgc+P3vf+9zv3a73WeiYSpIx9+JEEL8oYwTIYQkobq6OvzjH//Atddei0mTJuHmm2/GqFGj0NDQgFWrVqGzsxNvvPEGampqfH72+PHjuOSSS7BkyRJ8/fXXePXVV/G9730PU6ZMASBkCB566CEsX74cDQ0NuOyyy5Cbm4vjx4/j3XffxS233IKf/exn8f6VQ/b
|
|||
|
"text/plain": [
|
|||
|
"<Figure size 1000x600 with 1 Axes>"
|
|||
|
]
|
|||
|
},
|
|||
|
"metadata": {},
|
|||
|
"output_type": "display_data"
|
|||
|
}
|
|||
|
],
|
|||
|
"source": [
|
|||
|
"import pandas as pd\n",
|
|||
|
"import numpy as np\n",
|
|||
|
"import matplotlib.pyplot as plt\n",
|
|||
|
"\n",
|
|||
|
"\n",
|
|||
|
"\n",
|
|||
|
"# Plotting the 'Open' price as a line plot\n",
|
|||
|
"plt.figure(figsize=(10, 6))\n",
|
|||
|
"hist['Open'].plot(kind='line', title='Open Price Over Time', xlabel='Date', ylabel='Open Price')\n",
|
|||
|
"plt.grid(True)\n",
|
|||
|
"plt.show()\n"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"execution_count": 50,
|
|||
|
"id": "d52316a08ff9b66c",
|
|||
|
"metadata": {
|
|||
|
"ExecuteTime": {
|
|||
|
"end_time": "2024-03-09T13:14:26.336620Z",
|
|||
|
"start_time": "2024-03-09T13:14:25.884041Z"
|
|||
|
},
|
|||
|
"collapsed": false
|
|||
|
},
|
|||
|
"outputs": [
|
|||
|
{
|
|||
|
"data": {
|
|||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAA04AAAIICAYAAABZ1r5EAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjguMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/H5lhTAAAACXBIWXMAAA9hAAAPYQGoP6dpAADzmElEQVR4nOzdd3wUdfoH8M9s3ySbXkkCoSMgSJFeleKhgEZOERX1UEHghPP0FMtPUQFP5QT1RFS8s+OJwRNFETmqiCJFEBQQCAkppPdk6/z+mJ3Zvju72Zp93q+XL8xmsjvZ2ezOM0/5MizLsiCEEEIIIYQQ4pIk1DtACCGEEEIIIeGOAidCCCGEEEII8YACJ0IIIYQQQgjxgAInQgghhBBCCPGAAidCCCGEEEII8YACJ0IIIYQQQgjxgAInQgghhBBCCPGAAidCCCGEEEII8YACJ0IIIYQQQgjxgAInQgghYauwsBAMw+Df//53qHelw8jLy8Odd94Z6t0ghJCIQ4ETIYSEsRMnTuC2225DdnY2lEolOnXqhFtvvRUnTpwI9a6JkpeXB4ZhhP/S09MxduxYbN68OdS75pFer8fLL7+MK6+8EhqNBnFxcbjyyivx8ssvQ6/Xh3r3BLt27bJ5jt39RwghxHcMy7JsqHeCEEKIo4KCAtxyyy1ITk7GvHnz0LVrVxQWFmLDhg2orq7Gxo0bccMNN4R6N93Ky8tDUlIS/vrXvwIASktLsX79epw7dw7r1q3DggUL3P48y7LQarWQy+WQSqXB2GUAQHNzM6699lrs3r0b1113Ha655hpIJBJ8/fXX+PzzzzF+/Hh8+eWXiI2NDdo+uXLp0iVs377d5rZly5YhLi4Ojz32mM3tt912G7RaLSQSCeRyeTB3kxBCIh4FToQQEobOnj2LAQMGoHPnztizZw/S0tKE71VVVWHs2LEoLi7GsWPH0K1btxDuqXt5eXno378/vvjiC+G28vJy9OjRA9nZ2Th16pTTnzMYDDCZTFAoFMHaVRvz58/HG2+8gVdeeQWLFy+2+d4///lPLF68GAsWLMC6deuCtk8sy6KtrQ1qtdrjtv3790dqaip27doV+B0jhJAoQaV6hBAShl544QW0tLTgjTfesAmaACA1NRXr169Hc3Mznn/+eeH2p556CgzD4LfffsNNN92E+Ph4pKSkYMmSJWhra3N4jPfffx9DhgyBWq1GcnIyZs+ejeLiYpttJkyYgP79++PkyZOYOHEiYmJikJ2dbfO43srMzMRll12G8+fPA7D0Mb344otYs2YNunfvDqVSiZMnT7rsceJ/x7S0NKjVavTu3dshu1JSUoI//elPyMjIgFKpRL9+/fD222973L+LFy9iw4YNuOqqqxyCJgBYtGgRJk6ciLfeegsXL14EwAUqEydOdNjWZDIhOzsbs2bNsrltzZo16NevH1QqFTIyMjB//nzU1tba/GxeXh6uu+46bNu2DUOHDoVarcb69es97r8n9j1O//73v8EwDPbt24f7778faWlpSExMxPz586HT6VBXV4e5c+ciKSkJSUlJ+Nvf/gb7a65ifydCCIlkFDgRQkgY2rJlC/Ly8jB27Fin3x83bhzy8vLw5ZdfOnzvpptuQltbG1atWoVp06bh5Zdfxr333muzzYoVKzB37lz07NkT//jHP7B06VLs2LED48aNQ11dnc22tbW1uOaaazBw4ECsXr0affr0wcM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rrnmGnz//fd4//33MWfOHAwcOBAAlyF49tlnsWzZMhQWFuL666+HRqPB+fPnsXnzZtx777148MEHg/0ri/byyy9jzJgxGDx4MO69917hefnyyy9x9OhRAMBzzz2HnTt
|
|||
|
"text/plain": [
|
|||
|
"<Figure size 1000x600 with 1 Axes>"
|
|||
|
]
|
|||
|
},
|
|||
|
"metadata": {},
|
|||
|
"output_type": "display_data"
|
|||
|
}
|
|||
|
],
|
|||
|
"source": [
|
|||
|
"import pandas as pd\n",
|
|||
|
"import numpy as np\n",
|
|||
|
"import matplotlib.pyplot as plt\n",
|
|||
|
"\n",
|
|||
|
"# Assuming 'hist' is your DataFrame with 'Date' set as the index and non-zero 'Open' values\n",
|
|||
|
"\n",
|
|||
|
"# Calculate daily change in 'Open' prices\n",
|
|||
|
"hist['OpenChange'] = hist['Open'].diff()\n",
|
|||
|
"\n",
|
|||
|
"# Find points where the change in 'Open' price shifts direction\n",
|
|||
|
"# This is a simple way to spot potential trend changes\n",
|
|||
|
"trend_changes = hist['OpenChange'] * hist['OpenChange'].shift(-1) < 0\n",
|
|||
|
"\n",
|
|||
|
"# Plotting the 'Open' price as a line plot\n",
|
|||
|
"plt.figure(figsize=(10, 6))\n",
|
|||
|
"hist['Open'].plot(kind='line', title='Open Price Over Time', xlabel='Date', ylabel='Open Price')\n",
|
|||
|
"plt.grid(True)\n",
|
|||
|
"\n",
|
|||
|
"# Marking trend changes\n",
|
|||
|
"for date, change in trend_changes.items():\n",
|
|||
|
" if change:\n",
|
|||
|
" plt.plot(date, hist.loc[date, 'Open'], 'ro') # Mark with red circle\n",
|
|||
|
"\n",
|
|||
|
"plt.show()\n"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"execution_count": 30,
|
|||
|
"id": "2b5d8506b2dfa72d",
|
|||
|
"metadata": {
|
|||
|
"ExecuteTime": {
|
|||
|
"end_time": "2024-03-09T07:47:07.717890Z",
|
|||
|
"start_time": "2024-03-09T07:47:07.673377Z"
|
|||
|
},
|
|||
|
"collapsed": false
|
|||
|
},
|
|||
|
"outputs": [
|
|||
|
{
|
|||
|
"data": {
|
|||
|
"text/plain": [
|
|||
|
"{'currency': 'USD',\n",
|
|||
|
" 'symbol': 'HG=F',\n",
|
|||
|
" 'exchangeName': 'CMX',\n",
|
|||
|
" 'instrumentType': 'FUTURE',\n",
|
|||
|
" 'firstTradeDate': 967608000,\n",
|
|||
|
" 'regularMarketTime': 1709935198,\n",
|
|||
|
" 'hasPrePostMarketData': False,\n",
|
|||
|
" 'gmtoffset': -18000,\n",
|
|||
|
" 'timezone': 'EST',\n",
|
|||
|
" 'exchangeTimezoneName': 'America/New_York',\n",
|
|||
|
" 'regularMarketPrice': 3.891,\n",
|
|||
|
" 'chartPreviousClose': 4.042,\n",
|
|||
|
" 'priceHint': 4,\n",
|
|||
|
" 'currentTradingPeriod': {'pre': {'timezone': 'EST',\n",
|
|||
|
" 'start': 1709874000,\n",
|
|||
|
" 'end': 1709874000,\n",
|
|||
|
" 'gmtoffset': -18000},\n",
|
|||
|
" 'regular': {'timezone': 'EST',\n",
|
|||
|
" 'start': 1709874000,\n",
|
|||
|
" 'end': 1709960340,\n",
|
|||
|
" 'gmtoffset': -18000},\n",
|
|||
|
" 'post': {'timezone': 'EST',\n",
|
|||
|
" 'start': 1709960340,\n",
|
|||
|
" 'end': 1709960340,\n",
|
|||
|
" 'gmtoffset': -18000}},\n",
|
|||
|
" 'dataGranularity': '1d',\n",
|
|||
|
" 'range': '1y',\n",
|
|||
|
" 'validRanges': ['1d',\n",
|
|||
|
" '5d',\n",
|
|||
|
" '1mo',\n",
|
|||
|
" '3mo',\n",
|
|||
|
" '6mo',\n",
|
|||
|
" '1y',\n",
|
|||
|
" '2y',\n",
|
|||
|
" '5y',\n",
|
|||
|
" '10y',\n",
|
|||
|
" 'ytd',\n",
|
|||
|
" 'max']}"
|
|||
|
]
|
|||
|
},
|
|||
|
"execution_count": 30,
|
|||
|
"metadata": {},
|
|||
|
"output_type": "execute_result"
|
|||
|
}
|
|||
|
],
|
|||
|
"source": [
|
|||
|
"# show meta information about the history (requires history() to be called first)\n",
|
|||
|
"hg_f.history_metadata"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"execution_count": 16,
|
|||
|
"id": "1b4d37d54e81a9da",
|
|||
|
"metadata": {
|
|||
|
"ExecuteTime": {
|
|||
|
"end_time": "2024-03-09T07:40:48.287480Z",
|
|||
|
"start_time": "2024-03-09T07:40:48.264700Z"
|
|||
|
},
|
|||
|
"collapsed": false
|
|||
|
},
|
|||
|
"outputs": [
|
|||
|
{
|
|||
|
"data": {
|
|||
|
"text/plain": [
|
|||
|
"Series([], dtype: object)"
|
|||
|
]
|
|||
|
},
|
|||
|
"execution_count": 16,
|
|||
|
"metadata": {},
|
|||
|
"output_type": "execute_result"
|
|||
|
}
|
|||
|
],
|
|||
|
"source": [
|
|||
|
"# show actions (dividends, splits, capital gains)\n",
|
|||
|
"hg_f.actions\n",
|
|||
|
"hg_f.dividends\n",
|
|||
|
"hg_f.splits\n",
|
|||
|
"hg_f.capital_gains # only for mutual funds & etfs\n"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"execution_count": 18,
|
|||
|
"id": "de2e437452c43687",
|
|||
|
"metadata": {
|
|||
|
"ExecuteTime": {
|
|||
|
"end_time": "2024-03-09T07:41:18.436284Z",
|
|||
|
"start_time": "2024-03-09T07:41:18.411883Z"
|
|||
|
},
|
|||
|
"collapsed": false
|
|||
|
},
|
|||
|
"outputs": [
|
|||
|
{
|
|||
|
"data": {
|
|||
|
"text/plain": [
|
|||
|
"yfinance.Ticker object <HG=F>"
|
|||
|
]
|
|||
|
},
|
|||
|
"execution_count": 18,
|
|||
|
"metadata": {},
|
|||
|
"output_type": "execute_result"
|
|||
|
}
|
|||
|
],
|
|||
|
"source": [
|
|||
|
"# show share count\n",
|
|||
|
"hg_f.get_shares_full(start=\"2022-01-01\", end=None)\n"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"execution_count": 20,
|
|||
|
"id": "df7d9490335bf41a",
|
|||
|
"metadata": {
|
|||
|
"ExecuteTime": {
|
|||
|
"end_time": "2024-03-09T07:42:00.119462Z",
|
|||
|
"start_time": "2024-03-09T07:42:00.089495Z"
|
|||
|
},
|
|||
|
"collapsed": false
|
|||
|
},
|
|||
|
"outputs": [
|
|||
|
{
|
|||
|
"data": {
|
|||
|
"text/html": [
|
|||
|
"<div>\n",
|
|||
|
"<style scoped>\n",
|
|||
|
" .dataframe tbody tr th:only-of-type {\n",
|
|||
|
" vertical-align: middle;\n",
|
|||
|
" }\n",
|
|||
|
"\n",
|
|||
|
" .dataframe tbody tr th {\n",
|
|||
|
" vertical-align: top;\n",
|
|||
|
" }\n",
|
|||
|
"\n",
|
|||
|
" .dataframe thead th {\n",
|
|||
|
" text-align: right;\n",
|
|||
|
" }\n",
|
|||
|
"</style>\n",
|
|||
|
"<table border=\"1\" class=\"dataframe\">\n",
|
|||
|
" <thead>\n",
|
|||
|
" <tr style=\"text-align: right;\">\n",
|
|||
|
" <th></th>\n",
|
|||
|
" </tr>\n",
|
|||
|
" </thead>\n",
|
|||
|
" <tbody>\n",
|
|||
|
" </tbody>\n",
|
|||
|
"</table>\n",
|
|||
|
"</div>"
|
|||
|
],
|
|||
|
"text/plain": [
|
|||
|
"Empty DataFrame\n",
|
|||
|
"Columns: []\n",
|
|||
|
"Index: []"
|
|||
|
]
|
|||
|
},
|
|||
|
"execution_count": 20,
|
|||
|
"metadata": {},
|
|||
|
"output_type": "execute_result"
|
|||
|
}
|
|||
|
],
|
|||
|
"source": [
|
|||
|
"hg_f.income_stmt\n",
|
|||
|
"hg_f.quarterly_income_stmt"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"execution_count": 21,
|
|||
|
"id": "2909062e99a951b6",
|
|||
|
"metadata": {
|
|||
|
"ExecuteTime": {
|
|||
|
"end_time": "2024-03-09T07:42:15.633015Z",
|
|||
|
"start_time": "2024-03-09T07:42:15.630512Z"
|
|||
|
},
|
|||
|
"collapsed": false
|
|||
|
},
|
|||
|
"outputs": [
|
|||
|
{
|
|||
|
"data": {
|
|||
|
"text/html": [
|
|||
|
"<div>\n",
|
|||
|
"<style scoped>\n",
|
|||
|
" .dataframe tbody tr th:only-of-type {\n",
|
|||
|
" vertical-align: middle;\n",
|
|||
|
" }\n",
|
|||
|
"\n",
|
|||
|
" .dataframe tbody tr th {\n",
|
|||
|
" vertical-align: top;\n",
|
|||
|
" }\n",
|
|||
|
"\n",
|
|||
|
" .dataframe thead th {\n",
|
|||
|
" text-align: right;\n",
|
|||
|
" }\n",
|
|||
|
"</style>\n",
|
|||
|
"<table border=\"1\" class=\"dataframe\">\n",
|
|||
|
" <thead>\n",
|
|||
|
" <tr style=\"text-align: right;\">\n",
|
|||
|
" <th></th>\n",
|
|||
|
" </tr>\n",
|
|||
|
" </thead>\n",
|
|||
|
" <tbody>\n",
|
|||
|
" </tbody>\n",
|
|||
|
"</table>\n",
|
|||
|
"</div>"
|
|||
|
],
|
|||
|
"text/plain": [
|
|||
|
"Empty DataFrame\n",
|
|||
|
"Columns: []\n",
|
|||
|
"Index: []"
|
|||
|
]
|
|||
|
},
|
|||
|
"execution_count": 21,
|
|||
|
"metadata": {},
|
|||
|
"output_type": "execute_result"
|
|||
|
}
|
|||
|
],
|
|||
|
"source": [
|
|||
|
"# - balance sheet\n",
|
|||
|
"hg_f.balance_sheet\n",
|
|||
|
"hg_f.quarterly_balance_sheet"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"execution_count": 22,
|
|||
|
"id": "b96ce990167d3a45",
|
|||
|
"metadata": {
|
|||
|
"ExecuteTime": {
|
|||
|
"end_time": "2024-03-09T07:42:26.935833Z",
|
|||
|
"start_time": "2024-03-09T07:42:26.895263Z"
|
|||
|
},
|
|||
|
"collapsed": false
|
|||
|
},
|
|||
|
"outputs": [
|
|||
|
{
|
|||
|
"data": {
|
|||
|
"text/html": [
|
|||
|
"<div>\n",
|
|||
|
"<style scoped>\n",
|
|||
|
" .dataframe tbody tr th:only-of-type {\n",
|
|||
|
" vertical-align: middle;\n",
|
|||
|
" }\n",
|
|||
|
"\n",
|
|||
|
" .dataframe tbody tr th {\n",
|
|||
|
" vertical-align: top;\n",
|
|||
|
" }\n",
|
|||
|
"\n",
|
|||
|
" .dataframe thead th {\n",
|
|||
|
" text-align: right;\n",
|
|||
|
" }\n",
|
|||
|
"</style>\n",
|
|||
|
"<table border=\"1\" class=\"dataframe\">\n",
|
|||
|
" <thead>\n",
|
|||
|
" <tr style=\"text-align: right;\">\n",
|
|||
|
" <th></th>\n",
|
|||
|
" </tr>\n",
|
|||
|
" </thead>\n",
|
|||
|
" <tbody>\n",
|
|||
|
" </tbody>\n",
|
|||
|
"</table>\n",
|
|||
|
"</div>"
|
|||
|
],
|
|||
|
"text/plain": [
|
|||
|
"Empty DataFrame\n",
|
|||
|
"Columns: []\n",
|
|||
|
"Index: []"
|
|||
|
]
|
|||
|
},
|
|||
|
"execution_count": 22,
|
|||
|
"metadata": {},
|
|||
|
"output_type": "execute_result"
|
|||
|
}
|
|||
|
],
|
|||
|
"source": [
|
|||
|
"# - cash flow statement\n",
|
|||
|
"hg_f.cashflow\n",
|
|||
|
"hg_f.quarterly_cashflow\n",
|
|||
|
"# see `Ticker.get_income_stmt()` for more options"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"execution_count": 23,
|
|||
|
"id": "8c28e69e8dbba15e",
|
|||
|
"metadata": {
|
|||
|
"ExecuteTime": {
|
|||
|
"end_time": "2024-03-09T07:42:38.982803Z",
|
|||
|
"start_time": "2024-03-09T07:42:38.003279Z"
|
|||
|
},
|
|||
|
"collapsed": false
|
|||
|
},
|
|||
|
"outputs": [
|
|||
|
{
|
|||
|
"name": "stderr",
|
|||
|
"output_type": "stream",
|
|||
|
"text": [
|
|||
|
"404 Client Error: Not Found for url: https://query2.finance.yahoo.com/v10/finance/quoteSummary/?modules=institutionOwnership%2CfundOwnership%2CmajorDirectHolders%2CmajorHoldersBreakdown%2CinsiderTransactions%2CinsiderHolders%2CnetSharePurchaseActivity&corsDomain=finance.yahoo.com&symbol=HG%3DF&formatted=false&crumb=kY9MYXZrrjV\n"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"data": {
|
|||
|
"text/html": [
|
|||
|
"<div>\n",
|
|||
|
"<style scoped>\n",
|
|||
|
" .dataframe tbody tr th:only-of-type {\n",
|
|||
|
" vertical-align: middle;\n",
|
|||
|
" }\n",
|
|||
|
"\n",
|
|||
|
" .dataframe tbody tr th {\n",
|
|||
|
" vertical-align: top;\n",
|
|||
|
" }\n",
|
|||
|
"\n",
|
|||
|
" .dataframe thead th {\n",
|
|||
|
" text-align: right;\n",
|
|||
|
" }\n",
|
|||
|
"</style>\n",
|
|||
|
"<table border=\"1\" class=\"dataframe\">\n",
|
|||
|
" <thead>\n",
|
|||
|
" <tr style=\"text-align: right;\">\n",
|
|||
|
" <th></th>\n",
|
|||
|
" </tr>\n",
|
|||
|
" </thead>\n",
|
|||
|
" <tbody>\n",
|
|||
|
" </tbody>\n",
|
|||
|
"</table>\n",
|
|||
|
"</div>"
|
|||
|
],
|
|||
|
"text/plain": [
|
|||
|
"Empty DataFrame\n",
|
|||
|
"Columns: []\n",
|
|||
|
"Index: []"
|
|||
|
]
|
|||
|
},
|
|||
|
"execution_count": 23,
|
|||
|
"metadata": {},
|
|||
|
"output_type": "execute_result"
|
|||
|
}
|
|||
|
],
|
|||
|
"source": [
|
|||
|
"\n",
|
|||
|
"# show holders\n",
|
|||
|
"hg_f.major_holders\n",
|
|||
|
"hg_f.institutional_holders\n",
|
|||
|
"hg_f.mutualfund_holders\n",
|
|||
|
"hg_f.insider_transactions\n",
|
|||
|
"hg_f.insider_purchases\n",
|
|||
|
"hg_f.insider_roster_holders\n"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"execution_count": 24,
|
|||
|
"id": "f8b90eeae3dbad17",
|
|||
|
"metadata": {
|
|||
|
"ExecuteTime": {
|
|||
|
"end_time": "2024-03-09T07:42:58.365869Z",
|
|||
|
"start_time": "2024-03-09T07:42:57.287372Z"
|
|||
|
},
|
|||
|
"collapsed": false
|
|||
|
},
|
|||
|
"outputs": [
|
|||
|
{
|
|||
|
"name": "stderr",
|
|||
|
"output_type": "stream",
|
|||
|
"text": [
|
|||
|
"404 Client Error: Not Found for url: https://query2.finance.yahoo.com/v10/finance/quoteSummary/HG=F?modules=recommendationTrend&corsDomain=finance.yahoo.com&formatted=false&symbol=HG%3DF&crumb=kY9MYXZrrjV\n",
|
|||
|
"404 Client Error: Not Found for url: https://query2.finance.yahoo.com/v10/finance/quoteSummary/HG=F?modules=upgradeDowngradeHistory&corsDomain=finance.yahoo.com&formatted=false&symbol=HG%3DF&crumb=kY9MYXZrrjV\n"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"data": {
|
|||
|
"text/html": [
|
|||
|
"<div>\n",
|
|||
|
"<style scoped>\n",
|
|||
|
" .dataframe tbody tr th:only-of-type {\n",
|
|||
|
" vertical-align: middle;\n",
|
|||
|
" }\n",
|
|||
|
"\n",
|
|||
|
" .dataframe tbody tr th {\n",
|
|||
|
" vertical-align: top;\n",
|
|||
|
" }\n",
|
|||
|
"\n",
|
|||
|
" .dataframe thead th {\n",
|
|||
|
" text-align: right;\n",
|
|||
|
" }\n",
|
|||
|
"</style>\n",
|
|||
|
"<table border=\"1\" class=\"dataframe\">\n",
|
|||
|
" <thead>\n",
|
|||
|
" <tr style=\"text-align: right;\">\n",
|
|||
|
" <th></th>\n",
|
|||
|
" </tr>\n",
|
|||
|
" </thead>\n",
|
|||
|
" <tbody>\n",
|
|||
|
" </tbody>\n",
|
|||
|
"</table>\n",
|
|||
|
"</div>"
|
|||
|
],
|
|||
|
"text/plain": [
|
|||
|
"Empty DataFrame\n",
|
|||
|
"Columns: []\n",
|
|||
|
"Index: []"
|
|||
|
]
|
|||
|
},
|
|||
|
"execution_count": 24,
|
|||
|
"metadata": {},
|
|||
|
"output_type": "execute_result"
|
|||
|
}
|
|||
|
],
|
|||
|
"source": [
|
|||
|
"# show recommendations\n",
|
|||
|
"hg_f.recommendations\n",
|
|||
|
"hg_f.recommendations_summary\n",
|
|||
|
"hg_f.upgrades_downgrades\n"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"execution_count": 25,
|
|||
|
"id": "afa3e15b051554a",
|
|||
|
"metadata": {
|
|||
|
"ExecuteTime": {
|
|||
|
"end_time": "2024-03-09T07:43:16.861853Z",
|
|||
|
"start_time": "2024-03-09T07:43:16.247498Z"
|
|||
|
},
|
|||
|
"collapsed": false
|
|||
|
},
|
|||
|
"outputs": [
|
|||
|
{
|
|||
|
"name": "stderr",
|
|||
|
"output_type": "stream",
|
|||
|
"text": [
|
|||
|
"HG=F: No earnings dates found, symbol may be delisted\n"
|
|||
|
]
|
|||
|
}
|
|||
|
],
|
|||
|
"source": [
|
|||
|
"\n",
|
|||
|
"# Show future and historic earnings dates, returns at most next 4 quarters and last 8 quarters by default. \n",
|
|||
|
"# Note: If more are needed use msft.get_earnings_dates(limit=XX) with increased limit argument.\n",
|
|||
|
"hg_f.earnings_dates"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"execution_count": 26,
|
|||
|
"id": "506d811b32bc7e9c",
|
|||
|
"metadata": {
|
|||
|
"ExecuteTime": {
|
|||
|
"end_time": "2024-03-09T07:43:27.416624Z",
|
|||
|
"start_time": "2024-03-09T07:43:27.378458Z"
|
|||
|
},
|
|||
|
"collapsed": false
|
|||
|
},
|
|||
|
"outputs": [
|
|||
|
{
|
|||
|
"data": {
|
|||
|
"text/plain": [
|
|||
|
"'-'"
|
|||
|
]
|
|||
|
},
|
|||
|
"execution_count": 26,
|
|||
|
"metadata": {},
|
|||
|
"output_type": "execute_result"
|
|||
|
}
|
|||
|
],
|
|||
|
"source": [
|
|||
|
"\n",
|
|||
|
"# show ISIN code - *experimental*\n",
|
|||
|
"# ISIN = International Securities Identification Number\n",
|
|||
|
"hg_f.isin"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"execution_count": 27,
|
|||
|
"id": "842e7bd47877f711",
|
|||
|
"metadata": {
|
|||
|
"ExecuteTime": {
|
|||
|
"end_time": "2024-03-09T07:43:39.146196Z",
|
|||
|
"start_time": "2024-03-09T07:43:39.069686Z"
|
|||
|
},
|
|||
|
"collapsed": false
|
|||
|
},
|
|||
|
"outputs": [
|
|||
|
{
|
|||
|
"data": {
|
|||
|
"text/plain": [
|
|||
|
"()"
|
|||
|
]
|
|||
|
},
|
|||
|
"execution_count": 27,
|
|||
|
"metadata": {},
|
|||
|
"output_type": "execute_result"
|
|||
|
}
|
|||
|
],
|
|||
|
"source": [
|
|||
|
"\n",
|
|||
|
"# show options expirations\n",
|
|||
|
"hg_f.options\n"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"execution_count": 28,
|
|||
|
"id": "656b5ec6618e155f",
|
|||
|
"metadata": {
|
|||
|
"ExecuteTime": {
|
|||
|
"end_time": "2024-03-09T07:43:47.992734Z",
|
|||
|
"start_time": "2024-03-09T07:43:47.958054Z"
|
|||
|
},
|
|||
|
"collapsed": false
|
|||
|
},
|
|||
|
"outputs": [
|
|||
|
{
|
|||
|
"data": {
|
|||
|
"text/plain": [
|
|||
|
"[{'uuid': 'a081de49-3834-35d7-9b1a-49ae61a24622',\n",
|
|||
|
" 'title': 'EMERGING MARKETS-Latam stocks advance, weak copper prices drag currencies of Chile, Peru',\n",
|
|||
|
" 'publisher': 'Reuters',\n",
|
|||
|
" 'link': 'https://finance.yahoo.com/news/emerging-markets-latam-stocks-advance-153434824.html',\n",
|
|||
|
" 'providerPublishTime': 1706283274,\n",
|
|||
|
" 'type': 'STORY',\n",
|
|||
|
" 'relatedTickers': ['HG=F', '^BVSP', '^MXX']},\n",
|
|||
|
" {'uuid': '08c6cfc7-1146-374c-bf8f-8f02328cc4b1',\n",
|
|||
|
" 'title': 'CANADA STOCKS-TSX futures edge up on higher gold prices; US data in focus',\n",
|
|||
|
" 'publisher': 'Reuters',\n",
|
|||
|
" 'link': 'https://finance.yahoo.com/news/canada-stocks-tsx-futures-edge-123846632.html',\n",
|
|||
|
" 'providerPublishTime': 1706272726,\n",
|
|||
|
" 'type': 'STORY',\n",
|
|||
|
" 'relatedTickers': ['GC=F', 'ZG=F', 'HG=F', '^GSPC']},\n",
|
|||
|
" {'uuid': '1666725e-a880-3220-be81-4b39be02d706',\n",
|
|||
|
" 'title': 'These Are the 4 Best Silver Coin Types To Buy in Order To Turn a Profit',\n",
|
|||
|
" 'publisher': 'GOBankingRates',\n",
|
|||
|
" 'link': 'https://finance.yahoo.com/news/4-best-silver-coin-types-123010528.html',\n",
|
|||
|
" 'providerPublishTime': 1706272210,\n",
|
|||
|
" 'type': 'STORY',\n",
|
|||
|
" 'thumbnail': {'resolutions': [{'url': 'https://s.yimg.com/uu/api/res/1.2/BhiemWjsPOiPzWVgmzWacQ--~B/aD0xMDgwO3c9MTkyMDthcHBpZD15dGFjaHlvbg--/https://media.zenfs.com/en/gobankingrates_644/397831e32274b07c29579b8e42a54267',\n",
|
|||
|
" 'width': 1920,\n",
|
|||
|
" 'height': 1080,\n",
|
|||
|
" 'tag': 'original'},\n",
|
|||
|
" {'url': 'https://s.yimg.com/uu/api/res/1.2/__z5WbG1O.bg53xqLE74Dg--~B/Zmk9ZmlsbDtoPTE0MDtweW9mZj0wO3c9MTQwO2FwcGlkPXl0YWNoeW9u/https://media.zenfs.com/en/gobankingrates_644/397831e32274b07c29579b8e42a54267',\n",
|
|||
|
" 'width': 140,\n",
|
|||
|
" 'height': 140,\n",
|
|||
|
" 'tag': '140x140'}]},\n",
|
|||
|
" 'relatedTickers': ['GC=F', 'ZG=F', 'HG=F', 'SI=F', 'ZI=F']},\n",
|
|||
|
" {'uuid': '0edc4734-fb05-3bb1-a95b-9e11c776fdc5',\n",
|
|||
|
" 'title': 'Gold prices struggle before inflation, Fed cues; copper set for strong week',\n",
|
|||
|
" 'publisher': 'Investing.com',\n",
|
|||
|
" 'link': 'https://finance.yahoo.com/news/gold-prices-struggle-inflation-fed-001606596.html',\n",
|
|||
|
" 'providerPublishTime': 1706228166,\n",
|
|||
|
" 'type': 'STORY',\n",
|
|||
|
" 'relatedTickers': ['HG=F', 'GC=F', 'ZG=F']},\n",
|
|||
|
" {'uuid': '7b91db52-a3f1-335d-9176-6d61187cf0a7',\n",
|
|||
|
" 'title': 'Basic Materials Roundup: Market Talk',\n",
|
|||
|
" 'publisher': 'The Wall Street Journal',\n",
|
|||
|
" 'link': 'https://finance.yahoo.com/m/7b91db52-a3f1-335d-9176-6d61187cf0a7/basic-materials-roundup%3A.html',\n",
|
|||
|
" 'providerPublishTime': 1706219880,\n",
|
|||
|
" 'type': 'STORY',\n",
|
|||
|
" 'thumbnail': {'resolutions': [{'url': 'https://s.yimg.com/uu/api/res/1.2/hus7PFWagBBSuGWsuAHBxA--~B/aD02NDA7dz0xMjgwO2FwcGlkPXl0YWNoeW9u/https://media.zenfs.com/en/wsj.com/7e9c00d68c1ab82df50577310bb19679',\n",
|
|||
|
" 'width': 1280,\n",
|
|||
|
" 'height': 640,\n",
|
|||
|
" 'tag': 'original'},\n",
|
|||
|
" {'url': 'https://s.yimg.com/uu/api/res/1.2/2AS8Z8b8P15BKyqk61NEWQ--~B/Zmk9ZmlsbDtoPTE0MDtweW9mZj0wO3c9MTQwO2FwcGlkPXl0YWNoeW9u/https://media.zenfs.com/en/wsj.com/7e9c00d68c1ab82df50577310bb19679',\n",
|
|||
|
" 'width': 140,\n",
|
|||
|
" 'height': 140,\n",
|
|||
|
" 'tag': '140x140'}]},\n",
|
|||
|
" 'relatedTickers': ['GVDBF', 'GVDNY', 'GC=F', 'ZG=F', 'HG=F']},\n",
|
|||
|
" {'uuid': '2ce9d404-879c-3b5c-85c2-652c92639df1',\n",
|
|||
|
" 'title': 'Closing prices for crude oil, gold and other commodities',\n",
|
|||
|
" 'publisher': 'Associated Press Finance',\n",
|
|||
|
" 'link': 'https://finance.yahoo.com/news/closing-prices-crude-oil-gold-201521282.html',\n",
|
|||
|
" 'providerPublishTime': 1706213721,\n",
|
|||
|
" 'type': 'STORY',\n",
|
|||
|
" 'relatedTickers': ['CL=F',\n",
|
|||
|
" 'SI=F',\n",
|
|||
|
" 'ZI=F',\n",
|
|||
|
" 'NG=F',\n",
|
|||
|
" 'GC=F',\n",
|
|||
|
" 'ZG=F',\n",
|
|||
|
" 'HG=F',\n",
|
|||
|
" 'HO=F']},\n",
|
|||
|
" {'uuid': 'e0748b77-83b7-34c3-b83e-f55508291594',\n",
|
|||
|
" 'title': 'Crypto for Advisors: Unlocking Crypto Custody',\n",
|
|||
|
" 'publisher': 'CoinDesk',\n",
|
|||
|
" 'link': 'https://finance.yahoo.com/m/e0748b77-83b7-34c3-b83e-f55508291594/crypto-for-advisors%3A.html',\n",
|
|||
|
" 'providerPublishTime': 1706199734,\n",
|
|||
|
" 'type': 'STORY',\n",
|
|||
|
" 'thumbnail': {'resolutions': [{'url': 'https://s.yimg.com/uu/api/res/1.2/YvjxRlrTdjUCMJlc1MT4tg--~B/aD0zMDAwO3c9NDUwMDthcHBpZD15dGFjaHlvbg--/https://media.zenfs.com/en/coindesk_75/c7a00a6fe2bc93bfbbac3e92d2fac0e6',\n",
|
|||
|
" 'width': 4500,\n",
|
|||
|
" 'height': 3000,\n",
|
|||
|
" 'tag': 'original'},\n",
|
|||
|
" {'url': 'https://s.yimg.com/uu/api/res/1.2/q.NOd5AdTb2Y1wpOwX9L.w--~B/Zmk9ZmlsbDtoPTE0MDtweW9mZj0wO3c9MTQwO2FwcGlkPXl0YWNoeW9u/https://media.zenfs.com/en/coindesk_75/c7a00a6fe2bc93bfbbac3e92d2fac0e6',\n",
|
|||
|
" 'width': 140,\n",
|
|||
|
" 'height': 140,\n",
|
|||
|
" 'tag': '140x140'}]},\n",
|
|||
|
" 'relatedTickers': ['HG=F']},\n",
|
|||
|
" {'uuid': '922264e0-c1d2-3af4-9d38-c318b8a7b523',\n",
|
|||
|
" 'title': \"Blinken hails progress in construction of Angola's Lobito rail corridor\",\n",
|
|||
|
" 'publisher': 'Reuters',\n",
|
|||
|
" 'link': 'https://finance.yahoo.com/news/blinken-hails-progress-construction-angolas-155740812.html',\n",
|
|||
|
" 'providerPublishTime': 1706198260,\n",
|
|||
|
" 'type': 'STORY',\n",
|
|||
|
" 'relatedTickers': ['HG=F']}]"
|
|||
|
]
|
|||
|
},
|
|||
|
"execution_count": 28,
|
|||
|
"metadata": {},
|
|||
|
"output_type": "execute_result"
|
|||
|
}
|
|||
|
],
|
|||
|
"source": [
|
|||
|
"# show news\n",
|
|||
|
"hg_f.news"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"execution_count": 29,
|
|||
|
"id": "ffd1a25566eed606",
|
|||
|
"metadata": {
|
|||
|
"ExecuteTime": {
|
|||
|
"end_time": "2024-03-09T07:44:10.426336Z",
|
|||
|
"start_time": "2024-03-09T07:44:10.346101Z"
|
|||
|
},
|
|||
|
"collapsed": false
|
|||
|
},
|
|||
|
"outputs": [
|
|||
|
{
|
|||
|
"ename": "ValueError",
|
|||
|
"evalue": "Expiration `2024-06-21` cannot be found. Available expirations are: []",
|
|||
|
"output_type": "error",
|
|||
|
"traceback": [
|
|||
|
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
|
|||
|
"\u001b[0;31mValueError\u001b[0m Traceback (most recent call last)",
|
|||
|
"Cell \u001b[0;32mIn[29], line 2\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[38;5;66;03m# get option chain for specific expiration\u001b[39;00m\n\u001b[0;32m----> 2\u001b[0m opt \u001b[38;5;241m=\u001b[39m \u001b[43mhg_f\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43moption_chain\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;124;43m2024-06-21\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[43m)\u001b[49m\n\u001b[1;32m 3\u001b[0m \u001b[38;5;66;03m# data available via: opt.calls, opt.puts\u001b[39;00m\n",
|
|||
|
"File \u001b[0;32m~/miniconda3/envs/lang_chain/lib/python3.11/site-packages/yfinance/ticker.py:91\u001b[0m, in \u001b[0;36mTicker.option_chain\u001b[0;34m(self, date, tz)\u001b[0m\n\u001b[1;32m 89\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_download_options()\n\u001b[1;32m 90\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m date \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_expirations:\n\u001b[0;32m---> 91\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mValueError\u001b[39;00m(\n\u001b[1;32m 92\u001b[0m \u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mExpiration `\u001b[39m\u001b[38;5;132;01m{\u001b[39;00mdate\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m` cannot be found. \u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[1;32m 93\u001b[0m \u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mAvailable expirations are: [\u001b[39m\u001b[38;5;132;01m{\u001b[39;00m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124m, \u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;241m.\u001b[39mjoin(\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_expirations)\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m]\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n\u001b[1;32m 94\u001b[0m date \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_expirations[date]\n\u001b[1;32m 95\u001b[0m options \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_download_options(date)\n",
|
|||
|
"\u001b[0;31mValueError\u001b[0m: Expiration `2024-06-21` cannot be found. Available expirations are: []"
|
|||
|
]
|
|||
|
}
|
|||
|
],
|
|||
|
"source": [
|
|||
|
"# get option chain for specific expiration\n",
|
|||
|
"opt = hg_f.option_chain('2024-06-21')\n",
|
|||
|
"# data available via: opt.calls, opt.puts\n"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"execution_count": null,
|
|||
|
"id": "6b61bc4f626b4dc",
|
|||
|
"metadata": {
|
|||
|
"collapsed": false
|
|||
|
},
|
|||
|
"outputs": [],
|
|||
|
"source": []
|
|||
|
}
|
|||
|
],
|
|||
|
"metadata": {
|
|||
|
"kernelspec": {
|
|||
|
"display_name": "Python 3",
|
|||
|
"language": "python",
|
|||
|
"name": "python3"
|
|||
|
},
|
|||
|
"language_info": {
|
|||
|
"codemirror_mode": {
|
|||
|
"name": "ipython",
|
|||
|
"version": 2
|
|||
|
},
|
|||
|
"file_extension": ".py",
|
|||
|
"mimetype": "text/x-python",
|
|||
|
"name": "python",
|
|||
|
"nbconvert_exporter": "python",
|
|||
|
"pygments_lexer": "ipython2",
|
|||
|
"version": "2.7.6"
|
|||
|
}
|
|||
|
},
|
|||
|
"nbformat": 4,
|
|||
|
"nbformat_minor": 5
|
|||
|
}
|