Skip to content

Commit df4fa8f

Browse files
committed
chore: Black style adjustments
1 parent 73b6729 commit df4fa8f

25 files changed

+448
-377
lines changed

.ipynb_checkpoints/main_notebook-checkpoint.ipynb

Lines changed: 28 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,18 @@
9494
"source": [
9595
"from okama.common import make_asset_list\n",
9696
"\n",
97-
"ls = ['SPY.US', 'AGG.US', 'GC.COMM', 'VOO.US', 'MCFTR.INDX', 'RGBITR.INDX', 'MOW_PR.RE', 'MOW_SEC.RE', 'RUCBTRNS.INDX', 'USDRUB.FX']\n"
97+
"ls = [\n",
98+
" \"SPY.US\",\n",
99+
" \"AGG.US\",\n",
100+
" \"GC.COMM\",\n",
101+
" \"VOO.US\",\n",
102+
" \"MCFTR.INDX\",\n",
103+
" \"RGBITR.INDX\",\n",
104+
" \"MOW_PR.RE\",\n",
105+
" \"MOW_SEC.RE\",\n",
106+
" \"RUCBTRNS.INDX\",\n",
107+
" \"USDRUB.FX\",\n",
108+
"]"
98109
]
99110
},
100111
{
@@ -256,7 +267,7 @@
256267
}
257268
],
258269
"source": [
259-
"al = ok.AssetList(ls, ccy='RUB', inflation=True)\n",
270+
"al = ok.AssetList(ls, ccy=\"RUB\", inflation=True)\n",
260271
"print(al)"
261272
]
262273
},
@@ -282,9 +293,9 @@
282293
},
283294
"outputs": [],
284295
"source": [
285-
"assets = ['MCFTR.INDX', 'GC.COMM', 'RGBITR.INDX', 'RUCBTRNS.INDX']\n",
286-
"assets1 = ['MCFTR.INDX', 'GC.COMM']\n",
287-
"assets2 = ['SPY.US', 'AGG.US', 'GC.COMM']"
296+
"assets = [\"MCFTR.INDX\", \"GC.COMM\", \"RGBITR.INDX\", \"RUCBTRNS.INDX\"]\n",
297+
"assets1 = [\"MCFTR.INDX\", \"GC.COMM\"]\n",
298+
"assets2 = [\"SPY.US\", \"AGG.US\", \"GC.COMM\"]"
288299
]
289300
},
290301
{
@@ -525,11 +536,7 @@
525536
},
526537
"outputs": [],
527538
"source": [
528-
"pf.dcf.set_mc_parameters(\n",
529-
" distribution=\"norm\", # Normal distribution (or Gaussian distribution)\n",
530-
" period=10,\n",
531-
" number=100\n",
532-
")"
539+
"pf.dcf.set_mc_parameters(distribution=\"norm\", period=10, number=100) # Normal distribution (or Gaussian distribution)"
533540
]
534541
},
535542
{
@@ -1116,9 +1123,9 @@
11161123
}
11171124
],
11181125
"source": [
1119-
"assets = ['RGBITR.INDX', 'RUCBTRNS.INDX', 'MCFTR.INDX', 'GC.COMM']\n",
1120-
"weights = [0.16, 0.40, 0.25, 0.19]\n",
1121-
"pf = ok.Portfolio(assets, weights=weights, ccy='RUB', rebalancing_period='year', inflation=False)\n",
1126+
"assets = [\"RGBITR.INDX\", \"RUCBTRNS.INDX\", \"MCFTR.INDX\", \"GC.COMM\"]\n",
1127+
"weights = [0.16, 0.40, 0.25, 0.19]\n",
1128+
"pf = ok.Portfolio(assets, weights=weights, ccy=\"RUB\", rebalancing_period=\"year\", inflation=False)\n",
11221129
"pf.dcf.discount_rate = 0.09\n",
11231130
"print(pf)"
11241131
]
@@ -2546,6 +2553,7 @@
25462553
"import okama as ok\n",
25472554
"\n",
25482555
"import warnings\n",
2556+
"\n",
25492557
"warnings.simplefilter(action=\"ignore\", category=FutureWarning)"
25502558
]
25512559
},
@@ -2847,11 +2855,11 @@
28472855
"source": [
28482856
"pf = [\"SPY.US\", \"GLD.US\", \"VB.US\"]\n",
28492857
"\n",
2850-
"curr = 'RUB'\n",
2858+
"curr = \"RUB\"\n",
28512859
"\n",
2852-
"last_date=\"2024-07\"\n",
2860+
"last_date = \"2024-07\"\n",
28532861
"\n",
2854-
"bounds=((0, 1), (0, 1), (0, 1))\n",
2862+
"bounds = ((0, 1), (0, 1), (0, 1))\n",
28552863
"\n",
28562864
"ef = ok.EfficientFrontierReb(pf, ccy=curr, last_date=last_date, bounds=bounds)\n",
28572865
"\n",
@@ -2929,7 +2937,7 @@
29292937
" first_date=\"2004-10\",\n",
29302938
" last_date=\"2020-10\",\n",
29312939
" ccy=curr,\n",
2932-
" bounds=((0, 0.4), (0, 1), (0, 1)), # add bounds \n",
2940+
" bounds=((0, 0.4), (0, 1), (0, 1)), # add bounds\n",
29332941
" verbose=False,\n",
29342942
")\n",
29352943
"\n",
@@ -2968,7 +2976,7 @@
29682976
},
29692977
"outputs": [],
29702978
"source": [
2971-
"ef = ok.EfficientFrontierReb(['SPY.US', 'MCFTR.INDX'], ccy='RUB', last_date='2025-03', bounds=None)"
2979+
"ef = ok.EfficientFrontierReb([\"SPY.US\", \"MCFTR.INDX\"], ccy=\"RUB\", last_date=\"2025-03\", bounds=None)"
29722980
]
29732981
},
29742982
{
@@ -2982,7 +2990,7 @@
29822990
},
29832991
"outputs": [],
29842992
"source": [
2985-
"ef = ok.EfficientFrontierReb(['SPY.US', 'GLD.US'], ccy='USD', last_date='2020-10', bounds=None)"
2993+
"ef = ok.EfficientFrontierReb([\"SPY.US\", \"GLD.US\"], ccy=\"USD\", last_date=\"2020-10\", bounds=None)"
29862994
]
29872995
},
29882996
{
@@ -3026,7 +3034,7 @@
30263034
"# ax.plot(df1_not_reb.Risk, df1_not_reb.CAGR, label=\"Not rebalanced\")\n",
30273035
"\n",
30283036
"# Plot the assets\n",
3029-
"ef.plot_assets(kind=\"cagr\")\n"
3037+
"ef.plot_assets(kind=\"cagr\")"
30303038
]
30313039
},
30323040
{

examples/01 howto.ipynb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
"outputs": [],
5050
"source": [
5151
"import warnings\n",
52+
"\n",
5253
"warnings.filterwarnings(\"ignore\")\n",
5354
"\n",
5455
"import matplotlib.pyplot as plt\n",

examples/02 index funds perfomance.ipynb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
"outputs": [],
4949
"source": [
5050
"import warnings\n",
51+
"\n",
5152
"warnings.filterwarnings(\"ignore\")\n",
5253
"\n",
5354
"import matplotlib.pyplot as plt\n",

examples/03 investment portfolios.ipynb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,11 @@
6060
"outputs": [],
6161
"source": [
6262
"import warnings\n",
63+
"\n",
6364
"warnings.simplefilter(action=\"ignore\", category=FutureWarning)\n",
6465
"\n",
6566
"import matplotlib.pyplot as plt\n",
67+
"\n",
6668
"plt.rcParams[\"figure.figsize\"] = [12.0, 6.0]\n",
6769
"\n",
6870
"import okama as ok"

examples/04 investment portfolios with DCF.ipynb

Lines changed: 15 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,11 @@
6464
"outputs": [],
6565
"source": [
6666
"import warnings\n",
67+
"\n",
6768
"warnings.simplefilter(action=\"ignore\", category=FutureWarning)\n",
6869
"\n",
6970
"import matplotlib.pyplot as plt\n",
71+
"\n",
7072
"plt.rcParams[\"figure.figsize\"] = [12.0, 6.0]\n",
7173
"\n",
7274
"import okama as ok"
@@ -122,7 +124,7 @@
122124
" inflation=True,\n",
123125
" last_date=\"2024-01\",\n",
124126
" rebalancing_strategy=ok.Rebalance(period=\"year\"),\n",
125-
" symbol=\"My_portfolio.PF\"\n",
127+
" symbol=\"My_portfolio.PF\",\n",
126128
")\n",
127129
"pf"
128130
]
@@ -172,7 +174,7 @@
172174
},
173175
"outputs": [],
174176
"source": [
175-
"ind = ok.IndexationStrategy(pf) # create IndexationStrategy linked to the Portfolio"
177+
"ind = ok.IndexationStrategy(pf) # create IndexationStrategy linked to the Portfolio"
176178
]
177179
},
178180
{
@@ -551,9 +553,9 @@
551553
"outputs": [],
552554
"source": [
553555
"pf.dcf.set_mc_parameters(\n",
554-
" distribution=\"norm\", # Normal distribution (or Gaussian distribution) \n",
556+
" distribution=\"norm\", # Normal distribution (or Gaussian distribution)\n",
555557
" period=60, # the forecasting period is 10 years\n",
556-
" number=400 # generate 400 random simulations\n",
558+
" number=400, # generate 400 random simulations\n",
557559
")"
558560
]
559561
},
@@ -594,7 +596,7 @@
594596
],
595597
"source": [
596598
"pf.dcf.plot_forecast_monte_carlo(backtest=False)\n",
597-
"plt.yscale(\"log\") # set logarithmic scale for Y-axis to see negative scenarios "
599+
"plt.yscale(\"log\") # set logarithmic scale for Y-axis to see negative scenarios"
598600
]
599601
},
600602
{
@@ -1441,7 +1443,7 @@
14411443
}
14421444
],
14431445
"source": [
1444-
"pf.dcf.wealth_index['My_portfolio.PF'].iat[-1]"
1446+
"pf.dcf.wealth_index[\"My_portfolio.PF\"].iat[-1]"
14451447
]
14461448
},
14471449
{
@@ -1619,11 +1621,7 @@
16191621
},
16201622
"outputs": [],
16211623
"source": [
1622-
"pf.dcf.set_mc_parameters(\n",
1623-
" distribution=\"norm\", \n",
1624-
" period=30, # simulation period in years \n",
1625-
" number=400 \n",
1626-
")"
1624+
"pf.dcf.set_mc_parameters(distribution=\"norm\", period=30, number=400) # simulation period in years"
16271625
]
16281626
},
16291627
{
@@ -1742,7 +1740,7 @@
17421740
" percentile=25, # The percentile of Monte Carlo result distribution where the goal is to be achieved. The 25th percentile is a negative scenario.\n",
17431741
" threshold=0.10, # 10% - is the percentage of initial investments when the portfolio balance is considered voided.\n",
17441742
" iter_max=50, # The maximum number of iterations to find the solution.\n",
1745-
" tolerance_rel=0.15 # The allowed tolerance for the solution. The tolerance is the largest error for the achieved goal.\n",
1743+
" tolerance_rel=0.15, # The allowed tolerance for the solution. The tolerance is the largest error for the achieved goal.\n",
17461744
")"
17471745
]
17481746
},
@@ -1818,7 +1816,7 @@
18181816
" percentile=25, # The percentile of Monte Carlo result distribution where the goal is to be achieved. The 25th percentile is a negative scenario.\n",
18191817
" threshold=0.10, # 10% - is the percentage of initial investments when the portfolio balance is considered voided.\n",
18201818
" iter_max=50, # The maximum number of iterations to find the solution.\n",
1821-
" tolerance_rel=0.15 # The allowed tolerance for the solution. The tolerance is the largest error for the achieved goal.\n",
1819+
" tolerance_rel=0.15, # The allowed tolerance for the solution. The tolerance is the largest error for the achieved goal.\n",
18221820
")"
18231821
]
18241822
},
@@ -1912,10 +1910,7 @@
19121910
},
19131911
"outputs": [],
19141912
"source": [
1915-
"d = {\n",
1916-
" \"2018-02\": 2_000, # contribution\n",
1917-
" \"2024-03\": -4_000 # withdrawal\n",
1918-
"}"
1913+
"d = {\"2018-02\": 2_000, \"2024-03\": -4_000} # contribution # withdrawal"
19191914
]
19201915
},
19211916
{
@@ -2419,10 +2414,7 @@
24192414
},
24202415
"outputs": [],
24212416
"source": [
2422-
"d = {\n",
2423-
" \"2027-02\": 2_000, # contribution\n",
2424-
" \"2034-03\": -4_000 # withdrawal\n",
2425-
"}"
2417+
"d = {\"2027-02\": 2_000, \"2034-03\": -4_000} # contribution # withdrawal"
24262418
]
24272419
},
24282420
{
@@ -2475,9 +2467,9 @@
24752467
"outputs": [],
24762468
"source": [
24772469
"pf2.dcf.set_mc_parameters(\n",
2478-
" distribution=\"norm\", # Normal distribution (or Gaussian distribution) \n",
2470+
" distribution=\"norm\", # Normal distribution (or Gaussian distribution)\n",
24792471
" period=30, # the forecasting period is 30 years\n",
2480-
" number=500 # generate 500 random simulations\n",
2472+
" number=500, # generate 500 random simulations\n",
24812473
")"
24822474
]
24832475
},

