Kernel: Python 3 (ipykernel)
records
In [1]:
In [2]:
In [3]:
In [4]:
In [5]:
Out[5]:
[(0, 0, 0, 10., 21.) (1, 1, 0, 11., 20.) (2, 2, 0, 12., 19.)
(3, 0, 1, 13., 18.) (4, 1, 1, 14., 17.) (5, 2, 1, 13., 18.)
(6, 0, 2, 12., 19.) (7, 1, 2, 11., 20.) (8, 2, 2, 10., 21.)]
(9,)
In [6]:
Out[6]:
(1000000,)
In [7]:
Out[7]:
[(8, 2, 2, 10., 21.) (7, 1, 2, 11., 20.) (6, 0, 2, 12., 19.)
(5, 2, 1, 13., 18.) (4, 1, 1, 14., 17.) (3, 0, 1, 13., 18.)
(2, 2, 0, 12., 19.) (1, 1, 0, 11., 20.) (0, 0, 0, 10., 21.)]
In [8]:
ColumnMapper
In [9]:
Out[9]:
[0 0 0 1 1 1 2 2 2]
In [10]:
Out[10]:
[0 0 0 1 1 1 2 2 2]
[0 0 0 1 1 1 1 1 1]
7.57 µs ± 81.5 ns per loop (mean ± std. dev. of 7 runs, 100000 loops each)
In [11]:
Out[11]:
[[ 0 3]
[ 3 6]
[ 6 9]
[-1 -1]]
6.99 µs ± 73.1 ns per loop (mean ± std. dev. of 7 runs, 100000 loops each)
In [12]:
Out[12]:
[[ 0 3]
[ 3 6]
[ 6 9]
[-1 -1]]
[[0 3]
[3 9]]
7.38 µs ± 56.5 ns per loop (mean ± std. dev. of 7 runs, 100000 loops each)
In [13]:
Out[13]:
(array([0, 1, 2, 3, 4, 5, 6, 7, 8]), array([3, 3, 3, 0]))
7.03 µs ± 22.4 ns per loop (mean ± std. dev. of 7 runs, 100000 loops each)
In [14]:
Out[14]:
(array([0, 1, 2, 3, 4, 5, 6, 7, 8]), array([3, 3, 3, 0]))
(array([0, 1, 2, 3, 4, 5, 6, 7, 8]), array([3, 6]))
7.43 µs ± 46.4 ns per loop (mean ± std. dev. of 7 runs, 100000 loops each)
In [15]:
Out[15]:
True
7.48 µs ± 48.2 ns per loop (mean ± std. dev. of 7 runs, 100000 loops each)
False
7.49 µs ± 8.8 ns per loop (mean ± std. dev. of 7 runs, 100000 loops each)
MappedArray
In [9]:
In [12]:
Out[12]:
[10. 11. 12.]
[0 0 0]
MultiIndex([(0, 'a')],
names=['lvl1', 'lvl2'])
[13. 14. 13.]
[0 0 0]
MultiIndex([(1, 'b')],
names=['lvl1', 'lvl2'])
[10. 11. 12. 10. 11. 12.]
[0 0 0 1 1 1]
MultiIndex([(0, 'a'),
(0, 'a')],
names=['lvl1', 'lvl2'])
[10. 11. 12. 13. 14. 13.]
[0 0 0 1 1 1]
MultiIndex([(0, 'a'),
(1, 'b')],
names=['lvl1', 'lvl2'])
954 µs ± 11.3 µs per loop (mean ± std. dev. of 7 runs, 1000 loops each)
13.7 ms ± 1.09 ms per loop (mean ± std. dev. of 7 runs, 100 loops each)
In [13]:
Out[13]:
[12. 11. 10.]
[0 0 0]
MultiIndex([(0, 'a')],
names=['lvl1', 'lvl2'])
[13. 14. 13.]
[0 0 0]
MultiIndex([(1, 'b')],
names=['lvl1', 'lvl2'])
[12. 11. 10. 12. 11. 10.]
[0 0 0 1 1 1]
MultiIndex([(0, 'a'),
(0, 'a')],
names=['lvl1', 'lvl2'])
[12. 11. 10. 13. 14. 13.]
[0 0 0 1 1 1]
MultiIndex([(0, 'a'),
(1, 'b')],
names=['lvl1', 'lvl2'])
954 µs ± 7.38 µs per loop (mean ± std. dev. of 7 runs, 1000 loops each)
14.2 ms ± 448 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
In [14]:
Out[14]:
MultiIndex([(0, 'a')],
names=['lvl1', 'lvl2'])
1
1
Index([0], dtype='int64', name='lvl1')
MultiIndex([(1, 'b'),
(1, 'c'),
(1, 'd')],
names=['lvl1', 'lvl2'])
2
1
Index([1, 1, 1], dtype='int64', name='lvl1')
MultiIndex([(0, 'a')],
names=['lvl1', 'lvl2'])
2
2
Index([0], dtype='int64', name='lvl1')
MultiIndex([(0, 'a'),
(1, 'b'),
(1, 'c'),
(1, 'd')],
names=['lvl1', 'lvl2'])
2
2
Index([0, 1, 1, 1], dtype='int64', name='lvl1')
5.57 ms ± 375 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
12.1 ms ± 451 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
In [15]:
Out[15]:
Index(['x', 'y', 'z'], dtype='object')
MultiIndex([(0, 'a'),
(1, 'b'),
(1, 'c'),
(1, 'd')],
names=['lvl1', 'lvl2'])
2
None
Index(['x', 'y', 'z'], dtype='object')
MultiIndex([(0, 'a'),
(1, 'b'),
(1, 'c'),
(1, 'd')],
names=['lvl1', 'lvl2'])
2
Index([0, 1, 1, 1], dtype='int64', name='lvl1')
In [16]:
Out[16]:
[10. 11. 12. 13. 14. 13. 12. 11. 10.]
In [17]:
Out[17]:
[0 0 0 1 1 1 2 2 2]
In [18]:
Out[18]:
[0 1 2 3 4 5 6 7 8]
In [19]:
Out[19]:
[0 1 2 0 1 2 0 1 2]
In [20]:
Out[20]:
True
1.04 ms ± 7.48 µs per loop (mean ± std. dev. of 7 runs, 1000 loops each)
False
7.84 µs ± 31 ns per loop (mean ± std. dev. of 7 runs, 100000 loops each)
True
1.58 ms ± 65.5 µs per loop (mean ± std. dev. of 7 runs, 1000 loops each)
False
6.99 µs ± 20.4 ns per loop (mean ± std. dev. of 7 runs, 100000 loops each)
In [21]:
Out[21]:
[0 0 0 1 1 1 2 2 2]
[0 1 2 3 4 5 6 7 8]
1.41 ms ± 48.7 µs per loop (mean ± std. dev. of 7 runs, 1000 loops each)
[0 0 0 1 1 1 2 2 2]
[2 1 0 5 4 3 8 7 6]
20.1 ms ± 544 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
[0 0 0 1 1 1 2 2 2]
[0 1 2 3 4 5 6 7 8]
1.91 ms ± 3.77 µs per loop (mean ± std. dev. of 7 runs, 1000 loops each)
[0 0 0 1 1 1 2 2 2]
[0 1 2 3 4 5 6 7 8]
16.1 ms ± 1.42 ms per loop (mean ± std. dev. of 7 runs, 100 loops each)
In [10]:
Out[10]:
[12. 13. 14. 13. 12.]
18.2 ms ± 487 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
17.9 ms ± 143 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
In [24]:
Out[24]:
[ True False True True False True True False True]
1.11 ms ± 3.83 µs per loop (mean ± std. dev. of 7 runs, 1000 loops each)
1.64 ms ± 43.2 µs per loop (mean ± std. dev. of 7 runs, 1000 loops each)
In [25]:
Out[25]:
[10. 11. 12. 13. 14. 13. 12. 11. 10.]
[False False True False True False True False False]
50.8 ms ± 76.3 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
[ True False False True False False False False True]
51.6 ms ± 358 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
In [26]:
Out[26]:
[12. 14. 12.]
61.2 ms ± 642 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
[10. 13. 10.]
59.6 ms ± 362 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
In [27]:
Out[27]:
True
2.44 ms ± 11.7 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
In [28]:
Out[28]:
lvl1 0 1
lvl2 a b c d
x 10.0 13.0 12.0 NaN
y 11.0 14.0 11.0 NaN
z 12.0 13.0 10.0 NaN
lvl1 0 1
lvl2 a b c d
x 10.0 13.0 12.0 0.0
y 11.0 14.0 11.0 0.0
z 12.0 13.0 10.0 0.0
5.41 ms ± 239 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
In [29]:
Out[29]:
0 10.0
1 11.0
2 12.0
Name: (0, a), dtype: float64
8.29 ms ± 1.09 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)
lvl1 0 1
lvl2 a b c d
0 10.0 13.0 12.0 NaN
1 11.0 14.0 11.0 NaN
2 12.0 13.0 10.0 NaN
3.48 ms ± 202 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
lvl1 0 1
0 10.0 13.0
1 11.0 14.0
2 12.0 13.0
3 NaN 12.0
4 NaN 11.0
5 NaN 10.0
lvl1 0 1
0 10.0 13.0
1 11.0 14.0
2 12.0 13.0
3 0.0 12.0
4 0.0 11.0
5 0.0 10.0
3.34 ms ± 79.2 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
In [30]:
Out[30]:
11.0
lvl1 lvl2
0 a 11.000000
1 b 13.333333
Name: reduce, dtype: float64
lvl1 lvl2
0 a 11.000000
1 b 13.333333
c 11.000000
d NaN
Name: reduce, dtype: float64
lvl1 lvl2
0 a 11.000000
1 b 13.333333
c 11.000000
d 0.000000
Name: reduce, dtype: float64
lvl1 lvl2
0 a 11.000000
1 b 13.333333
c 11.000000
d 0.000000
Name: reduce, dtype: float64
lvl1 lvl2
0 a 11 days 00:00:00
1 b 13 days 08:00:00
c 11 days 00:00:00
d NaT
Name: reduce, dtype: timedelta64[ns]
2.07 ms ± 18.3 µs per loop (mean ± std. dev. of 7 runs, 1000 loops each)
2.52 ms ± 38 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
In [31]:
Out[31]:
11.0
lvl1
0 11.0
Name: reduce, dtype: float64
lvl1
0 11.000000
1 12.166667
Name: reduce, dtype: float64
lvl1 lvl2
0 a 11.000000
1 b 13.333333
c 11.000000
d NaN
Name: reduce, dtype: float64
2.13 ms ± 141 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
In [32]:
Out[32]:
lvl1 lvl2
0 a x
1 b x
c z
d NaN
Name: reduce, dtype: object
3.9 ms ± 76.7 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
lvl1 lvl2
0 a 0
1 b 0
c 2
d -1
Name: reduce, dtype: int64
2.89 ms ± 113 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
lvl1
0 x
1 z
Name: reduce, dtype: object
3.15 ms ± 100 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
In [33]:
Out[33]:
0 10.0
1 12.0
Name: (0, a), dtype: float64
lvl1 0 1
lvl2 a b
0 10.0 13.0
1 12.0 14.0
lvl1 0 1
lvl2 a b c d
0 10.0 13.0 10.0 NaN
1 12.0 14.0 12.0 NaN
lvl1 0 1
lvl2 a b c d
min 10.0 13.0 10.0 NaN
max 12.0 14.0 12.0 NaN
lvl1 0 1
lvl2 a b c d
min 10.0 13.0 10.0 0.0
max 12.0 14.0 12.0 0.0
lvl1 0 1
lvl2 a b c d
0 10 days 13 days 10 days NaT
1 12 days 14 days 12 days NaT
2.45 ms ± 12.1 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
In [34]:
Out[34]:
0 10.0
1 12.0
dtype: float64
lvl1 0
0 10.0
1 12.0
lvl1 0 1
0 10.0 10.0
1 12.0 14.0
lvl1 0 1
lvl2 a b c d
0 10.0 13.0 10.0 NaN
1 12.0 14.0 12.0 NaN
2.38 ms ± 3.66 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
In [35]:
Out[35]:
lvl1 0 1
lvl2 a b c d
0 x x z NaN
1 z y x NaN
82.4 ms ± 388 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
lvl1 0 1
lvl2 a b c d
0 0 0 2 -1
1 2 1 0 -1
4.04 ms ± 17.8 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
lvl1 0 1
0 x z
1 z y
4.45 ms ± 3.78 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
In [36]:
Out[36]:
lvl1 lvl2
0 a 10.0
1 b 13.0
c 12.0
d NaN
Name: nth, dtype: float64
lvl1 lvl2
0 a 12.0
1 b 13.0
c 10.0
d NaN
Name: nth, dtype: float64
1.03 ms ± 1.44 µs per loop (mean ± std. dev. of 7 runs, 1000 loops each)
lvl1
0 10.0
1 13.0
Name: nth, dtype: float64
1.11 ms ± 3.55 µs per loop (mean ± std. dev. of 7 runs, 1000 loops each)
In [37]:
Out[37]:
lvl1 lvl2
0 a 10.0
1 b 13.0
c 10.0
d NaN
Name: min, dtype: float64
10.1 ms ± 458 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
lvl1 lvl2
0 a 10.0
1 b 13.0
c 10.0
d NaN
Name: min, dtype: float64
2.98 ms ± 4.29 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
lvl1
0 10.0
1 10.0
Name: min, dtype: float64
3.02 ms ± 5.68 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
In [38]:
Out[38]:
lvl1 lvl2
0 a 12.0
1 b 14.0
c 12.0
d NaN
Name: max, dtype: float64
9.97 ms ± 92 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
lvl1 lvl2
0 a 12.0
1 b 14.0
c 12.0
d NaN
Name: max, dtype: float64
2.98 ms ± 6.4 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
lvl1
0 12.0
1 14.0
Name: max, dtype: float64
3.03 ms ± 3.58 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
In [39]:
Out[39]:
lvl1 lvl2
0 a 11.000000
1 b 13.333333
c 11.000000
d NaN
Name: mean, dtype: float64
8.4 ms ± 336 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
lvl1 lvl2
0 a 11.000000
1 b 13.333333
c 11.000000
d NaN
Name: mean, dtype: float64
3.27 ms ± 10.9 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
lvl1
0 11.000000
1 12.166667
Name: mean, dtype: float64
3.32 ms ± 5.36 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
In [40]:
Out[40]:
lvl1 lvl2
0 a 11.0
1 b 13.0
c 11.0
d NaN
Name: median, dtype: float64
16.9 ms ± 151 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
lvl1 lvl2
0 a 11.0
1 b 13.0
c 11.0
d NaN
Name: median, dtype: float64
12.5 ms ± 7.77 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
lvl1
0 11.0
1 12.5
Name: median, dtype: float64
11.7 ms ± 13.3 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
In [41]:
Out[41]:
lvl1 lvl2
0 a 1.00000
1 b 0.57735
c 1.00000
d NaN
Name: std, dtype: float64
lvl1 lvl2
0 a 0.816497
1 b 0.471405
c 0.816497
d NaN
Name: std, dtype: float64
8.7 ms ± 23.4 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
lvl1 lvl2
0 a 1.00000
1 b 0.57735
c 1.00000
d NaN
Name: std, dtype: float64
lvl1 lvl2
0 a 0.816497
1 b 0.471405
c 0.816497
d NaN
Name: std, dtype: float64
6.59 ms ± 134 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
lvl1
0 1.00000
1 1.47196
Name: std, dtype: float64
6.24 ms ± 3.6 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
In [42]:
Out[42]:
lvl1 lvl2
0 a 33.0
1 b 40.0
c 33.0
d 0.0
Name: sum, dtype: float64
8.63 ms ± 36.9 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
lvl1 lvl2
0 a 33.0
1 b 40.0
c 33.0
d 0.0
Name: sum, dtype: float64
3.26 ms ± 6.28 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
lvl1
0 33.0
1 73.0
Name: sum, dtype: float64
3.31 ms ± 3.33 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
In [43]:
Out[43]:
lvl1 lvl2
0 a x
1 b x
c z
d NaN
Name: idxmin, dtype: object
9.22 ms ± 130 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
lvl1 lvl2
0 a x
1 b x
c z
d NaN
Name: idxmin, dtype: object
4.86 ms ± 28.4 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
lvl1
0 x
1 z
Name: idxmin, dtype: object
4.21 ms ± 7.54 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
In [44]:
Out[44]:
lvl1 lvl2
0 a z
1 b y
c x
d NaN
Name: idxmax, dtype: object
9.4 ms ± 395 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
lvl1 lvl2
0 a z
1 b y
c x
d NaN
Name: idxmax, dtype: object
4.88 ms ± 41.7 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
lvl1
0 z
1 y
Name: idxmax, dtype: object
4.22 ms ± 7.03 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
In [45]:
Out[45]:
lvl1 0 1
lvl2 a b c d
count 3.0 3.000000 3.0 0.0
mean 11.0 13.333333 11.0 NaN
std 1.0 0.577350 1.0 NaN
min 10.0 13.000000 10.0 NaN
25% 10.5 13.000000 10.5 NaN
50% 11.0 13.000000 11.0 NaN
75% 11.5 13.500000 11.5 NaN
max 12.0 14.000000 12.0 NaN
lvl1 0 1
lvl2 a b c d
count 3.0 3.000000 3.0 0.0
mean 11.0 13.333333 11.0 NaN
std 1.0 0.577350 1.0 NaN
min 10.0 13.000000 10.0 NaN
30% 10.6 13.000000 10.6 NaN
50% 11.0 13.000000 11.0 NaN
70% 11.4 13.400000 11.4 NaN
max 12.0 14.000000 12.0 NaN
41.4 ms ± 24.4 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
lvl1 0 1
lvl2 a b c d
count 3.0 3.000000 3.0 0.0
mean 11.0 13.333333 11.0 NaN
std 1.0 0.577350 1.0 NaN
min 10.0 13.000000 10.0 NaN
25% 10.5 13.000000 10.5 NaN
50% 11.0 13.000000 11.0 NaN
75% 11.5 13.500000 11.5 NaN
max 12.0 14.000000 12.0 NaN
lvl1 0 1
lvl2 a b c d
count 3.0 3.000000 3.0 0.0
mean 11.0 13.333333 11.0 NaN
std 1.0 0.577350 1.0 NaN
min 10.0 13.000000 10.0 NaN
30% 10.6 13.000000 10.6 NaN
50% 11.0 13.000000 11.0 NaN
70% 11.4 13.400000 11.4 NaN
max 12.0 14.000000 12.0 NaN
35.6 ms ± 432 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
lvl1 0 1
count 3.0 6.000000
mean 11.0 12.166667
std 1.0 1.471960
min 10.0 10.000000
25% 10.5 11.250000
50% 11.0 12.500000
75% 11.5 13.000000
max 12.0 14.000000
37.9 ms ± 123 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
In [46]:
Out[46]:
lvl1 lvl2
0 a 3
1 b 3
c 3
d 0
Name: count, dtype: int64
7.45 ms ± 215 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
lvl1 lvl2
0 a 3
1 b 3
c 3
d 0
Name: count, dtype: int64
49.6 µs ± 200 ns per loop (mean ± std. dev. of 7 runs, 10000 loops each)
lvl1
0 3
1 6
Name: count, dtype: int64
48.3 µs ± 83.7 ns per loop (mean ± std. dev. of 7 runs, 10000 loops each)
In [47]:
In [48]:
Out[48]:
10.0 1
11.0 1
12.0 1
Name: (0, a), dtype: int64
13.4 ms ± 584 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
10.0 1
11.0 1
12.0 1
Name: (0, a), dtype: int64
12.9 ms ± 353 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
lvl1 0 1
lvl2 a b c d
10.0 1 0 1 0
11.0 1 0 1 0
12.0 1 0 1 0
13.0 0 2 0 0
14.0 0 1 0 0
10.9 ms ± 23.5 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
lvl1 0 1
lvl2 a b c d
10.0 1 0 1 0
11.0 1 0 1 0
12.0 1 0 1 0
13.0 0 2 0 0
14.0 0 1 0 0
11.2 ms ± 121 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
lvl1 0 1
10.0 1 1
11.0 1 1
12.0 1 1
13.0 0 2
14.0 0 1
10.9 ms ± 451 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
In [49]:
Out[49]:
Start x
End z
Period 3 days 00:00:00
Count 3
Mean 11.0
Std 1.0
Min 10.0
Median 11.0
Max 12.0
Min Index x
Max Index z
Name: (0, a), dtype: object
29 ms ± 287 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
Start x
End z
Period 3 days 00:00:00
Count 3
Mean 11.0
Std 1.0
Min 10.0
Median 11.0
Max 12.0
Min Index x
Max Index z
Name: (0, a), dtype: object
46 ms ± 1.01 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)
Start x
End z
Period 3 days 00:00:00
Count 2.25
Mean 11.777778
Std 0.859117
Min 11.0
Median 11.666667
Max 12.666667
Name: agg_func_mean, dtype: object
/Users/olegpolakow/miniconda3/lib/python3.7/site-packages/ipykernel_launcher.py:7: UserWarning: Metric 'idx_min' returned multiple values despite having no aggregation function
import sys
/Users/olegpolakow/miniconda3/lib/python3.7/site-packages/ipykernel_launcher.py:7: UserWarning: Metric 'idx_max' returned multiple values despite having no aggregation function
import sys
/Users/olegpolakow/miniconda3/lib/python3.7/site-packages/ipykernel_launcher.py:7: UserWarning: Object has multiple columns. Aggregating using <function mean at 0x7feb1013b598>. Pass column to select a single column/group.
import sys
44.3 ms ± 343 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
Start x
End z
Period 3 days 00:00:00
Count 2.25
Value Counts: 10.0 0.5
Value Counts: 11.0 0.5
Value Counts: 12.0 0.5
Value Counts: 13.0 0.5
Value Counts: 14.0 0.25
Name: agg_func_mean, dtype: object
/Users/olegpolakow/miniconda3/lib/python3.7/site-packages/ipykernel_launcher.py:10: UserWarning: Object has multiple columns. Aggregating using <function mean at 0x7feb1013b598>. Pass column to select a single column/group.
# Remove the CWD from sys.path while we load stuff.
23.1 ms ± 475 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
In [50]:
Out[50]:
In [51]:
Out[51]:
In [11]:
Out[11]:
Records
In [52]:
Out[52]:
[(0, 0, 0, 10., 21.) (1, 1, 0, 11., 20.) (2, 2, 0, 12., 19.)]
MultiIndex([(0, 'a')],
names=['lvl1', 'lvl2'])
[(3, 0, 0, 13., 18.) (4, 1, 0, 14., 17.) (5, 2, 0, 13., 18.)]
MultiIndex([(1, 'b')],
names=['lvl1', 'lvl2'])
[(0, 0, 0, 10., 21.) (1, 1, 0, 11., 20.) (2, 2, 0, 12., 19.)
(0, 0, 1, 10., 21.) (1, 1, 1, 11., 20.) (2, 2, 1, 12., 19.)]
MultiIndex([(0, 'a'),
(0, 'a')],
names=['lvl1', 'lvl2'])
[(0, 0, 0, 10., 21.) (1, 1, 0, 11., 20.) (2, 2, 0, 12., 19.)
(3, 0, 1, 13., 18.) (4, 1, 1, 14., 17.) (5, 2, 1, 13., 18.)]
MultiIndex([(0, 'a'),
(1, 'b')],
names=['lvl1', 'lvl2'])
810 µs ± 9.11 µs per loop (mean ± std. dev. of 7 runs, 1000 loops each)
13.7 ms ± 259 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
In [53]:
Out[53]:
[(2, 2, 0, 12., 19.) (1, 1, 0, 11., 20.) (0, 0, 0, 10., 21.)]
MultiIndex([(0, 'a')],
names=['lvl1', 'lvl2'])
[(5, 2, 0, 13., 18.) (4, 1, 0, 14., 17.) (3, 0, 0, 13., 18.)]
MultiIndex([(1, 'b')],
names=['lvl1', 'lvl2'])
[(2, 2, 0, 12., 19.) (1, 1, 0, 11., 20.) (0, 0, 0, 10., 21.)
(2, 2, 1, 12., 19.) (1, 1, 1, 11., 20.) (0, 0, 1, 10., 21.)]
MultiIndex([(0, 'a'),
(0, 'a')],
names=['lvl1', 'lvl2'])
[(2, 2, 0, 12., 19.) (1, 1, 0, 11., 20.) (0, 0, 0, 10., 21.)
(5, 2, 1, 13., 18.) (4, 1, 1, 14., 17.) (3, 0, 1, 13., 18.)]
MultiIndex([(0, 'a'),
(1, 'b')],
names=['lvl1', 'lvl2'])
842 µs ± 5.42 µs per loop (mean ± std. dev. of 7 runs, 1000 loops each)
15.9 ms ± 678 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
In [54]:
Out[54]:
MultiIndex([(0, 'a')],
names=['lvl1', 'lvl2'])
1
1
Index([0], dtype='int64', name='lvl1')
MultiIndex([(1, 'b'),
(1, 'c'),
(1, 'd')],
names=['lvl1', 'lvl2'])
2
1
Index([1, 1, 1], dtype='int64', name='lvl1')
MultiIndex([(0, 'a')],
names=['lvl1', 'lvl2'])
2
2
Index([0], dtype='int64', name='lvl1')
MultiIndex([(0, 'a'),
(1, 'b'),
(1, 'c'),
(1, 'd')],
names=['lvl1', 'lvl2'])
2
2
Index([0, 1, 1, 1], dtype='int64', name='lvl1')
6.25 ms ± 70.1 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
13.9 ms ± 264 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
In [55]:
Out[55]:
Index(['x', 'y', 'z'], dtype='object')
MultiIndex([(0, 'a'),
(1, 'b'),
(1, 'c'),
(1, 'd')],
names=['lvl1', 'lvl2'])
2
None
Index(['x', 'y', 'z'], dtype='object')
MultiIndex([(0, 'a'),
(1, 'b'),
(1, 'c'),
(1, 'd')],
names=['lvl1', 'lvl2'])
2
Index([0, 1, 1, 1], dtype='int64', name='lvl1')
In [56]:
Out[56]:
[(0, 0, 0, 10., 21.) (1, 1, 0, 11., 20.) (2, 2, 0, 12., 19.)
(3, 0, 1, 13., 18.) (4, 1, 1, 14., 17.) (5, 2, 1, 13., 18.)
(6, 0, 2, 12., 19.) (7, 1, 2, 11., 20.) (8, 2, 2, 10., 21.)]
[(0, 0, 0, 10., 21.) (1, 1, 0, 11., 20.) (2, 2, 0, 12., 19.)
(3, 0, 1, 13., 18.) (4, 1, 1, 14., 17.) (5, 2, 1, 13., 18.)
(6, 0, 2, 12., 19.) (7, 1, 2, 11., 20.) (8, 2, 2, 10., 21.)]
3.54 µs ± 13.6 ns per loop (mean ± std. dev. of 7 runs, 100000 loops each)
In [57]:
Out[57]:
id idx col some_field1 some_field2
0 0 0 0 10.0 21.0
1 1 1 0 11.0 20.0
2 2 2 0 12.0 19.0
3 3 0 1 13.0 18.0
4 4 1 1 14.0 17.0
5 5 2 1 13.0 18.0
6 6 0 2 12.0 19.0
7 7 1 2 11.0 20.0
8 8 2 2 10.0 21.0
In [58]:
Out[58]:
True
1.06 ms ± 1.99 µs per loop (mean ± std. dev. of 7 runs, 1000 loops each)
False
8.89 µs ± 232 ns per loop (mean ± std. dev. of 7 runs, 100000 loops each)
True
1.56 ms ± 1.74 µs per loop (mean ± std. dev. of 7 runs, 1000 loops each)
False
8.41 µs ± 37.3 ns per loop (mean ± std. dev. of 7 runs, 100000 loops each)
In [59]:
Out[59]:
[(0, 0, 0, 10., 21.) (1, 1, 0, 11., 20.) (2, 2, 0, 12., 19.)
(3, 0, 1, 13., 18.) (4, 1, 1, 14., 17.) (5, 2, 1, 13., 18.)
(6, 0, 2, 12., 19.) (7, 1, 2, 11., 20.) (8, 2, 2, 10., 21.)]
1.3 ms ± 771 ns per loop (mean ± std. dev. of 7 runs, 1000 loops each)
[(2, 2, 0, 12., 19.) (1, 1, 0, 11., 20.) (0, 0, 0, 10., 21.)
(5, 2, 1, 13., 18.) (4, 1, 1, 14., 17.) (3, 0, 1, 13., 18.)
(8, 2, 2, 10., 21.) (7, 1, 2, 11., 20.) (6, 0, 2, 12., 19.)]
70.6 ms ± 1.59 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)
[(0, 0, 0, 10., 21.) (1, 1, 0, 11., 20.) (2, 2, 0, 12., 19.)
(3, 0, 1, 13., 18.) (4, 1, 1, 14., 17.) (5, 2, 1, 13., 18.)
(6, 0, 2, 12., 19.) (7, 1, 2, 11., 20.) (8, 2, 2, 10., 21.)]
1.83 ms ± 12.4 µs per loop (mean ± std. dev. of 7 runs, 1000 loops each)
[(0, 0, 0, 10., 21.) (1, 1, 0, 11., 20.) (2, 2, 0, 12., 19.)
(3, 0, 1, 13., 18.) (4, 1, 1, 14., 17.) (5, 2, 1, 13., 18.)
(6, 0, 2, 12., 19.) (7, 1, 2, 11., 20.) (8, 2, 2, 10., 21.)]
66 ms ± 1.53 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)
In [10]:
Out[10]:
[(2, 2, 0, 12., 19.) (3, 0, 1, 13., 18.) (4, 1, 1, 14., 17.)
(5, 2, 1, 13., 18.) (6, 0, 2, 12., 19.)]
10.4 ms ± 232 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
In [61]:
Out[61]:
lvl1 lvl2
0 a 153.0
1 b 146.0
c 153.0
d 0.0
Name: sum, dtype: float64
lvl1
0 153.0
1 299.0
Name: sum, dtype: float64
lvl1 lvl2
0 a 153.0
1 b 146.0
c 153.0
d 0.0
Name: sum, dtype: float64
3.25 ms ± 735 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
4.53 ms ± 278 µs per loop (mean ± std. dev. of 7 runs, 1000 loops each)
In [62]:
Out[62]:
[0 0 0 1 1 1 2 2 2]
[0 1 2 0 1 2 0 1 2]
[10. 11. 12. 13. 14. 13. 12. 11. 10.]
[21. 20. 19. 18. 17. 18. 19. 20. 21.]
lvl1 lvl2
0 a 33.0
1 b 40.0
c 33.0
d 0.0
Name: sum, dtype: float64
lvl1
0 33.0
1 73.0
Name: sum, dtype: float64
lvl1 lvl2
0 a 33.0
1 b 40.0
c 33.0
d 0.0
Name: sum, dtype: float64
293 µs ± 4.43 µs per loop (mean ± std. dev. of 7 runs, 1000 loops each)
In [63]:
Out[63]:
[52. 51. 50. 49. 48. 49. 50. 51. 52.]
lvl1
0 153.0
1 299.0
Name: sum, dtype: float64
lvl1 lvl2
0 a 153.0
1 b 146.0
c 153.0
d 0.0
Name: sum, dtype: float64
2.55 ms ± 544 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
In [64]:
Out[64]:
lvl1 lvl2
0 a 3
1 b 3
c 3
d 0
Name: count, dtype: int64
lvl1
0 3
1 6
Name: count, dtype: int64
lvl1 lvl2
0 a 3
1 b 3
c 3
d 0
Name: count, dtype: int64
49.5 µs ± 133 ns per loop (mean ± std. dev. of 7 runs, 10000 loops each)
48.5 µs ± 595 ns per loop (mean ± std. dev. of 7 runs, 10000 loops each)
In [11]:
Out[11]:
lvl1 lvl2
0 a 1
1 b 0
c 1
d 0
Name: count, dtype: int64
lvl1
0 1
1 1
Name: count, dtype: int64
lvl1 lvl2
0 a 1
1 b 0
c 1
d 0
Name: count, dtype: int64
In [12]:
Out[12]:
id idx col some_field1 some_field2
0 0 0 0 10.0 21.0
1 8 2 2 10.0 21.0
In [67]:
Out[67]:
id idx col some_field1 some_field2
0 0 0 0 10.0 21.0
[10.]
10.0
1
In [68]:
Out[68]:
Empty DataFrame
Columns: [id, idx, col, some_field1, some_field2]
Index: []
[]
nan
0
In [69]:
Out[69]:
id idx col some_field1 some_field2
0 8 2 0 10.0 21.0
[10.]
10.0
1
In [70]:
Out[70]:
Empty DataFrame
Columns: [id, idx, col, some_field1, some_field2]
Index: []
[]
nan
0
In [12]:
Out[12]:
Start x
End z
Period 3 days 00:00:00
Count 3
Name: (0, a), dtype: object
12.7 ms ± 680 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
Start x
End z
Period 3 days 00:00:00
Count 3
Name: (0, a), dtype: object
2.18 ms ± 42.2 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
Start x
End z
Period 3 days 00:00:00
Count 2.25
Name: agg_func_mean, dtype: object
2.1 ms ± 1.67 µs per loop (mean ± std. dev. of 7 runs, 1000 loops each)
/Users/olegpolakow/miniconda3/lib/python3.7/site-packages/ipykernel_launcher.py:7: UserWarning:
Object has multiple columns. Aggregating using <function mean at 0x7fbd30c34598>. Pass column to select a single column/group.
In [13]:
Out[13]:
/Users/olegpolakow/miniconda3/lib/python3.7/site-packages/ipykernel_launcher.py:1: UserWarning:
No subplots to plot
Drawdowns
In [14]:
In [15]:
Out[15]:
(6,)
In [16]:
Out[16]:
(99845,)
In [74]:
Out[74]:
5.37 ms ± 57.5 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
In [75]:
Out[75]:
id col peak_idx start_idx valley_idx end_idx peak_val valley_val \
0 0 0 0 1 1 2 2.0 1.0
1 1 0 2 3 3 4 3.0 1.0
2 2 0 4 5 5 5 4.0 1.0
3 3 1 1 2 2 3 2.0 1.0
4 4 1 3 4 4 5 3.0 1.0
5 5 2 2 3 4 5 3.0 1.0
end_val status
0 2.0 1
1 3.0 1
2 1.0 0
3 2.0 1
4 3.0 1
5 2.0 0
a b c d
2020-01-01 2 1 1 1
2020-01-02 1 2 2 2
2020-01-03 3 1 3 3
2020-01-04 1 3 2 4
2020-01-05 4 1 1 5
2020-01-06 1 4 2 6
id col peak_idx start_idx valley_idx end_idx peak_val valley_val \
0 0 0 0 1 1 2 2.0 1.0
1 1 0 2 3 3 4 3.0 1.0
2 2 0 4 5 5 5 4.0 1.0
end_val status
0 2.0 1
1 3.0 1
2 1.0 0
2020-01-01 2
2020-01-02 1
2020-01-03 3
2020-01-04 1
2020-01-05 4
2020-01-06 1
Name: a, dtype: int64
1.21 ms ± 12.6 µs per loop (mean ± std. dev. of 7 runs, 1000 loops each)
3.81 ms ± 418 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
In [76]:
Out[76]:
Drawdown Id Column Peak Timestamp Start Timestamp Valley Timestamp \
0 0 a 2020-01-01 2020-01-02 2020-01-02
1 1 a 2020-01-03 2020-01-04 2020-01-04
2 2 a 2020-01-05 2020-01-06 2020-01-06
3 3 b 2020-01-02 2020-01-03 2020-01-03
4 4 b 2020-01-04 2020-01-05 2020-01-05
5 5 c 2020-01-03 2020-01-04 2020-01-05
End Timestamp Peak Value Valley Value End Value Status
0 2020-01-03 2.0 1.0 2.0 Recovered
1 2020-01-05 3.0 1.0 3.0 Recovered
2 2020-01-06 4.0 1.0 1.0 Active
3 2020-01-04 2.0 1.0 2.0 Recovered
4 2020-01-06 3.0 1.0 3.0 Recovered
5 2020-01-06 3.0 1.0 2.0 Active
In [77]:
Out[77]:
3
a 3
b 2
c 1
d 0
Name: count, dtype: int64
group
first 5
second 1
Name: count, dtype: int64
In [80]:
Out[80]:
2020-01-01 NaN
2020-01-02 NaN
2020-01-03 -0.500000
2020-01-04 NaN
2020-01-05 -0.666667
2020-01-06 -0.750000
Name: a, dtype: float64
a b c d
2020-01-01 NaN NaN NaN NaN
2020-01-02 NaN NaN NaN NaN
2020-01-03 -0.500000 NaN NaN NaN
2020-01-04 NaN -0.500000 NaN NaN
2020-01-05 -0.666667 NaN NaN NaN
2020-01-06 -0.750000 -0.666667 -0.666667 NaN
463 µs ± 21.5 µs per loop (mean ± std. dev. of 7 runs, 1000 loops each)
In [81]:
Out[81]:
-0.6388888888888888
a -0.638889
b -0.583333
c -0.666667
d NaN
Name: avg_drawdown, dtype: float64
1.12 ms ± 200 µs per loop (mean ± std. dev. of 7 runs, 1000 loops each)
group
first -0.616667
second -0.666667
Name: avg_drawdown, dtype: float64
4.65 ms ± 1.91 ms per loop (mean ± std. dev. of 7 runs, 100 loops each)
In [82]:
Out[82]:
-0.75
a -0.750000
b -0.666667
c -0.666667
d NaN
Name: max_drawdown, dtype: float64
1.15 ms ± 214 µs per loop (mean ± std. dev. of 7 runs, 1000 loops each)
group
first -0.750000
second -0.666667
Name: max_drawdown, dtype: float64
3.81 ms ± 652 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
In [83]:
Out[83]:
2020-01-01 NaN
2020-01-02 NaN
2020-01-03 1.0
2020-01-04 NaN
2020-01-05 2.0
2020-01-06 0.0
Name: a, dtype: float64
a b c d
2020-01-01 NaN NaN NaN NaN
2020-01-02 NaN NaN NaN NaN
2020-01-03 1.0 NaN NaN NaN
2020-01-04 NaN 1.0 NaN NaN
2020-01-05 2.0 NaN NaN NaN
2020-01-06 0.0 2.0 1.0 NaN
479 µs ± 45.9 µs per loop (mean ± std. dev. of 7 runs, 1000 loops each)
In [84]:
Out[84]:
1.0
a 1.0
b 1.5
c 1.0
d NaN
Name: avg_recovery_return, dtype: float64
1.01 ms ± 8.88 µs per loop (mean ± std. dev. of 7 runs, 1000 loops each)
group
first 1.2
second 1.0
Name: avg_recovery_return, dtype: float64
3.48 ms ± 80 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
In [85]:
Out[85]:
2.0
a 2.0
b 2.0
c 1.0
d NaN
Name: max_recovery_return, dtype: float64
1.06 ms ± 35.7 µs per loop (mean ± std. dev. of 7 runs, 1000 loops each)
group
first 2.0
second 1.0
Name: max_recovery_return, dtype: float64
3.72 ms ± 302 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
In [86]:
Out[86]:
2020-01-01 NaN
2020-01-02 NaN
2020-01-03 1.0
2020-01-04 NaN
2020-01-05 1.0
2020-01-06 1.0
Name: a, dtype: float64
a b c d
2020-01-01 NaN NaN NaN NaN
2020-01-02 NaN NaN NaN NaN
2020-01-03 1.0 NaN NaN NaN
2020-01-04 NaN 1.0 NaN NaN
2020-01-05 1.0 NaN NaN NaN
2020-01-06 1.0 1.0 3.0 NaN
483 µs ± 6.53 µs per loop (mean ± std. dev. of 7 runs, 1000 loops each)
In [87]:
Out[87]:
1 days 00:00:00
a 1 days
b 1 days
c 3 days
d NaT
Name: avg_duration, dtype: timedelta64[ns]
/Users/olegpolakow/Documents/SourceTree/vectorbt/vectorbt/base/array_wrapper.py:661: UserWarning:
Couldn't parse the frequency of index. Pass it as `freq` or define it globally under `settings.array_wrapper`.
905 µs ± 3.32 µs per loop (mean ± std. dev. of 7 runs, 1000 loops each)
group
first 1 days
second 3 days
Name: avg_duration, dtype: timedelta64[ns]
3.34 ms ± 35.3 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
In [88]:
Out[88]:
1 days 00:00:00
a 1 days
b 1 days
c 3 days
d NaT
Name: max_duration, dtype: timedelta64[ns]
/Users/olegpolakow/Documents/SourceTree/vectorbt/vectorbt/base/array_wrapper.py:661: UserWarning:
Couldn't parse the frequency of index. Pass it as `freq` or define it globally under `settings.array_wrapper`.
992 µs ± 72.6 µs per loop (mean ± std. dev. of 7 runs, 1000 loops each)
group
first 1 days
second 3 days
Name: max_duration, dtype: timedelta64[ns]
3.35 ms ± 18.6 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
In [89]:
Out[89]:
0.5
a 0.500000
b 0.333333
c 0.500000
d NaN
Name: coverage, dtype: float64
13.8 ms ± 181 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
group
first 0.416667
second 0.250000
Name: coverage, dtype: float64
16.8 ms ± 164 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
In [90]:
Out[90]:
2020-01-01 NaN
2020-01-02 NaN
2020-01-03 1.0
2020-01-04 NaN
2020-01-05 1.0
2020-01-06 1.0
Name: a, dtype: float64
a b c d
2020-01-01 NaN NaN NaN NaN
2020-01-02 NaN NaN NaN NaN
2020-01-03 1.0 NaN NaN NaN
2020-01-04 NaN 1.0 NaN NaN
2020-01-05 1.0 NaN NaN NaN
2020-01-06 1.0 1.0 2.0 NaN
518 µs ± 30.9 µs per loop (mean ± std. dev. of 7 runs, 1000 loops each)
In [91]:
Out[91]:
2020-01-01 NaN
2020-01-02 NaN
2020-01-03 1.0
2020-01-04 NaN
2020-01-05 1.0
2020-01-06 0.0
Name: a, dtype: float64
a b c d
2020-01-01 NaN NaN NaN NaN
2020-01-02 NaN NaN NaN NaN
2020-01-03 1.0 NaN NaN NaN
2020-01-04 NaN 1.0 NaN NaN
2020-01-05 1.0 NaN NaN NaN
2020-01-06 0.0 1.0 1.0 NaN
479 µs ± 17.5 µs per loop (mean ± std. dev. of 7 runs, 1000 loops each)
In [92]:
Out[92]:
2020-01-01 NaN
2020-01-02 NaN
2020-01-03 1.0
2020-01-04 NaN
2020-01-05 1.0
2020-01-06 0.0
Name: a, dtype: float64
a b c d
2020-01-01 NaN NaN NaN NaN
2020-01-02 NaN NaN NaN NaN
2020-01-03 1.0 NaN NaN NaN
2020-01-04 NaN 1.0 NaN NaN
2020-01-05 1.0 NaN NaN NaN
2020-01-06 0.0 1.0 0.5 NaN
699 µs ± 43.2 µs per loop (mean ± std. dev. of 7 runs, 1000 loops each)
In [17]:
Out[17]:
Drawdowns(**Config({
"wrapper": "<vectorbt.base.array_wrapper.ArrayWrapper object at 0x7fa004833748> of shape (6, 4)",
"records_arr": "<numpy.ndarray object at 0x7fa021f50870> of shape (2,)",
"col_mapper": null,
"ts": "<pandas.core.frame.DataFrame object at 0x7f9ff803f898> of shape (6, 4)",
"freq": "1 days"
}))
id col peak_idx start_idx valley_idx end_idx peak_val valley_val \
0 2 0 4 5 5 5 4.0 1.0
end_val status
0 1.0 0
id col peak_idx start_idx valley_idx end_idx peak_val valley_val \
0 2 0 4 5 5 5 4.0 1.0
end_val status
0 1.0 0
id col peak_idx start_idx valley_idx end_idx peak_val valley_val \
0 2 0 4 5 5 5 4.0 1.0
1 5 2 2 3 4 5 3.0 1.0
end_val status
0 1.0 0
1 2.0 0
707 µs ± 42.7 µs per loop (mean ± std. dev. of 7 runs, 1000 loops each)
In [18]:
Out[18]:
Drawdowns(**Config({
"wrapper": "<vectorbt.base.array_wrapper.ArrayWrapper object at 0x7fa004833748> of shape (6, 4)",
"records_arr": "<numpy.ndarray object at 0x7fa021f4bad8> of shape (4,)",
"col_mapper": null,
"ts": "<pandas.core.frame.DataFrame object at 0x7f9ff803f898> of shape (6, 4)",
"freq": "1 days"
}))
id col peak_idx start_idx valley_idx end_idx peak_val valley_val \
0 0 0 0 1 1 2 2.0 1.0
1 1 0 2 3 3 4 3.0 1.0
end_val status
0 2.0 1
1 3.0 1
id col peak_idx start_idx valley_idx end_idx peak_val valley_val \
0 0 0 0 1 1 2 2.0 1.0
1 1 0 2 3 3 4 3.0 1.0
end_val status
0 2.0 1
1 3.0 1
id col peak_idx start_idx valley_idx end_idx peak_val valley_val \
0 0 0 0 1 1 2 2.0 1.0
1 1 0 2 3 3 4 3.0 1.0
2 3 1 1 2 2 3 2.0 1.0
3 4 1 3 4 4 5 3.0 1.0
end_val status
0 2.0 1
1 3.0 1
2 2.0 1
3 3.0 1
2.26 ms ± 266 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
In [95]:
Out[95]:
-0.75
a -0.750000
b NaN
c -0.333333
d NaN
Name: active_drawdown, dtype: float64
2.03 ms ± 48.2 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
In [96]:
Out[96]:
1 days 00:00:00
a 1 days
b NaT
c 3 days
d NaT
Name: active_duration, dtype: timedelta64[ns]
/Users/olegpolakow/Documents/SourceTree/vectorbt/vectorbt/base/array_wrapper.py:661: UserWarning:
Couldn't parse the frequency of index. Pass it as `freq` or define it globally under `settings.array_wrapper`.
1.41 ms ± 65.6 µs per loop (mean ± std. dev. of 7 runs, 1000 loops each)
In [97]:
Out[97]:
0.0
a 0.0
b NaN
c 1.0
d NaN
Name: active_recovery_return, dtype: float64
1.43 ms ± 43.3 µs per loop (mean ± std. dev. of 7 runs, 1000 loops each)
In [98]:
Out[98]:
0 days 00:00:00
a 0 days
b NaT
c 1 days
d NaT
Name: active_recovery_duration, dtype: timedelta64[ns]
1.41 ms ± 53.7 µs per loop (mean ± std. dev. of 7 runs, 1000 loops each)
In [19]:
Out[19]:
Start 2020-01-01 00:00:00
End 2020-01-06 00:00:00
Period 6 days 00:00:00
Coverage [%] 50.0
Total Records 3
Total Recovered Drawdowns 2
Total Active Drawdowns 1
Active Drawdown [%] 75.0
Active Duration 1 days 00:00:00
Active Recovery [%] 0.0
Active Recovery Return [%] 0.0
Active Recovery Duration 0 days 00:00:00
Max Drawdown [%] 66.666667
Avg Drawdown [%] 58.333333
Max Drawdown Duration 1 days 00:00:00
Avg Drawdown Duration 1 days 00:00:00
Max Recovery Return [%] 200.0
Avg Recovery Return [%] 150.0
Max Recovery Duration 1 days 00:00:00
Avg Recovery Duration 1 days 00:00:00
Avg Recovery Duration Ratio 1.0
Name: a, dtype: object
21.6 ms ± 115 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
Start 2020-01-01 00:00:00
End 2020-01-06 00:00:00
Period 6 days 00:00:00
Coverage [%] 50.0
Total Records 3
Total Recovered Drawdowns 2
Total Active Drawdowns 1
Active Drawdown [%] 75.0
Active Duration 1 days 00:00:00
Active Recovery [%] 0.0
Active Recovery Return [%] 0.0
Active Recovery Duration 0 days 00:00:00
Max Drawdown [%] 66.666667
Avg Drawdown [%] 58.333333
Max Drawdown Duration 1 days 00:00:00
Avg Drawdown Duration 1 days 00:00:00
Max Recovery Return [%] 200.0
Avg Recovery Return [%] 150.0
Max Recovery Duration 1 days 00:00:00
Avg Recovery Duration 1 days 00:00:00
Avg Recovery Duration Ratio 1.0
Name: a, dtype: object
44.9 ms ± 2.18 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)
Start 2020-01-01 00:00:00
End 2020-01-06 00:00:00
Period 6 days 00:00:00
Coverage [%] 44.444444
Total Records 1.5
Total Recovered Drawdowns 1.0
Total Active Drawdowns 0.5
Active Drawdown [%] 54.166667
Active Duration 2 days 00:00:00
Active Recovery [%] 25.0
Active Recovery Return [%] 50.0
Active Recovery Duration 0 days 12:00:00
Max Drawdown [%] 66.666667
Avg Drawdown [%] 58.333333
Max Drawdown Duration 1 days 00:00:00
Avg Drawdown Duration 1 days 00:00:00
Max Recovery Return [%] 200.0
Avg Recovery Return [%] 150.0
Max Recovery Duration 1 days 00:00:00
Avg Recovery Duration 1 days 00:00:00
Avg Recovery Duration Ratio 1.0
Name: agg_func_mean, dtype: object
/Users/olegpolakow/miniconda3/lib/python3.7/site-packages/ipykernel_launcher.py:7: UserWarning: Object has multiple columns. Aggregating using <function mean at 0x7fa020856598>. Pass column to select a single column/group.
import sys
45.2 ms ± 757 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
In [12]:
Out[12]:
In [13]:
Out[13]:
In [19]:
Out[19]:
Orders
In [20]:
Out[20]:
a b c d
2020-01-01 1 1 1 1
2020-01-02 2 2 2 2
2020-01-03 3 3 3 3
2020-01-04 4 4 4 4
2020-01-05 5 5 5 5
2020-01-06 6 6 6 6
2020-01-07 7 7 7 7
2020-01-08 8 8 8 8
In [21]:
Out[21]:
(21,)
In [22]:
Out[22]:
(1000000,)
In [106]:
Out[106]:
id col idx size price fees side
0 0 0 0 1.0 1.0 0.010 0
1 1 0 1 0.1 2.0 0.002 0
2 2 0 2 1.0 3.0 0.030 1
3 3 0 3 0.1 4.0 0.004 1
4 4 0 5 1.0 6.0 0.060 0
5 5 0 6 1.0 7.0 0.070 1
6 6 0 7 2.0 8.0 0.160 0
7 7 1 0 1.0 1.0 0.010 1
8 8 1 1 0.1 2.0 0.002 1
9 9 1 2 1.0 3.0 0.030 0
10 10 1 3 0.1 4.0 0.004 0
11 11 1 5 1.0 6.0 0.060 1
12 12 1 6 1.0 7.0 0.070 0
13 13 1 7 2.0 8.0 0.160 1
14 14 2 0 1.0 1.0 0.010 0
15 15 2 1 0.1 2.0 0.002 0
16 16 2 2 1.0 3.0 0.030 1
17 17 2 3 0.1 4.0 0.004 1
18 18 2 5 1.0 6.0 0.060 0
19 19 2 6 2.0 7.0 0.140 1
20 20 2 7 2.0 8.0 0.160 0
a b c d
2020-01-01 1 1 1 1
2020-01-02 2 2 2 2
2020-01-03 3 3 3 3
2020-01-04 4 4 4 4
2020-01-05 5 5 5 5
2020-01-06 6 6 6 6
2020-01-07 7 7 7 7
2020-01-08 8 8 8 8
id col idx size price fees side
0 0 0 0 1.0 1.0 0.010 0
1 1 0 1 0.1 2.0 0.002 0
2 2 0 2 1.0 3.0 0.030 1
3 3 0 3 0.1 4.0 0.004 1
4 4 0 5 1.0 6.0 0.060 0
5 5 0 6 1.0 7.0 0.070 1
6 6 0 7 2.0 8.0 0.160 0
2020-01-01 1
2020-01-02 2
2020-01-03 3
2020-01-04 4
2020-01-05 5
2020-01-06 6
2020-01-07 7
2020-01-08 8
Name: a, dtype: int64
1.06 ms ± 17.4 µs per loop (mean ± std. dev. of 7 runs, 1000 loops each)
12.5 ms ± 2.47 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)
13.5 ms ± 1.52 ms per loop (mean ± std. dev. of 7 runs, 100 loops each)
13 ms ± 4.86 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)
In [107]:
Out[107]:
Order Id Column Timestamp Size Price Fees Side
0 0 a 2020-01-01 1.0 1.0 0.010 Buy
1 1 a 2020-01-02 0.1 2.0 0.002 Buy
2 2 a 2020-01-03 1.0 3.0 0.030 Sell
3 3 a 2020-01-04 0.1 4.0 0.004 Sell
4 4 a 2020-01-06 1.0 6.0 0.060 Buy
5 5 a 2020-01-07 1.0 7.0 0.070 Sell
6 6 a 2020-01-08 2.0 8.0 0.160 Buy
7 7 b 2020-01-01 1.0 1.0 0.010 Sell
8 8 b 2020-01-02 0.1 2.0 0.002 Sell
9 9 b 2020-01-03 1.0 3.0 0.030 Buy
10 10 b 2020-01-04 0.1 4.0 0.004 Buy
11 11 b 2020-01-06 1.0 6.0 0.060 Sell
12 12 b 2020-01-07 1.0 7.0 0.070 Buy
13 13 b 2020-01-08 2.0 8.0 0.160 Sell
14 14 c 2020-01-01 1.0 1.0 0.010 Buy
15 15 c 2020-01-02 0.1 2.0 0.002 Buy
16 16 c 2020-01-03 1.0 3.0 0.030 Sell
17 17 c 2020-01-04 0.1 4.0 0.004 Sell
18 18 c 2020-01-06 1.0 6.0 0.060 Buy
19 19 c 2020-01-07 2.0 7.0 0.140 Sell
20 20 c 2020-01-08 2.0 8.0 0.160 Buy
In [23]:
Out[23]:
Orders(**Config({
"wrapper": "<vectorbt.base.array_wrapper.ArrayWrapper object at 0x7f9f78606d30> of shape (8, 4)",
"records_arr": "<numpy.ndarray object at 0x7f9f780709d0> of shape (11,)",
"col_mapper": null,
"close": "<pandas.core.frame.DataFrame object at 0x7f9f782a4390> of shape (8, 4)"
}))
id col idx size price fees side
0 0 0 0 1.0 1.0 0.010 0
1 1 0 1 0.1 2.0 0.002 0
2 4 0 5 1.0 6.0 0.060 0
3 6 0 7 2.0 8.0 0.160 0
id col idx size price fees side
0 0 0 0 1.0 1.0 0.010 0
1 1 0 1 0.1 2.0 0.002 0
2 4 0 5 1.0 6.0 0.060 0
3 6 0 7 2.0 8.0 0.160 0
id col idx size price fees side
0 0 0 0 1.0 1.0 0.010 0
1 1 0 1 0.1 2.0 0.002 0
2 4 0 5 1.0 6.0 0.060 0
3 6 0 7 2.0 8.0 0.160 0
4 9 1 2 1.0 3.0 0.030 0
5 10 1 3 0.1 4.0 0.004 0
6 12 1 6 1.0 7.0 0.070 0
7 14 2 0 1.0 1.0 0.010 0
8 15 2 1 0.1 2.0 0.002 0
9 18 2 5 1.0 6.0 0.060 0
10 20 2 7 2.0 8.0 0.160 0
11.1 ms ± 387 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
In [24]:
Out[24]:
Orders(**Config({
"wrapper": "<vectorbt.base.array_wrapper.ArrayWrapper object at 0x7f9f78606d30> of shape (8, 4)",
"records_arr": "<numpy.ndarray object at 0x7fa0223c06b8> of shape (10,)",
"col_mapper": null,
"close": "<pandas.core.frame.DataFrame object at 0x7f9f782a4390> of shape (8, 4)"
}))
id col idx size price fees side
0 2 0 2 1.0 3.0 0.030 1
1 3 0 3 0.1 4.0 0.004 1
2 5 0 6 1.0 7.0 0.070 1
id col idx size price fees side
0 2 0 2 1.0 3.0 0.030 1
1 3 0 3 0.1 4.0 0.004 1
2 5 0 6 1.0 7.0 0.070 1
id col idx size price fees side
0 2 0 2 1.0 3.0 0.030 1
1 3 0 3 0.1 4.0 0.004 1
2 5 0 6 1.0 7.0 0.070 1
3 7 1 0 1.0 1.0 0.010 1
4 8 1 1 0.1 2.0 0.002 1
5 11 1 5 1.0 6.0 0.060 1
6 13 1 7 2.0 8.0 0.160 1
7 16 2 2 1.0 3.0 0.030 1
8 17 2 3 0.1 4.0 0.004 1
9 19 2 6 2.0 7.0 0.140 1
10.7 ms ± 117 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
In [25]:
Out[25]:
Start 2020-01-01 00:00:00
End 2020-01-08 00:00:00
Period 8 days 00:00:00
Total Records 7
Total Buy Orders 4
Total Sell Orders 3
Min Size 0.1
Max Size 2.0
Avg Size 0.885714
Avg Buy Size 1.025
Avg Sell Size 0.7
Avg Buy Price 4.25
Avg Sell Price 4.666667
Total Fees 0.336
Min Fees 0.002
Max Fees 0.16
Avg Fees 0.048
Avg Buy Fees 0.058
Avg Sell Fees 0.034667
Name: a, dtype: object
14 ms ± 171 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
Start 2020-01-01 00:00:00
End 2020-01-08 00:00:00
Period 8 days 00:00:00
Total Records 7
Total Buy Orders 4
Total Sell Orders 3
Min Size 0.1
Max Size 2.0
Avg Size 0.885714
Avg Buy Size 1.025
Avg Sell Size 0.7
Avg Buy Price 4.25
Avg Sell Price 4.666667
Total Fees 0.336
Min Fees 0.002
Max Fees 0.16
Avg Fees 0.048
Avg Buy Fees 0.058
Avg Sell Fees 0.034667
Name: a, dtype: object
85.6 ms ± 3.18 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)
Start 2020-01-01 00:00:00
End 2020-01-08 00:00:00
Period 8 days 00:00:00
Total Records 5.25
Total Buy Orders 2.75
Total Sell Orders 2.5
Min Size 0.1
Max Size 2.0
Avg Size 0.933333
Avg Buy Size 0.916667
Avg Sell Size 0.919444
Avg Buy Price 4.388889
Avg Sell Price 4.527778
Total Fees 0.2695
Min Fees 0.002
Max Fees 0.16
Avg Fees 0.051333
Avg Buy Fees 0.050222
Avg Sell Fees 0.050222
Name: agg_func_mean, dtype: object
/Users/olegpolakow/miniconda3/lib/python3.7/site-packages/ipykernel_launcher.py:7: UserWarning: Object has multiple columns. Aggregating using <function mean at 0x7fa020856598>. Pass column to select a single column/group.
import sys
84.7 ms ± 2.13 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)
In [27]:
Out[27]:
In [28]:
Out[28]:
In [23]:
Out[23]:
Trades
In [24]:
Out[24]:
(13,)
In [25]:
Out[25]:
(1000,)
In [22]:
Out[22]:
4.55 ms ± 46.1 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
In [32]:
Out[32]:
id col size entry_idx entry_price entry_fees exit_idx exit_price \
0 0 0 1.0 0 1.090909 0.010909 2 3.0
1 1 0 0.1 0 1.090909 0.001091 3 4.0
2 2 0 1.0 5 6.000000 0.060000 6 7.0
3 3 0 2.0 7 8.000000 0.160000 7 8.0
4 4 1 1.0 0 1.090909 0.010909 2 3.0
5 5 1 0.1 0 1.090909 0.001091 3 4.0
6 6 1 1.0 5 6.000000 0.060000 6 7.0
7 7 1 2.0 7 8.000000 0.160000 7 8.0
8 8 2 1.0 0 1.090909 0.010909 2 3.0
9 9 2 0.1 0 1.090909 0.001091 3 4.0
10 10 2 1.0 5 6.000000 0.060000 6 7.0
11 11 2 1.0 6 7.000000 0.070000 7 8.0
12 12 2 1.0 7 8.000000 0.080000 7 8.0
exit_fees pnl return direction status position_id
0 0.030 1.868182 1.712500 0 1 0
1 0.004 0.285818 2.620000 0 1 0
2 0.070 0.870000 0.145000 0 1 1
3 0.000 -0.160000 -0.010000 0 0 2
4 0.030 -1.950000 -1.787500 1 1 3
5 0.004 -0.296000 -2.713333 1 1 3
6 0.070 -1.130000 -0.188333 1 1 4
7 0.000 -0.160000 -0.010000 1 0 5
8 0.030 1.868182 1.712500 0 1 6
9 0.004 0.285818 2.620000 0 1 6
10 0.070 0.870000 0.145000 0 1 7
11 0.080 -1.150000 -0.164286 1 1 8
12 0.000 -0.080000 -0.010000 0 0 9
a b c d
2020-01-01 1 1 1 1
2020-01-02 2 2 2 2
2020-01-03 3 3 3 3
2020-01-04 4 4 4 4
2020-01-05 5 5 5 5
2020-01-06 6 6 6 6
2020-01-07 7 7 7 7
2020-01-08 8 8 8 8
id col size entry_idx entry_price entry_fees exit_idx exit_price \
0 0 0 1.0 0 1.090909 0.010909 2 3.0
1 1 0 0.1 0 1.090909 0.001091 3 4.0
2 2 0 1.0 5 6.000000 0.060000 6 7.0
3 3 0 2.0 7 8.000000 0.160000 7 8.0
exit_fees pnl return direction status position_id
0 0.030 1.868182 1.7125 0 1 0
1 0.004 0.285818 2.6200 0 1 0
2 0.070 0.870000 0.1450 0 1 1
3 0.000 -0.160000 -0.0100 0 0 2
2020-01-01 1
2020-01-02 2
2020-01-03 3
2020-01-04 4
2020-01-05 5
2020-01-06 6
2020-01-07 7
2020-01-08 8
Name: a, dtype: int64
1.56 ms ± 288 µs per loop (mean ± std. dev. of 7 runs, 1000 loops each)
3.37 ms ± 567 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
2.84 ms ± 218 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
3.65 ms ± 225 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
In [33]:
Out[33]:
Trade Id Column Size Entry Timestamp Avg Entry Price Entry Fees \
0 0 a 1.0 2020-01-01 1.090909 0.010909
1 1 a 0.1 2020-01-01 1.090909 0.001091
2 2 a 1.0 2020-01-06 6.000000 0.060000
3 3 a 2.0 2020-01-08 8.000000 0.160000
4 4 b 1.0 2020-01-01 1.090909 0.010909
5 5 b 0.1 2020-01-01 1.090909 0.001091
6 6 b 1.0 2020-01-06 6.000000 0.060000
7 7 b 2.0 2020-01-08 8.000000 0.160000
8 8 c 1.0 2020-01-01 1.090909 0.010909
9 9 c 0.1 2020-01-01 1.090909 0.001091
10 10 c 1.0 2020-01-06 6.000000 0.060000
11 11 c 1.0 2020-01-07 7.000000 0.070000
12 12 c 1.0 2020-01-08 8.000000 0.080000
Exit Timestamp Avg Exit Price Exit Fees PnL Return Direction \
0 2020-01-03 3.0 0.030 1.868182 1.712500 Long
1 2020-01-04 4.0 0.004 0.285818 2.620000 Long
2 2020-01-07 7.0 0.070 0.870000 0.145000 Long
3 2020-01-08 8.0 0.000 -0.160000 -0.010000 Long
4 2020-01-03 3.0 0.030 -1.950000 -1.787500 Short
5 2020-01-04 4.0 0.004 -0.296000 -2.713333 Short
6 2020-01-07 7.0 0.070 -1.130000 -0.188333 Short
7 2020-01-08 8.0 0.000 -0.160000 -0.010000 Short
8 2020-01-03 3.0 0.030 1.868182 1.712500 Long
9 2020-01-04 4.0 0.004 0.285818 2.620000 Long
10 2020-01-07 7.0 0.070 0.870000 0.145000 Long
11 2020-01-08 8.0 0.080 -1.150000 -0.164286 Short
12 2020-01-08 8.0 0.000 -0.080000 -0.010000 Long
Status Position Id
0 Closed 0
1 Closed 0
2 Closed 1
3 Open 2
4 Closed 3
5 Closed 3
6 Closed 4
7 Open 5
8 Closed 6
9 Closed 6
10 Closed 7
11 Closed 8
12 Open 9
In [34]:
Out[34]:
4
a 4
b 4
c 5
d 0
Name: count, dtype: int64
49.4 µs ± 504 ns per loop (mean ± std. dev. of 7 runs, 10000 loops each)
group
first 8
second 5
Name: count, dtype: int64
49 µs ± 303 ns per loop (mean ± std. dev. of 7 runs, 10000 loops each)
In [35]:
Out[35]:
Trades(**Config({
"wrapper": "<vectorbt.base.array_wrapper.ArrayWrapper object at 0x7f9f78606d30> of shape (8, 4)",
"records_arr": "<numpy.ndarray object at 0x7f9f7cf155b0> of shape (6,)",
"col_mapper": null,
"ts": null,
"close": "<pandas.core.frame.DataFrame object at 0x7f9f782a4390> of shape (8, 4)"
}))
id col size entry_idx entry_price entry_fees exit_idx exit_price \
0 0 0 1.0 0 1.090909 0.010909 2 3.0
1 1 0 0.1 0 1.090909 0.001091 3 4.0
2 2 0 1.0 5 6.000000 0.060000 6 7.0
exit_fees pnl return direction status position_id
0 0.030 1.868182 1.7125 0 1 0
1 0.004 0.285818 2.6200 0 1 0
2 0.070 0.870000 0.1450 0 1 1
id col size entry_idx entry_price entry_fees exit_idx exit_price \
0 0 0 1.0 0 1.090909 0.010909 2 3.0
1 1 0 0.1 0 1.090909 0.001091 3 4.0
2 2 0 1.0 5 6.000000 0.060000 6 7.0
exit_fees pnl return direction status position_id
0 0.030 1.868182 1.7125 0 1 0
1 0.004 0.285818 2.6200 0 1 0
2 0.070 0.870000 0.1450 0 1 1
id col size entry_idx entry_price entry_fees exit_idx exit_price \
0 0 0 1.0 0 1.090909 0.010909 2 3.0
1 1 0 0.1 0 1.090909 0.001091 3 4.0
2 2 0 1.0 5 6.000000 0.060000 6 7.0
3 8 2 1.0 0 1.090909 0.010909 2 3.0
4 9 2 0.1 0 1.090909 0.001091 3 4.0
5 10 2 1.0 5 6.000000 0.060000 6 7.0
exit_fees pnl return direction status position_id
0 0.030 1.868182 1.7125 0 1 0
1 0.004 0.285818 2.6200 0 1 0
2 0.070 0.870000 0.1450 0 1 1
3 0.030 1.868182 1.7125 0 1 6
4 0.004 0.285818 2.6200 0 1 6
5 0.070 0.870000 0.1450 0 1 7
756 µs ± 11 µs per loop (mean ± std. dev. of 7 runs, 1000 loops each)
In [36]:
Out[36]:
Trades(**Config({
"wrapper": "<vectorbt.base.array_wrapper.ArrayWrapper object at 0x7f9f78606d30> of shape (8, 4)",
"records_arr": "<numpy.ndarray object at 0x7fa007ca3a28> of shape (7,)",
"col_mapper": null,
"ts": null,
"close": "<pandas.core.frame.DataFrame object at 0x7f9f782a4390> of shape (8, 4)"
}))
id col size entry_idx entry_price entry_fees exit_idx exit_price \
0 3 0 2.0 7 8.0 0.16 7 8.0
exit_fees pnl return direction status position_id
0 0.0 -0.16 -0.01 0 0 2
id col size entry_idx entry_price entry_fees exit_idx exit_price \
0 3 0 2.0 7 8.0 0.16 7 8.0
exit_fees pnl return direction status position_id
0 0.0 -0.16 -0.01 0 0 2
id col size entry_idx entry_price entry_fees exit_idx exit_price \
0 3 0 2.0 7 8.000000 0.160000 7 8.0
1 4 1 1.0 0 1.090909 0.010909 2 3.0
2 5 1 0.1 0 1.090909 0.001091 3 4.0
3 6 1 1.0 5 6.000000 0.060000 6 7.0
4 7 1 2.0 7 8.000000 0.160000 7 8.0
5 11 2 1.0 6 7.000000 0.070000 7 8.0
6 12 2 1.0 7 8.000000 0.080000 7 8.0
exit_fees pnl return direction status position_id
0 0.000 -0.160 -0.010000 0 0 2
1 0.030 -1.950 -1.787500 1 1 3
2 0.004 -0.296 -2.713333 1 1 3
3 0.070 -1.130 -0.188333 1 1 4
4 0.000 -0.160 -0.010000 1 0 5
5 0.080 -1.150 -0.164286 1 1 8
6 0.000 -0.080 -0.010000 0 0 9
751 µs ± 8.53 µs per loop (mean ± std. dev. of 7 runs, 1000 loops each)
In [39]:
Out[39]:
0 1
1 2
2 3
3 0
Name: a, dtype: int64
a b c d
0 1.0 0.0 1.0 NaN
1 2.0 0.0 2.0 NaN
2 3.0 0.0 3.0 NaN
3 0.0 0.0 0.0 NaN
4 NaN NaN 0.0 NaN
565 µs ± 7.54 µs per loop (mean ± std. dev. of 7 runs, 1000 loops each)
In [41]:
Out[41]:
0 0
1 0
2 0
3 1
Name: a, dtype: int64
a b c d
0 0.0 1.0 0.0 NaN
1 0.0 2.0 0.0 NaN
2 0.0 3.0 0.0 NaN
3 1.0 4.0 1.0 NaN
4 NaN NaN 2.0 NaN
551 µs ± 5.51 µs per loop (mean ± std. dev. of 7 runs, 1000 loops each)
In [37]:
Out[37]:
0.75
a 0.75
b 0.00
c 0.60
d NaN
Name: win_rate, dtype: float64
/Users/olegpolakow/Documents/SourceTree/vectorbt/vectorbt/portfolio/trades.py:530: RuntimeWarning:
invalid value encountered in true_divide
951 µs ± 3.9 µs per loop (mean ± std. dev. of 7 runs, 1000 loops each)
group
first 0.375
second 0.600
Name: win_rate, dtype: float64
5.47 ms ± 21.8 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
In [42]:
Out[42]:
18.9
a 18.900000
b 0.000000
c 2.458537
d NaN
Name: profit_factor, dtype: float64
/Users/olegpolakow/Documents/SourceTree/vectorbt/vectorbt/portfolio/trades.py:544: RuntimeWarning:
invalid value encountered in true_divide
/Users/olegpolakow/Documents/SourceTree/vectorbt/vectorbt/portfolio/trades.py:544: RuntimeWarning:
divide by zero encountered in true_divide
2.65 ms ± 136 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
group
first 0.818182
second 2.458537
Name: profit_factor, dtype: float64
2.57 ms ± 65.5 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
In [43]:
Out[43]:
0.716
a 0.7160
b -0.8840
c 0.3588
d NaN
Name: expectancy, dtype: float64
/Users/olegpolakow/Documents/SourceTree/vectorbt/vectorbt/portfolio/trades.py:530: RuntimeWarning:
invalid value encountered in true_divide
3.55 ms ± 34.4 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
group
first -0.0840
second 0.3588
Name: expectancy, dtype: float64
3.54 ms ± 37.8 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
In [44]:
Out[44]:
1.634155521947584
a 1.634156
b -2.130073
c 0.716604
d NaN
Name: sqn, dtype: float64
1.32 ms ± 11.9 µs per loop (mean ± std. dev. of 7 runs, 1000 loops each)
group
first -0.204047
second 0.716604
Name: sqn, dtype: float64
924 µs ± 9.78 µs per loop (mean ± std. dev. of 7 runs, 1000 loops each)
In [45]:
Out[45]:
Trades(**Config({
"wrapper": "<vectorbt.base.array_wrapper.ArrayWrapper object at 0x7f9f78606d30> of shape (8, 4)",
"records_arr": "<numpy.ndarray object at 0x7f9f68734be0> of shape (8,)",
"col_mapper": null,
"ts": null,
"close": "<pandas.core.frame.DataFrame object at 0x7f9f782a4390> of shape (8, 4)"
}))
id col size entry_idx entry_price entry_fees exit_idx exit_price \
0 0 0 1.0 0 1.090909 0.010909 2 3.0
1 1 0 0.1 0 1.090909 0.001091 3 4.0
2 2 0 1.0 5 6.000000 0.060000 6 7.0
3 3 0 2.0 7 8.000000 0.160000 7 8.0
exit_fees pnl return direction status position_id
0 0.030 1.868182 1.7125 0 1 0
1 0.004 0.285818 2.6200 0 1 0
2 0.070 0.870000 0.1450 0 1 1
3 0.000 -0.160000 -0.0100 0 0 2
id col size entry_idx entry_price entry_fees exit_idx exit_price \
0 0 0 1.0 0 1.090909 0.010909 2 3.0
1 1 0 0.1 0 1.090909 0.001091 3 4.0
2 2 0 1.0 5 6.000000 0.060000 6 7.0
3 3 0 2.0 7 8.000000 0.160000 7 8.0
exit_fees pnl return direction status position_id
0 0.030 1.868182 1.7125 0 1 0
1 0.004 0.285818 2.6200 0 1 0
2 0.070 0.870000 0.1450 0 1 1
3 0.000 -0.160000 -0.0100 0 0 2
id col size entry_idx entry_price entry_fees exit_idx exit_price \
0 0 0 1.0 0 1.090909 0.010909 2 3.0
1 1 0 0.1 0 1.090909 0.001091 3 4.0
2 2 0 1.0 5 6.000000 0.060000 6 7.0
3 3 0 2.0 7 8.000000 0.160000 7 8.0
4 8 2 1.0 0 1.090909 0.010909 2 3.0
5 9 2 0.1 0 1.090909 0.001091 3 4.0
6 10 2 1.0 5 6.000000 0.060000 6 7.0
7 12 2 1.0 7 8.000000 0.080000 7 8.0
exit_fees pnl return direction status position_id
0 0.030 1.868182 1.7125 0 1 0
1 0.004 0.285818 2.6200 0 1 0
2 0.070 0.870000 0.1450 0 1 1
3 0.000 -0.160000 -0.0100 0 0 2
4 0.030 1.868182 1.7125 0 1 6
5 0.004 0.285818 2.6200 0 1 6
6 0.070 0.870000 0.1450 0 1 7
7 0.000 -0.080000 -0.0100 0 0 9
764 µs ± 12.7 µs per loop (mean ± std. dev. of 7 runs, 1000 loops each)
In [46]:
Out[46]:
Trades(**Config({
"wrapper": "<vectorbt.base.array_wrapper.ArrayWrapper object at 0x7f9f78606d30> of shape (8, 4)",
"records_arr": "<numpy.ndarray object at 0x7f9f7a2d8608> of shape (5,)",
"col_mapper": null,
"ts": null,
"close": "<pandas.core.frame.DataFrame object at 0x7f9f782a4390> of shape (8, 4)"
}))
Empty DataFrame
Columns: [id, col, size, entry_idx, entry_price, entry_fees, exit_idx, exit_price, exit_fees, pnl, return, direction, status, position_id]
Index: []
Empty DataFrame
Columns: [id, col, size, entry_idx, entry_price, entry_fees, exit_idx, exit_price, exit_fees, pnl, return, direction, status, position_id]
Index: []
id col size entry_idx entry_price entry_fees exit_idx exit_price \
0 4 1 1.0 0 1.090909 0.010909 2 3.0
1 5 1 0.1 0 1.090909 0.001091 3 4.0
2 6 1 1.0 5 6.000000 0.060000 6 7.0
3 7 1 2.0 7 8.000000 0.160000 7 8.0
4 11 2 1.0 6 7.000000 0.070000 7 8.0
exit_fees pnl return direction status position_id
0 0.030 -1.950 -1.787500 1 1 3
1 0.004 -0.296 -2.713333 1 1 3
2 0.070 -1.130 -0.188333 1 1 4
3 0.000 -0.160 -0.010000 1 0 5
4 0.080 -1.150 -0.164286 1 1 8
762 µs ± 9.5 µs per loop (mean ± std. dev. of 7 runs, 1000 loops each)
In [47]:
Out[47]:
Trades(**Config({
"wrapper": "<vectorbt.base.array_wrapper.ArrayWrapper object at 0x7f9f78606d30> of shape (8, 4)",
"records_arr": "<numpy.ndarray object at 0x7f9f7cd48978> of shape (3,)",
"col_mapper": null,
"ts": null,
"close": "<pandas.core.frame.DataFrame object at 0x7f9f782a4390> of shape (8, 4)"
}))
id col size entry_idx entry_price entry_fees exit_idx exit_price \
0 3 0 2.0 7 8.0 0.16 7 8.0
exit_fees pnl return direction status position_id
0 0.0 -0.16 -0.01 0 0 2
id col size entry_idx entry_price entry_fees exit_idx exit_price \
0 3 0 2.0 7 8.0 0.16 7 8.0
exit_fees pnl return direction status position_id
0 0.0 -0.16 -0.01 0 0 2
id col size entry_idx entry_price entry_fees exit_idx exit_price \
0 3 0 2.0 7 8.0 0.16 7 8.0
1 7 1 2.0 7 8.0 0.16 7 8.0
2 12 2 1.0 7 8.0 0.08 7 8.0
exit_fees pnl return direction status position_id
0 0.0 -0.16 -0.01 0 0 2
1 0.0 -0.16 -0.01 1 0 5
2 0.0 -0.08 -0.01 0 0 9
777 µs ± 10.3 µs per loop (mean ± std. dev. of 7 runs, 1000 loops each)
In [48]:
Out[48]:
Trades(**Config({
"wrapper": "<vectorbt.base.array_wrapper.ArrayWrapper object at 0x7f9f78606d30> of shape (8, 4)",
"records_arr": "<numpy.ndarray object at 0x7f9f7a4e3608> of shape (10,)",
"col_mapper": null,
"ts": null,
"close": "<pandas.core.frame.DataFrame object at 0x7f9f782a4390> of shape (8, 4)"
}))
id col size entry_idx entry_price entry_fees exit_idx exit_price \
0 0 0 1.0 0 1.090909 0.010909 2 3.0
1 1 0 0.1 0 1.090909 0.001091 3 4.0
2 2 0 1.0 5 6.000000 0.060000 6 7.0
exit_fees pnl return direction status position_id
0 0.030 1.868182 1.7125 0 1 0
1 0.004 0.285818 2.6200 0 1 0
2 0.070 0.870000 0.1450 0 1 1
id col size entry_idx entry_price entry_fees exit_idx exit_price \
0 0 0 1.0 0 1.090909 0.010909 2 3.0
1 1 0 0.1 0 1.090909 0.001091 3 4.0
2 2 0 1.0 5 6.000000 0.060000 6 7.0
exit_fees pnl return direction status position_id
0 0.030 1.868182 1.7125 0 1 0
1 0.004 0.285818 2.6200 0 1 0
2 0.070 0.870000 0.1450 0 1 1
id col size entry_idx entry_price entry_fees exit_idx exit_price \
0 0 0 1.0 0 1.090909 0.010909 2 3.0
1 1 0 0.1 0 1.090909 0.001091 3 4.0
2 2 0 1.0 5 6.000000 0.060000 6 7.0
3 4 1 1.0 0 1.090909 0.010909 2 3.0
4 5 1 0.1 0 1.090909 0.001091 3 4.0
5 6 1 1.0 5 6.000000 0.060000 6 7.0
6 8 2 1.0 0 1.090909 0.010909 2 3.0
7 9 2 0.1 0 1.090909 0.001091 3 4.0
8 10 2 1.0 5 6.000000 0.060000 6 7.0
9 11 2 1.0 6 7.000000 0.070000 7 8.0
exit_fees pnl return direction status position_id
0 0.030 1.868182 1.712500 0 1 0
1 0.004 0.285818 2.620000 0 1 0
2 0.070 0.870000 0.145000 0 1 1
3 0.030 -1.950000 -1.787500 1 1 3
4 0.004 -0.296000 -2.713333 1 1 3
5 0.070 -1.130000 -0.188333 1 1 4
6 0.030 1.868182 1.712500 0 1 6
7 0.004 0.285818 2.620000 0 1 6
8 0.070 0.870000 0.145000 0 1 7
9 0.080 -1.150000 -0.164286 1 1 8
759 µs ± 11.4 µs per loop (mean ± std. dev. of 7 runs, 1000 loops each)
In [49]:
Out[49]:
/Users/olegpolakow/Documents/SourceTree/vectorbt/vectorbt/portfolio/trades.py:544: RuntimeWarning:
divide by zero encountered in true_divide
Start 2020-01-01 00:00:00
End 2020-01-08 00:00:00
Period 8 days 00:00:00
First Trade Start 2020-01-01 00:00:00
Last Trade End 2020-01-08 00:00:00
Coverage 5 days 00:00:00
Overlap Coverage 2 days 00:00:00
Total Records 4
Total Long Trades 4
Total Short Trades 0
Total Closed Trades 3
Total Open Trades 1
Open Trade PnL -0.16
Win Rate [%] 100.0
Max Win Streak 3
Max Loss Streak 0
Best Trade [%] 262.0
Worst Trade [%] 14.5
Avg Winning Trade [%] 149.25
Avg Losing Trade [%] NaN
Avg Winning Trade Duration 2 days 00:00:00
Avg Losing Trade Duration NaT
Profit Factor inf
Expectancy 1.008
SQN 2.181955
Name: a, dtype: object
/Users/olegpolakow/Documents/SourceTree/vectorbt/vectorbt/portfolio/trades.py:530: RuntimeWarning:
invalid value encountered in true_divide
/Users/olegpolakow/Documents/SourceTree/vectorbt/vectorbt/portfolio/trades.py:544: RuntimeWarning:
invalid value encountered in true_divide
/Users/olegpolakow/Documents/SourceTree/vectorbt/vectorbt/portfolio/trades.py:530: RuntimeWarning:
invalid value encountered in true_divide
/Users/olegpolakow/Documents/SourceTree/vectorbt/vectorbt/portfolio/trades.py:544: RuntimeWarning:
invalid value encountered in true_divide
42.1 ms ± 2.02 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)
Start 2020-01-01 00:00:00
End 2020-01-08 00:00:00
Period 8 days 00:00:00
First Trade Start 2020-01-01 00:00:00
Last Trade End 2020-01-08 00:00:00
Coverage 5 days 00:00:00
Overlap Coverage 2 days 00:00:00
Total Records 4
Total Long Trades 4
Total Short Trades 0
Total Closed Trades 3
Total Open Trades 1
Open Trade PnL -0.16
Win Rate [%] 100.0
Max Win Streak 3
Max Loss Streak 0
Best Trade [%] 262.0
Worst Trade [%] 14.5
Avg Winning Trade [%] 149.25
Avg Losing Trade [%] NaN
Avg Winning Trade Duration 2 days 00:00:00
Avg Losing Trade Duration NaT
Profit Factor inf
Expectancy 1.008
SQN 2.181955
Name: a, dtype: object
/Users/olegpolakow/Documents/SourceTree/vectorbt/vectorbt/portfolio/trades.py:530: RuntimeWarning:
invalid value encountered in true_divide
/Users/olegpolakow/Documents/SourceTree/vectorbt/vectorbt/portfolio/trades.py:544: RuntimeWarning:
divide by zero encountered in true_divide
/Users/olegpolakow/Documents/SourceTree/vectorbt/vectorbt/portfolio/trades.py:544: RuntimeWarning:
invalid value encountered in true_divide
44.4 ms ± 1.17 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)
Start 2020-01-01 00:00:00
End 2020-01-08 00:00:00
Period 8 days 00:00:00
First Trade Start 2020-01-01 00:00:00
Last Trade End 2020-01-08 00:00:00
Coverage 5 days 08:00:00
Overlap Coverage 2 days 00:00:00
Total Records 3.25
Total Long Trades 2.0
Total Short Trades 1.25
Total Closed Trades 2.5
Total Open Trades 0.75
Open Trade PnL -0.1
Win Rate [%] 58.333333
Max Win Streak 2.0
Max Loss Streak 1.333333
Best Trade [%] 168.388889
Worst Trade [%] -91.087302
Avg Winning Trade [%] 149.25
Avg Losing Trade [%] -86.367063
Avg Winning Trade Duration 2 days 00:00:00
Avg Losing Trade Duration 1 days 12:00:00
Profit Factor inf
Expectancy 0.117056
SQN 0.189316
Name: agg_func_mean, dtype: object
/Users/olegpolakow/Documents/SourceTree/vectorbt/vectorbt/portfolio/trades.py:530: RuntimeWarning:
invalid value encountered in true_divide
/Users/olegpolakow/Documents/SourceTree/vectorbt/vectorbt/portfolio/trades.py:544: RuntimeWarning:
divide by zero encountered in true_divide
/Users/olegpolakow/Documents/SourceTree/vectorbt/vectorbt/portfolio/trades.py:544: RuntimeWarning:
invalid value encountered in true_divide
/Users/olegpolakow/miniconda3/lib/python3.7/site-packages/ipykernel_launcher.py:7: UserWarning:
Object has multiple columns. Aggregating using <function mean at 0x7fa020856598>. Pass column to select a single column/group.
44.9 ms ± 1.26 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)
In [27]:
Out[27]:
In [28]:
Out[28]:
In [29]:
Out[29]:
Positions
In [ ]:
(10,)
In [31]:
Out[31]:
(1000,)
In [31]:
Out[31]:
724 µs ± 12.6 µs per loop (mean ± std. dev. of 7 runs, 1000 loops each)
In [55]:
Out[55]:
id col size entry_idx entry_price entry_fees exit_idx exit_price \
0 0 0 1.1 0 1.090909 0.012 3 3.090909
1 1 0 1.0 5 6.000000 0.060 6 7.000000
2 2 0 2.0 7 8.000000 0.160 7 8.000000
3 3 1 1.1 0 1.090909 0.012 3 3.090909
4 4 1 1.0 5 6.000000 0.060 6 7.000000
5 5 1 2.0 7 8.000000 0.160 7 8.000000
6 6 2 1.1 0 1.090909 0.012 3 3.090909
7 7 2 1.0 5 6.000000 0.060 6 7.000000
8 8 2 1.0 6 7.000000 0.070 7 8.000000
9 9 2 1.0 7 8.000000 0.080 7 8.000000
exit_fees pnl return direction status
0 0.034 2.154 1.795000 0 1
1 0.070 0.870 0.145000 0 1
2 0.000 -0.160 -0.010000 0 0
3 0.034 -2.246 -1.871667 1 1
4 0.070 -1.130 -0.188333 1 1
5 0.000 -0.160 -0.010000 1 0
6 0.034 2.154 1.795000 0 1
7 0.070 0.870 0.145000 0 1
8 0.080 -1.150 -0.164286 1 1
9 0.000 -0.080 -0.010000 0 0
a b c d
2020-01-01 1 1 1 1
2020-01-02 2 2 2 2
2020-01-03 3 3 3 3
2020-01-04 4 4 4 4
2020-01-05 5 5 5 5
2020-01-06 6 6 6 6
2020-01-07 7 7 7 7
2020-01-08 8 8 8 8
id col size entry_idx entry_price entry_fees exit_idx exit_price \
0 0 0 1.1 0 1.090909 0.012 3 3.090909
1 1 0 1.0 5 6.000000 0.060 6 7.000000
2 2 0 2.0 7 8.000000 0.160 7 8.000000
exit_fees pnl return direction status
0 0.034 2.154 1.795 0 1
1 0.070 0.870 0.145 0 1
2 0.000 -0.160 -0.010 0 0
2020-01-01 1
2020-01-02 2
2020-01-03 3
2020-01-04 4
2020-01-05 5
2020-01-06 6
2020-01-07 7
2020-01-08 8
Name: a, dtype: int64
1.4 ms ± 43.5 µs per loop (mean ± std. dev. of 7 runs, 1000 loops each)
3.06 ms ± 757 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
2.52 ms ± 53.5 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
3.22 ms ± 89.3 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
In [ ]: