Kernel: Python 3 (ipykernel)
In [1]:
Out[1]:
(5,) (5, 3)
(1000, 1) (1000, 1000)
from_orders
In [2]:
In [46]:
Out[46]:
2.24 ms ± 179 µs per loop (mean ± std. dev. of 7 runs, 1 loop each)
In [48]:
Out[48]:
67 ms ± 2.3 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)
In [9]:
Out[9]:
64.3 ms ± 1.05 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)
In [7]:
Out[7]:
65.9 ms ± 1.68 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)
In [8]:
Out[8]:
71.7 ms ± 510 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
In [9]:
Out[9]:
66.3 ms ± 285 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
In [10]:
Out[10]:
63.7 ms ± 728 µs per loop (mean ± std. dev. of 7 runs, 1 loop each)
In [11]:
Out[11]:
68.3 ms ± 443 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
In [48]:
In [49]:
Out[49]:
All
id idx col size price fees side
0 0 0 0 100.0 1.0 0.0 0
1 1 1 0 200.0 2.0 0.0 1
2 2 3 0 100.0 4.0 0.0 0
LongOnly
id idx col size price fees side
0 0 0 0 100.0 1.0 0.0 0
1 1 1 0 100.0 2.0 0.0 1
2 2 3 0 50.0 4.0 0.0 0
3 3 4 0 50.0 5.0 0.0 1
ShortOnly
id idx col size price fees side
0 0 0 0 100.0 1.0 0.0 1
1 1 1 0 100.0 2.0 0.0 0
In [50]:
Out[50]:
All
id idx col size price fees side
0 0 0 0 100.0 1.0 0.0 0
1 1 1 0 200.0 2.0 0.0 1
2 2 3 0 100.0 4.0 0.0 0
3 3 0 1 100.0 1.0 0.0 0
4 4 1 1 200.0 2.0 0.0 1
5 5 3 1 100.0 4.0 0.0 0
6 6 0 2 100.0 1.0 0.0 0
7 7 1 2 200.0 2.0 0.0 1
8 8 3 2 100.0 4.0 0.0 0
LongOnly
id idx col size price fees side
0 0 0 0 100.0 1.0 0.0 0
1 1 1 0 100.0 2.0 0.0 1
2 2 3 0 50.0 4.0 0.0 0
3 3 4 0 50.0 5.0 0.0 1
4 4 0 1 100.0 1.0 0.0 0
5 5 1 1 100.0 2.0 0.0 1
6 6 3 1 50.0 4.0 0.0 0
7 7 4 1 50.0 5.0 0.0 1
8 8 0 2 100.0 1.0 0.0 0
9 9 1 2 100.0 2.0 0.0 1
10 10 3 2 50.0 4.0 0.0 0
11 11 4 2 50.0 5.0 0.0 1
ShortOnly
id idx col size price fees side
0 0 0 0 100.0 1.0 0.0 1
1 1 1 0 100.0 2.0 0.0 0
2 2 0 1 100.0 1.0 0.0 1
3 3 1 1 100.0 2.0 0.0 0
4 4 0 2 100.0 1.0 0.0 1
5 5 1 2 100.0 2.0 0.0 0
In [51]:
Out[51]:
All
id idx col size price fees side
0 0 0 0 100.0 1.0 0.0 0
1 1 0 1 100.0 1.0 0.0 1
LongOnly
id idx col size price fees side
0 0 0 0 100.0 1.0 0.0 0
ShortOnly
id idx col size price fees side
0 0 0 0 100.0 1.0 0.0 1
In [52]:
In [53]:
Out[53]:
All
id idx col size price fees side
0 0 0 0 99.009901 1.01 0.0 0
1 1 1 0 198.019802 2.02 0.0 1
2 2 3 0 99.009901 4.04 0.0 0
LongOnly
id idx col size price fees side
0 0 0 0 99.009901 1.01 0.0 0
1 1 1 0 99.009901 2.02 0.0 1
2 2 3 0 49.504950 4.04 0.0 0
3 3 4 0 49.504950 5.05 0.0 1
ShortOnly
id idx col size price fees side
0 0 0 0 99.009901 1.01 0.0 1
1 1 1 0 99.009901 2.02 0.0 0
In [54]:
Out[54]:
All
id idx col size price fees side
0 0 0 0 1.0 1.0 0.0 0
1 1 1 0 1.0 2.0 0.0 1
2 2 3 0 1.0 4.0 0.0 0
3 3 4 0 1.0 5.0 0.0 1
4 4 0 1 1.0 1.0 0.1 0
5 5 1 1 1.0 2.0 0.2 1
6 6 3 1 1.0 4.0 0.4 0
7 7 4 1 1.0 5.0 0.5 1
8 8 0 2 1.0 1.0 1.0 0
9 9 1 2 1.0 2.0 2.0 1
10 10 3 2 1.0 4.0 4.0 0
11 11 4 2 1.0 5.0 5.0 1
LongOnly
id idx col size price fees side
0 0 0 0 1.0 1.0 0.0 0
1 1 1 0 1.0 2.0 0.0 1
2 2 3 0 1.0 4.0 0.0 0
3 3 4 0 1.0 5.0 0.0 1
4 4 0 1 1.0 1.0 0.1 0
5 5 1 1 1.0 2.0 0.2 1
6 6 3 1 1.0 4.0 0.4 0
7 7 4 1 1.0 5.0 0.5 1
8 8 0 2 1.0 1.0 1.0 0
9 9 1 2 1.0 2.0 2.0 1
10 10 3 2 1.0 4.0 4.0 0
11 11 4 2 1.0 5.0 5.0 1
ShortOnly
id idx col size price fees side
0 0 0 0 1.0 1.0 0.0 1
1 1 1 0 1.0 2.0 0.0 0
2 2 3 0 1.0 4.0 0.0 1
3 3 4 0 1.0 5.0 0.0 0
4 4 0 1 1.0 1.0 0.1 1
5 5 1 1 1.0 2.0 0.2 0
6 6 3 1 1.0 4.0 0.4 1
7 7 4 1 1.0 5.0 0.5 0
8 8 0 2 1.0 1.0 1.0 1
9 9 1 2 1.0 2.0 2.0 0
10 10 3 2 1.0 4.0 4.0 1
11 11 4 2 1.0 5.0 5.0 0
In [55]:
Out[55]:
All
id idx col size price fees side
0 0 0 0 1.0 1.0 0.0 0
1 1 1 0 1.0 2.0 0.0 1
2 2 3 0 1.0 4.0 0.0 0
3 3 4 0 1.0 5.0 0.0 1
4 4 0 1 1.0 1.0 0.1 0
5 5 1 1 1.0 2.0 0.1 1
6 6 3 1 1.0 4.0 0.1 0
7 7 4 1 1.0 5.0 0.1 1
8 8 0 2 1.0 1.0 1.0 0
9 9 1 2 1.0 2.0 1.0 1
10 10 3 2 1.0 4.0 1.0 0
11 11 4 2 1.0 5.0 1.0 1
LongOnly
id idx col size price fees side
0 0 0 0 1.0 1.0 0.0 0
1 1 1 0 1.0 2.0 0.0 1
2 2 3 0 1.0 4.0 0.0 0
3 3 4 0 1.0 5.0 0.0 1
4 4 0 1 1.0 1.0 0.1 0
5 5 1 1 1.0 2.0 0.1 1
6 6 3 1 1.0 4.0 0.1 0
7 7 4 1 1.0 5.0 0.1 1
8 8 0 2 1.0 1.0 1.0 0
9 9 1 2 1.0 2.0 1.0 1
10 10 3 2 1.0 4.0 1.0 0
11 11 4 2 1.0 5.0 1.0 1
ShortOnly
id idx col size price fees side
0 0 0 0 1.0 1.0 0.0 1
1 1 1 0 1.0 2.0 0.0 0
2 2 3 0 1.0 4.0 0.0 1
3 3 4 0 1.0 5.0 0.0 0
4 4 0 1 1.0 1.0 0.1 1
5 5 1 1 1.0 2.0 0.1 0
6 6 3 1 1.0 4.0 0.1 1
7 7 4 1 1.0 5.0 0.1 0
8 8 0 2 1.0 1.0 1.0 1
9 9 1 2 1.0 2.0 1.0 0
10 10 3 2 1.0 4.0 1.0 1
11 11 4 2 1.0 5.0 1.0 0
In [56]:
Out[56]:
All
id idx col size price fees side
0 0 0 0 1.0 1.0 0.0 0
1 1 1 0 1.0 2.0 0.0 1
2 2 3 0 1.0 4.0 0.0 0
3 3 4 0 1.0 5.0 0.0 1
4 4 0 1 1.0 1.1 0.0 0
5 5 1 1 1.0 1.8 0.0 1
6 6 3 1 1.0 4.4 0.0 0
7 7 4 1 1.0 4.5 0.0 1
8 8 0 2 1.0 2.0 0.0 0
9 9 1 2 1.0 0.0 0.0 1
10 10 3 2 1.0 8.0 0.0 0
11 11 4 2 1.0 0.0 0.0 1
LongOnly
id idx col size price fees side
0 0 0 0 1.0 1.0 0.0 0
1 1 1 0 1.0 2.0 0.0 1
2 2 3 0 1.0 4.0 0.0 0
3 3 4 0 1.0 5.0 0.0 1
4 4 0 1 1.0 1.1 0.0 0
5 5 1 1 1.0 1.8 0.0 1
6 6 3 1 1.0 4.4 0.0 0
7 7 4 1 1.0 4.5 0.0 1
8 8 0 2 1.0 2.0 0.0 0
9 9 1 2 1.0 0.0 0.0 1
10 10 3 2 1.0 8.0 0.0 0
11 11 4 2 1.0 0.0 0.0 1
ShortOnly
id idx col size price fees side
0 0 0 0 1.0 1.0 0.0 1
1 1 1 0 1.0 2.0 0.0 0
2 2 3 0 1.0 4.0 0.0 1
3 3 4 0 1.0 5.0 0.0 0
4 4 0 1 1.0 0.9 0.0 1
5 5 1 1 1.0 2.2 0.0 0
6 6 3 1 1.0 3.6 0.0 1
7 7 4 1 1.0 5.5 0.0 0
8 8 0 2 1.0 0.0 0.0 1
9 9 1 2 1.0 4.0 0.0 0
10 10 3 2 1.0 0.0 0.0 1
11 11 4 2 1.0 10.0 0.0 0
In [57]:
Out[57]:
All
id idx col size price fees side
0 0 0 0 1.0 1.0 0.0 0
1 1 1 0 1.0 2.0 0.0 1
2 2 3 0 1.0 4.0 0.0 0
3 3 4 0 1.0 5.0 0.0 1
4 4 0 1 1.0 1.0 0.0 0
5 5 1 1 1.0 2.0 0.0 1
6 6 3 1 1.0 4.0 0.0 0
7 7 4 1 1.0 5.0 0.0 1
LongOnly
id idx col size price fees side
0 0 0 0 1.0 1.0 0.0 0
1 1 1 0 1.0 2.0 0.0 1
2 2 3 0 1.0 4.0 0.0 0
3 3 4 0 1.0 5.0 0.0 1
4 4 0 1 1.0 1.0 0.0 0
5 5 1 1 1.0 2.0 0.0 1
6 6 3 1 1.0 4.0 0.0 0
7 7 4 1 1.0 5.0 0.0 1
ShortOnly
id idx col size price fees side
0 0 0 0 1.0 1.0 0.0 1
1 1 1 0 1.0 2.0 0.0 0
2 2 3 0 1.0 4.0 0.0 1
3 3 4 0 1.0 5.0 0.0 0
4 4 0 1 1.0 1.0 0.0 1
5 5 1 1 1.0 2.0 0.0 0
6 6 3 1 1.0 4.0 0.0 1
7 7 4 1 1.0 5.0 0.0 0
In [58]:
Out[58]:
All
id idx col size price fees side
0 0 0 0 0.5 1.0 0.0 0
1 1 1 0 0.5 2.0 0.0 1
2 2 3 0 0.5 4.0 0.0 0
3 3 4 0 0.5 5.0 0.0 1
4 4 0 1 1.0 1.0 0.0 0
5 5 1 1 1.0 2.0 0.0 1
6 6 3 1 1.0 4.0 0.0 0
7 7 4 1 1.0 5.0 0.0 1
8 8 0 2 1.0 1.0 0.0 0
9 9 1 2 1.0 2.0 0.0 1
10 10 3 2 1.0 4.0 0.0 0
11 11 4 2 1.0 5.0 0.0 1
LongOnly
id idx col size price fees side
0 0 0 0 0.5 1.0 0.0 0
1 1 1 0 0.5 2.0 0.0 1
2 2 3 0 0.5 4.0 0.0 0
3 3 4 0 0.5 5.0 0.0 1
4 4 0 1 1.0 1.0 0.0 0
5 5 1 1 1.0 2.0 0.0 1
6 6 3 1 1.0 4.0 0.0 0
7 7 4 1 1.0 5.0 0.0 1
8 8 0 2 1.0 1.0 0.0 0
9 9 1 2 1.0 2.0 0.0 1
10 10 3 2 1.0 4.0 0.0 0
11 11 4 2 1.0 5.0 0.0 1
ShortOnly
id idx col size price fees side
0 0 0 0 0.5 1.0 0.0 1
1 1 1 0 0.5 2.0 0.0 0
2 2 3 0 0.5 4.0 0.0 1
3 3 4 0 0.5 5.0 0.0 0
4 4 0 1 1.0 1.0 0.0 1
5 5 1 1 1.0 2.0 0.0 0
6 6 3 1 1.0 4.0 0.0 1
7 7 4 1 1.0 5.0 0.0 0
8 8 0 2 1.0 1.0 0.0 1
9 9 1 2 1.0 2.0 0.0 0
10 10 3 2 1.0 4.0 0.0 1
11 11 4 2 1.0 5.0 0.0 0
In [59]:
Out[59]:
All
id idx col size price fees side
0 0 0 0 1.0 1.0 0.0 0
1 1 1 0 1.0 2.0 0.0 1
2 2 3 0 1.0 4.0 0.0 0
3 3 4 0 1.0 5.0 0.0 1
4 4 1 1 1.0 2.0 0.0 1
5 5 3 1 1.0 4.0 0.0 0
6 6 4 1 1.0 5.0 0.0 1
LongOnly
id idx col size price fees side
0 0 0 0 1.0 1.0 0.0 0
1 1 1 0 1.0 2.0 0.0 1
2 2 3 0 1.0 4.0 0.0 0
3 3 4 0 1.0 5.0 0.0 1
4 4 3 1 1.0 4.0 0.0 0
5 5 4 1 1.0 5.0 0.0 1
ShortOnly
id idx col size price fees side
0 0 0 0 1.0 1.0 0.0 1
1 1 1 0 1.0 2.0 0.0 0
2 2 3 0 1.0 4.0 0.0 1
3 3 4 0 1.0 5.0 0.0 0
4 4 3 1 1.0 4.0 0.0 1
5 5 4 1 1.0 5.0 0.0 0
In [60]:
Out[60]:
All
__init__() got an unexpected keyword argument 'close_first'
LongOnly
__init__() got an unexpected keyword argument 'close_first'
ShortOnly
__init__() got an unexpected keyword argument 'close_first'
In [61]:
Out[61]:
All
id idx col size price fees side
0 0 0 0 100.0 1.0 0.0 0
1 1 1 0 1000.0 2.0 0.0 1
2 2 3 0 500.0 4.0 0.0 0
3 3 4 0 1000.0 5.0 0.0 1
4 4 1 1 1000.0 2.0 0.0 1
5 5 4 1 1000.0 5.0 0.0 1
LongOnly
id idx col size price fees side
0 0 0 0 100.0 1.0 0.0 0
1 1 1 0 100.0 2.0 0.0 1
2 2 3 0 50.0 4.0 0.0 0
3 3 4 0 50.0 5.0 0.0 1
ShortOnly
id idx col size price fees side
0 0 0 0 1000.0 1.0 0.0 1
1 1 1 0 550.0 2.0 0.0 0
2 2 3 0 1000.0 4.0 0.0 1
3 3 4 0 800.0 5.0 0.0 0
4 4 0 1 1000.0 1.0 0.0 1
5 5 3 1 1000.0 4.0 0.0 1
6 6 4 1 1000.0 5.0 0.0 0
All
id idx col size price fees side
0 0 0 0 100.0 1.0 0.0 0
1 1 1 0 200.0 2.0 0.0 1
2 2 3 0 100.0 4.0 0.0 0
3 3 0 1 100.0 1.0 0.0 0
4 4 1 1 200.0 2.0 0.0 1
5 5 3 1 100.0 4.0 0.0 0
LongOnly
id idx col size price fees side
0 0 0 0 100.0 1.0 0.0 0
1 1 1 0 100.0 2.0 0.0 1
2 2 3 0 50.0 4.0 0.0 0
3 3 4 0 50.0 5.0 0.0 1
4 4 0 1 100.0 1.0 0.0 0
5 5 1 1 100.0 2.0 0.0 1
6 6 3 1 50.0 4.0 0.0 0
7 7 4 1 50.0 5.0 0.0 1
ShortOnly
id idx col size price fees side
0 0 0 0 100.0 1.0 0.0 1
1 1 1 0 100.0 2.0 0.0 0
2 2 0 1 100.0 1.0 0.0 1
3 3 1 1 100.0 2.0 0.0 0
In [62]:
Out[62]:
All
id idx col size price fees side
0 0 0 0 100.0 1.0 0.0 0
1 1 1 0 1000.0 2.0 0.0 1
2 2 3 0 500.0 4.0 0.0 0
3 3 4 0 1000.0 5.0 0.0 1
LongOnly
id idx col size price fees side
0 0 0 0 100.0 1.0 0.0 0
1 1 1 0 100.0 2.0 0.0 1
2 2 3 0 50.0 4.0 0.0 0
3 3 4 0 50.0 5.0 0.0 1
ShortOnly
id idx col size price fees side
0 0 0 0 1000.0 1.0 0.0 1
1 1 1 0 550.0 2.0 0.0 0
2 2 3 0 1000.0 4.0 0.0 1
3 3 4 0 800.0 5.0 0.0 0
All
Final size is less than requested
LongOnly
Final size is less than requested
ShortOnly
Final size is less than requested
In [63]:
Out[63]:
id idx col group cash position debt free_cash val_price value \
0 0 0 0 0 100.0 0.0 0.0 100.0 1.0 100.0
1 1 1 0 0 0.0 100.0 0.0 0.0 2.0 200.0
2 2 2 0 0 400.0 -100.0 200.0 0.0 3.0 100.0
3 3 3 0 0 400.0 -100.0 200.0 0.0 4.0 0.0
4 4 4 0 0 0.0 0.0 0.0 0.0 5.0 0.0
... new_free_cash new_val_price new_value res_size res_price \
0 ... 0.0 1.0 100.0 100.0 1.0
1 ... 0.0 2.0 200.0 200.0 2.0
2 ... 0.0 3.0 100.0 NaN NaN
3 ... 0.0 4.0 0.0 100.0 4.0
4 ... 0.0 5.0 0.0 NaN NaN
res_fees res_side res_status res_status_info order_id
0 0.0 0 0 -1 0
1 0.0 1 0 -1 1
2 NaN -1 1 0 -1
3 0.0 0 0 -1 2
4 NaN -1 2 6 -1
[5 rows x 37 columns]
In [64]:
Out[64]:
id idx col size price fees side
0 0 0 0 100.0 1.0 0.0 0
1 1 1 0 200.0 2.0 0.0 1
2 2 3 0 100.0 4.0 0.0 0
3 3 0 1 100.0 1.0 0.0 0
4 4 1 1 200.0 2.0 0.0 1
5 5 3 1 100.0 4.0 0.0 0
6 6 0 2 100.0 1.0 0.0 0
7 7 1 2 200.0 2.0 0.0 1
8 8 3 2 100.0 4.0 0.0 0
In [65]:
Out[65]:
id idx col size price fees side
0 0 0 0 100.0 1.0 0.0 0
1 1 1 0 200.0 2.0 0.0 1
2 2 3 0 100.0 4.0 0.0 0
3 3 0 2 100.0 1.0 0.0 0
4 4 1 2 200.0 2.0 0.0 1
5 5 3 2 100.0 4.0 0.0 0
a b c
2020-01-01 0 1 0
2020-01-02 0 1 0
2020-01-03 0 1 0
2020-01-04 0 1 0
2020-01-05 0 1 0
In [66]:
Out[66]:
id idx col size price fees side
0 0 0 1 100.0 1.0 0.0 0
1 1 1 1 200.0 2.0 0.0 1
2 2 3 1 100.0 4.0 0.0 0
3 3 0 2 100.0 1.0 0.0 0
4 4 1 2 200.0 2.0 0.0 1
5 5 3 2 100.0 4.0 0.0 0
a b c
2020-01-01 1 0 0
2020-01-02 1 0 0
2020-01-03 1 0 0
2020-01-04 1 0 0
2020-01-05 1 0 0
In [67]:
Out[67]:
id idx col size price fees side
0 0 0 0 100.0 1.0 0.0 0
1 1 1 0 200.0 2.0 0.0 1
2 2 3 1 100.0 4.0 0.0 0
3 3 4 1 120.0 5.0 0.0 1
4 4 0 2 100.0 1.0 0.0 0
5 5 1 2 200.0 2.0 0.0 1
6 6 3 2 100.0 4.0 0.0 0
a b c
2020-01-01 0 1 0
2020-01-02 0 1 0
2020-01-03 0 1 0
2020-01-04 1 0 0
2020-01-05 0 1 0
id idx col size price fees side
0 0 0 1 100.0 1.0 0.0 0
1 1 1 1 200.0 2.0 0.0 1
2 2 3 1 100.0 4.0 0.0 0
3 3 0 2 100.0 1.0 0.0 0
4 4 1 2 200.0 2.0 0.0 1
5 5 3 2 100.0 4.0 0.0 0
a b c
2020-01-01 1 0 0
2020-01-02 0 1 0
2020-01-03 1 0 0
2020-01-04 1 0 0
2020-01-05 1 0 0
In [68]:
Out[68]:
All
id idx col size price fees side
0 0 0 2 100.0 1.0 0.0 0
1 1 1 2 200.0 1.0 0.0 1
2 2 1 1 200.0 1.0 0.0 0
3 3 2 1 200.0 1.0 0.0 1
4 4 2 0 200.0 1.0 0.0 0
5 5 3 0 200.0 1.0 0.0 1
6 6 3 2 200.0 1.0 0.0 0
7 7 4 2 200.0 1.0 0.0 1
8 8 4 1 200.0 1.0 0.0 0
0 1 2
0 0 1 2
1 2 0 1
2 1 2 0
3 0 1 2
4 2 0 1
0 1 2
0 0.0 0.0 100.0
1 0.0 200.0 -100.0
2 200.0 0.0 -100.0
3 0.0 0.0 100.0
4 0.0 200.0 -100.0
0 100.0
1 100.0
2 100.0
3 100.0
4 100.0
dtype: float64
LongOnly
id idx col size price fees side
0 0 0 2 100.0 1.0 0.0 0
1 1 1 2 100.0 1.0 0.0 1
2 2 1 1 100.0 1.0 0.0 0
3 3 2 1 100.0 1.0 0.0 1
4 4 2 0 100.0 1.0 0.0 0
5 5 3 0 100.0 1.0 0.0 1
6 6 3 2 100.0 1.0 0.0 0
7 7 4 2 100.0 1.0 0.0 1
8 8 4 1 100.0 1.0 0.0 0
0 1 2
0 0 1 2
1 2 0 1
2 1 2 0
3 0 1 2
4 2 0 1
0 1 2
0 0.0 0.0 100.0
1 0.0 100.0 0.0
2 100.0 0.0 0.0
3 0.0 0.0 100.0
4 0.0 100.0 0.0
0 100.0
1 100.0
2 100.0
3 100.0
4 100.0
dtype: float64
ShortOnly
id idx col size price fees side
0 0 0 2 100.0 1.0 0.0 1
1 1 1 2 100.0 1.0 0.0 0
2 2 2 0 100.0 1.0 0.0 1
3 3 3 0 100.0 1.0 0.0 0
4 4 4 1 100.0 1.0 0.0 1
0 1 2
0 2 0 1
1 1 0 2
2 0 2 1
3 2 1 0
4 1 0 2
0 1 2
0 0.0 0.0 -100.0
1 0.0 0.0 0.0
2 -100.0 0.0 0.0
3 0.0 0.0 0.0
4 0.0 -100.0 0.0
0 100.0
1 100.0
2 100.0
3 100.0
4 100.0
dtype: float64
In [69]:
Out[69]:
All
id idx col size price fees side
0 0 0 0 75.0 1.0 0.0 0
1 1 0 1 75.0 1.0 0.0 1
LongOnly
id idx col size price fees side
0 0 0 0 75.0 1.0 0.0 0
ShortOnly
id idx col size price fees side
0 0 0 0 75.0 1.0 0.0 1
0 1
2020-01-01 75.0 -75.0
2020-01-02 75.0 -75.0
2020-01-03 75.0 -75.0
2020-01-04 75.0 -75.0
2020-01-05 75.0 -75.0
id idx col size price fees side
0 0 0 0 75.0 1.0 0.0 0
1 1 0 1 25.0 1.0 0.0 0
a b c
2020-01-01 75.0 25.0 0.0
2020-01-02 75.0 25.0 0.0
2020-01-03 75.0 25.0 0.0
2020-01-04 75.0 25.0 0.0
2020-01-05 75.0 25.0 0.0
In [70]:
Out[70]:
All
id idx col size price fees side
0 0 0 0 50.000000 1.0 0.0 0
1 1 1 0 25.000000 2.0 0.0 1
2 2 2 0 8.333333 3.0 0.0 1
3 3 3 0 4.166667 4.0 0.0 1
4 4 4 0 2.500000 5.0 0.0 1
5 5 0 1 50.000000 1.0 0.0 1
6 6 1 1 25.000000 2.0 0.0 0
7 7 2 1 8.333333 3.0 0.0 0
8 8 3 1 4.166667 4.0 0.0 0
9 9 4 1 2.500000 5.0 0.0 0
LongOnly
id idx col size price fees side
0 0 0 0 50.000000 1.0 0.0 0
1 1 1 0 25.000000 2.0 0.0 1
2 2 2 0 8.333333 3.0 0.0 1
3 3 3 0 4.166667 4.0 0.0 1
4 4 4 0 2.500000 5.0 0.0 1
ShortOnly
id idx col size price fees side
0 0 0 0 50.000000 1.0 0.0 1
1 1 1 0 25.000000 2.0 0.0 0
2 2 2 0 8.333333 3.0 0.0 0
3 3 3 0 4.166667 4.0 0.0 0
4 4 4 0 2.500000 5.0 0.0 0
0 1
2020-01-01 50.0 -50.0
2020-01-02 50.0 -50.0
2020-01-03 50.0 -50.0
2020-01-04 50.0 -50.0
2020-01-05 50.0 -50.0
id idx col size price fees side
0 0 0 0 50.000000 1.0 0.0 0
1 1 0 1 50.000000 1.0 0.0 0
2 2 1 0 25.000000 2.0 0.0 1
3 3 1 1 25.000000 2.0 0.0 1
4 4 1 2 25.000000 2.0 0.0 0
5 5 2 0 8.333333 3.0 0.0 1
6 6 2 1 8.333333 3.0 0.0 1
7 7 2 2 8.333333 3.0 0.0 1
8 8 3 0 4.166667 4.0 0.0 1
9 9 3 1 4.166667 4.0 0.0 1
10 10 3 2 4.166667 4.0 0.0 1
11 11 4 0 2.500000 5.0 0.0 1
12 12 4 1 2.500000 5.0 0.0 1
13 13 4 2 2.500000 5.0 0.0 1
a b c
2020-01-01 50.0 50.0 0.0
2020-01-02 50.0 50.0 50.0
2020-01-03 50.0 50.0 50.0
2020-01-04 50.0 50.0 50.0
2020-01-05 50.0 50.0 50.0
In [71]:
Out[71]:
All
id idx col size price fees side
0 0 0 0 50.000000 1.0 0.0 0
1 1 1 0 12.500000 2.0 0.0 1
2 2 2 0 6.250000 3.0 0.0 1
3 3 3 0 3.906250 4.0 0.0 1
4 4 4 0 2.734375 5.0 0.0 1
5 5 0 1 50.000000 1.0 0.0 1
6 6 1 1 37.500000 2.0 0.0 0
7 7 2 1 6.250000 3.0 0.0 0
8 8 3 1 2.343750 4.0 0.0 0
9 9 4 1 1.171875 5.0 0.0 0
LongOnly
id idx col size price fees side
0 0 0 0 50.000000 1.0 0.0 0
1 1 1 0 12.500000 2.0 0.0 1
2 2 2 0 6.250000 3.0 0.0 1
3 3 3 0 3.906250 4.0 0.0 1
4 4 4 0 2.734375 5.0 0.0 1
ShortOnly
id idx col size price fees side
0 0 0 0 50.000000 1.0 0.0 1
1 1 1 0 37.500000 2.0 0.0 0
2 2 2 0 6.250000 3.0 0.0 0
3 3 3 0 2.343750 4.0 0.0 0
4 4 4 0 1.171875 5.0 0.0 0
0 1
2020-01-01 0.5 -0.5
2020-01-02 0.5 -0.5
2020-01-03 0.5 -0.5
2020-01-04 0.5 -0.5
2020-01-05 0.5 -0.5
id idx col size price fees side
0 0 0 0 50.0 1.0 0.0 0
1 1 0 1 50.0 1.0 0.0 0
a b c
2020-01-01 0.500000 0.500000 0.0
2020-01-02 0.666667 0.666667 0.0
2020-01-03 0.750000 0.750000 0.0
2020-01-04 0.800000 0.800000 0.0
2020-01-05 0.833333 0.833333 0.0
In [72]:
Out[72]:
a b c
2020-01-01 0.0 30.0 70.0
2020-01-02 70.0 0.0 30.0
2020-01-03 30.0 70.0 0.0
2020-01-04 0.0 30.0 70.0
2020-01-05 70.0 30.0 0.0
In [75]:
Out[75]:
id idx col size price fees side
0 0 0 1 30.0 1.0 0.0 0
1 1 0 2 70.0 1.0 0.0 0
2 2 1 2 40.0 1.0 0.0 1
3 3 1 1 30.0 1.0 0.0 1
4 4 2 1 70.0 1.0 0.0 0
5 5 2 2 30.0 1.0 0.0 1
6 6 3 2 30.0 1.0 0.0 0
7 7 3 1 40.0 1.0 0.0 1
8 8 4 0 40.0 1.0 0.0 0
9 9 4 2 30.0 1.0 0.0 1
a b c
2020-01-01 0.0 30.0 70.0
2020-01-02 0.0 -30.0 -40.0
2020-01-03 0.0 70.0 -30.0
2020-01-04 0.0 -40.0 30.0
2020-01-05 40.0 0.0 -30.0
a b c
2020-01-01 0.0 30.0 70.0
2020-01-02 0.0 0.0 30.0
2020-01-03 0.0 70.0 0.0
2020-01-04 0.0 30.0 30.0
2020-01-05 40.0 30.0 0.0
a b c
2020-01-01 1 2 0
2020-01-02 0 2 1
2020-01-03 1 0 2
2020-01-04 0 2 1
2020-01-05 1 0 2
In [76]:
Out[76]:
id idx col size price fees side
0 0 0 1 30.0 1.0 0.0 0
1 1 0 2 70.0 1.0 0.0 0
2 2 1 2 40.0 1.0 0.0 1
3 3 1 1 30.0 1.0 0.0 1
4 4 1 0 70.0 1.0 0.0 0
5 5 2 0 40.0 1.0 0.0 1
6 6 2 2 30.0 1.0 0.0 1
7 7 2 1 70.0 1.0 0.0 0
8 8 3 1 40.0 1.0 0.0 1
9 9 3 0 30.0 1.0 0.0 1
10 10 3 2 70.0 1.0 0.0 0
11 11 4 2 70.0 1.0 0.0 1
12 12 4 0 70.0 1.0 0.0 0
a b c
2020-01-01 0.0 30.0 70.0
2020-01-02 70.0 -30.0 -40.0
2020-01-03 -40.0 70.0 -30.0
2020-01-04 -30.0 -40.0 70.0
2020-01-05 70.0 0.0 -70.0
a b c
2020-01-01 0.0 30.0 70.0
2020-01-02 70.0 0.0 30.0
2020-01-03 30.0 70.0 0.0
2020-01-04 0.0 30.0 70.0
2020-01-05 70.0 30.0 0.0
a b c
2020-01-01 0 1 2
2020-01-02 2 1 0
2020-01-03 0 2 1
2020-01-04 1 0 2
2020-01-05 2 1 0
In [77]:
Out[77]:
id idx col size price fees side
0 0 0 1 30.0 1.0 0.0 0
1 1 0 2 70.0 1.0 0.0 0
2 2 1 2 40.0 1.0 0.0 1
3 3 1 1 30.0 1.0 0.0 1
4 4 1 0 70.0 1.0 0.0 0
5 5 2 0 40.0 1.0 0.0 1
6 6 2 2 30.0 1.0 0.0 1
7 7 2 1 70.0 1.0 0.0 0
8 8 3 1 40.0 1.0 0.0 1
9 9 3 0 30.0 1.0 0.0 1
10 10 3 2 70.0 1.0 0.0 0
11 11 4 2 70.0 1.0 0.0 1
12 12 4 0 70.0 1.0 0.0 0
a b c
2020-01-01 0.0 30.0 70.0
2020-01-02 70.0 -30.0 -40.0
2020-01-03 -40.0 70.0 -30.0
2020-01-04 -30.0 -40.0 70.0
2020-01-05 70.0 0.0 -70.0
a b c
2020-01-01 0.0 30.0 70.0
2020-01-02 70.0 0.0 30.0
2020-01-03 30.0 70.0 0.0
2020-01-04 0.0 30.0 70.0
2020-01-05 70.0 30.0 0.0
a b c
2020-01-01 0 1 2
2020-01-02 2 1 0
2020-01-03 0 2 1
2020-01-04 1 0 2
2020-01-05 2 1 0
from_signals
In [2]:
Out[2]:
(5,) (5, 3)
(5,) (5, 3)
(1000,) (1000, 1000)
(1000,) (1000, 1000)
In [3]:
Out[3]:
2.72 ms ± 238 µs per loop (mean ± std. dev. of 7 runs, 1 loop each)
In [5]:
Out[5]:
95.1 ms ± 2.6 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)
In [6]:
Out[6]:
104 ms ± 1.87 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)
In [8]:
Out[8]:
171 ms ± 6.43 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)
In [10]:
Out[10]:
98.4 ms ± 250 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
In [11]:
Out[11]:
100 ms ± 564 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
In [12]:
Out[12]:
101 ms ± 191 µs per loop (mean ± std. dev. of 7 runs, 1 loop each)
In [13]:
Out[13]:
98.6 ms ± 848 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
In [7]:
Out[7]:
96 ms ± 501 µs per loop (mean ± std. dev. of 7 runs, 1 loop each)
In [15]:
Out[15]:
279 ms ± 1.83 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)
In [7]:
In [8]:
Out[8]:
Both
id col idx size price fees side
0 0 0 0 100.0 1.0 0.0 0
1 1 0 3 200.0 4.0 0.0 1
LongOnly
id col idx size price fees side
0 0 0 0 100.0 1.0 0.0 0
1 1 0 3 100.0 4.0 0.0 1
ShortOnly
id col idx size price fees side
0 0 0 0 100.0 1.0 0.0 1
1 1 0 3 50.0 4.0 0.0 0
In [9]:
Out[9]:
Both
id col idx size price fees side
0 0 1 0 1.0 1.0 0.0 0
1 1 1 3 2.0 4.0 0.0 1
2 2 2 0 100.0 1.0 0.0 0
3 3 2 3 200.0 4.0 0.0 1
LongOnly
id col idx size price fees side
0 0 1 0 1.0 1.0 0.0 0
1 1 1 3 1.0 4.0 0.0 1
2 2 2 0 100.0 1.0 0.0 0
3 3 2 3 100.0 4.0 0.0 1
ShortOnly
id col idx size price fees side
0 0 1 0 1.0 1.0 0.0 1
1 1 1 3 1.0 4.0 0.0 0
2 2 2 0 100.0 1.0 0.0 1
3 3 2 3 50.0 4.0 0.0 0
In [10]:
Out[10]:
Both
SizeType.Percent does not support position reversal using signals
LongOnly
id col idx size price fees side
0 0 0 0 50.0 1.0 0.0 0
1 1 0 3 50.0 4.0 0.0 1
ShortOnly
id col idx size price fees side
0 0 0 0 50.0 1.0 0.0 1
1 1 0 3 37.5 4.0 0.0 0
In [11]:
Out[11]:
Both
id col idx size price fees side
0 0 0 0 50.000 1.0 0.0 0
1 1 0 1 12.500 2.0 0.0 0
2 2 0 3 65.625 4.0 0.0 1
3 3 0 4 26.250 5.0 0.0 1
LongOnly
id col idx size price fees side
0 0 0 0 50.000 1.0 0.0 0
1 1 0 1 12.500 2.0 0.0 0
2 2 0 3 31.250 4.0 0.0 1
3 3 0 4 15.625 5.0 0.0 1
ShortOnly
id col idx size price fees side
0 0 0 0 50.000 1.0 0.0 1
1 1 0 1 12.500 2.0 0.0 1
2 2 0 3 21.875 4.0 0.0 0
3 3 0 4 8.750 5.0 0.0 0
In [12]:
Out[12]:
Both
id col idx size price fees side
0 0 0 0 99.009901 1.01 0.0 0
1 1 0 3 198.019802 4.04 0.0 1
LongOnly
id col idx size price fees side
0 0 0 0 99.009901 1.01 0.0 0
1 1 0 3 99.009901 4.04 0.0 1
ShortOnly
id col idx size price fees side
0 0 0 0 99.009901 1.01 0.0 1
1 1 0 3 49.504950 4.04 0.0 0
In [13]:
Out[13]:
Both
id col idx size price fees side
0 0 0 0 1.0 1.0 0.0 0
1 1 0 3 2.0 4.0 0.0 1
2 2 1 0 1.0 1.0 0.1 0
3 3 1 3 2.0 4.0 0.8 1
4 4 2 0 1.0 1.0 1.0 0
5 5 2 3 2.0 4.0 8.0 1
LongOnly
id col idx size price fees side
0 0 0 0 1.0 1.0 0.0 0
1 1 0 3 1.0 4.0 0.0 1
2 2 1 0 1.0 1.0 0.1 0
3 3 1 3 1.0 4.0 0.4 1
4 4 2 0 1.0 1.0 1.0 0
5 5 2 3 1.0 4.0 4.0 1
ShortOnly
id col idx size price fees side
0 0 0 0 1.0 1.0 0.0 1
1 1 0 3 1.0 4.0 0.0 0
2 2 1 0 1.0 1.0 0.1 1
3 3 1 3 1.0 4.0 0.4 0
4 4 2 0 1.0 1.0 1.0 1
5 5 2 3 1.0 4.0 4.0 0
In [14]:
Out[14]:
Both
id col idx size price fees side
0 0 0 0 1.0 1.0 0.0 0
1 1 0 3 2.0 4.0 0.0 1
2 2 1 0 1.0 1.0 0.1 0
3 3 1 3 2.0 4.0 0.1 1
4 4 2 0 1.0 1.0 1.0 0
5 5 2 3 2.0 4.0 1.0 1
LongOnly
id col idx size price fees side
0 0 0 0 1.0 1.0 0.0 0
1 1 0 3 1.0 4.0 0.0 1
2 2 1 0 1.0 1.0 0.1 0
3 3 1 3 1.0 4.0 0.1 1
4 4 2 0 1.0 1.0 1.0 0
5 5 2 3 1.0 4.0 1.0 1
ShortOnly
id col idx size price fees side
0 0 0 0 1.0 1.0 0.0 1
1 1 0 3 1.0 4.0 0.0 0
2 2 1 0 1.0 1.0 0.1 1
3 3 1 3 1.0 4.0 0.1 0
4 4 2 0 1.0 1.0 1.0 1
5 5 2 3 1.0 4.0 1.0 0
In [15]:
Out[15]:
Both
id col idx size price fees side
0 0 0 0 1.0 1.0 0.0 0
1 1 0 3 2.0 4.0 0.0 1
2 2 1 0 1.0 1.1 0.0 0
3 3 1 3 2.0 3.6 0.0 1
4 4 2 0 1.0 2.0 0.0 0
5 5 2 3 2.0 0.0 0.0 1
LongOnly
id col idx size price fees side
0 0 0 0 1.0 1.0 0.0 0
1 1 0 3 1.0 4.0 0.0 1
2 2 1 0 1.0 1.1 0.0 0
3 3 1 3 1.0 3.6 0.0 1
4 4 2 0 1.0 2.0 0.0 0
5 5 2 3 1.0 0.0 0.0 1
ShortOnly
id col idx size price fees side
0 0 0 0 1.0 1.0 0.0 1
1 1 0 3 1.0 4.0 0.0 0
2 2 1 0 1.0 0.9 0.0 1
3 3 1 3 1.0 4.4 0.0 0
4 4 2 0 1.0 0.0 0.0 1
5 5 2 3 1.0 8.0 0.0 0
In [16]:
Out[16]:
Both
id col idx size price fees side
0 0 0 0 1.0 1.0 0.0 0
1 1 0 3 2.0 4.0 0.0 1
2 2 1 0 1.0 1.0 0.0 0
3 3 1 3 2.0 4.0 0.0 1
LongOnly
id col idx size price fees side
0 0 0 0 1.0 1.0 0.0 0
1 1 0 3 1.0 4.0 0.0 1
2 2 1 0 1.0 1.0 0.0 0
3 3 1 3 1.0 4.0 0.0 1
ShortOnly
id col idx size price fees side
0 0 0 0 1.0 1.0 0.0 1
1 1 0 3 1.0 4.0 0.0 0
2 2 1 0 1.0 1.0 0.0 1
3 3 1 3 1.0 4.0 0.0 0
In [17]:
Out[17]:
Both
id col idx size price fees side
0 0 0 0 0.5 1.0 0.0 0
1 1 0 3 0.5 4.0 0.0 1
2 2 0 4 0.5 5.0 0.0 1
3 3 1 0 1.0 1.0 0.0 0
4 4 1 3 1.0 4.0 0.0 1
5 5 1 4 1.0 5.0 0.0 1
6 6 2 0 1.0 1.0 0.0 0
7 7 2 3 2.0 4.0 0.0 1
LongOnly
id col idx size price fees side
0 0 0 0 0.5 1.0 0.0 0
1 1 0 3 0.5 4.0 0.0 1
2 2 1 0 1.0 1.0 0.0 0
3 3 1 3 1.0 4.0 0.0 1
4 4 2 0 1.0 1.0 0.0 0
5 5 2 3 1.0 4.0 0.0 1
ShortOnly
id col idx size price fees side
0 0 0 0 0.5 1.0 0.0 1
1 1 0 3 0.5 4.0 0.0 0
2 2 1 0 1.0 1.0 0.0 1
3 3 1 3 1.0 4.0 0.0 0
4 4 2 0 1.0 1.0 0.0 1
5 5 2 3 1.0 4.0 0.0 0
In [18]:
Out[18]:
Both
id col idx size price fees side
0 0 0 0 1.0 1.0 0.0 0
1 1 0 3 2.0 4.0 0.0 1
2 2 1 1 1.0 2.0 0.0 0
3 3 1 3 2.0 4.0 0.0 1
LongOnly
id col idx size price fees side
0 0 0 0 1.0 1.0 0.0 0
1 1 0 3 1.0 4.0 0.0 1
2 2 1 1 1.0 2.0 0.0 0
3 3 1 3 1.0 4.0 0.0 1
ShortOnly
id col idx size price fees side
0 0 0 0 1.0 1.0 0.0 1
1 1 0 3 1.0 4.0 0.0 0
2 2 1 1 1.0 2.0 0.0 1
3 3 1 3 1.0 4.0 0.0 0
In [21]:
Out[21]:
id col idx size price fees side
0 0 0 0 100.0 1.0 0.0 0
1 1 0 3 200.0 4.0 0.0 1
2 2 1 0 100.0 1.0 0.0 0
3 3 1 3 100.0 4.0 0.0 1
4 4 1 4 80.0 5.0 0.0 1
id col idx size price fees side
0 0 0 0 20.0 5.0 0.0 1
1 1 0 3 100.0 2.0 0.0 0
2 2 1 0 20.0 5.0 0.0 1
3 3 1 3 20.0 2.0 0.0 0
4 4 1 4 160.0 1.0 0.0 0
In [22]:
Out[22]:
Both
id col idx size price fees side
0 0 0 0 100.0 1.0 0.0 0
1 1 0 3 1100.0 4.0 0.0 1
2 2 1 3 1000.0 4.0 0.0 1
LongOnly
id col idx size price fees side
0 0 0 0 100.0 1.0 0.0 0
1 1 0 3 100.0 4.0 0.0 1
ShortOnly
id col idx size price fees side
0 0 0 0 1000.0 1.0 0.0 1
1 1 0 3 275.0 4.0 0.0 0
2 2 1 0 1000.0 1.0 0.0 1
Both
id col idx size price fees side
0 0 0 0 100.0 1.0 0.0 0
1 1 0 3 200.0 4.0 0.0 1
2 2 1 0 100.0 1.0 0.0 0
3 3 1 3 200.0 4.0 0.0 1
LongOnly
id col idx size price fees side
0 0 0 0 100.0 1.0 0.0 0
1 1 0 3 100.0 4.0 0.0 1
2 2 1 0 100.0 1.0 0.0 0
3 3 1 3 100.0 4.0 0.0 1
ShortOnly
id col idx size price fees side
0 0 0 0 100.0 1.0 0.0 1
1 1 0 3 50.0 4.0 0.0 0
2 2 1 0 100.0 1.0 0.0 1
In [23]:
Out[23]:
Both
id col idx size price fees side
0 0 0 0 100.0 1.0 0.0 0
1 1 0 3 1100.0 4.0 0.0 1
LongOnly
id col idx size price fees side
0 0 0 0 100.0 1.0 0.0 0
1 1 0 3 100.0 4.0 0.0 1
ShortOnly
Not enough cash to cover fees
Both
Final size is less than requested
LongOnly
Final size is less than requested
ShortOnly
Final size is less than requested
In [24]:
Out[24]:
Both
id col idx size price fees side
0 0 0 0 1.0 1.0 0.0 0
1 1 0 1 1.0 2.0 0.0 0
2 2 0 3 1.0 4.0 0.0 1
3 3 0 4 1.0 5.0 0.0 1
LongOnly
id col idx size price fees side
0 0 0 0 1.0 1.0 0.0 0
1 1 0 1 1.0 2.0 0.0 0
2 2 0 3 1.0 4.0 0.0 1
3 3 0 4 1.0 5.0 0.0 1
ShortOnly
id col idx size price fees side
0 0 0 0 1.0 1.0 0.0 1
1 1 0 1 1.0 2.0 0.0 1
2 2 0 3 1.0 4.0 0.0 0
3 3 0 4 1.0 5.0 0.0 0
In [25]:
Out[25]:
id col idx size price fees side
0 0 0 0 100.0 1.0 0.0 0
1 1 0 3 200.0 4.0 0.0 1
id group col idx cash position debt free_cash val_price value \
0 0 0 0 0 100.0 0.0 0.0 100.0 1.0 100.0
1 1 0 0 3 0.0 100.0 0.0 0.0 4.0 400.0
... new_free_cash new_val_price new_value res_size res_price \
0 ... 0.0 1.0 100.0 100.0 1.0
1 ... 0.0 4.0 400.0 200.0 4.0
res_fees res_side res_status res_status_info order_id
0 0.0 0 0 -1 0
1 0.0 1 0 -1 1
[2 rows x 37 columns]
In [27]:
Out[27]:
Both
id col idx size price fees side
0 0 0 1 1.0 2.0 0.0 0
1 1 1 1 1.0 2.0 0.0 0
2 2 2 1 1.0 2.0 0.0 0
3 3 3 1 1.0 2.0 0.0 0
4 4 4 1 1.0 2.0 0.0 1
LongOnly
id col idx size price fees side
0 0 0 1 1.0 2.0 0.0 0
1 1 1 0 1.0 1.0 0.0 0
2 2 2 1 1.0 2.0 0.0 0
3 3 2 2 1.0 3.0 0.0 1
4 4 3 1 1.0 2.0 0.0 0
5 5 3 2 1.0 3.0 0.0 1
ShortOnly
id col idx size price fees side
0 0 0 1 1.0 2.0 0.0 1
1 1 1 0 1.0 1.0 0.0 1
2 2 2 1 1.0 2.0 0.0 1
3 3 2 2 1.0 3.0 0.0 0
4 4 3 1 1.0 2.0 0.0 1
5 5 3 2 1.0 3.0 0.0 0
In [30]:
Out[30]:
Both
id col idx size price fees side
0 0 0 1 1.0 2.0 0.0 0
1 1 1 0 1.0 1.0 0.0 0
2 2 2 0 1.0 1.0 0.0 1
3 3 2 1 2.0 2.0 0.0 0
4 4 2 2 2.0 3.0 0.0 1
5 5 3 1 1.0 2.0 0.0 0
6 6 3 2 2.0 3.0 0.0 1
7 7 4 1 1.0 2.0 0.0 1
8 8 4 2 2.0 3.0 0.0 0
LongOnly
id col idx size price fees side
0 0 0 1 1.0 2.0 0.0 0
1 1 1 1 1.0 2.0 0.0 0
2 2 2 1 1.0 2.0 0.0 0
3 3 3 1 1.0 2.0 0.0 0
ShortOnly
id col idx size price fees side
0 0 0 1 1.0 2.0 0.0 1
1 1 1 1 1.0 2.0 0.0 1
2 2 2 1 1.0 2.0 0.0 1
3 3 3 1 1.0 2.0 0.0 1
In [31]:
Out[31]:
Both
id col idx size price fees side
0 0 0 3 1.0 4.0 0.0 1
1 1 1 0 1.0 1.0 0.0 0
2 2 1 3 2.0 4.0 0.0 1
3 3 2 0 1.0 1.0 0.0 0
4 4 2 3 2.0 4.0 0.0 1
LongOnly
id col idx size price fees side
0 0 1 0 1.0 1.0 0.0 0
1 1 1 3 1.0 4.0 0.0 1
2 2 2 0 1.0 1.0 0.0 0
3 3 2 3 1.0 4.0 0.0 1
ShortOnly
id col idx size price fees side
0 0 0 0 1.00 1.0 0.0 1
1 1 0 3 0.25 4.0 0.0 0
2 2 1 0 1.00 1.0 0.0 1
3 3 1 3 0.50 4.0 0.0 0
4 4 2 0 1.00 1.0 0.0 1
5 5 2 3 1.00 4.0 0.0 0
Both
Attempt to go in long direction infinitely
LongOnly
Attempt to go in long direction infinitely
ShortOnly
Attempt to go in short direction infinitely
In [32]:
Out[32]:
id col idx size price fees side
0 0 0 0 100.0 1.0 0.0 0
1 1 0 3 200.0 4.0 0.0 1
2 2 1 0 100.0 1.0 0.0 0
3 3 1 3 200.0 4.0 0.0 1
4 4 2 0 100.0 1.0 0.0 0
5 5 2 3 200.0 4.0 0.0 1
In [33]:
Out[33]:
id col idx size price fees side
0 0 0 0 100.0 1.0 0.0 0
1 1 0 3 200.0 4.0 0.0 1
2 2 2 0 100.0 1.0 0.0 0
3 3 2 3 200.0 4.0 0.0 1
a b c
2020-01-01 0 1 0
2020-01-02 0 1 0
2020-01-03 0 1 0
2020-01-04 0 1 0
2020-01-05 0 1 0
Cannot modify grouping globally when cash_sharing=True
In [34]:
Out[34]:
id col idx size price fees side
0 0 1 0 100.0 1.0 0.0 0
1 1 1 3 200.0 4.0 0.0 1
2 2 2 0 100.0 1.0 0.0 0
3 3 2 3 200.0 4.0 0.0 1
a b c
2020-01-01 1 0 0
2020-01-02 1 0 0
2020-01-03 1 0 0
2020-01-04 1 0 0
2020-01-05 1 0 0
In [35]:
Out[35]:
id col idx size price fees side
0 0 1 0 100.0 1.0 0.0 0
1 1 1 3 200.0 4.0 0.0 1
2 2 2 0 100.0 1.0 0.0 0
3 3 2 3 200.0 4.0 0.0 1
a b c
2020-01-01 1 0 0
2020-01-02 1 0 0
2020-01-03 1 0 0
2020-01-04 1 0 0
2020-01-05 0 1 0
id col idx size price fees side
0 0 1 0 100.0 1.0 0.0 0
1 1 1 3 200.0 4.0 0.0 1
2 2 2 0 100.0 1.0 0.0 0
3 3 2 3 200.0 4.0 0.0 1
a b c
2020-01-01 1 0 0
2020-01-02 0 1 0
2020-01-03 1 0 0
2020-01-04 1 0 0
2020-01-05 1 0 0
In [36]:
Out[36]:
Both
id col idx size price fees side
0 0 2 0 100.0 1.0 0.0 0
1 1 2 1 200.0 1.0 0.0 1
2 2 1 1 200.0 1.0 0.0 0
3 3 1 2 200.0 1.0 0.0 1
4 4 0 2 200.0 1.0 0.0 0
5 5 0 3 200.0 1.0 0.0 1
6 6 2 3 200.0 1.0 0.0 0
7 7 2 4 200.0 1.0 0.0 1
8 8 1 4 200.0 1.0 0.0 0
0 1 2
0 0 1 2
1 2 0 1
2 1 2 0
3 0 1 2
4 2 0 1
0 1 2
0 0.0 0.0 100.0
1 0.0 200.0 -100.0
2 200.0 0.0 -100.0
3 0.0 0.0 100.0
4 0.0 200.0 -100.0
0 100.0
1 100.0
2 100.0
3 100.0
4 100.0
dtype: float64
LongOnly
id col idx size price fees side
0 0 2 0 100.0 1.0 0.0 0
1 1 2 1 100.0 1.0 0.0 1
2 2 1 1 100.0 1.0 0.0 0
3 3 1 2 100.0 1.0 0.0 1
4 4 0 2 100.0 1.0 0.0 0
5 5 0 3 100.0 1.0 0.0 1
6 6 2 3 100.0 1.0 0.0 0
7 7 2 4 100.0 1.0 0.0 1
8 8 1 4 100.0 1.0 0.0 0
0 1 2
0 0 1 2
1 2 0 1
2 1 2 0
3 0 1 2
4 2 0 1
0 1 2
0 0.0 0.0 100.0
1 0.0 100.0 0.0
2 100.0 0.0 0.0
3 0.0 0.0 100.0
4 0.0 100.0 0.0
0 100.0
1 100.0
2 100.0
3 100.0
4 100.0
dtype: float64
ShortOnly
id col idx size price fees side
0 0 2 0 100.0 1.0 0.0 1
1 1 2 1 100.0 1.0 0.0 0
2 2 0 2 100.0 1.0 0.0 1
3 3 0 3 100.0 1.0 0.0 0
4 4 1 4 100.0 1.0 0.0 1
0 1 2
0 2 0 1
1 1 0 2
2 0 1 2
3 2 1 0
4 1 0 2
0 1 2
0 0.0 0.0 -100.0
1 0.0 0.0 0.0
2 -100.0 0.0 0.0
3 0.0 0.0 0.0
4 0.0 -100.0 0.0
0 100.0
1 100.0
2 100.0
3 100.0
4 100.0
dtype: float64
from_order_func
In [7]:
In [8]:
Out[8]:
1.92 ms ± 156 µs per loop (mean ± std. dev. of 7 runs, 1 loop each)
2.02 ms ± 189 µs per loop (mean ± std. dev. of 7 runs, 1 loop each)
1.85 ms ± 140 µs per loop (mean ± std. dev. of 7 runs, 1 loop each)
1.85 ms ± 145 µs per loop (mean ± std. dev. of 7 runs, 1 loop each)
In [9]:
Out[9]:
95 ms ± 181 µs per loop (mean ± std. dev. of 7 runs, 1 loop each)
101 ms ± 2.48 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)
90.9 ms ± 489 µs per loop (mean ± std. dev. of 7 runs, 1 loop each)
89.1 ms ± 1.69 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)
In [44]:
Out[44]:
76.4 ms ± 217 µs per loop (mean ± std. dev. of 7 runs, 1 loop each)
84.2 ms ± 284 µs per loop (mean ± std. dev. of 7 runs, 1 loop each)
71.5 ms ± 1.39 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)
71.1 ms ± 101 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
In [45]:
Out[45]:
89.1 ms ± 851 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
93.5 ms ± 692 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
86.2 ms ± 287 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
86.3 ms ± 131 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
In [46]:
Out[46]:
88.7 ms ± 763 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
93 ms ± 686 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
85.4 ms ± 39.1 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
85.7 ms ± 140 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
In [47]:
Out[47]:
87 ms ± 487 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
86.2 ms ± 369 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
83.4 ms ± 151 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
83.3 ms ± 153 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
In [48]:
Out[48]:
83.6 ms ± 622 µs per loop (mean ± std. dev. of 7 runs, 1 loop each)
82.7 ms ± 192 µs per loop (mean ± std. dev. of 7 runs, 1 loop each)
82.3 ms ± 927 µs per loop (mean ± std. dev. of 7 runs, 1 loop each)
82 ms ± 680 µs per loop (mean ± std. dev. of 7 runs, 1 loop each)
In [52]:
In [10]:
Out[10]:
a b c
2020-01-01 0 1 2
2020-01-02 0 1 2
2020-01-03 0 1 2
2020-01-04 0 1 2
2020-01-05 0 1 2
46.2 ms ± 838 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
a b c
2020-01-01 2 1 0
2020-01-02 2 1 0
2020-01-03 2 1 0
2020-01-04 2 1 0
2020-01-05 2 1 0
46.4 ms ± 683 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
a b c
2020-01-01 0 1 2
2020-01-02 2 1 0
2020-01-03 1 0 2
2020-01-04 2 0 1
2020-01-05 2 1 0
55.1 ms ± 849 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
In [53]:
In [54]:
Out[54]:
a b c
2020-01-01 2 1 0
2020-01-02 2 1 0
2020-01-03 2 1 0
2020-01-04 2 1 0
2020-01-05 2 1 0
262 ms ± 109 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)
206 ms ± 2.16 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)
a b c
2020-01-01 2 1 0
2020-01-02 2 1 0
2020-01-03 2 1 0
2020-01-04 2 1 0
2020-01-05 2 1 0
209 ms ± 1.67 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)
211 ms ± 1.97 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)
a b c
2020-01-01 2 1 0
2020-01-02 2 1 0
2020-01-03 2 1 0
2020-01-04 2 1 0
2020-01-05 2 1 0
94.2 ms ± 1.26 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)
99.2 ms ± 394 µs per loop (mean ± std. dev. of 7 runs, 1 loop each)
a b c
2020-01-01 1 2 0
2020-01-02 0 1 2
2020-01-03 1 0 2
2020-01-04 1 0 2
2020-01-05 2 1 0
148 ms ± 2.78 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)
148 ms ± 3.6 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)
In [6]:
Out[6]:
Index([0], dtype='int64')
1
Index([0], dtype='int64', name='iteration_idx')
2
Index(['first'], dtype='object', name='custom')
2
Index([0, 1, 2], dtype='int64', name='iteration_idx')
2
Index(['first', 'second', 'third'], dtype='object', name='custom')
2
In [7]:
Out[7]:
id idx col size price fees side
0 0 0 0 100.000000 1.0 0.0 0
1 1 1 0 200.000000 2.0 0.0 1
2 2 2 0 133.333333 3.0 0.0 0
3 3 3 0 66.666667 4.0 0.0 1
4 4 4 0 53.333333 5.0 0.0 0
id idx col size price fees side
0 0 0 0 100.000000 1.0 0.0 0
1 1 1 0 200.000000 2.0 0.0 1
2 2 2 0 133.333333 3.0 0.0 0
3 3 3 0 66.666667 4.0 0.0 1
4 4 4 0 53.333333 5.0 0.0 0
In [8]:
Out[8]:
id idx col size price fees side
0 0 0 0 100.000000 1.0 0.0 0
1 1 1 0 200.000000 2.0 0.0 1
2 2 2 0 133.333333 3.0 0.0 0
3 3 3 0 66.666667 4.0 0.0 1
4 4 4 0 53.333333 5.0 0.0 0
5 5 0 1 100.000000 1.0 0.0 0
6 6 1 1 200.000000 2.0 0.0 1
7 7 2 1 133.333333 3.0 0.0 0
8 8 3 1 66.666667 4.0 0.0 1
9 9 4 1 53.333333 5.0 0.0 0
10 10 0 2 100.000000 1.0 0.0 0
11 11 1 2 200.000000 2.0 0.0 1
12 12 2 2 133.333333 3.0 0.0 0
13 13 3 2 66.666667 4.0 0.0 1
14 14 4 2 53.333333 5.0 0.0 0
id idx col size price fees side
0 0 0 0 100.000000 1.0 0.0 0
1 1 0 1 100.000000 1.0 0.0 0
2 2 0 2 100.000000 1.0 0.0 0
3 3 1 0 200.000000 2.0 0.0 1
4 4 1 1 200.000000 2.0 0.0 1
5 5 1 2 200.000000 2.0 0.0 1
6 6 2 0 133.333333 3.0 0.0 0
7 7 2 1 133.333333 3.0 0.0 0
8 8 2 2 133.333333 3.0 0.0 0
9 9 3 0 66.666667 4.0 0.0 1
10 10 3 1 66.666667 4.0 0.0 1
11 11 3 2 66.666667 4.0 0.0 1
12 12 4 0 53.333333 5.0 0.0 0
13 13 4 1 53.333333 5.0 0.0 0
14 14 4 2 53.333333 5.0 0.0 0
In [9]:
Out[9]:
id idx col size price fees side
0 0 0 0 100.000000 1.0 0.0 0
1 1 0 1 100.000000 1.0 0.0 0
2 2 1 0 200.000000 2.0 0.0 1
3 3 1 1 200.000000 2.0 0.0 1
4 4 2 0 133.333333 3.0 0.0 0
5 5 2 1 133.333333 3.0 0.0 0
6 6 3 0 66.666667 4.0 0.0 1
7 7 3 1 66.666667 4.0 0.0 1
8 8 4 0 53.333333 5.0 0.0 0
9 9 4 1 53.333333 5.0 0.0 0
10 10 0 2 100.000000 1.0 0.0 0
11 11 1 2 200.000000 2.0 0.0 1
12 12 2 2 133.333333 3.0 0.0 0
13 13 3 2 66.666667 4.0 0.0 1
14 14 4 2 53.333333 5.0 0.0 0
id idx col size price fees side
0 0 0 0 100.000000 1.0 0.0 0
1 1 0 1 100.000000 1.0 0.0 0
2 2 0 2 100.000000 1.0 0.0 0
3 3 1 0 200.000000 2.0 0.0 1
4 4 1 1 200.000000 2.0 0.0 1
5 5 1 2 200.000000 2.0 0.0 1
6 6 2 0 133.333333 3.0 0.0 0
7 7 2 1 133.333333 3.0 0.0 0
8 8 2 2 133.333333 3.0 0.0 0
9 9 3 0 66.666667 4.0 0.0 1
10 10 3 1 66.666667 4.0 0.0 1
11 11 3 2 66.666667 4.0 0.0 1
12 12 4 0 53.333333 5.0 0.0 0
13 13 4 1 53.333333 5.0 0.0 0
14 14 4 2 53.333333 5.0 0.0 0
In [10]:
Out[10]:
id idx col size price fees side
0 0 0 0 100.000000 1.0 0.0 0
1 1 1 0 200.000000 2.0 0.0 1
2 2 2 0 133.333333 3.0 0.0 0
3 3 3 0 66.666667 4.0 0.0 1
4 4 4 0 53.333333 5.0 0.0 0
5 5 0 2 100.000000 1.0 0.0 0
6 6 1 2 200.000000 2.0 0.0 1
7 7 2 2 133.333333 3.0 0.0 0
8 8 3 2 66.666667 4.0 0.0 1
9 9 4 2 53.333333 5.0 0.0 0
id idx col size price fees side
0 0 0 0 100.000000 1.0 0.0 0
1 1 0 2 100.000000 1.0 0.0 0
2 2 1 0 200.000000 2.0 0.0 1
3 3 1 2 200.000000 2.0 0.0 1
4 4 2 0 133.333333 3.0 0.0 0
5 5 2 2 133.333333 3.0 0.0 0
6 6 3 0 66.666667 4.0 0.0 1
7 7 3 2 66.666667 4.0 0.0 1
8 8 4 0 53.333333 5.0 0.0 0
9 9 4 2 53.333333 5.0 0.0 0
In [11]:
Out[11]:
[1.] 25.0
[2.] -33.33333333333333
[3.] -12.5
[4.] -6.666666666666668
id idx col size price fees side
0 0 0 0 50.000000 2.0 0.0 0
1 1 1 0 25.000000 3.0 0.0 1
2 2 2 0 8.333333 4.0 0.0 1
3 3 3 0 4.166667 5.0 0.0 1
[1.] 25.0
[2.] -33.33333333333333
[3.] -12.5
[4.] -6.666666666666668
id idx col size price fees side
0 0 0 0 50.000000 2.0 0.0 0
1 1 1 0 25.000000 3.0 0.0 1
2 2 2 0 8.333333 4.0 0.0 1
3 3 3 0 4.166667 5.0 0.0 1
In [12]:
Out[12]:
[2.] 25.0
[3.] -8.333333333333332
[4.] -4.166666666666668
[5.] -2.5
id idx col size price fees side
0 0 0 0 25.000000 2.0 0.0 0
1 1 1 0 8.333333 3.0 0.0 1
2 2 2 0 4.166667 4.0 0.0 1
3 3 3 0 2.500000 5.0 0.0 1
[2.] 25.0
[3.] -8.333333333333332
[4.] -4.166666666666668
[5.] -2.5
id idx col size price fees side
0 0 0 0 25.000000 2.0 0.0 0
1 1 1 0 8.333333 3.0 0.0 1
2 2 2 0 4.166667 4.0 0.0 1
3 3 3 0 2.500000 5.0 0.0 1
In [13]:
Out[13]:
[1.] 25.0
[2.] -33.33333333333333
[3.] -6.25
[4.] -7.5
id idx col size price fees side
0 0 0 0 50.000 2.0 0.0 0
1 1 1 0 25.000 3.0 0.0 1
2 2 3 0 3.125 5.0 0.0 1
[1.] 25.0
[2.] -33.33333333333333
[3.] -6.25
[4.] -7.5
id idx col size price fees side
0 0 0 0 50.000 2.0 0.0 0
1 1 1 0 25.000 3.0 0.0 1
2 2 3 0 3.125 5.0 0.0 1
In [14]:
Out[14]:
[2.] 25.0
[3.] -4.166666666666668
[4.] -2.604166666666668
[5.] -1.8229166666666643
id idx col size price fees side
0 0 0 0 25.000000 2.0 0.0 0
1 1 1 0 4.166667 3.0 0.0 1
2 2 2 0 2.604167 4.0 0.0 1
3 3 3 0 1.822917 5.0 0.0 1
[2.] 25.0
[3.] -4.166666666666668
[4.] -2.604166666666668
[5.] -1.8229166666666643
id idx col size price fees side
0 0 0 0 25.000000 2.0 0.0 0
1 1 1 0 4.166667 3.0 0.0 1
2 2 2 0 2.604167 4.0 0.0 1
3 3 3 0 1.822917 5.0 0.0 1
In [15]:
Out[15]:
id idx col size price fees side
0 0 0 0 1.0 1.0 0.0 0
1 1 2 0 1.0 3.0 0.0 0
2 2 4 0 1.0 5.0 0.0 0
id idx col size price fees side
0 0 0 0 1.0 1.0 0.0 0
1 1 2 0 1.0 3.0 0.0 0
2 2 4 0 1.0 5.0 0.0 0
In [16]:
Out[16]:
preparing simulation
preparing group 0
preparing segment 0 (row)
processing order 0 at column 0
processing order 1 at column 1
preparing segment 1 (row)
processing order 0 at column 0
processing order 1 at column 1
preparing segment 2 (row)
processing order 0 at column 0
processing order 1 at column 1
preparing segment 3 (row)
processing order 0 at column 0
processing order 1 at column 1
preparing segment 4 (row)
processing order 0 at column 0
processing order 1 at column 1
preparing group 1
preparing segment 0 (row)
processing order 0 at column 2
preparing segment 1 (row)
processing order 0 at column 2
preparing segment 2 (row)
processing order 0 at column 2
preparing segment 3 (row)
processing order 0 at column 2
preparing segment 4 (row)
processing order 0 at column 2
[1] [2] [10] [15]
In [17]:
Out[17]:
preparing simulation
preparing row 0
preparing segment 0 (group)
processing order 0 at column 0
processing order 1 at column 1
preparing segment 1 (group)
processing order 0 at column 2
preparing row 1
preparing segment 0 (group)
processing order 0 at column 0
processing order 1 at column 1
preparing segment 1 (group)
processing order 0 at column 2
preparing row 2
preparing segment 0 (group)
processing order 0 at column 0
processing order 1 at column 1
preparing segment 1 (group)
processing order 0 at column 2
preparing row 3
preparing segment 0 (group)
processing order 0 at column 0
processing order 1 at column 1
preparing segment 1 (group)
processing order 0 at column 2
preparing row 4
preparing segment 0 (group)
processing order 0 at column 0
processing order 1 at column 1
preparing segment 1 (group)
processing order 0 at column 2
[1] [5] [10] [15]
methods and properties
In [3]:
In [4]:
Out[4]:
id col idx size price fees side
0 0 0 1 0.1 2.02 0.10202 0
1 1 0 2 0.1 2.97 0.10297 1
2 2 0 4 1.0 5.05 0.15050 0
3 3 1 0 1.0 0.99 0.10990 1
4 4 1 1 0.1 1.98 0.10198 1
5 5 1 3 0.1 4.04 0.10404 0
6 6 1 4 1.0 4.95 0.14950 1
7 7 2 0 1.0 1.01 0.11010 0
8 8 2 1 0.1 2.02 0.10202 0
9 9 2 2 1.0 2.97 0.12970 1
10 10 2 3 0.1 3.96 0.10396 1
id col idx size price fees side
0 0 0 1 0.1 2.02 0.10202 0
1 1 0 2 0.1 2.97 0.10297 1
2 2 0 4 1.0 5.05 0.15050 0
3 3 1 0 1.0 0.99 0.10990 1
4 4 1 1 0.1 1.98 0.10198 1
5 5 1 3 0.1 4.04 0.10404 0
6 6 1 4 1.0 4.95 0.14950 1
7 7 2 0 1.0 1.01 0.11010 0
8 8 2 1 0.1 2.02 0.10202 0
9 9 2 2 1.0 2.97 0.12970 1
10 10 2 3 0.1 3.96 0.10396 1
id col idx size price fees side
0 0 1 0 1.0 0.99 0.10990 1
1 1 1 1 0.1 1.98 0.10198 1
2 2 0 1 0.1 2.02 0.10202 0
3 3 0 2 0.1 2.97 0.10297 1
4 4 1 3 0.1 4.04 0.10404 0
5 5 1 4 1.0 4.95 0.14950 1
6 6 0 4 1.0 5.05 0.15050 0
7 7 2 0 1.0 1.01 0.11010 0
8 8 2 1 0.1 2.02 0.10202 0
9 9 2 2 1.0 2.97 0.12970 1
10 10 2 3 0.1 3.96 0.10396 1
In [5]:
Out[5]:
(1000000,)
(1000000,)
(1000000,)
In [6]:
Out[6]:
DatetimeIndex(['2020-01-01', '2020-01-02', '2020-01-03', '2020-01-04',
'2020-01-05'],
dtype='datetime64[ns]', freq=None)
Index(['a', 'b', 'c'], dtype='object')
2
None
True
True
True
DatetimeIndex(['2020-01-01', '2020-01-02', '2020-01-03', '2020-01-04',
'2020-01-05'],
dtype='datetime64[ns]', freq=None)
Index(['a', 'b', 'c'], dtype='object')
2
Index(['first', 'first', 'second'], dtype='object', name='group')
True
True
True
DatetimeIndex(['2020-01-01', '2020-01-02', '2020-01-03', '2020-01-04',
'2020-01-05'],
dtype='datetime64[ns]', freq=None)
Index(['a', 'b', 'c'], dtype='object')
2
Index(['first', 'first', 'second'], dtype='object', name='group')
False
True
False
In [106]:
Out[106]:
id idx col size price fees side
0 0 1 0 0.1 2.02 0.10202 0
1 1 2 0 0.1 2.97 0.10297 1
2 2 4 0 1.0 5.05 0.15050 0
3 3 0 1 1.0 0.99 0.10990 1
4 4 1 1 0.1 1.98 0.10198 1
5 5 3 1 0.1 4.04 0.10404 0
6 6 4 1 1.0 4.95 0.14950 1
7 7 0 2 1.0 1.01 0.11010 0
8 8 1 2 0.1 2.02 0.10202 0
9 9 2 2 1.0 2.97 0.12970 1
10 10 3 2 0.1 3.96 0.10396 1
a 3
b 4
c 4
Name: count, dtype: int64
a 5
b 5
c 5
Name: count, dtype: int64
a b c
2020-01-01 NaN 1.0 1.0
2020-01-02 2.0 2.0 2.0
2020-01-03 3.0 NaN 3.0
2020-01-04 4.0 4.0 4.0
2020-01-05 5.0 5.0 NaN
a 100.0
b 100.0
c 100.0
Name: init_cash, dtype: float64
a b c
2020-01-01 100.00000 99.88010 99.87990
2020-01-02 99.89598 98.77612 100.77588
2020-01-03 99.89001 98.77612 101.71618
2020-01-04 99.89001 96.46808 101.70822
2020-01-05 99.68951 95.26858 101.70822
a 99.68951
b 95.26858
c 101.70822
Name: final_value, dtype: float64
In [107]:
Out[107]:
id idx col size price fees side
0 0 1 0 0.1 2.02 0.10202 0
1 1 2 0 0.1 2.97 0.10297 1
2 2 4 0 1.0 5.05 0.15050 0
3
5
2020-01-01 NaN
2020-01-02 2.0
2020-01-03 3.0
2020-01-04 4.0
2020-01-05 5.0
Name: a, dtype: float64
100.0
2020-01-01 100.00000
2020-01-02 99.89598
2020-01-03 99.89001
2020-01-04 99.89001
2020-01-05 99.68951
Name: a, dtype: float64
99.68951
In [108]:
Out[108]:
id idx col size price fees side
0 7 0 0 1.0 1.01 0.11010 0
1 8 1 0 0.1 2.02 0.10202 0
2 9 2 0 1.0 2.97 0.12970 1
3 10 3 0 0.1 3.96 0.10396 1
4
5
2020-01-01 1.0
2020-01-02 2.0
2020-01-03 3.0
2020-01-04 4.0
2020-01-05 NaN
Name: c, dtype: float64
100.0
2020-01-01 99.87990
2020-01-02 100.77588
2020-01-03 101.71618
2020-01-04 101.70822
2020-01-05 101.70822
Name: c, dtype: float64
101.70822
In [109]:
Out[109]:
id idx col size price fees side
0 7 0 0 1.0 1.01 0.11010 0
1 8 1 0 0.1 2.02 0.10202 0
2 9 2 0 1.0 2.97 0.12970 1
3 10 3 0 0.1 3.96 0.10396 1
c 4
Name: count, dtype: int64
c 5
Name: count, dtype: int64
c
2020-01-01 1.0
2020-01-02 2.0
2020-01-03 3.0
2020-01-04 4.0
2020-01-05 NaN
c 100.0
Name: init_cash, dtype: float64
c
2020-01-01 99.87990
2020-01-02 100.77588
2020-01-03 101.71618
2020-01-04 101.70822
2020-01-05 101.70822
c 101.70822
Name: final_value, dtype: float64
In [110]:
Out[110]:
id idx col size price fees side
0 0 1 0 0.1 2.02 0.10202 0
1 1 2 0 0.1 2.97 0.10297 1
2 2 4 0 1.0 5.05 0.15050 0
3 3 0 1 1.0 0.99 0.10990 1
4 4 1 1 0.1 1.98 0.10198 1
5 5 3 1 0.1 4.04 0.10404 0
6 6 4 1 1.0 4.95 0.14950 1
7 7 0 2 1.0 1.01 0.11010 0
8 8 1 2 0.1 2.02 0.10202 0
9 9 2 2 1.0 2.97 0.12970 1
10 10 3 2 0.1 3.96 0.10396 1
group
first 7
second 4
Name: count, dtype: int64
group
first 10
second 5
Name: count, dtype: int64
a b c
2020-01-01 NaN 1.0 1.0
2020-01-02 2.0 2.0 2.0
2020-01-03 3.0 NaN 3.0
2020-01-04 4.0 4.0 4.0
2020-01-05 5.0 5.0 NaN
group
first 200.0
second 100.0
Name: init_cash, dtype: float64
group first second
2020-01-01 199.88010 99.87990
2020-01-02 198.67210 100.77588
2020-01-03 198.66613 101.71618
2020-01-04 196.35809 101.70822
2020-01-05 194.95809 101.70822
group
first 194.95809
second 101.70822
Name: final_value, dtype: float64
In [111]:
Out[111]:
id idx col size price fees side
0 0 1 0 0.1 2.02 0.10202 0
1 1 2 0 0.1 2.97 0.10297 1
2 2 4 0 1.0 5.05 0.15050 0
3 3 0 1 1.0 0.99 0.10990 1
4 4 1 1 0.1 1.98 0.10198 1
5 5 3 1 0.1 4.04 0.10404 0
6 6 4 1 1.0 4.95 0.14950 1
7
10
a b
2020-01-01 NaN 1.0
2020-01-02 2.0 2.0
2020-01-03 3.0 NaN
2020-01-04 4.0 4.0
2020-01-05 5.0 5.0
200.0
2020-01-01 199.88010
2020-01-02 198.67210
2020-01-03 196.46613
2020-01-04 196.35809
2020-01-05 194.95809
Name: first, dtype: float64
194.95809
In [112]:
Out[112]:
id idx col size price fees side
0 7 0 0 1.0 1.01 0.11010 0
1 8 1 0 0.1 2.02 0.10202 0
2 9 2 0 1.0 2.97 0.12970 1
3 10 3 0 0.1 3.96 0.10396 1
4
5
2020-01-01 1.0
2020-01-02 2.0
2020-01-03 3.0
2020-01-04 4.0
2020-01-05 NaN
Name: c, dtype: float64
100.0
2020-01-01 99.87990
2020-01-02 100.77588
2020-01-03 101.71618
2020-01-04 101.70822
2020-01-05 101.70822
Name: second, dtype: float64
101.70822
In [113]:
Out[113]:
id idx col size price fees side
0 7 0 0 1.0 1.01 0.11010 0
1 8 1 0 0.1 2.02 0.10202 0
2 9 2 0 1.0 2.97 0.12970 1
3 10 3 0 0.1 3.96 0.10396 1
group
second 4
Name: count, dtype: int64
group
second 5
Name: count, dtype: int64
c
2020-01-01 1.0
2020-01-02 2.0
2020-01-03 3.0
2020-01-04 4.0
2020-01-05 NaN
group
second 100.0
Name: init_cash, dtype: float64
group second
2020-01-01 99.87990
2020-01-02 100.77588
2020-01-03 101.71618
2020-01-04 101.70822
2020-01-05 101.70822
group
second 101.70822
Name: final_value, dtype: float64
In [62]:
Out[62]:
3.42 ms ± 283 µs per loop (mean ± std. dev. of 7 runs, 1 loop each)
The slowest run took 17.43 times longer than the fastest. This could mean that an intermediate result is being cached.
111 ms ± 89.2 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)
3.37 ms ± 46.7 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
14.3 ms ± 1.99 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)
6.41 ms ± 139 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
18.1 ms ± 366 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
In [114]:
Out[114]:
False
False
True
In [115]:
Out[115]:
a b c
2020-01-01 0 0 0
2020-01-02 0 0 0
2020-01-03 0 0 0
2020-01-04 0 0 0
2020-01-05 0 0 0
a b c
2020-01-01 1 0 0
2020-01-02 1 0 0
2020-01-03 1 0 0
2020-01-04 1 0 0
2020-01-05 1 0 0
a b c
2020-01-01 1 0 0
2020-01-02 1 0 0
2020-01-03 1 0 0
2020-01-04 1 0 0
2020-01-05 1 0 0
In [116]:
Out[116]:
a 3
b 4
c 4
Name: count, dtype: int64
a 3
b 4
c 4
Name: count, dtype: int64
a 3
b 4
c 4
Name: count, dtype: int64
group
first 7
second 4
Name: count, dtype: int64
group
first 7
second 4
Name: count, dtype: int64
group
first 7
second 4
Name: count, dtype: int64
In [117]:
Out[117]:
a 5
b 5
c 5
Name: count, dtype: int64
a 5
b 5
c 5
Name: count, dtype: int64
a 5
b 5
c 5
Name: count, dtype: int64
group
first 10
second 5
Name: count, dtype: int64
group
first 10
second 5
Name: count, dtype: int64
group
first 10
second 5
Name: count, dtype: int64
In [6]:
Out[6]:
a 2
b 3
c 2
Name: count, dtype: int64
a 2
b 3
c 2
Name: count, dtype: int64
a 2
b 3
c 2
Name: count, dtype: int64
group
first 5
second 2
Name: count, dtype: int64
group
first 5
second 2
Name: count, dtype: int64
group
first 5
second 2
Name: count, dtype: int64
In [7]:
Out[7]:
397 ms ± 3.87 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)
In [8]:
Out[8]:
a 2
b 2
c 2
Name: count, dtype: int64
a 2
b 2
c 2
Name: count, dtype: int64
a 2
b 2
c 2
Name: count, dtype: int64
group
first 4
second 2
Name: count, dtype: int64
group
first 4
second 2
Name: count, dtype: int64
group
first 4
second 2
Name: count, dtype: int64
In [9]:
Out[9]:
13.8 ms ± 607 µs per loop (mean ± std. dev. of 7 runs, 1 loop each)
In [10]:
Out[10]:
a 2
b 1
c 1
Name: count, dtype: int64
a 2
b 1
c 1
Name: count, dtype: int64
a 2
b 1
c 1
Name: count, dtype: int64
group
first 3
second 1
Name: count, dtype: int64
group
first 3
second 1
Name: count, dtype: int64
group
first 3
second 1
Name: count, dtype: int64
In [11]:
Out[11]:
28.4 ms ± 3 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)
In [120]:
Out[120]:
a 1
b 1
c 1
Name: count, dtype: int64
a 1
b 1
c 1
Name: count, dtype: int64
a 1
b 1
c 1
Name: count, dtype: int64
group
first 1
second 1
Name: count, dtype: int64
group
first 1
second 1
Name: count, dtype: int64
group
first 1
second 1
Name: count, dtype: int64
In [72]:
Out[72]:
39.9 ms ± 907 µs per loop (mean ± std. dev. of 7 runs, 1 loop each)
In [121]:
Out[121]:
a b c
2020-01-01 NaN 1.0 1.0
2020-01-02 2.0 2.0 2.0
2020-01-03 3.0 NaN 3.0
2020-01-04 4.0 4.0 4.0
2020-01-05 5.0 5.0 NaN
a b c
2020-01-01 NaN 1.0 1.0
2020-01-02 2.0 2.0 2.0
2020-01-03 3.0 NaN 3.0
2020-01-04 4.0 4.0 4.0
2020-01-05 5.0 5.0 NaN
a b c
2020-01-01 NaN 1.0 1.0
2020-01-02 2.0 2.0 2.0
2020-01-03 3.0 NaN 3.0
2020-01-04 4.0 4.0 4.0
2020-01-05 5.0 5.0 NaN
In [122]:
Out[122]:
a b c
2020-01-01 NaN 1.0 1.0
2020-01-02 2.0 2.0 2.0
2020-01-03 3.0 NaN 3.0
2020-01-04 4.0 4.0 4.0
2020-01-05 5.0 5.0 NaN
a b c
2020-01-01 NaN 1.0 1.0
2020-01-02 2.0 2.0 2.0
2020-01-03 3.0 2.0 3.0
2020-01-04 4.0 4.0 4.0
2020-01-05 5.0 5.0 4.0
a b c
2020-01-01 2.0 1.0 1.0
2020-01-02 2.0 2.0 2.0
2020-01-03 3.0 4.0 3.0
2020-01-04 4.0 4.0 4.0
2020-01-05 5.0 5.0 NaN
a b c
2020-01-01 2.0 1.0 1.0
2020-01-02 2.0 2.0 2.0
2020-01-03 3.0 2.0 3.0
2020-01-04 4.0 4.0 4.0
2020-01-05 5.0 5.0 4.0
In [75]:
Out[75]:
67.6 µs ± 1.39 µs per loop (mean ± std. dev. of 7 runs, 10000 loops each)
In [123]:
Out[123]:
a b c
2020-01-01 0.0 0.0 1.0
2020-01-02 0.1 0.0 0.1
2020-01-03 -0.1 0.0 -1.0
2020-01-04 0.0 0.0 -0.1
2020-01-05 1.0 0.0 0.0
a b c
2020-01-01 0.0 1.0 0.0
2020-01-02 0.0 0.1 0.0
2020-01-03 0.0 0.0 0.0
2020-01-04 0.0 -0.1 0.0
2020-01-05 0.0 1.0 0.0
a b c
2020-01-01 0.0 -1.0 1.0
2020-01-02 0.1 -0.1 0.1
2020-01-03 -0.1 0.0 -1.0
2020-01-04 0.0 0.1 -0.1
2020-01-05 1.0 -1.0 0.0
a b c
2020-01-01 0.0 -1.0 1.0
2020-01-02 0.1 -0.1 0.1
2020-01-03 -0.1 0.0 -1.0
2020-01-04 0.0 0.1 -0.1
2020-01-05 1.0 -1.0 0.0
a b c
2020-01-01 0.0 -1.0 1.0
2020-01-02 0.1 -0.1 0.1
2020-01-03 -0.1 0.0 -1.0
2020-01-04 0.0 0.1 -0.1
2020-01-05 1.0 -1.0 0.0
In [77]:
Out[77]:
11 ms ± 539 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
10.6 ms ± 276 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
10.5 ms ± 148 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
In [124]:
Out[124]:
a b c
2020-01-01 0.0 0.0 1.0
2020-01-02 0.1 0.0 1.1
2020-01-03 0.0 0.0 0.1
2020-01-04 0.0 0.0 0.0
2020-01-05 1.0 0.0 0.0
a b c
2020-01-01 0.0 1.0 0.0
2020-01-02 0.0 1.1 0.0
2020-01-03 0.0 1.1 0.0
2020-01-04 0.0 1.0 0.0
2020-01-05 0.0 2.0 0.0
a b c
2020-01-01 0.0 -1.0 1.0
2020-01-02 0.1 -1.1 1.1
2020-01-03 0.0 -1.1 0.1
2020-01-04 0.0 -1.0 0.0
2020-01-05 1.0 -2.0 0.0
a b c
2020-01-01 0.0 -1.0 1.0
2020-01-02 0.1 -1.1 1.1
2020-01-03 0.0 -1.1 0.1
2020-01-04 0.0 -1.0 0.0
2020-01-05 1.0 -2.0 0.0
a b c
2020-01-01 0.0 -1.0 1.0
2020-01-02 0.1 -1.1 1.1
2020-01-03 0.0 -1.1 0.1
2020-01-04 0.0 -1.0 0.0
2020-01-05 1.0 -2.0 0.0
In [79]:
Out[79]:
14.4 ms ± 539 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
14.6 ms ± 265 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
14 ms ± 50.3 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
In [127]:
Out[127]:
a b c
2020-01-01 False False True
2020-01-02 True False True
2020-01-03 False False True
2020-01-04 False False False
2020-01-05 True False False
a b c
2020-01-01 False True False
2020-01-02 False True False
2020-01-03 False True False
2020-01-04 False True False
2020-01-05 False True False
a b c
2020-01-01 False True True
2020-01-02 True True True
2020-01-03 False True True
2020-01-04 False True False
2020-01-05 True True False
a b c
2020-01-01 False True True
2020-01-02 True True True
2020-01-03 False True True
2020-01-04 False True False
2020-01-05 True True False
a b c
2020-01-01 False True True
2020-01-02 True True True
2020-01-03 False True True
2020-01-04 False True False
2020-01-05 True True False
group first second
2020-01-01 True True
2020-01-02 True True
2020-01-03 True True
2020-01-04 True False
2020-01-05 True False
group first second
2020-01-01 True True
2020-01-02 True True
2020-01-03 True True
2020-01-04 True False
2020-01-05 True False
group first second
2020-01-01 True True
2020-01-02 True True
2020-01-03 True True
2020-01-04 True False
2020-01-05 True False
In [81]:
Out[81]:
14.8 ms ± 113 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
15.1 ms ± 462 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
15.6 ms ± 299 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
31.4 ms ± 275 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
31 ms ± 198 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
32 ms ± 208 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
In [128]:
Out[128]:
a 0.4
b 0.0
c 0.6
Name: position_coverage, dtype: float64
a 0.0
b 1.0
c 0.0
Name: position_coverage, dtype: float64
a 0.4
b 1.0
c 0.6
Name: position_coverage, dtype: float64
a 0.4
b 1.0
c 0.6
Name: position_coverage, dtype: float64
a 0.4
b 1.0
c 0.6
Name: position_coverage, dtype: float64
group
first 0.7
second 0.6
Name: position_coverage, dtype: float64
group
first 0.7
second 0.6
Name: position_coverage, dtype: float64
group
first 0.7
second 0.6
Name: position_coverage, dtype: float64
In [83]:
Out[83]:
16.6 ms ± 1.51 ms per loop (mean ± std. dev. of 7 runs, 100 loops each)
14.8 ms ± 104 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
15 ms ± 116 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
34.1 ms ± 1.49 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)
32.2 ms ± 1.15 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)
33.4 ms ± 1.19 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)
In [129]:
Out[129]:
a b c
2020-01-01 0.00000 -1.09990 -1.12010
2020-01-02 -0.30402 -0.29998 -0.30402
2020-01-03 0.19403 0.00000 2.84030
2020-01-04 0.00000 -0.29204 0.29204
2020-01-05 -5.20050 -5.09950 0.00000
a b c
2020-01-01 0.00000 0.88010 -1.12010
2020-01-02 -0.30402 0.09602 -0.30402
2020-01-03 0.19403 0.00000 2.84030
2020-01-04 0.00000 -0.50804 0.29204
2020-01-05 -5.20050 4.80050 0.00000
a b c
2020-01-01 0.00000 0.88010 -1.12010
2020-01-02 -0.30402 0.09602 -0.30402
2020-01-03 0.19403 0.00000 2.84030
2020-01-04 0.00000 -0.50804 0.29204
2020-01-05 -5.20050 4.80050 0.00000
a b c
2020-01-01 0.00000 0.88010 -1.12010
2020-01-02 -0.30402 0.09602 -0.30402
2020-01-03 0.19403 0.00000 2.84030
2020-01-04 0.00000 -0.50804 0.29204
2020-01-05 -5.20050 4.80050 0.00000
group first second
2020-01-01 0.88010 -1.12010
2020-01-02 -0.20800 -0.30402
2020-01-03 0.19403 2.84030
2020-01-04 -0.50804 0.29204
2020-01-05 -0.40000 0.00000
group first second
2020-01-01 0.88010 -1.12010
2020-01-02 -0.20800 -0.30402
2020-01-03 0.19403 2.84030
2020-01-04 -0.50804 0.29204
2020-01-05 -0.40000 0.00000
group first second
2020-01-01 0.88010 -1.12010
2020-01-02 -0.20800 -0.30402
2020-01-03 0.19403 2.84030
2020-01-04 -0.50804 0.29204
2020-01-05 -0.40000 0.00000
In [122]:
Out[122]:
14.4 ms ± 912 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
20.4 ms ± 144 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
14.6 ms ± 88.3 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
16.3 ms ± 81.6 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
17.9 ms ± 126 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
16.7 ms ± 118 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
20.1 ms ± 155 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
In [130]:
Out[130]:
a 100.0
b 100.0
c 100.0
Name: init_cash, dtype: float64
a 100.0
b 100.0
c 100.0
Name: init_cash, dtype: float64
a 200.0
b 200.0
c 100.0
Name: init_cash, dtype: float64
group
first 200.0
second 100.0
Name: init_cash, dtype: float64
group
first 200.0
second 100.0
Name: init_cash, dtype: float64
group
first 200.0
second 100.0
Name: init_cash, dtype: float64
In [10]:
Out[10]:
53.9 µs ± 387 ns per loop (mean ± std. dev. of 7 runs, 10000 loops each)
53.6 µs ± 187 ns per loop (mean ± std. dev. of 7 runs, 10000 loops each)
870 µs ± 2.61 µs per loop (mean ± std. dev. of 7 runs, 1000 loops each)
912 µs ± 2.62 µs per loop (mean ± std. dev. of 7 runs, 1000 loops each)
57.9 µs ± 1.76 µs per loop (mean ± std. dev. of 7 runs, 10000 loops each)
1.26 ms ± 20.8 µs per loop (mean ± std. dev. of 7 runs, 1000 loops each)
In [87]:
Out[87]:
43.2 µs ± 125 ns per loop (mean ± std. dev. of 7 runs, 10000 loops each)
42.9 µs ± 611 ns per loop (mean ± std. dev. of 7 runs, 10000 loops each)
533 µs ± 13.9 µs per loop (mean ± std. dev. of 7 runs, 1000 loops each)
737 µs ± 44.3 µs per loop (mean ± std. dev. of 7 runs, 1 loop each)
46.6 µs ± 617 ns per loop (mean ± std. dev. of 7 runs, 10000 loops each)
850 µs ± 37.8 µs per loop (mean ± std. dev. of 7 runs, 1000 loops each)
In [131]:
Out[131]:
a 14000.0
b 12000.0
c 10000.0
Name: init_cash, dtype: float64
group
first 26000.0
second 10000.0
Name: init_cash, dtype: float64
group
first 26000.0
second 10000.0
Name: init_cash, dtype: float64
a 14000.0
b 14000.0
c 14000.0
Name: init_cash, dtype: float64
group
first 26000.0
second 26000.0
Name: init_cash, dtype: float64
group
first 26000.0
second 26000.0
Name: init_cash, dtype: float64
In [132]:
Out[132]:
a b c
2020-01-01 100.00000 98.90010 98.87990
2020-01-02 99.69598 98.60012 98.57588
2020-01-03 99.89001 98.60012 101.41618
2020-01-04 99.89001 98.30808 101.70822
2020-01-05 94.68951 93.20858 101.70822
a b c
2020-01-01 100.00000 100.88010 98.87990
2020-01-02 99.69598 100.97612 98.57588
2020-01-03 99.89001 100.97612 101.41618
2020-01-04 99.89001 100.46808 101.70822
2020-01-05 94.68951 105.26858 101.70822
a b c
2020-01-01 100.00000 100.88010 98.87990
2020-01-02 99.69598 100.97612 98.57588
2020-01-03 99.89001 100.97612 101.41618
2020-01-04 99.89001 100.46808 101.70822
2020-01-05 94.68951 105.26858 101.70822
a b c
2020-01-01 200.00000 200.88010 98.87990
2020-01-02 199.69598 200.97612 98.57588
2020-01-03 199.89001 200.97612 101.41618
2020-01-04 199.89001 200.46808 101.70822
2020-01-05 194.68951 205.26858 101.70822
a b c
2020-01-01 200.88010 200.88010 98.87990
2020-01-02 200.67210 200.97612 98.57588
2020-01-03 200.86613 200.67210 101.41618
2020-01-04 200.35809 200.35809 101.70822
2020-01-05 199.95809 205.15859 101.70822
group first second
2020-01-01 200.88010 98.87990
2020-01-02 200.67210 98.57588
2020-01-03 200.86613 101.41618
2020-01-04 200.35809 101.70822
2020-01-05 199.95809 101.70822
group first second
2020-01-01 200.88010 98.87990
2020-01-02 200.67210 98.57588
2020-01-03 200.86613 101.41618
2020-01-04 200.35809 101.70822
2020-01-05 199.95809 101.70822
group first second
2020-01-01 200.88010 98.87990
2020-01-02 200.67210 98.57588
2020-01-03 200.86613 101.41618
2020-01-04 200.35809 101.70822
2020-01-05 199.95809 101.70822
In [90]:
Out[90]:
19.4 ms ± 920 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
18.3 ms ± 470 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
18.4 ms ± 2.12 ms per loop (mean ± std. dev. of 7 runs, 100 loops each)
17.6 ms ± 201 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
18.7 ms ± 303 µs per loop (mean ± std. dev. of 7 runs, 1 loop each)
18.3 ms ± 292 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
19.6 ms ± 1.75 ms per loop (mean ± std. dev. of 7 runs, 100 loops each)
21.7 ms ± 1.76 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)
In [133]:
Out[133]:
a b c
2020-01-01 0.0 0.0 1.0
2020-01-02 0.2 0.0 2.2
2020-01-03 0.0 0.0 0.3
2020-01-04 0.0 0.0 0.0
2020-01-05 5.0 0.0 0.0
a b c
2020-01-01 0.0 1.0 0.0
2020-01-02 0.0 2.2 0.0
2020-01-03 0.0 2.2 0.0
2020-01-04 0.0 4.0 0.0
2020-01-05 0.0 10.0 0.0
a b c
2020-01-01 0.0 -1.0 1.0
2020-01-02 0.2 -2.2 2.2
2020-01-03 0.0 -2.2 0.3
2020-01-04 0.0 -4.0 0.0
2020-01-05 5.0 -10.0 0.0
a b c
2020-01-01 0.0 -1.0 1.0
2020-01-02 0.2 -2.2 2.2
2020-01-03 0.0 -2.2 0.3
2020-01-04 0.0 -4.0 0.0
2020-01-05 5.0 -10.0 0.0
a b c
2020-01-01 0.0 -1.0 1.0
2020-01-02 0.2 -2.2 2.2
2020-01-03 0.0 -2.2 0.3
2020-01-04 0.0 -4.0 0.0
2020-01-05 5.0 -10.0 0.0
group first second
2020-01-01 -1.0 1.0
2020-01-02 -2.0 2.2
2020-01-03 -2.2 0.3
2020-01-04 -4.0 0.0
2020-01-05 -5.0 0.0
group first second
2020-01-01 -1.0 1.0
2020-01-02 -2.0 2.2
2020-01-03 -2.2 0.3
2020-01-04 -4.0 0.0
2020-01-05 -5.0 0.0
group first second
2020-01-01 -1.0 1.0
2020-01-02 -2.0 2.2
2020-01-03 -2.2 0.3
2020-01-04 -4.0 0.0
2020-01-05 -5.0 0.0
In [92]:
Out[92]:
16.7 ms ± 331 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
19.4 ms ± 2.51 ms per loop (mean ± std. dev. of 7 runs, 100 loops each)
18.4 ms ± 1.48 ms per loop (mean ± std. dev. of 7 runs, 100 loops each)
34.4 ms ± 308 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
33.6 ms ± 428 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
34.7 ms ± 213 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
In [134]:
Out[134]:
a b c
2020-01-01 0.000000 0.0 0.010012
2020-01-02 0.002002 0.0 0.021831
2020-01-03 0.000000 0.0 0.002949
2020-01-04 0.000000 0.0 0.000000
2020-01-05 0.050156 0.0 0.000000
a b c
2020-01-01 0.0 0.010010 0.0
2020-01-02 0.0 0.021825 0.0
2020-01-03 0.0 0.021825 0.0
2020-01-04 0.0 0.039098 0.0
2020-01-05 0.0 0.096891 0.0
a b c
2020-01-01 0.000000 -0.010214 0.010012
2020-01-02 0.002002 -0.022822 0.021831
2020-01-03 0.000000 -0.022822 0.002949
2020-01-04 0.000000 -0.042414 0.000000
2020-01-05 0.050156 -0.120180 0.000000
a b c
2020-01-01 0.000000 -0.010214 0.010012
2020-01-02 0.002002 -0.022822 0.021831
2020-01-03 0.000000 -0.022822 0.002949
2020-01-04 0.000000 -0.042414 0.000000
2020-01-05 0.050156 -0.120180 0.000000
a b c
2020-01-01 0.000000 -0.005053 0.010012
2020-01-02 0.001001 -0.011202 0.021831
2020-01-03 0.000000 -0.011202 0.002949
2020-01-04 0.000000 -0.020586 0.000000
2020-01-05 0.025039 -0.054583 0.000000
group first second
2020-01-01 -0.005053 0.010012
2020-01-02 -0.010189 0.021831
2020-01-03 -0.011208 0.002949
2020-01-04 -0.020598 0.000000
2020-01-05 -0.027338 0.000000
group first second
2020-01-01 -0.005053 0.010012
2020-01-02 -0.010189 0.021831
2020-01-03 -0.011208 0.002949
2020-01-04 -0.020598 0.000000
2020-01-05 -0.027338 0.000000
group first second
2020-01-01 -0.005053 0.010012
2020-01-02 -0.010189 0.021831
2020-01-03 -0.011208 0.002949
2020-01-04 -0.020598 0.000000
2020-01-05 -0.027338 0.000000
In [10]:
Out[10]:
54.6 ms ± 5.8 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)
44.3 ms ± 1.64 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)
44.2 ms ± 1.07 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)
58.8 ms ± 2.64 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)
55 ms ± 1.09 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)
60.9 ms ± 1.87 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)
In [135]:
Out[135]:
a b c
2020-01-01 0.000000 -0.010010 0.010012
2020-01-02 0.002002 -0.021825 0.021831
2020-01-03 0.000000 -0.021825 0.002949
2020-01-04 0.000000 -0.039098 0.000000
2020-01-05 0.050156 -0.096891 0.000000
a b c
2020-01-01 0.000000 -0.010010 0.010012
2020-01-02 0.002002 -0.021825 0.021831
2020-01-03 0.000000 -0.021825 0.002949
2020-01-04 0.000000 -0.039098 0.000000
2020-01-05 0.050156 -0.096891 0.000000
a b c
2020-01-01 0.000000 -0.005002 0.010012
2020-01-02 0.001001 -0.010956 0.021831
2020-01-03 0.000000 -0.010956 0.002949
2020-01-04 0.000000 -0.019772 0.000000
2020-01-05 0.025039 -0.049211 0.000000
group first second
2020-01-01 -0.005002 0.010012
2020-01-02 -0.009965 0.021831
2020-01-03 -0.010962 0.002949
2020-01-04 -0.019783 0.000000
2020-01-05 -0.024611 0.000000
group first second
2020-01-01 -0.005002 0.010012
2020-01-02 -0.009965 0.021831
2020-01-03 -0.010962 0.002949
2020-01-04 -0.019783 0.000000
2020-01-05 -0.024611 0.000000
group first second
2020-01-01 -0.005002 0.010012
2020-01-02 -0.009965 0.021831
2020-01-03 -0.010962 0.002949
2020-01-04 -0.019783 0.000000
2020-01-05 -0.024611 0.000000
In [12]:
Out[12]:
91.5 ms ± 1.76 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)
90.4 ms ± 1.52 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)
95.4 ms ± 4.26 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)
129 ms ± 3.21 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)
119 ms ± 1.51 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)
127 ms ± 1.85 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)
In [136]:
Out[136]:
a b c
2020-01-01 100.00000 99.88010 99.87990
2020-01-02 99.89598 98.77612 100.77588
2020-01-03 99.89001 98.77612 101.71618
2020-01-04 99.89001 96.46808 101.70822
2020-01-05 99.68951 95.26858 101.70822
a b c
2020-01-01 100.00000 99.88010 99.87990
2020-01-02 99.89598 98.77612 100.77588
2020-01-03 99.89001 98.77612 101.71618
2020-01-04 99.89001 96.46808 101.70822
2020-01-05 99.68951 95.26858 101.70822
a b c
2020-01-01 200.00000 199.88010 99.87990
2020-01-02 199.89598 198.77612 100.77588
2020-01-03 199.89001 198.77612 101.71618
2020-01-04 199.89001 196.46808 101.70822
2020-01-05 199.68951 195.26858 101.70822
a b c
2020-01-01 199.88010 199.88010 99.87990
2020-01-02 198.67210 198.77612 100.77588
2020-01-03 198.66613 198.67210 101.71618
2020-01-04 196.35809 196.35809 101.70822
2020-01-05 194.95809 195.15859 101.70822
group first second
2020-01-01 199.88010 99.87990
2020-01-02 198.67210 100.77588
2020-01-03 198.66613 101.71618
2020-01-04 196.35809 101.70822
2020-01-05 194.95809 101.70822
group first second
2020-01-01 199.88010 99.87990
2020-01-02 198.67210 100.77588
2020-01-03 198.66613 101.71618
2020-01-04 196.35809 101.70822
2020-01-05 194.95809 101.70822
group first second
2020-01-01 199.88010 99.87990
2020-01-02 198.67210 100.77588
2020-01-03 198.66613 101.71618
2020-01-04 196.35809 101.70822
2020-01-05 194.95809 101.70822
In [14]:
Out[14]:
36.9 ms ± 1.21 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)
35 ms ± 210 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
35.8 ms ± 81.1 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
46 ms ± 152 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
53.9 ms ± 626 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
50.4 ms ± 722 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
55.3 ms ± 941 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
In [137]:
Out[137]:
a -0.31049
b -4.73142
c 1.70822
Name: total_profit, dtype: float64
a -0.31049
b -4.73142
c 1.70822
Name: total_profit, dtype: float64
a -0.31049
b -4.73142
c 1.70822
Name: total_profit, dtype: float64
group
first -5.04191
second 1.70822
Name: total_profit, dtype: float64
group
first -5.04191
second 1.70822
Name: total_profit, dtype: float64
group
first -5.04191
second 1.70822
Name: total_profit, dtype: float64
In [16]:
Out[16]:
12.3 ms ± 79.7 µs per loop (mean ± std. dev. of 7 runs, 1 loop each)
12.5 ms ± 190 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
12.5 ms ± 225 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
13.2 ms ± 224 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
12.6 ms ± 176 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
13.4 ms ± 217 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
In [138]:
Out[138]:
a 99.68951
b 95.26858
c 101.70822
Name: final_value, dtype: float64
a 99.68951
b 95.26858
c 101.70822
Name: final_value, dtype: float64
a 199.68951
b 195.26858
c 101.70822
Name: final_value, dtype: float64
group
first 194.95809
second 101.70822
Name: final_value, dtype: float64
group
first 194.95809
second 101.70822
Name: final_value, dtype: float64
group
first 194.95809
second 101.70822
Name: final_value, dtype: float64
In [18]:
Out[18]:
12.3 ms ± 159 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
12.2 ms ± 122 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
12.9 ms ± 128 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
14.1 ms ± 280 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
12 ms ± 145 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
14.1 ms ± 231 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
In [139]:
Out[139]:
a -0.003105
b -0.047314
c 0.017082
Name: total_return, dtype: float64
a -0.003105
b -0.047314
c 0.017082
Name: total_return, dtype: float64
a -0.001552
b -0.023657
c 0.017082
Name: total_return, dtype: float64
group
first -0.025210
second 0.017082
Name: total_return, dtype: float64
group
first -0.025210
second 0.017082
Name: total_return, dtype: float64
group
first -0.025210
second 0.017082
Name: total_return, dtype: float64
In [20]:
Out[20]:
12.5 ms ± 200 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
12.4 ms ± 207 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
12.8 ms ± 151 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
14 ms ± 178 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
12.6 ms ± 199 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
14.2 ms ± 122 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
In [140]:
Out[140]:
a b c
2020-01-01 0.000000 -0.001199 -0.001201
2020-01-02 -0.001040 -0.011053 0.008971
2020-01-03 -0.000060 0.000000 0.009331
2020-01-04 0.000000 -0.023366 -0.000078
2020-01-05 -0.002007 -0.012434 0.000000
a b c
2020-01-01 0.000000 -0.001199 -0.001201
2020-01-02 -0.001040 -0.011053 0.008971
2020-01-03 -0.000060 0.000000 0.009331
2020-01-04 0.000000 -0.023366 -0.000078
2020-01-05 -0.002007 -0.012434 0.000000
a b c
2020-01-01 0.000000 -0.000600 -0.001201
2020-01-02 -0.000520 -0.005523 0.008971
2020-01-03 -0.000030 0.000000 0.009331
2020-01-04 0.000000 -0.011611 -0.000078
2020-01-05 -0.001003 -0.006105 0.000000
a b c
2020-01-01 0.000000 -0.000600 -0.001201
2020-01-02 -0.000523 -0.005523 0.008971
2020-01-03 -0.000030 0.000000 0.009331
2020-01-04 0.000000 -0.011618 -0.000078
2020-01-05 -0.001027 -0.006109 0.000000
group first second
2020-01-01 -0.000600 -0.001201
2020-01-02 -0.006044 0.008971
2020-01-03 -0.000030 0.009331
2020-01-04 -0.011618 -0.000078
2020-01-05 -0.007130 0.000000
group first second
2020-01-01 -0.000600 -0.001201
2020-01-02 -0.006044 0.008971
2020-01-03 -0.000030 0.009331
2020-01-04 -0.011618 -0.000078
2020-01-05 -0.007130 0.000000
group first second
2020-01-01 -0.000600 -0.001201
2020-01-02 -0.006044 0.008971
2020-01-03 -0.000030 0.009331
2020-01-04 -0.011618 -0.000078
2020-01-05 -0.007130 0.000000
In [22]:
Out[22]:
39.5 ms ± 2.59 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)
37.4 ms ± 313 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
39.4 ms ± 226 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
52.3 ms ± 149 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
55.6 ms ± 310 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
50.9 ms ± 276 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
63.5 ms ± 4.23 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)
In [141]:
Out[141]:
a b c
2020-01-01 0.00000 -inf -inf
2020-01-02 -inf -1.103980 0.895980
2020-01-03 -0.02985 0.000000 0.427409
2020-01-04 0.00000 -1.049109 -0.026533
2020-01-05 -inf -0.299875 0.000000
a b c
2020-01-01 0.00000 -inf -inf
2020-01-02 -inf -1.103980 0.895980
2020-01-03 -0.02985 0.000000 0.427409
2020-01-04 0.00000 -1.049109 -0.026533
2020-01-05 -inf -0.299875 0.000000
a b c
2020-01-01 0.00000 -inf -inf
2020-01-02 -inf -1.103980 0.895980
2020-01-03 -0.02985 0.000000 0.427409
2020-01-04 0.00000 -1.049109 -0.026533
2020-01-05 -inf -0.299875 0.000000
group first second
2020-01-01 -inf -inf
2020-01-02 -1.208000 0.895980
2020-01-03 -0.002985 0.427409
2020-01-04 -1.049109 -0.026533
2020-01-05 -0.350000 0.000000
group first second
2020-01-01 -inf -inf
2020-01-02 -1.208000 0.895980
2020-01-03 -0.002985 0.427409
2020-01-04 -1.049109 -0.026533
2020-01-05 -0.350000 0.000000
group first second
2020-01-01 -inf -inf
2020-01-02 -1.208000 0.895980
2020-01-03 -0.002985 0.427409
2020-01-04 -1.049109 -0.026533
2020-01-05 -0.350000 0.000000
In [24]:
Out[24]:
40.2 ms ± 5.18 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)
36.9 ms ± 235 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
37.4 ms ± 193 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
51.7 ms ± 195 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
49.8 ms ± 220 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
52.4 ms ± 264 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
In [142]:
Out[142]:
a b c
2020-01-01 100.0 100.0 100.0
2020-01-02 100.0 200.0 200.0
2020-01-03 150.0 200.0 300.0
2020-01-04 200.0 400.0 400.0
2020-01-05 250.0 500.0 400.0
a b c
2020-01-01 100.0 100.0 100.0
2020-01-02 100.0 200.0 200.0
2020-01-03 150.0 200.0 300.0
2020-01-04 200.0 400.0 400.0
2020-01-05 250.0 500.0 400.0
a b c
2020-01-01 200.0 200.0 100.0
2020-01-02 200.0 400.0 200.0
2020-01-03 300.0 400.0 300.0
2020-01-04 400.0 800.0 400.0
2020-01-05 500.0 1000.0 400.0
group first second
2020-01-01 200.0 100.0
2020-01-02 300.0 200.0
2020-01-03 350.0 300.0
2020-01-04 600.0 400.0
2020-01-05 750.0 400.0
group first second
2020-01-01 200.0 100.0
2020-01-02 300.0 200.0
2020-01-03 350.0 300.0
2020-01-04 600.0 400.0
2020-01-05 750.0 400.0
group first second
2020-01-01 200.0 100.0
2020-01-02 300.0 200.0
2020-01-03 350.0 300.0
2020-01-04 600.0 400.0
2020-01-05 750.0 400.0
In [26]:
Out[26]:
909 µs ± 51.7 µs per loop (mean ± std. dev. of 7 runs, 1000 loops each)
967 µs ± 34.4 µs per loop (mean ± std. dev. of 7 runs, 1000 loops each)
1.81 ms ± 111 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
4.86 ms ± 415 µs per loop (mean ± std. dev. of 7 runs, 1 loop each)
2.82 ms ± 35.5 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
5.2 ms ± 387 µs per loop (mean ± std. dev. of 7 runs, 1 loop each)
In [143]:
Out[143]:
a b c
2020-01-01 0.000000 0.00 0.000000
2020-01-02 0.000000 1.00 1.000000
2020-01-03 0.500000 0.00 0.500000
2020-01-04 0.333333 1.00 0.333333
2020-01-05 0.250000 0.25 0.000000
a b c
2020-01-01 0.000000 0.00 0.000000
2020-01-02 0.000000 1.00 1.000000
2020-01-03 0.500000 0.00 0.500000
2020-01-04 0.333333 1.00 0.333333
2020-01-05 0.250000 0.25 0.000000
a b c
2020-01-01 0.000000 0.00 0.000000
2020-01-02 0.000000 1.00 1.000000
2020-01-03 0.500000 0.00 0.500000
2020-01-04 0.333333 1.00 0.333333
2020-01-05 0.250000 0.25 0.000000
group first second
2020-01-01 0.000000 0.000000
2020-01-02 0.500000 1.000000
2020-01-03 0.166667 0.500000
2020-01-04 0.714286 0.333333
2020-01-05 0.250000 0.000000
group first second
2020-01-01 0.000000 0.000000
2020-01-02 0.500000 1.000000
2020-01-03 0.166667 0.500000
2020-01-04 0.714286 0.333333
2020-01-05 0.250000 0.000000
group first second
2020-01-01 0.000000 0.000000
2020-01-02 0.500000 1.000000
2020-01-03 0.166667 0.500000
2020-01-04 0.714286 0.333333
2020-01-05 0.250000 0.000000
In [28]:
Out[28]:
3.7 ms ± 67.9 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
3.72 ms ± 66.8 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
5.11 ms ± 5.82 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
7.2 ms ± 618 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
4.1 ms ± 52.4 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
7.28 ms ± 40.2 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
In [144]:
Out[144]:
a 1.5
b 4.0
c 3.0
Name: total_market_return, dtype: float64
a 1.5
b 4.0
c 3.0
Name: total_market_return, dtype: float64
a 1.5
b 4.0
c 3.0
Name: total_market_return, dtype: float64
group
first 2.75
second 3.00
Name: total_market_return, dtype: float64
group
first 2.75
second 3.00
Name: total_market_return, dtype: float64
group
first 2.75
second 3.00
Name: total_market_return, dtype: float64
In [30]:
Out[30]:
975 µs ± 61.3 µs per loop (mean ± std. dev. of 7 runs, 1000 loops each)
937 µs ± 10.7 µs per loop (mean ± std. dev. of 7 runs, 1000 loops each)
1.83 ms ± 7.9 µs per loop (mean ± std. dev. of 7 runs, 1000 loops each)
4.77 ms ± 30 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
2.85 ms ± 11.9 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
5.21 ms ± 79.8 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
In [145]:
Out[145]:
group first second
2020-01-01 -0.000599 -0.001201
2020-01-02 -0.006639 0.007759
2020-01-03 -0.006669 0.017162
2020-01-04 -0.018210 0.017082
2020-01-05 -0.025210 0.017082
a b c
2020-01-01 0.000000 -0.000599 -0.001201
2020-01-02 -0.000520 -0.006119 0.007759
2020-01-03 -0.000550 -0.006119 0.017162
2020-01-04 -0.000550 -0.017660 0.017082
2020-01-05 -0.001552 -0.023657 0.017082
In [6]:
Out[6]:
group
first -20.095907
second 12.345065
Name: sharpe_ratio, dtype: float64
group
first -59.622588
second -23.917188
Name: sharpe_ratio, dtype: float64
group
first -16.697884
second 10.257635
Name: sharpe_ratio, dtype: float64
a -13.309506
b -19.278625
c 12.345065
Name: sharpe_ratio, dtype: float64
In [7]:
Out[7]:
Start 2020-01-01 00:00:00
End 2020-01-05 00:00:00
Period 5 days 00:00:00
Start Value 100.0
End Value 98.88877
Total Return [%] -1.11123
Benchmark Return [%] 283.333333
Max Gross Exposure [%] 2.059062
Total Fees Paid 0.42223
Max Drawdown [%] 1.645124
Max Drawdown Duration 3 days 08:00:00
Total Trades 2.0
Total Closed Trades 1.333333
Total Open Trades 0.666667
Open Trade PnL -1.504206
Win Rate [%] 33.333333
Best Trade [%] -98.380588
Worst Trade [%] -100.803855
Avg Winning Trade [%] 143.916254
Avg Losing Trade [%] -221.34646
Avg Winning Trade Duration 2 days 12:00:00
Avg Losing Trade Duration 2 days 00:00:00
Profit Factor inf
Expectancy 0.108273
Sharpe Ratio -6.751008
Calmar Ratio 10378.930331
Omega Ratio 4.7687
Sortino Ratio 31.599761
Name: agg_func_mean, dtype: object
/Users/olegpolakow/miniconda3/lib/python3.7/site-packages/ipykernel_launcher.py:1: UserWarning: Object has multiple columns. Aggregating using <function mean at 0x7ff110b83620>. Pass column to select a single column/group.
"""Entry point for launching an IPython kernel.
In [13]:
Out[13]:
Start 2020-01-01 00:00:00
End 2020-01-05 00:00:00
Period 5 days 00:00:00
Start Value 100.0
End Value 99.68951
Total Return [%] -0.31049
Benchmark Return [%] 150.0
Max Gross Exposure [%] 5.015573
Total Fees Paid 0.35549
Max Drawdown [%] 0.31049
Max Drawdown Duration 4 days 00:00:00
Total Trades 2
Total Closed Trades 1
Total Open Trades 1
Open Trade PnL -0.2005
Win Rate [%] 0.0
Best Trade [%] -54.450495
Worst Trade [%] -54.450495
Avg Winning Trade [%] NaN
Avg Losing Trade [%] -54.450495
Avg Winning Trade Duration NaT
Avg Losing Trade Duration 1 days 00:00:00
Profit Factor 0.0
Expectancy -0.10999
Sharpe Ratio -13.308045
Calmar Ratio -65.408686
Omega Ratio 0.0
Sortino Ratio -11.738865
Name: a, dtype: object
In [14]:
Out[14]:
Start 2020-01-01 00:00:00
End 2020-01-05 00:00:00
Period 5 days 00:00:00
Start Value 100.0
End Value 99.68951
Total Return [%] -0.31049
Benchmark Return [%] 150.0
Max Gross Exposure [%] 5.015573
Total Fees Paid 0.35549
Max Drawdown [%] 0.31049
Max Drawdown Duration 4 days 00:00:00
Total Trades 2
Total Closed Trades 1
Total Open Trades 1
Open Trade PnL -0.2005
Win Rate [%] 0.0
Best Trade [%] -54.450495
Worst Trade [%] -54.450495
Avg Winning Trade [%] NaN
Avg Losing Trade [%] -54.450495
Avg Winning Trade Duration NaT
Avg Losing Trade Duration 1 days 00:00:00
Profit Factor 0.0
Expectancy -0.10999
Sharpe Ratio -227.458628
Calmar Ratio -65.408686
Omega Ratio 0.0
Sortino Ratio -19.104372
Name: a, dtype: object
In [15]:
Out[15]:
Start 2020-01-01 00:00:00
End 2020-01-05 00:00:00
Period 5 days 00:00:00
Start Value 100.0
End Value 99.68951
Total Return [%] -0.31049
Benchmark Return [%] 150.0
Max Gross Exposure [%] 5.015573
Total Fees Paid 0.35549
Max Drawdown [%] 0.31049
Max Drawdown Duration 4 days 00:00:00
Total Trades 2
Total Closed Trades 1
Total Open Trades 1
Open Trade PnL -0.2005
Win Rate [%] 0.0
Best Trade [%] -3.970297
Worst Trade [%] -54.450495
Avg Winning Trade [%] NaN
Avg Losing Trade [%] -29.210396
Avg Winning Trade Duration NaT
Avg Losing Trade Duration 1 days 00:00:00
Profit Factor 0.0
Expectancy -0.155245
Sharpe Ratio -13.308045
Calmar Ratio -65.408686
Omega Ratio 0.0
Sortino Ratio -11.738865
Name: a, dtype: object
In [16]:
Out[16]:
Start 2020-01-01 00:00:00
End 2020-01-05 00:00:00
Period 5 days 00:00:00
Start Value 200.0
End Value 194.95809
Total Return [%] -2.520955
Benchmark Return [%] 275.0
Max Gross Exposure [%] -0.505305
Total Fees Paid 0.82091
Max Drawdown [%] 2.462481
Max Drawdown Duration 4 days 00:00:00
Total Trades 4
Total Closed Trades 2
Total Open Trades 2
Open Trade PnL -4.512618
Win Rate [%] 0.0
Best Trade [%] -54.450495
Worst Trade [%] -388.242424
Avg Winning Trade [%] NaN
Avg Losing Trade [%] -221.34646
Avg Winning Trade Duration NaT
Avg Losing Trade Duration 2 days 00:00:00
Profit Factor 0.0
Expectancy -0.264646
Sharpe Ratio -20.095907
Calmar Ratio -34.312217
Omega Ratio 0.0
Sortino Ratio -14.554512
Name: first, dtype: object
In [17]:
In [12]:
Out[12]:
64.9 ms ± 525 µs per loop (mean ± std. dev. of 7 runs, 1 loop each)
76 ms ± 478 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
145 ms ± 588 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
101 ms ± 87.9 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
72.4 ms ± 151 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
158 ms ± 1.02 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)
In [12]:
In [13]:
Out[13]:
start
1.72 ms ± 643 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
end
1.17 ms ± 25.3 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
period
1.18 ms ± 33.2 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
start_value
1.23 ms ± 51.1 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
end_value
2.43 ms ± 126 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
total_return
2.38 ms ± 7.53 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
benchmark_return
1.56 ms ± 12.2 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
max_gross_exposure
5.51 ms ± 22.4 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
total_fees_paid
2.11 ms ± 132 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
max_dd
5.3 ms ± 22.5 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
max_dd_duration
5.39 ms ± 49.2 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
total_trades
2.68 ms ± 320 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
total_closed_trades
4.07 ms ± 111 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
total_open_trades
3.24 ms ± 28.8 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
open_trade_pnl
3.72 ms ± 136 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
win_rate
4.19 ms ± 128 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
best_trade
3.62 ms ± 44.6 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
worst_trade
3.71 ms ± 178 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
avg_winning_trade
4.54 ms ± 161 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
avg_losing_trade
4.46 ms ± 122 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
avg_winning_trade_duration
4.5 ms ± 140 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
avg_losing_trade_duration
4.99 ms ± 224 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
profit_factor
5.82 ms ± 86.1 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
expectancy
7.09 ms ± 288 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
sharpe_ratio
8.79 ms ± 613 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
calmar_ratio
8.56 ms ± 527 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
omega_ratio
8.38 ms ± 215 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
sortino_ratio
8.15 ms ± 101 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
In [14]:
Out[14]:
start
1.51 ms ± 362 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
end
1.54 ms ± 74 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
period
1.92 ms ± 19.8 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
start_value
2.46 ms ± 117 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
end_value
4.1 ms ± 117 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
total_return
5.67 ms ± 12.9 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
benchmark_return
6.59 ms ± 46.7 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
max_gross_exposure
11.4 ms ± 33.9 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
total_fees_paid
12.8 ms ± 232 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
max_dd
17.6 ms ± 281 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
max_dd_duration
19.1 ms ± 833 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
total_trades
20.6 ms ± 434 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
total_closed_trades
22.5 ms ± 234 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
total_open_trades
23.9 ms ± 228 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
open_trade_pnl
25.7 ms ± 140 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
win_rate
28 ms ± 246 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
best_trade
30.3 ms ± 710 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
worst_trade
31.9 ms ± 606 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
avg_winning_trade
35.8 ms ± 1.27 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)
avg_losing_trade
36.8 ms ± 183 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
avg_winning_trade_duration
39.5 ms ± 140 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
avg_losing_trade_duration
41.7 ms ± 235 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
profit_factor
45.8 ms ± 240 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
expectancy
50.6 ms ± 425 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
sharpe_ratio
58 ms ± 176 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
calmar_ratio
58.5 ms ± 182 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
omega_ratio
59.1 ms ± 227 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
sortino_ratio
60 ms ± 144 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
In [15]:
Out[15]:
38 ms ± 179 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
47.3 ms ± 852 µs per loop (mean ± std. dev. of 7 runs, 1 loop each)
94.6 ms ± 237 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
68.4 ms ± 511 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
40.1 ms ± 161 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
90.3 ms ± 1.48 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)
In [16]:
Out[16]:
560 ms ± 29.3 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)
554 ms ± 13.2 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)
609 ms ± 4.04 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)
676 ms ± 10.3 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)
635 ms ± 12.1 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)
741 ms ± 14.1 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)
In [17]:
Out[17]:
Start 2020-01-01 00:00:00
End 2020-01-05 00:00:00
Period 5 days 00:00:00
Total Return [%] -1.11123
Benchmark Return [%] 283.333333
Annualized Return [%] 42.313666
Annualized Volatility [%] 9.984895
Max Drawdown [%] 1.645124
Max Drawdown Duration 3 days 08:00:00
Sharpe Ratio -6.751008
Calmar Ratio 10378.930331
Omega Ratio 4.7687
Sortino Ratio 31.599761
Skew -0.399797
Kurtosis -1.202541
Tail Ratio 3.164402
Common Sense Ratio 10.883528
Value at Risk -0.00799
Alpha -0.35365
Beta -0.001234
Name: agg_func_mean, dtype: object
/Users/olegpolakow/Documents/SourceTree/vectorbt/vectorbt/portfolio/base.py:4618: UserWarning: Object has multiple columns. Aggregating using <function mean at 0x7ffd1144a620>. Pass column to select a single column/group.
return getattr(returns_acc, 'stats')(settings=settings, **kwargs)
In [18]:
Out[18]:
Start 2020-01-01 00:00:00
End 2020-01-05 00:00:00
Period 5 days 00:00:00
Total Return [%] -0.31049
Benchmark Return [%] 150.0
Annualized Return [%] -20.308743
Annualized Volatility [%] 1.704408
Max Drawdown [%] 0.31049
Max Drawdown Duration 4 days 00:00:00
Sharpe Ratio -13.308045
Calmar Ratio -65.408686
Omega Ratio 0.0
Sortino Ratio -11.738865
Skew -1.219107
Kurtosis 0.122976
Tail Ratio 0.0
Common Sense Ratio 0.0
Value at Risk -0.001814
Alpha -0.248883
Beta 0.000749
Name: a, dtype: object
In [19]:
Out[19]:
Start 2020-01-01 00:00:00
End 2020-01-05 00:00:00
Period 5 days 00:00:00
Total Return [%] -2.520955
Benchmark Return [%] 275.0
Annualized Return [%] -84.493192
Annualized Volatility [%] 9.234269
Max Drawdown [%] 2.462481
Max Drawdown Duration 4 days 00:00:00
Sharpe Ratio -20.095907
Calmar Ratio -34.312217
Omega Ratio 0.0
Sortino Ratio -14.554512
Skew -0.254782
Kurtosis -1.363876
Tail Ratio 0.013427
Common Sense Ratio 0.002082
Value at Risk -0.01072
Alpha -0.053947
Beta -0.015121
Name: first, dtype: object
In [20]:
In [8]:
Out[8]:
In [9]:
Out[9]:
/Users/olegpolakow/Documents/SourceTree/vectorbt/vectorbt/generic/plots_builder.py:340: UserWarning:
Subplot 'orders' does not support grouped data
/Users/olegpolakow/Documents/SourceTree/vectorbt/vectorbt/generic/plots_builder.py:340: UserWarning:
Subplot 'trade_pnl' does not support grouped data
In [10]:
Out[10]:
In [11]:
Out[11]:
/Users/olegpolakow/Documents/SourceTree/vectorbt/vectorbt/generic/plots_builder.py:340: UserWarning:
Subplot 'orders' does not support grouped data
/Users/olegpolakow/Documents/SourceTree/vectorbt/vectorbt/generic/plots_builder.py:340: UserWarning:
Subplot 'trades' does not support grouped data
/Users/olegpolakow/Documents/SourceTree/vectorbt/vectorbt/generic/plots_builder.py:340: UserWarning:
Subplot 'trade_pnl' does not support grouped data
/Users/olegpolakow/Documents/SourceTree/vectorbt/vectorbt/generic/plots_builder.py:340: UserWarning:
Subplot 'asset_flow' does not support grouped data
/Users/olegpolakow/Documents/SourceTree/vectorbt/vectorbt/generic/plots_builder.py:340: UserWarning:
Subplot 'assets' does not support grouped data
In [12]:
Out[12]:
/Users/olegpolakow/Documents/SourceTree/vectorbt/vectorbt/generic/plots_builder.py:340: UserWarning:
Subplot 'orders' does not support grouped data
/Users/olegpolakow/Documents/SourceTree/vectorbt/vectorbt/generic/plots_builder.py:340: UserWarning:
Subplot 'trades' does not support grouped data
/Users/olegpolakow/Documents/SourceTree/vectorbt/vectorbt/generic/plots_builder.py:340: UserWarning:
Subplot 'trade_pnl' does not support grouped data
/Users/olegpolakow/Documents/SourceTree/vectorbt/vectorbt/generic/plots_builder.py:340: UserWarning:
Subplot 'asset_flow' does not support grouped data
/Users/olegpolakow/Documents/SourceTree/vectorbt/vectorbt/generic/plots_builder.py:340: UserWarning:
Subplot 'assets' does not support grouped data
In [13]:
Out[13]:
In [14]:
Out[14]:
In [15]:
Out[15]:
In [ ]: