mirror of
https://github.com/norandom/trading_analysis.git
synced 2024-11-21 12:53:42 +00:00
Preparing Distribution of Returns SpreadSheet analysis w Excel and Python
This commit is contained in:
parent
3e6ea8c517
commit
2d998d29f0
5912
Data_COPPER.csv
Normal file
5912
Data_COPPER.csv
Normal file
File diff suppressed because it is too large
Load Diff
92
Yahoo_Finance_DL_COPPER_EXCEL.ipynb
Normal file
92
Yahoo_Finance_DL_COPPER_EXCEL.ipynb
Normal file
@ -0,0 +1,92 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "initial_id",
|
||||
"metadata": {
|
||||
"collapsed": true
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"%pip install \"yfinance[optional]\"==\"0.2.37\""
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"id": "904104edfdda9e89",
|
||||
"metadata": {
|
||||
"ExecuteTime": {
|
||||
"end_time": "2024-03-15T12:53:50.140736Z",
|
||||
"start_time": "2024-03-15T12:53:49.262218Z"
|
||||
},
|
||||
"collapsed": false
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import yfinance as yf\n",
|
||||
"\n",
|
||||
"hg_f = yf.Ticker(\"HG=F\")"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 5,
|
||||
"id": "f8531df814e529fb",
|
||||
"metadata": {
|
||||
"ExecuteTime": {
|
||||
"end_time": "2024-03-15T12:59:52.590852Z",
|
||||
"start_time": "2024-03-15T12:59:52.243074Z"
|
||||
},
|
||||
"collapsed": false
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import pandas as pd\n",
|
||||
"import numpy as np\n",
|
||||
"\n",
|
||||
"# get historical market data\n",
|
||||
"hist = hg_f.history(period=\"100y\")\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",
|
||||
"columns = ['Open', 'High', 'Low', 'Close', 'Volume']\n",
|
||||
"\n",
|
||||
"hist.to_csv(f'./Data_COPPER.csv')"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"id": "de2634931db1a5d6",
|
||||
"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
|
||||
}
|
1208
Yahoo_Finance_QUANT_COPPER.ipynb
Normal file
1208
Yahoo_Finance_QUANT_COPPER.ipynb
Normal file
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user