examples/05 macroeconomics - inflation rates.ipynb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
"outputs": [],
5757
"source": [
5858
"import warnings\n",
59+
"\n",
5960
"warnings.simplefilter(action=\"ignore\", category=FutureWarning)\n",
6061
"\n",
6162
"import matplotlib.pyplot as plt\n",

examples/06 efficient frontier single period.ipynb

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
"outputs": [],
2929
"source": [
3030
"import warnings\n",
31+
"\n",
3132
"warnings.simplefilter(action=\"ignore\", category=FutureWarning)\n",
3233
"\n",
3334
"import matplotlib.pyplot as plt\n",
@@ -2226,9 +2227,9 @@
22262227
"source": [
22272228
"df = four_assets.mdp_points\n",
22282229
"fig = plt.figure()\n",
2229-
"four_assets.plot_assets(kind='cagr')\n",
2230+
"four_assets.plot_assets(kind=\"cagr\")\n",
22302231
"ax = plt.gca()\n",
2231-
"ax.plot(df['Risk'], df['CAGR'])\n"
2232+
"ax.plot(df[\"Risk\"], df[\"CAGR\"])"
22322233
]
22332234
},
22342235
{
@@ -2264,15 +2265,15 @@
22642265
"df2 = four_assets.ef_points # the Efficient Frontier points\n",
22652266
"mdp = four_assets.get_most_diversified_portfolio() # the global Most diversified portfolio\n",
22662267
"fig = plt.figure()\n",
2267-
"four_assets.plot_assets(kind='cagr')\n",
2268+
"four_assets.plot_assets(kind=\"cagr\")\n",
22682269
"ax = plt.gca()\n",
2269-
"ax.plot(df1['Risk'], df1['CAGR'], label='Most diversified portfolios')\n",
2270-
"ax.plot(df2['Risk'], df2['CAGR'], label='Efficient Frontier')\n",
2271-
"ax.scatter(mdp['Risk'], mdp['CAGR'], s=30, marker='o', label='MDP')\n",
2270+
"ax.plot(df1[\"Risk\"], df1[\"CAGR\"], label=\"Most diversified portfolios\")\n",
2271+
"ax.plot(df2[\"Risk\"], df2[\"CAGR\"], label=\"Efficient Frontier\")\n",
2272+
"ax.scatter(mdp[\"Risk\"], mdp[\"CAGR\"], s=30, marker=\"o\", label=\"MDP\")\n",
22722273
"# Set title, legend and labels for axes\n",
2273-
"ax.set_title('Efficient Frontier vs Most diversified portfolios')\n",
2274-
"ax.set_xlabel('Risk (Standard Deviation)')\n",
2275-
"ax.set_ylabel('Return (CAGR)')\n",
2274+
"ax.set_title(\"Efficient Frontier vs Most diversified portfolios\")\n",
2275+
"ax.set_xlabel(\"Risk (Standard Deviation)\")\n",
2276+
"ax.set_ylabel(\"Return (CAGR)\")\n",
22762277
"ax.legend();"
22772278
]
22782279
},

0 commit comments

Comments
 (0)