Path: blob/master/finrl/applications/imitation_learning/Weight_Initialization.ipynb
732 views
Kernel: finrl
Installation Setup
In [1]:
In [2]:
Out[2]:
%pylab is deprecated, use %matplotlib inline and import the required libraries.
Populating the interactive namespace from numpy and matplotlib
C:\Users\kentw\AppData\Local\Continuum\anaconda3\envs\finrl\lib\site-packages\IPython\core\magics\pylab.py:162: UserWarning: pylab import has clobbered these variables: ['WE', 'MO', 'SU', 'FR', 'SA', 'TH', 'TU']
`%matplotlib` prevents importing * from pylab and numpy
warn("pylab import has clobbered these variables: %s" % clobbered +
In [3]:
In [4]:
Load Data
In [5]:
Out[5]:
Weight Initialization
Retail Weights (Rank-based method)
In [6]:
Out[6]:
Mean-Variance Optimization Weights
In [7]:
Data Split
In [8]:
In [9]:
Out[9]:
In [10]:
Out[10]:
In [11]:
Benchmarks
We compare the performance of different weighting methods on the train period
Mean Variance
Equally weighted (Buy and hold)
Market indexes (NASDAQ and XLK)
Individual stocks
Environment configuration
A gym-style portfolio allocation environment for agents to interact. It is handy to compare the performances.
In [12]:
Out[12]:
Stock Dimension: 11, State Space: 11
Feature Dimension: 4
Sampling
In [13]:
Out[13]:
=================================
begin_total_asset:1000000
end_total_asset:4904419.075973194
Sharpe: 0.6729768484476762
=================================
In [21]:
Out[21]:
=================================
begin_total_asset:1000000
end_total_asset:2954456.9590735934
Sharpe: 0.58838920208855
=================================
In [112]:
Out[112]:
[*********************100%***********************] 1 of 1 completed
Shape of DataFrame: (4074, 8)
Successfully added technical indicators
Successfully added turbulence index
In [113]:
Performance Comparison
In [114]:
Out[114]:
In [110]:
Out[110]:
In [ ]: