Kernel: Python 3
returns
In [2]:
In [3]:
Out[3]:
/Users/olegpolakow/miniconda3/lib/python3.7/site-packages/pandas_datareader/compat/__init__.py:7: FutureWarning: pandas.util.testing is deprecated. Use the functions in the public API at pandas.testing instead.
from pandas.util.testing import assert_frame_equal
/Users/olegpolakow/miniconda3/lib/python3.7/site-packages/empyrical/utils.py:32: UserWarning: Unable to import pandas_datareader. Suppressing import error and continuing. All data reading functionality will raise errors; but has been deprecated and will be removed in a later version.
warnings.warn(msg)
In [4]:
In [5]:
Out[5]:
a b c
2018-01-01 1.0 5.0 1.0
2018-01-02 2.0 4.0 2.0
2018-01-03 3.0 3.0 3.0
2018-01-04 4.0 2.0 2.0
2018-01-05 5.0 1.0 1.0
In [6]:
Out[6]:
(1000, 1000)
In [7]:
Out[7]:
a b c
2018-01-01 NaN NaN NaN
2018-01-02 1.000000 -0.200000 1.000000
2018-01-03 0.500000 -0.250000 0.500000
2018-01-04 0.333333 -0.333333 -0.333333
2018-01-05 0.250000 -0.500000 -0.500000
In [8]:
In [9]:
Out[9]:
252 days 00:00:00
252 days 00:00:00
252 days 00:00:00
252 days 00:00:00
In [10]:
Out[10]:
252.0
252.0
In [11]:
Out[11]:
2018-01-01 NaN
2018-01-02 1.000000
2018-01-03 0.500000
2018-01-04 0.333333
2018-01-05 0.250000
Freq: D, Name: a, dtype: float64
a b c
2018-01-01 NaN NaN NaN
2018-01-02 1.000000 -0.200000 1.000000
2018-01-03 0.500000 -0.250000 0.500000
2018-01-04 0.333333 -0.333333 -0.333333
2018-01-05 0.250000 -0.500000 -0.500000
The slowest run took 24.92 times longer than the fastest. This could mean that an intermediate result is being cached.
56 µs ± 106 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
In [12]:
Out[12]:
2018-01-01 4.0
Freq: 252D, Name: a, dtype: float64
a b c
2018-01-01 4.0 -0.8 2.980232e-08
5.96 ms ± 69.6 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
In [13]:
Out[13]:
2018-01-01 0.0
2018-01-02 1.0
2018-01-03 2.0
2018-01-04 3.0
2018-01-05 4.0
Freq: D, dtype: float64
963 µs ± 24.7 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
2018-01-01 0.0
2018-01-02 1.0
2018-01-03 2.0
2018-01-04 3.0
2018-01-05 4.0
Freq: D, Name: a, dtype: float64
The slowest run took 10.08 times longer than the fastest. This could mean that an intermediate result is being cached.
161 µs ± 220 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
a b c
2018-01-01 0.0 0.0 0.000000e+00
2018-01-02 1.0 -0.2 1.000000e+00
2018-01-03 2.0 -0.4 2.000000e+00
2018-01-04 3.0 -0.6 1.000000e+00
2018-01-05 4.0 -0.8 2.980232e-08
a b c
2018-01-01 1.0 1.0 1.0
2018-01-02 2.0 0.8 2.0
2018-01-03 3.0 0.6 3.0
2018-01-04 4.0 0.4 2.0
2018-01-05 5.0 0.2 1.0
4.31 ms ± 308 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
In [14]:
Out[14]:
4.000000149011612
84.9 µs ± 10.8 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
4.000000149011612
The slowest run took 7.79 times longer than the fastest. This could mean that an intermediate result is being cached.
124 µs ± 145 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
a 4.000000e+00
b -8.000000e-01
c 2.980232e-08
Name: total_return, dtype: float64
3.31 ms ± 74.7 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
a b c
2018-01-01 NaN NaN NaN
2018-01-02 1.0 -0.20 1.0
2018-01-03 2.0 -0.40 2.0
2018-01-04 3.0 -0.60 1.0
2018-01-05 1.5 -0.75 -0.5
117 ms ± 9.41 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)
In [15]:
Out[15]:
1.690786886567203e+35
88.2 µs ± 19.2 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
1.6907868865671834e+35
The slowest run took 5.69 times longer than the fastest. This could mean that an intermediate result is being cached.
160 µs ± 152 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
a 1.690787e+35
b -1.000000e+00
c 1.502038e-06
Name: annualized_return, dtype: float64
3.66 ms ± 122 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
a b c
2018-01-01 NaN NaN NaN
2018-01-02 8.507059e+37 -1.0 8.507059e+37
2018-01-03 1.197252e+40 -1.0 1.197252e+40
2018-01-04 3.741454e+50 -1.0 1.934286e+25
2018-01-05 2.672771e+33 -1.0 -1.000000e+00
145 ms ± 10.7 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)
In [16]:
Out[16]:
2.121838249438074
24.1 µs ± 10.1 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
2.121838249438074
The slowest run took 5.02 times longer than the fastest. This could mean that an intermediate result is being cached.
172 µs ± 149 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
a 2.121838
b 0.830587
c 4.466341
Name: annualized_volatility, dtype: float64
5.78 ms ± 82.4 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
a b c
2018-01-01 NaN NaN NaN
2018-01-02 NaN NaN NaN
2018-01-03 2.233170 0.223317 2.233170
2018-01-04 2.191425 0.425454 4.254544
2018-01-05 0.804033 0.804033 3.384043
262 ms ± 13.6 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)
In [17]:
Out[17]:
-1.2500000139698388
143 µs ± 36.8 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
-1.2500000139698388
The slowest run took 138.16 times longer than the fastest. This could mean that an intermediate result is being cached.
2.12 ms ± 4.94 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)
a NaN
b -1.250000
c 0.000002
Name: calmar_ratio, dtype: float64
11.5 ms ± 61.6 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
a b c
2018-01-01 NaN NaN NaN
2018-01-02 NaN -5.0 NaN
2018-01-03 NaN -2.5 NaN
2018-01-04 NaN -2.0 5.802859e+25
2018-01-05 NaN -1.5 -1.500000e+00
616 ms ± 13.9 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)
In [18]:
Out[18]:
1.7319528661672228
414 µs ± 31.5 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
1.7319528661672228
The slowest run took 136.51 times longer than the fastest. This could mean that an intermediate result is being cached.
1.99 ms ± 4.63 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)
a inf
b 0.000000
c 1.731953
Name: omega_ratio, dtype: float64
8.65 ms ± 66.1 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
a b c
2018-01-01 NaN NaN NaN
2018-01-02 inf 0.0 inf
2018-01-03 inf 0.0 inf
2018-01-04 inf 0.0 4.303734
2018-01-05 inf 0.0 0.573267
652 ms ± 13.7 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)
In [19]:
Out[19]:
24.139822936194918
80.5 µs ± 19.4 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
24.139822936194918
The slowest run took 124.12 times longer than the fastest. This could mean that an intermediate result is being cached.
2 ms ± 4.62 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)
a 24.139823
b -39.938439
c 3.517158
Name: sharpe_ratio, dtype: float64
8.53 ms ± 70.5 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
a b c
2018-01-01 NaN NaN NaN
2018-01-02 NaN NaN NaN
2018-01-03 33.225918 -105.514710 33.225918
2018-01-04 27.503962 -63.894201 8.929476
2018-01-05 43.786248 -46.280396 -3.588519
387 ms ± 14.5 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)
In [20]:
Out[20]:
a NaN
b NaN
c 0.000536
Name: deflated_sharpe_ratio, dtype: float64
/Users/olegpolakow/Documents/SourceTree/vectorbt/vectorbt/returns/metrics.py:23: RuntimeWarning: invalid value encountered in sqrt
np.sqrt(1 - skew * est_sharpe + ((kurtosis - 1) / 4) * est_sharpe ** 2))
/Users/olegpolakow/miniconda3/lib/python3.7/site-packages/scipy/stats/_distn_infrastructure.py:1922: RuntimeWarning: invalid value encountered in greater_equal
cond2 = (x >= np.asarray(_b)) & cond0
19 ms ± 751 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
1.0
In [21]:
Out[21]:
6.920801865722236
44.2 µs ± 23.6 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
6.920801865722236
The slowest run took 115.52 times longer than the fastest. This could mean that an intermediate result is being cached.
1.69 ms ± 3.89 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)
a 0.000000
b 6.920802
c 5.874521
Name: downside_risk, dtype: float64
6.09 ms ± 59.7 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
a b c
2018-01-01 NaN NaN NaN
2018-01-02 0.0 4.762352 0.000000
2018-01-03 0.0 5.174456 0.000000
2018-01-04 0.0 5.798563 3.971565
2018-01-05 0.0 7.503555 6.783313
377 ms ± 13.7 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)
In [22]:
Out[22]:
-15.32336860018125
113 µs ± 33.5 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
-15.32336860018125
The slowest run took 123.76 times longer than the fastest. This could mean that an intermediate result is being cached.
1.85 ms ± 4.29 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)
a inf
b -15.323369
c 2.859808
Name: sortino_ratio, dtype: float64
8.87 ms ± 72.6 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
a b c
2018-01-01 NaN NaN NaN
2018-01-02 inf -15.874508 inf
2018-01-03 inf -15.827749 inf
2018-01-04 inf -15.693543 18.330304
2018-01-05 inf -15.485994 -7.842775
491 ms ± 13.3 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)
In [26]:
Out[26]:
-0.5575108270794908
432 µs ± 73.3 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
-0.5575108270794908
144 µs ± 12.5 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
a -0.557511
b -2.718676
c -1.185416
Name: information_ratio, dtype: float64
8.39 ms ± 224 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
a b c
2018-01-01 NaN NaN NaN
2018-01-02 NaN NaN NaN
2018-01-03 -1.197205 -2.636038 -1.197205
2018-01-04 -0.903634 -2.536990 -0.905136
2018-01-05 -0.206482 -12.233914 -1.276646
386 ms ± 15.2 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)
In [28]:
Out[28]:
0.7853755820643185
1.17 ms ± 451 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
0.7853755820643185
107 µs ± 6.25 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
a 0.785376
b 0.252235
c 1.547239
Name: beta, dtype: float64
10 ms ± 253 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
a b c
2018-01-01 NaN NaN NaN
2018-01-02 NaN NaN NaN
2018-01-03 0.788784 0.078878 0.788784
2018-01-04 0.796948 0.140305 1.403054
2018-01-05 0.762210 0.727668 3.117926
592 ms ± 13.1 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)
In [29]:
Out[29]:
21533608.259557564
1.08 ms ± 185 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
21533608.259557564
The slowest run took 126.75 times longer than the fastest. This could mean that an intermediate result is being cached.
2.62 ms ± 6.07 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)
a 2.153361e+07
b -1.000000e+00
c -1.000000e+00
Name: alpha, dtype: float64
16.3 ms ± 5.61 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)
a b c
2018-01-01 NaN NaN NaN
2018-01-02 NaN NaN NaN
2018-01-03 1.221461e+07 -1.0 1.221461e+07
2018-01-04 1.606601e+06 -1.0 -1.000000e+00
2018-01-05 1.344194e+08 -1.0 -1.000000e+00
1.01 s ± 17.8 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)
In [30]:
Out[30]:
3.5238094437960337
137 µs ± 18.6 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
3.5238094437960337
The slowest run took 481.62 times longer than the fastest. This could mean that an intermediate result is being cached.
4.87 ms ± 11.7 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)
a 3.523809
b 0.436842
c 1.947368
Name: tail_ratio, dtype: float64
23.7 ms ± 90.3 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
a b c
2018-01-01 NaN NaN NaN
2018-01-02 1.000000 1.000000 1.000000
2018-01-03 1.857143 0.818182 1.857143
2018-01-04 2.714285 0.630769 3.800000
2018-01-05 1.870968 0.534483 0.862069
2.44 s ± 64.9 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)
In [31]:
Out[31]:
0.26250000596046447
81.6 µs ± 32.3 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
0.26250000596046447
The slowest run took 503.96 times longer than the fastest. This could mean that an intermediate result is being cached.
4.88 ms ± 11.8 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)
a 0.2625
b -0.4750
c -0.4750
Name: value_at_risk, dtype: float64
13.6 ms ± 196 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
a b c
2018-01-01 NaN NaN NaN
2018-01-02 1.000000 -0.200000 1.000000
2018-01-03 0.525000 -0.247500 0.525000
2018-01-04 0.350000 -0.325000 -0.250000
2018-01-05 0.258333 -0.483333 -0.483333
1.29 s ± 36.3 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)
In [32]:
Out[32]:
0.25
The slowest run took 4.48 times longer than the fastest. This could mean that an intermediate result is being cached.
41.2 µs ± 27.7 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
0.25
The slowest run took 433.89 times longer than the fastest. This could mean that an intermediate result is being cached.
4.25 ms ± 10.2 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)
a 0.25
b -0.50
c -0.50
Name: cond_value_at_risk, dtype: float64
12.4 ms ± 117 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
a b c
2018-01-01 NaN NaN NaN
2018-01-02 1.000000 -0.200000 1.000000
2018-01-03 0.500000 -0.250000 0.500000
2018-01-04 0.333333 -0.333333 -0.333333
2018-01-05 0.250000 -0.500000 -0.500000
1.97 s ± 39.4 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)
In [33]:
Out[33]:
0.00691706997447195
188 µs ± 118 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
0.006917069974471952
The slowest run took 99.74 times longer than the fastest. This could mean that an intermediate result is being cached.
2.06 ms ± 4.72 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)
/Users/olegpolakow/miniconda3/lib/python3.7/site-packages/empyrical/stats.py:447: RuntimeWarning: invalid value encountered in double_scalars
return ending_value ** (1 / num_years) - 1
a 6.917070e-03
b -4.091036e-38
c 6.144892e-44
Name: capture, dtype: float64
8.52 ms ± 3.92 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)
a b c
2018-01-01 NaN NaN NaN
2018-01-02 0.000019 -2.224899e-43 1.892734e-05
2018-01-03 0.000055 -4.590579e-45 5.496077e-05
2018-01-04 0.000024 -6.439659e-56 1.245614e-30
2018-01-05 0.353571 -1.322864e-34 -1.322864e-34
297 ms ± 12.9 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)
In [34]:
Out[34]:
0.0019948153957327634
428 µs ± 55.2 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
0.0019948153957327634
The slowest run took 108.89 times longer than the fastest. This could mean that an intermediate result is being cached.
2.18 ms ± 5 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)
a 1.994815e-03
b -1.839889e-47
c 3.454480e-53
Name: up_capture, dtype: float64
7.84 ms ± 4.83 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)
a b c
2018-01-01 NaN NaN NaN
2018-01-02 3.582444e-10 -4.950174e-86 3.582444e-10
2018-01-03 4.074546e-07 -3.110292e-67 4.074546e-07
2018-01-04 2.409368e-05 -6.439659e-56 1.245614e-30
2018-01-05 3.535714e-01 -1.322864e-34 -1.322864e-34
844 ms ± 15.5 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)
In [35]:
Out[35]:
nan
nan
The slowest run took 114.37 times longer than the fastest. This could mean that an intermediate result is being cached.
2.29 ms ± 5.28 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)
a NaN
b NaN
c NaN
Name: down_capture, dtype: float64
7.7 ms ± 4.79 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)
a b c
2018-01-01 NaN NaN NaN
2018-01-02 NaN NaN NaN
2018-01-03 NaN NaN NaN
2018-01-04 NaN NaN NaN
2018-01-05 NaN NaN NaN
844 ms ± 19.2 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)
In [36]:
Out[36]:
a b c
2018-01-01 0.0 0.0 0.000000
2018-01-02 0.0 -0.2 0.000000
2018-01-03 0.0 -0.4 0.000000
2018-01-04 0.0 -0.6 -0.333333
2018-01-05 0.0 -0.8 -0.666667
8.76 ms ± 831 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
In [37]:
Out[37]:
-0.7999999910593033
The slowest run took 4.07 times longer than the fastest. This could mean that an intermediate result is being cached.
87.9 µs ± 62.1 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
-0.7999999910593032
The slowest run took 210.20 times longer than the fastest. This could mean that an intermediate result is being cached.
2.01 ms ± 4.76 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)
a 0.000000
b -0.800000
c -0.666667
Name: max_drawdown, dtype: float64
8.07 ms ± 124 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
a b c
2018-01-01 NaN NaN NaN
2018-01-02 0.0 -0.200000 0.000000
2018-01-03 0.0 -0.400000 0.000000
2018-01-04 0.0 -0.500000 -0.333333
2018-01-05 0.0 -0.666667 -0.666667
490 ms ± 14 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)
In [38]:
Out[38]:
Drawdowns(**Config({
"wrapper": "<vectorbt.base.array_wrapper.ArrayWrapper object at 0x7fb4a0a65ef0> of shape (5, 3)",
"records_arr": "<numpy.ndarray object at 0x7fb4865b94e0> of shape (2,)",
"idx_field": "end_idx",
"col_mapper": null,
"ts": "<pandas.core.frame.DataFrame object at 0x7fb486d7a438> of shape (5, 3)"
}))
11.3 ms ± 620 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
a NaN
b -0.800000
c -0.666667
Name: max_drawdown, dtype: float64
In [42]:
Out[42]:
Start 2018-01-01 00:00:00
End 2018-01-05 00:00:00
Period 5 days 00:00:00
Total Return [%] -79.999999
Benchmark Return [%] 451.85973
Annualized Return [%] -100.0
Annualized Volatility [%] 83.05873
Max Drawdown [%] 79.999999
Max Drawdown Duration 4 days 00:00:00
Sharpe Ratio -39.938439
Calmar Ratio -1.25
Omega Ratio 0.0
Sortino Ratio -15.323369
Skew -1.065369
Kurtosis 0.645216
Tail Ratio 0.436842
Common Sense Ratio 0.0
Value at Risk -0.475
Alpha -1.0
Beta 0.252235
Name: b, dtype: object
48.8 ms ± 623 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
Start 2018-01-01 00:00:00
End 2018-01-05 00:00:00
Period 5 days 00:00:00
Total Return [%] 106.666673
Benchmark Return [%] 451.85973
Annualized Return [%] 5635956288557277813711347645725802496.0
Annualized Volatility [%] 247.292207
Max Drawdown [%] 73.333332
Max Drawdown Duration 3 days 00:00:00
Sharpe Ratio -4.093819
Calmar Ratio -0.624999
Omega Ratio inf
Sortino Ratio inf
Skew 0.256871
Kurtosis -0.254095
Tail Ratio 1.96934
Common Sense Ratio 198600359944397791384906716353134592.0
Value at Risk -0.229167
Alpha 7177868.753186
Beta 0.861616
Name: agg_func_mean, dtype: object
/Users/olegpolakow/miniconda3/lib/python3.7/site-packages/ipykernel_launcher.py:6: UserWarning: Object has multiple columns. Aggregating using <function mean at 0x7fb48139f9d8>. Pass column to select a single column/group.
207 ms ± 2.43 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)
In [43]:
Out[43]:
In [44]:
Out[44]:
In [ ]: