Compare commits
611 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8897164794 | ||
|
|
a66f279852 | ||
|
|
6575b57146 | ||
|
|
3fa700e450 | ||
|
|
7735917c83 | ||
|
|
67489eef57 | ||
|
|
241306275a | ||
|
|
773bd53525 | ||
|
|
0854ab82da | ||
|
|
2c0390fde3 | ||
|
|
32fcd94abc | ||
|
|
090ffebd03 | ||
|
|
914d0810af | ||
|
|
10902f95dd | ||
|
|
2e67b9ad4f | ||
|
|
7adf27aa61 | ||
|
|
7ea0f60905 | ||
|
|
d9c71e3d34 | ||
|
|
b040518d52 | ||
|
|
725737610a | ||
|
|
37ccee4937 | ||
|
|
0ab0abd1ca | ||
|
|
c565f4cfd0 | ||
|
|
f804b8f0ca | ||
|
|
ef1cf8e4df | ||
|
|
661356e33e | ||
|
|
5842f50b03 | ||
|
|
0f80591f51 | ||
|
|
0622f43a0f | ||
|
|
8f0224feb6 | ||
|
|
781897984e | ||
|
|
340b40c6ce | ||
|
|
58ce899b5d | ||
|
|
ead8335c84 | ||
|
|
84ee81b35b | ||
|
|
03be232f31 | ||
|
|
e568162bff | ||
|
|
e395892b8e | ||
|
|
3483fee766 | ||
|
|
6cba915950 | ||
|
|
046df38be8 | ||
|
|
c7e96b837d | ||
|
|
2f23c89307 | ||
|
|
67d19d88d7 | ||
|
|
b4401db512 | ||
|
|
bc646c974a | ||
|
|
857a950e23 | ||
|
|
888752fa0a | ||
|
|
14427129c7 | ||
|
|
683bfe007a | ||
|
|
263a9099ed | ||
|
|
a78004a1e6 | ||
|
|
9acd30c355 | ||
|
|
441ba1a7b5 | ||
|
|
52b788d9de | ||
|
|
16fdf61903 | ||
|
|
59990573c2 | ||
|
|
acb787e8f6 | ||
|
|
6260b2f7e0 | ||
|
|
95739b8a58 | ||
|
|
c81f5d7d1a | ||
|
|
4961844f82 | ||
|
|
afca923cd9 | ||
|
|
a31436bc6d | ||
|
|
ebaa355bf1 | ||
|
|
46639fc4ec | ||
|
|
2052a86351 | ||
|
|
7a5ff8054b | ||
|
|
a3d6e24741 | ||
|
|
6c5b577b46 | ||
|
|
f4bab98b00 | ||
|
|
733be65148 | ||
|
|
2c26e9fc26 | ||
|
|
2faf921731 | ||
|
|
89f3968eef | ||
|
|
9c7d633b41 | ||
|
|
cfba82e17a | ||
|
|
6811b93d6a | ||
|
|
6916636e8e | ||
|
|
0a4c19527b | ||
|
|
f807d62b18 | ||
|
|
f5c5c5a3b0 | ||
|
|
553bd3993a | ||
|
|
e74bfeb7f9 | ||
|
|
9ab9fe5f2b | ||
|
|
93e7e3edb4 | ||
|
|
49fe020b84 | ||
|
|
6c95372d27 | ||
|
|
cfd46cf63f | ||
|
|
ff1638f653 | ||
|
|
0dff60442e | ||
|
|
d8d6deb675 | ||
|
|
81b2d45440 | ||
|
|
fda4859b5a | ||
|
|
9fa2630dc8 | ||
|
|
b27e9e67dd | ||
|
|
afa7cce46a | ||
|
|
e9c15b2806 | ||
|
|
8ee7a190c6 | ||
|
|
ec3b7a8e6a | ||
|
|
58b422976a | ||
|
|
ee0cf7b3d3 | ||
|
|
ebda5dba93 | ||
|
|
89110aa9f6 | ||
|
|
6f94d765fc | ||
|
|
fd940463b5 | ||
|
|
3f8fd6ac3d | ||
|
|
758c1704b5 | ||
|
|
0e5b6ce91e | ||
|
|
ccf32d3b4f | ||
|
|
0026cca422 | ||
|
|
633833e3c7 | ||
|
|
be64cdffa0 | ||
|
|
9670a6684f | ||
|
|
8447137a3f | ||
|
|
e75bbf9615 | ||
|
|
68af7ec15d | ||
|
|
f08ac5bcce | ||
|
|
ff2d749d61 | ||
|
|
4cc1dec80b | ||
|
|
75993cd021 | ||
|
|
f7ce35ae82 | ||
|
|
36404a6187 | ||
|
|
496f210116 | ||
|
|
b25d53ed6d | ||
|
|
ee7be1a233 | ||
|
|
5644520545 | ||
|
|
5b465216f9 | ||
|
|
d82d70dacf | ||
|
|
23afff13fc | ||
|
|
d7b4fb002f | ||
|
|
85fe39e31b | ||
|
|
690eb7fc9f | ||
|
|
e44f8cd498 | ||
|
|
ceb52c1b9b | ||
|
|
dea1d2eac3 | ||
|
|
f448ab7372 | ||
|
|
fd9c29c87c | ||
|
|
0b62fefb10 | ||
|
|
e13214135a | ||
|
|
c2fdfb235a | ||
|
|
50f8633e90 | ||
|
|
a3ad12e7e0 | ||
|
|
db25a3402e | ||
|
|
06f0da69c3 | ||
|
|
838232e696 | ||
|
|
e13f8c10a7 | ||
|
|
4c3e79b441 | ||
|
|
cffd20236c | ||
|
|
3f04b6c90a | ||
|
|
852c9cd856 | ||
|
|
37237206dd | ||
|
|
58979872c1 | ||
|
|
4c4a34007d | ||
|
|
a7265c8a41 | ||
|
|
db96e9e8e4 | ||
|
|
cc79cab3dc | ||
|
|
69dfdcefc5 | ||
|
|
f29bcbc9ae | ||
|
|
5ba7f611dd | ||
|
|
101d382594 | ||
|
|
3ef41ee2c9 | ||
|
|
4e71203b4c | ||
|
|
84b991b577 | ||
|
|
9f378a1a6d | ||
|
|
8df6c77ca8 | ||
|
|
eac9fa0d69 | ||
|
|
435a82b4db | ||
|
|
2b7b26d512 | ||
|
|
a64f70888d | ||
|
|
ad1f1c629c | ||
|
|
0d6d2f7c46 | ||
|
|
0282954b57 | ||
|
|
2372153eec | ||
|
|
480790e3f3 | ||
|
|
014389a880 | ||
|
|
d703cc6660 | ||
|
|
12be29fcfb | ||
|
|
546afd2a61 | ||
|
|
9f5f93c5a6 | ||
|
|
9df9f32827 | ||
|
|
7008d17714 | ||
|
|
734a99392e | ||
|
|
3d763cf98d | ||
|
|
d639c13d08 | ||
|
|
e63217a953 | ||
|
|
910b50b787 | ||
|
|
f0781413e0 | ||
|
|
233a357d9d | ||
|
|
96fcc032b9 | ||
|
|
1f23813cf5 | ||
|
|
c2e9c16569 | ||
|
|
2e9cc39c89 | ||
|
|
ed551458f5 | ||
|
|
4bfd93770c | ||
|
|
09f0239101 | ||
|
|
7c62e410b9 | ||
|
|
c69275a5fe | ||
|
|
bc4458d293 | ||
|
|
75ccf0199b | ||
|
|
1c82eb6313 | ||
|
|
45cc12a5c0 | ||
|
|
7bca81c4a8 | ||
|
|
2ca4c0573e | ||
|
|
c1e3b79010 | ||
|
|
d1e927cfce | ||
|
|
3826b1d86a | ||
|
|
b991dc8ada | ||
|
|
5729be4661 | ||
|
|
4dcd41b690 | ||
|
|
4602a9d222 | ||
|
|
e2de840aed | ||
|
|
93d58d5cdf | ||
|
|
d611105413 | ||
|
|
3f53f6ec77 | ||
|
|
dbcb464268 | ||
|
|
26a00a2adb | ||
|
|
a75e132bed | ||
|
|
890fcd114e | ||
|
|
f3d734c4fe | ||
|
|
dbdf014a4c | ||
|
|
0d70244d7b | ||
|
|
e72362b14d | ||
|
|
52365ed766 | ||
|
|
592118b323 | ||
|
|
cd01b769a6 | ||
|
|
9e349259b2 | ||
|
|
b1ce8f0045 | ||
|
|
9e31261116 | ||
|
|
e70d783c93 | ||
|
|
11ddf6abc2 | ||
|
|
515606dc35 | ||
|
|
61376cd5cc | ||
|
|
1fc0c37388 | ||
|
|
bfa0e26605 | ||
|
|
85bcb9ef43 | ||
|
|
abaa73ebce | ||
|
|
d9bdbab810 | ||
|
|
ba931a26c3 | ||
|
|
1d6a5472b0 | ||
|
|
c9c892510a | ||
|
|
666f810dd9 | ||
|
|
4363801ec9 | ||
|
|
29ab1d6acd | ||
|
|
5d732a877a | ||
|
|
2edac83d4f | ||
|
|
791a40596a | ||
|
|
54e58c6302 | ||
|
|
eb8043e7c6 | ||
|
|
7dad4deb5a | ||
|
|
88947a96b9 | ||
|
|
9f322e150b | ||
|
|
201ea1ce74 | ||
|
|
d2d1ca5c9e | ||
|
|
5f27689c53 | ||
|
|
dec831f361 | ||
|
|
7942f7d6dc | ||
|
|
359c7a7c8e | ||
|
|
053c9a20c4 | ||
|
|
4e13189787 | ||
|
|
25c4a879f6 | ||
|
|
db3f567ebf | ||
|
|
abf0e70a20 | ||
|
|
33d850ae34 | ||
|
|
07f6cd494d | ||
|
|
77a240ff25 | ||
|
|
e5a81ef285 | ||
|
|
818108b944 | ||
|
|
cc38a6410f | ||
|
|
55b21cd714 | ||
|
|
25618ae5bc | ||
|
|
515408b167 | ||
|
|
0df082cc68 | ||
|
|
cf8c5b854a | ||
|
|
e4ff27a738 | ||
|
|
a087d7e766 | ||
|
|
065dbf3959 | ||
|
|
1be7c9e141 | ||
|
|
1ad4afa54e | ||
|
|
5845f3cd81 | ||
|
|
d60b3323c3 | ||
|
|
4584feb7da | ||
|
|
b81bcf086e | ||
|
|
e34a7e0bfa | ||
|
|
e8cdb23cc0 | ||
|
|
ea7d73d95d | ||
|
|
7daa0929fa | ||
|
|
a55c387512 | ||
|
|
c130bb2de4 | ||
|
|
a1302d2bcd | ||
|
|
020cf013df | ||
|
|
fe46e5ec3b | ||
|
|
4c7bda8e34 | ||
|
|
13ace56eea | ||
|
|
ff185d0311 | ||
|
|
e90309678e | ||
|
|
ea41fedb30 | ||
|
|
1cb0405517 | ||
|
|
1e4ef83132 | ||
|
|
e416a54873 | ||
|
|
a9927fe111 | ||
|
|
cd7663ef97 | ||
|
|
e1cd63643f | ||
|
|
87487ec4c0 | ||
|
|
1974884c13 | ||
|
|
f963e43346 | ||
|
|
980cdeaa75 | ||
|
|
26ef02399f | ||
|
|
68ec0b72b2 | ||
|
|
a8d36497d4 | ||
|
|
73684e8e70 | ||
|
|
1e84ee59ce | ||
|
|
2cafba85f7 | ||
|
|
513ced31d7 | ||
|
|
581e87809b | ||
|
|
80498d5a1f | ||
|
|
f5dd7236fc | ||
|
|
69d2f5ae82 | ||
|
|
2d7e3297a6 | ||
|
|
57adac59ee | ||
|
|
d57f75ade2 | ||
|
|
bbb72b771c | ||
|
|
1b4613bc75 | ||
|
|
e994562d60 | ||
|
|
057f0b4d9e | ||
|
|
e6f2776fcf | ||
|
|
87a65451ea | ||
|
|
d00ef1c181 | ||
|
|
2e1f28d20d | ||
|
|
d68a41ba73 | ||
|
|
09ca345ae8 | ||
|
|
49265bd773 | ||
|
|
07003af6d5 | ||
|
|
5f8d76f6dd | ||
|
|
bcc53eff3b | ||
|
|
bca9ada795 | ||
|
|
5cba110b64 | ||
|
|
88b32b8352 | ||
|
|
fef5c8e9c8 | ||
|
|
867b7e8eb6 | ||
|
|
f9d84a6893 | ||
|
|
bd144e021d | ||
|
|
1a852d2d45 | ||
|
|
99dc63a08d | ||
|
|
f59fedc042 | ||
|
|
5596295774 | ||
|
|
fabf1191b7 | ||
|
|
9be02d7fa5 | ||
|
|
55c995e13f | ||
|
|
1d169a19ce | ||
|
|
956ffdfa9c | ||
|
|
0b6255c1fc | ||
|
|
6415de83cf | ||
|
|
e38f3f3aaf | ||
|
|
40e887a106 | ||
|
|
8149c291fc | ||
|
|
de9f9bf309 | ||
|
|
077b6e41d8 | ||
|
|
37d0c42149 | ||
|
|
ac1365cd7c | ||
|
|
c3530a6a7f | ||
|
|
7318c6fc7c | ||
|
|
2e0c3a03a5 | ||
|
|
824a754f81 | ||
|
|
1000669975 | ||
|
|
24a1fbba60 | ||
|
|
25d53fe6ff | ||
|
|
cad5f20a3d | ||
|
|
c5c56bf98e | ||
|
|
9b35411f45 | ||
|
|
2fe7f5b457 | ||
|
|
64f848a7b1 | ||
|
|
0937d08aa8 | ||
|
|
8330dd939e | ||
|
|
1ef66a1083 | ||
|
|
0fccf6017d | ||
|
|
41f9d1bd3a | ||
|
|
c35d6ee194 | ||
|
|
1cb8fcf2d9 | ||
|
|
58b7a9d22a | ||
|
|
2d4ca75670 | ||
|
|
cda769df74 | ||
|
|
5accfd6be3 | ||
|
|
265fd8b3b9 | ||
|
|
d633fed3ff | ||
|
|
f689826051 | ||
|
|
af7a2cfc85 | ||
|
|
6982f6713b | ||
|
|
50f887ca64 | ||
|
|
f08eda3bac | ||
|
|
8ad1016710 | ||
|
|
8937995ee4 | ||
|
|
ca7f7710e7 | ||
|
|
0b1b72e921 | ||
|
|
c44819617f | ||
|
|
3569a1f8d0 | ||
|
|
d71dd86ff5 | ||
|
|
96410b57a0 | ||
|
|
f17726b890 | ||
|
|
7ee297ab77 | ||
|
|
94fd3c8f64 | ||
|
|
50a8de5f67 | ||
|
|
af2043d7d3 | ||
|
|
57ce6958dd | ||
|
|
75d8e710d1 | ||
|
|
f75ea380e7 | ||
|
|
f3ea223f2a | ||
|
|
fb49f5da70 | ||
|
|
0cda5c7f0d | ||
|
|
9175b862d0 | ||
|
|
eca4f5b7f2 | ||
|
|
2bdddc94b4 | ||
|
|
12930c444b | ||
|
|
2ec979940c | ||
|
|
edd1aea8b0 | ||
|
|
be4a34c7e4 | ||
|
|
3b559a5f3f | ||
|
|
d4fd936772 | ||
|
|
a0328426d9 | ||
|
|
890a19c871 | ||
|
|
5359561b9d | ||
|
|
a8592e08b5 | ||
|
|
fcb4ce637d | ||
|
|
ec428c5f6c | ||
|
|
2a62f16833 | ||
|
|
f1c50e41a5 | ||
|
|
7445f7ec5a | ||
|
|
8febb9ac45 | ||
|
|
463044b64a | ||
|
|
9865ce9815 | ||
|
|
81d7774c80 | ||
|
|
22e04913a5 | ||
|
|
8e5893b708 | ||
|
|
99558928f0 | ||
|
|
a2efee8be9 | ||
|
|
a1d0b6cde2 | ||
|
|
8123e76e3c | ||
|
|
a28d1f2ffe | ||
|
|
f4314549c3 | ||
|
|
d416580456 | ||
|
|
93ce62536f | ||
|
|
312392d6ae | ||
|
|
01734e1f61 | ||
|
|
124063a2a4 | ||
|
|
b99da54d5a | ||
|
|
bc5d51806d | ||
|
|
f3ed5b1206 | ||
|
|
eb6c5d20f5 | ||
|
|
b70b5bd5fe | ||
|
|
5ac7d00e24 | ||
|
|
469d960f50 | ||
|
|
7eea365aa1 | ||
|
|
760071a2f7 | ||
|
|
fa1ef4f763 | ||
|
|
f7b012aa11 | ||
|
|
725ad73240 | ||
|
|
7bbf42f79b | ||
|
|
f2da037d42 | ||
|
|
5c5c527252 | ||
|
|
71d09a3567 | ||
|
|
085476a222 | ||
|
|
c78774b99a | ||
|
|
d5b2e4d8cc | ||
|
|
828d9238b8 | ||
|
|
f2100adb46 | ||
|
|
159fa5a182 | ||
|
|
8ef0a4977b | ||
|
|
ffdb615a4d | ||
|
|
8f57a8c8ff | ||
|
|
a831adc9c8 | ||
|
|
6b22254924 | ||
|
|
0e61415ce2 | ||
|
|
16c893deb6 | ||
|
|
33048149af | ||
|
|
0a2c05ab1e | ||
|
|
e16b27f089 | ||
|
|
0a9dc2c71c | ||
|
|
7c9aa858c2 | ||
|
|
8fb70b20d0 | ||
|
|
809faa24de | ||
|
|
ad5aa263c0 | ||
|
|
a1bb907e03 | ||
|
|
71540f5015 | ||
|
|
a0055a3695 | ||
|
|
0b285df496 | ||
|
|
4d37096b3f | ||
|
|
7c42ea795f | ||
|
|
f2f1d06237 | ||
|
|
86fd80a31a | ||
|
|
c556d16775 | ||
|
|
6351773a01 | ||
|
|
bf4b08e202 | ||
|
|
fa9ff399cc | ||
|
|
16c4259342 | ||
|
|
724d0b06a5 | ||
|
|
ba7fe05574 | ||
|
|
50437946e2 | ||
|
|
418970bb48 | ||
|
|
bef045a360 | ||
|
|
49bf436aa2 | ||
|
|
e29bb2c5e0 | ||
|
|
8fcc9f7d4e | ||
|
|
5209332074 | ||
|
|
adfad475cc | ||
|
|
21fcadf0f8 | ||
|
|
e893e67e9b | ||
|
|
3b588d04fb | ||
|
|
e81bcbb987 | ||
|
|
96e91b446d | ||
|
|
403f0348bd | ||
|
|
eeeb310438 | ||
|
|
271f0bb08e | ||
|
|
3a09c70851 | ||
|
|
f31251732e | ||
|
|
9baacdbdd6 | ||
|
|
363d469d6a | ||
|
|
c186addf94 | ||
|
|
17049dcd56 | ||
|
|
d88387ac67 | ||
|
|
74c3501ed3 | ||
|
|
a543af71dc | ||
|
|
9b332c2149 | ||
|
|
1e620e54fe | ||
|
|
7879795207 | ||
|
|
d2d366e3f9 | ||
|
|
5226b7a468 | ||
|
|
1947a58541 | ||
|
|
1bca3f6081 | ||
|
|
2b1136e446 | ||
|
|
86fcc40c3e | ||
|
|
9eb484625d | ||
|
|
85ca5be258 | ||
|
|
9a84a6bd17 | ||
|
|
a46acef9f8 | ||
|
|
69fa2fd689 | ||
|
|
2df58bbca3 | ||
|
|
050030bca8 | ||
|
|
7e40b4f1ab | ||
|
|
229d636628 | ||
|
|
034bf3d8ae | ||
|
|
31b32442c8 | ||
|
|
9a92933397 | ||
|
|
97959d560a | ||
|
|
0352a0b07c | ||
|
|
bd87ba6f14 | ||
|
|
ab601cbb08 | ||
|
|
72a1bd4c48 | ||
|
|
3bdde74096 | ||
|
|
ba626f18d2 | ||
|
|
12f6263d8b | ||
|
|
14db9caf90 | ||
|
|
dda950b6e4 | ||
|
|
9b3400e9d1 | ||
|
|
162d3cbca2 | ||
|
|
53c2a214a1 | ||
|
|
8136a73801 | ||
|
|
554a82527f | ||
|
|
8b312efd0c | ||
|
|
fcb33d8ba3 | ||
|
|
a7efcfe9d5 | ||
|
|
5a7a162d34 | ||
|
|
268285e2b3 | ||
|
|
db1f63bae7 | ||
|
|
99a949586c | ||
|
|
e0c90e8c04 | ||
|
|
12644f8b2a | ||
|
|
28f9db194e | ||
|
|
6c30157fab | ||
|
|
014ec7f626 | ||
|
|
2941210d20 | ||
|
|
6185a4c6a4 | ||
|
|
16a737ee26 | ||
|
|
ee35c75e62 | ||
|
|
0a0c012ae9 | ||
|
|
574eafd00d | ||
|
|
eff8b6f2fb | ||
|
|
5fd021996a | ||
|
|
ee1a6ef87b | ||
|
|
3d17e0e122 | ||
|
|
9229ddbef0 | ||
|
|
409f93a3aa | ||
|
|
25c635d846 | ||
|
|
1911cda7b1 | ||
|
|
a2b420cb0a | ||
|
|
cd1aad657d | ||
|
|
aae6d617fb | ||
|
|
621d1252b9 | ||
|
|
6392b5eed0 | ||
|
|
ba2d519910 | ||
|
|
c8446ae26e | ||
|
|
8a34d4a7a3 | ||
|
|
57f89620a1 | ||
|
|
47acbd66a2 | ||
|
|
56d36b97d5 | ||
|
|
a8b106ae3e | ||
|
|
8bd046a6b8 | ||
|
|
9e2b697792 | ||
|
|
5699fa48fd | ||
|
|
aa5ab68b47 | ||
|
|
f8b169aa51 | ||
|
|
b41df5b0f2 | ||
|
|
5432c7c6d8 | ||
|
|
8c33536498 | ||
|
|
f0d02feb13 | ||
|
|
0e0e6bd142 | ||
|
|
8424e85ade | ||
|
|
a159950117 | ||
|
|
4ca5cbca7e | ||
|
|
6b963c735c | ||
|
|
62373ede5b | ||
|
|
7975a44d1c |
@@ -1,33 +1,43 @@
|
||||
{
|
||||
"name": "Lean Development Container",
|
||||
|
||||
"workspaceMount": "source=${localWorkspaceFolder},target=/Lean,type=bind",
|
||||
"workspaceFolder": "/Lean",
|
||||
|
||||
// Use devcontainer Dockerfile that is based on Lean foundation image
|
||||
"build": { "dockerfile": "Dockerfile" },
|
||||
|
||||
// Set *default* container specific settings.json values on container create.
|
||||
"settings": {
|
||||
"terminal.integrated.profiles.linux": {
|
||||
"bash": {
|
||||
"path": "bash",
|
||||
"icon": "terminal-bash"
|
||||
"build": {
|
||||
"dockerfile": "Dockerfile"
|
||||
},
|
||||
//See https://containers.dev/implementors/json_reference/ for a comprehensive json schema used to define this file.
|
||||
"customizations": {
|
||||
"vscode": {
|
||||
// Add the IDs of extensions you want installed when the container is created.
|
||||
"extensions": [
|
||||
"ms-dotnettools.csdevkit",
|
||||
"ms-python.python",
|
||||
"eamodio.gitlens",
|
||||
"yzhang.markdown-all-in-one",
|
||||
"SonarSource.sonarlint-vscode"
|
||||
],
|
||||
// Set *default* vscode specific settings.json values on container create.
|
||||
"settings": {
|
||||
"terminal.integrated.profiles.linux": {
|
||||
"bash": {
|
||||
"path": "bash",
|
||||
"icon": "terminal-bash"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
// Add the IDs of extensions you want installed when the container is created.
|
||||
"extensions": ["ms-dotnettools.csharp", "ms-python.python", "ms-python.vscode-pylance", "formulahendry.dotnet-test-explorer", "eamodio.gitlens", "yzhang.markdown-all-in-one"],
|
||||
|
||||
//use the same network configuration as the host machine, ensuring no problems with firewalls, proxies etc.
|
||||
"runArgs": [
|
||||
"--network=host"
|
||||
],
|
||||
// Use 'forwardPorts' to make a list of ports inside the container available locally.
|
||||
// "forwardPorts": [],
|
||||
|
||||
// Uncomment the next line to run commands after the container is created - for example installing curl.
|
||||
"postCreateCommand": "dotnet nuget add source /Lean/LocalPackages;chmod u+x /Lean/.vscode/launch_research.sh;dos2unix /Lean/.vscode/launch_research.sh",
|
||||
|
||||
// Add mounts to docker container
|
||||
"mounts": [
|
||||
"mounts": [
|
||||
// Example data mount from local machine, must use target directory in Config.json
|
||||
// "source=C:/Users/XXXXXXXXXXXX/Lean/Data,target=/Data,type=bind,consistency=cached"
|
||||
]
|
||||
|
||||
@@ -1,4 +1,11 @@
|
||||
<!--- This template provides sections for bugs and features. Please delete any irrelevant sections before submitting -->
|
||||
---
|
||||
name: Bug report
|
||||
about: Create a report to help us improve
|
||||
title: ''
|
||||
labels: ''
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
#### Expected Behavior
|
||||
<!--- Required. Describe the behavior you expect to see for your case. -->
|
||||
@@ -24,4 +31,4 @@
|
||||
<!--- Required for Bugs, feature request can delete the line below. -->
|
||||
- [ ] I have provided detailed steps to reproduce the issue
|
||||
|
||||
<!--- Template inspired by https://github.com/stevemao/github-issue-templates -->
|
||||
<!--- Template inspired by https://github.com/stevemao/github-issue-templates -->
|
||||
1
.github/ISSUE_TEMPLATE/config.yml
vendored
Normal file
1
.github/ISSUE_TEMPLATE/config.yml
vendored
Normal file
@@ -0,0 +1 @@
|
||||
blank_issues_enabled: false
|
||||
26
.github/ISSUE_TEMPLATE/feature_request.md
vendored
Normal file
26
.github/ISSUE_TEMPLATE/feature_request.md
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
---
|
||||
name: Feature request
|
||||
about: Suggest an idea for this project
|
||||
title: ''
|
||||
labels: ''
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
#### Expected Behavior
|
||||
<!--- Required. Describe the behavior you expect to see for your case. -->
|
||||
|
||||
#### Actual Behavior
|
||||
<!--- Required. Describe the actual behavior for your case. -->
|
||||
|
||||
#### Potential Solution
|
||||
<!--- Optional. Describe any potential solutions and/or thoughts as to what may be causing the difference between expected and actual behavior. -->
|
||||
|
||||
#### Checklist
|
||||
<!--- Confirm that you've provided all the required information. -->
|
||||
<!--- Required fields --->
|
||||
- [ ] I have completely filled out this template
|
||||
- [ ] I have confirmed that this issue exists on the current `master` branch
|
||||
- [ ] I have confirmed that this is not a duplicate issue by searching [issues](https://github.com/QuantConnect/Lean/issues)
|
||||
|
||||
<!--- Template inspired by https://github.com/stevemao/github-issue-templates -->
|
||||
13
.github/workflows/api-tests.yml
vendored
13
.github/workflows/api-tests.yml
vendored
@@ -9,14 +9,19 @@ on:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-20.04
|
||||
runs-on: ubuntu-24.04
|
||||
# Only run on push events (not on pull_request) for security reasons in order to be able to use secrets
|
||||
if: ${{ github.event_name == 'push' }}
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
- name: Free space
|
||||
run: df -h && rm -rf /usr/share/dotnet && sudo rm -rf /usr/local/lib/android && sudo rm -rf /opt/ghc && rm -rf /opt/hostedtoolcache* && df -h
|
||||
- name: Liberate disk space
|
||||
uses: jlumbroso/free-disk-space@main
|
||||
with:
|
||||
tool-cache: true
|
||||
large-packages: false
|
||||
docker-images: false
|
||||
swap-storage: false
|
||||
- name: Run API Tests
|
||||
uses: addnab/docker-run-action@v3
|
||||
with:
|
||||
@@ -27,4 +32,4 @@ jobs:
|
||||
# Build
|
||||
dotnet build /p:Configuration=Release /v:quiet /p:WarningLevel=1 QuantConnect.Lean.sln
|
||||
# Run Projects tests
|
||||
dotnet test ./Tests/bin/Release/QuantConnect.Tests.dll --blame-hang-timeout 300seconds --blame-crash --filter "FullyQualifiedName=QuantConnect.Tests.API.ProjectTests|ObjectStoreTests" -- TestRunParameters.Parameter\(name=\"log-handler\", value=\"ConsoleErrorLogHandler\"\)
|
||||
dotnet test ./Tests/bin/Release/QuantConnect.Tests.dll --blame-hang-timeout 7minutes --blame-crash --logger "console;verbosity=detailed" --filter "FullyQualifiedName=QuantConnect.Tests.API.ProjectTests|FullyQualifiedName=QuantConnect.Tests.API.ObjectStoreTests" -- TestRunParameters.Parameter\(name=\"log-handler\", value=\"ConsoleErrorLogHandler\"\)
|
||||
|
||||
22
.github/workflows/gh-actions.yml
vendored
22
.github/workflows/gh-actions.yml
vendored
@@ -9,12 +9,20 @@ on:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-20.04
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
- name: Free space
|
||||
run: df -h && rm -rf /usr/share/dotnet && sudo rm -rf /usr/local/lib/android && sudo rm -rf /opt/ghc && rm -rf /opt/hostedtoolcache* && df -h
|
||||
with:
|
||||
fetch-depth: 0 # Ensures we fetch all history
|
||||
|
||||
- name: Liberate disk space
|
||||
uses: jlumbroso/free-disk-space@main
|
||||
with:
|
||||
tool-cache: true
|
||||
large-packages: false
|
||||
docker-images: false
|
||||
swap-storage: false
|
||||
|
||||
- uses: addnab/docker-run-action@v3
|
||||
with:
|
||||
@@ -22,9 +30,15 @@ jobs:
|
||||
options: --workdir /__w/Lean/Lean -v /home/runner/work:/__w -e GITHUB_REF=${{ github.ref }} -e PYPI_API_TOKEN=${{ secrets.PYPI_API_TOKEN }} -e ADDITIONAL_STUBS_REPOS=${{ secrets.ADDITIONAL_STUBS_REPOS }} -e QC_GIT_TOKEN=${{ secrets.QC_GIT_TOKEN }}
|
||||
shell: bash
|
||||
run: |
|
||||
# Add exception
|
||||
git config --global --add safe.directory /__w/Lean/Lean
|
||||
# Get Last Commit of the Current Tag
|
||||
TAG_COMMIT=$(git rev-parse HEAD) && echo "CURRENT BRANCH LAST COMMIT $TAG_COMMIT"
|
||||
# Get Last Commit of the master
|
||||
MASTER_COMMIT=$(git rev-parse origin/master) && echo "MASTER BRANCH LAST COMMIT $MASTER_COMMIT"
|
||||
# Build
|
||||
dotnet build /p:Configuration=Release /v:quiet /p:WarningLevel=1 QuantConnect.Lean.sln && \
|
||||
# Run Tests
|
||||
dotnet test ./Tests/bin/Release/QuantConnect.Tests.dll --blame-hang-timeout 300seconds --blame-crash --filter "TestCategory!=TravisExclude&TestCategory!=ResearchRegressionTests" -- TestRunParameters.Parameter\(name=\"log-handler\", value=\"ConsoleErrorLogHandler\"\) && \
|
||||
# Generate & Publish python stubs
|
||||
echo "GITHUB_REF $GITHUB_REF" && if [[ $GITHUB_REF = refs/tags/* ]]; then (chmod +x ci_build_stubs.sh && ./ci_build_stubs.sh -t -g -p); else echo "Skipping stub generation"; fi
|
||||
echo "GITHUB_REF $GITHUB_REF" && if [[ $GITHUB_REF = refs/tags/* && "$TAG_COMMIT" = "$MASTER_COMMIT" ]]; then echo "Generating stubs" && (chmod +x ci_build_stubs.sh && ./ci_build_stubs.sh -t -g -p); else echo "Skipping stub generation"; fi
|
||||
|
||||
2
.github/workflows/rebase-org-branches.yml
vendored
2
.github/workflows/rebase-org-branches.yml
vendored
@@ -7,7 +7,7 @@ on:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-20.04
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
|
||||
11
.github/workflows/regression-tests.yml
vendored
11
.github/workflows/regression-tests.yml
vendored
@@ -9,12 +9,17 @@ on:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-20.04
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
- name: Free space
|
||||
run: df -h && rm -rf /usr/share/dotnet && sudo rm -rf /usr/local/lib/android && sudo rm -rf /opt/ghc && rm -rf /opt/hostedtoolcache* && df -h
|
||||
- name: Liberate disk space
|
||||
uses: jlumbroso/free-disk-space@main
|
||||
with:
|
||||
tool-cache: true
|
||||
large-packages: false
|
||||
docker-images: false
|
||||
swap-storage: false
|
||||
|
||||
- uses: addnab/docker-run-action@v3
|
||||
with:
|
||||
|
||||
11
.github/workflows/report-generator.yml
vendored
11
.github/workflows/report-generator.yml
vendored
@@ -9,12 +9,17 @@ on:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-20.04
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
- name: Free space
|
||||
run: df -h && rm -rf /usr/share/dotnet && sudo rm -rf /usr/local/lib/android && sudo rm -rf /opt/ghc && rm -rf /opt/hostedtoolcache* && df -h
|
||||
- name: Liberate disk space
|
||||
uses: jlumbroso/free-disk-space@main
|
||||
with:
|
||||
tool-cache: true
|
||||
large-packages: false
|
||||
docker-images: false
|
||||
swap-storage: false
|
||||
|
||||
- uses: addnab/docker-run-action@v3
|
||||
with:
|
||||
|
||||
15
.github/workflows/research-regression-tests.yml
vendored
15
.github/workflows/research-regression-tests.yml
vendored
@@ -9,12 +9,17 @@ on:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-20.04
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
- name: Free space
|
||||
run: df -h && rm -rf /usr/share/dotnet && sudo rm -rf /usr/local/lib/android && sudo rm -rf /opt/ghc && rm -rf /opt/hostedtoolcache* && df -h
|
||||
- name: Liberate disk space
|
||||
uses: jlumbroso/free-disk-space@main
|
||||
with:
|
||||
tool-cache: true
|
||||
large-packages: false
|
||||
docker-images: false
|
||||
swap-storage: false
|
||||
|
||||
- uses: addnab/docker-run-action@v3
|
||||
with:
|
||||
@@ -23,9 +28,9 @@ jobs:
|
||||
shell: bash
|
||||
run: |
|
||||
# install dependencies
|
||||
pip3 install papermill==2.4.0 clr-loader==0.1.6
|
||||
pip3 install papermill==2.4.0 clr-loader==0.2.9
|
||||
# install kernel
|
||||
dotnet tool install --global Microsoft.dotnet-interactive --version 1.0.340501
|
||||
dotnet tool install -g --no-cache --version 1.0.661703 --add-source "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-tools/nuget/v3/index.json" Microsoft.dotnet-interactive
|
||||
# Add dotnet tools to Path
|
||||
export PATH="$HOME/.dotnet/tools:$PATH"
|
||||
# activate kernel for jupyter
|
||||
|
||||
32
.github/workflows/syntax-tests.yml
vendored
Normal file
32
.github/workflows/syntax-tests.yml
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
name: Syntax Tests
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: ['*']
|
||||
tags: ['*']
|
||||
pull_request:
|
||||
branches: [master]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Liberate disk space
|
||||
uses: jlumbroso/free-disk-space@main
|
||||
with:
|
||||
tool-cache: true
|
||||
large-packages: false
|
||||
docker-images: false
|
||||
swap-storage: false
|
||||
- name: Run Syntax Test
|
||||
uses: addnab/docker-run-action@v3
|
||||
with:
|
||||
image: quantconnect/lean:foundation
|
||||
options: --workdir /__w/Lean/Lean -v /home/runner/work:/__w
|
||||
shell: bash
|
||||
run: |
|
||||
pip install --no-cache-dir quantconnect-stubs types-requests==2.32.* types-pytz==2025.2.0.* mypy==1.15.0 && \
|
||||
python run_syntax_check.py
|
||||
29
.github/workflows/virtual-environments.yml
vendored
29
.github/workflows/virtual-environments.yml
vendored
@@ -9,12 +9,17 @@ on:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-20.04
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
- name: Free space
|
||||
run: df -h && rm -rf /usr/share/dotnet && sudo rm -rf /usr/local/lib/android && sudo rm -rf /opt/ghc && rm -rf /opt/hostedtoolcache* && df -h
|
||||
- name: Liberate disk space
|
||||
uses: jlumbroso/free-disk-space@main
|
||||
with:
|
||||
tool-cache: true
|
||||
large-packages: false
|
||||
docker-images: false
|
||||
swap-storage: false
|
||||
|
||||
- uses: addnab/docker-run-action@v3
|
||||
with:
|
||||
@@ -25,11 +30,11 @@ jobs:
|
||||
# Build
|
||||
dotnet build /p:Configuration=Release /v:quiet /p:WarningLevel=1 QuantConnect.Lean.sln && \
|
||||
# Python Virtual Environment System Packages
|
||||
python -m venv /lean-testenv --system-site-packages && . /lean-testenv/bin/activate && pip install --no-cache-dir lean==1.0.185 && deactivate && \
|
||||
python -m venv /lean-testenv --system-site-packages && . /lean-testenv/bin/activate && pip install --no-cache-dir lean==1.0.221 && deactivate && \
|
||||
# Run Virtual Environment Test System Packages
|
||||
dotnet test ./Tests/bin/Release/QuantConnect.Tests.dll --filter "FullyQualifiedName=QuantConnect.Tests.Python.PythonVirtualEnvironmentTests.AssertVirtualEnvironment" && \
|
||||
# Python Virtual Environment
|
||||
rm -rf /lean-testenv && python -m venv /lean-testenv && . /lean-testenv/bin/activate && pip install --no-cache-dir lean==1.0.185 && deactivate && \
|
||||
rm -rf /lean-testenv && python -m venv /lean-testenv && . /lean-testenv/bin/activate && pip install --no-cache-dir lean==1.0.221 && deactivate && \
|
||||
# Run Virtual Environment Test
|
||||
dotnet test ./Tests/bin/Release/QuantConnect.Tests.dll --filter "FullyQualifiedName=QuantConnect.Tests.Python.PythonVirtualEnvironmentTests.AssertVirtualEnvironment" && \
|
||||
# Run Python Package Tests
|
||||
@@ -41,17 +46,21 @@ jobs:
|
||||
# Run TensorlyTest Python Package Test
|
||||
dotnet test ./Tests/bin/Release/QuantConnect.Tests.dll --filter "FullyQualifiedName=QuantConnect.Tests.Python.PythonPackagesTests.TensorlyTest" --blame-hang-timeout 120seconds --blame-crash && \
|
||||
# Run NeuralTangents, Ignite Python Package Test
|
||||
dotnet test ./Tests/bin/Release/QuantConnect.Tests.dll --filter "FullyQualifiedName=QuantConnect.Tests.Python.PythonPackagesTests.NeuralTangentsTest|IgniteTest" --blame-hang-timeout 120seconds --blame-crash && \
|
||||
dotnet test ./Tests/bin/Release/QuantConnect.Tests.dll --filter "FullyQualifiedName=QuantConnect.Tests.Python.PythonPackagesTests.IgniteTest" --blame-hang-timeout 120seconds --blame-crash && \
|
||||
# Run TensorflowTest
|
||||
dotnet test ./Tests/bin/Release/QuantConnect.Tests.dll --filter "FullyQualifiedName=QuantConnect.Tests.Python.PythonPackagesTests.TensorflowTest" --blame-hang-timeout 120seconds --blame-crash && \
|
||||
# Run TensorflowProbability
|
||||
dotnet test ./Tests/bin/Release/QuantConnect.Tests.dll --filter "FullyQualifiedName=QuantConnect.Tests.Python.PythonPackagesTests.TensorflowProbabilityTest" --blame-hang-timeout 120seconds --blame-crash && \
|
||||
# Run Hvplot Python Package Test
|
||||
dotnet test ./Tests/bin/Release/QuantConnect.Tests.dll --filter "FullyQualifiedName=QuantConnect.Tests.Python.PythonPackagesTests.HvplotTest" --blame-hang-timeout 120seconds --blame-crash && \
|
||||
# Run Keras Python Package Test
|
||||
dotnet test ./Tests/bin/Release/QuantConnect.Tests.dll --filter "FullyQualifiedName=QuantConnect.Tests.Python.PythonPackagesTests.KerasTest" --blame-hang-timeout 120seconds --blame-crash && \
|
||||
dotnet test ./Tests/bin/Release/QuantConnect.Tests.dll --filter "FullyQualifiedName=QuantConnect.Tests.Python.PythonPackagesTests.RiskparityportfolioTest" --blame-hang-timeout 120seconds --blame-crash && \
|
||||
# Run Transformers
|
||||
dotnet test ./Tests/bin/Release/QuantConnect.Tests.dll --filter "FullyQualifiedName=QuantConnect.Tests.Python.PythonPackagesTests.Transformers" --blame-hang-timeout 120seconds --blame-crash && \
|
||||
dotnet test ./Tests/bin/Release/QuantConnect.Tests.dll --filter "FullyQualifiedName=QuantConnect.Tests.Python.PythonPackagesTests.XTransformers" --blame-hang-timeout 120seconds --blame-crash && \
|
||||
# Run Shap
|
||||
dotnet test ./Tests/bin/Release/QuantConnect.Tests.dll --filter "FullyQualifiedName=QuantConnect.Tests.Python.PythonPackagesTests.ShapTest" --blame-hang-timeout 120seconds --blame-crash
|
||||
dotnet test ./Tests/bin/Release/QuantConnect.Tests.dll --filter "FullyQualifiedName=QuantConnect.Tests.Python.PythonPackagesTests.KerasTest|PyvinecopulibTest" --blame-hang-timeout 120seconds --blame-crash && \
|
||||
dotnet test ./Tests/bin/Release/QuantConnect.Tests.dll --filter "FullyQualifiedName=QuantConnect.Tests.Python.PythonPackagesTests.StatsForecast|Mlforecast" --blame-hang-timeout 120seconds --blame-crash && \
|
||||
dotnet test ./Tests/bin/Release/QuantConnect.Tests.dll --filter "FullyQualifiedName=QuantConnect.Tests.Python.PythonPackagesTests.MlxtendTest|Thinc" --blame-hang-timeout 120seconds --blame-crash && \
|
||||
dotnet test ./Tests/bin/Release/QuantConnect.Tests.dll --filter "FullyQualifiedName=QuantConnect.Tests.Python.PythonPackagesTests.ModuleVersionTestExplicit" --blame-hang-timeout 120seconds --blame-crash && \
|
||||
dotnet test ./Tests/bin/Release/QuantConnect.Tests.dll --filter "FullyQualifiedName=QuantConnect.Tests.Python.PythonPackagesTests.Neuralforecast" --blame-hang-timeout 120seconds --blame-crash && \
|
||||
dotnet test ./Tests/bin/Release/QuantConnect.Tests.dll --filter "FullyQualifiedName=QuantConnect.Tests.Python.PythonPackagesTests.Tsfel" --blame-hang-timeout 120seconds --blame-crash && \
|
||||
dotnet test ./Tests/bin/Release/QuantConnect.Tests.dll --filter "FullyQualifiedName=QuantConnect.Tests.Python.PythonPackagesTests.ScikitOptimizeTest" --blame-hang-timeout 120seconds --blame-crash
|
||||
|
||||
3
.gitignore
vendored
3
.gitignore
vendored
@@ -279,4 +279,5 @@ QuantConnect.Lean.sln.DotSettings*
|
||||
Research/Notebooks
|
||||
|
||||
#Docker result files
|
||||
Results/
|
||||
Results/
|
||||
QuantConnect.Lean.sln.DotSettings
|
||||
|
||||
@@ -12,16 +12,16 @@ This document contains information regarding ways to use Visual Studio to work w
|
||||
|
||||
<h2>Option 1: Lean CLI</h2>
|
||||
|
||||
To use Lean CLI follow the instructions for installation and tutorial for usage in our [documentation](https://www.quantconnect.com/docs/v2/lean-cli/getting-started/lean-cli).
|
||||
To use Lean CLI follow the instructions for installation and tutorial for usage in our [documentation](https://www.quantconnect.com/docs/v2/lean-cli/key-concepts/getting-started).
|
||||
|
||||
<br />
|
||||
|
||||
<h2>Option 2: Install Locally</h2>
|
||||
|
||||
1. Install [.Net 6](https://dotnet.microsoft.com/download) for the project
|
||||
1. Install [.Net 9](https://dotnet.microsoft.com/en-us/download/dotnet/9.0) for the project
|
||||
|
||||
2. (Optional) Get [Python 3.8.13](https://www.python.org/downloads/release/python-3813/) for running Python algorithms
|
||||
- Follow Python instructions [here](https://github.com/QuantConnect/Lean/tree/master/Algorithm.Python#installing-python-38) for your platform
|
||||
2. (Optional) Get [Python 3.11.11](https://www.python.org/downloads/release/python-31111/) for running Python algorithms
|
||||
- Follow Python instructions [here](https://github.com/QuantConnect/Lean/tree/master/Algorithm.Python#installing-python-311) for your platform
|
||||
|
||||
3. Get [Visual Studio](https://visualstudio.microsoft.com/vs/)
|
||||
|
||||
@@ -35,7 +35,7 @@ Your environment is prepared and ready to run lean
|
||||
|
||||
<h1>How to use Lean</h1>
|
||||
|
||||
This section will cover configuring, launching and debugging lean. This is only applicable to option 2 from above. This does not apply to Lean CLI, please refer to [CLI documentation](https://www.quantconnect.com/docs/v2/lean-cli/getting-started/lean-cli)
|
||||
This section will cover configuring, launching and debugging lean. This is only applicable to option 2 from above. This does not apply to Lean CLI, please refer to [CLI documentation](https://www.quantconnect.com/docs/v2/lean-cli/key-concepts/getting-started)
|
||||
|
||||
<br />
|
||||
|
||||
|
||||
6
.vscode/readme.md
vendored
6
.vscode/readme.md
vendored
@@ -51,10 +51,10 @@ If you would like to mount any additional local files to your container, checkou
|
||||
|
||||
<h2>Option 3: Install Dependencies Locally</h2>
|
||||
|
||||
1. Install [.NET 6](https://dotnet.microsoft.com/en-us/download/dotnet/6.0) for the project
|
||||
1. Install [.NET 9](https://dotnet.microsoft.com/en-us/download/dotnet/9.0) for the project
|
||||
|
||||
2. (Optional) Get [Python 3.8.13](https://www.python.org/downloads/release/python-3813/) for running Python algorithms
|
||||
- Follow Python instructions [here](https://github.com/QuantConnect/Lean/tree/master/Algorithm.Python#installing-python-38) for your platform
|
||||
2. (Optional) Get [Python 3.11.11](https://www.python.org/downloads/release/python-31111/) for running Python algorithms
|
||||
- Follow Python instructions [here](https://github.com/QuantConnect/Lean/tree/master/Algorithm.Python#installing-python-311) for your platform
|
||||
|
||||
3. Get [Visual Studio Code](https://code.visualstudio.com/download)
|
||||
- Get the Extension [C#](https://marketplace.visualstudio.com/items?itemName=ms-dotnettools.csharp) for C# Debugging
|
||||
|
||||
@@ -55,7 +55,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
||
|
||||
Portfolio.TotalHoldingsValue < Portfolio.TotalPortfolioValue * 0.01m)
|
||||
{
|
||||
throw new Exception($"Unexpected Total Holdings Value: {Portfolio.TotalHoldingsValue}");
|
||||
throw new RegressionTestException($"Unexpected Total Holdings Value: {Portfolio.TotalHoldingsValue}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate which languages this algorithm is written in.
|
||||
/// </summary>
|
||||
public Language[] Languages { get; } = { Language.CSharp, Language.Python };
|
||||
public List<Language> Languages { get; } = new() { Language.CSharp, Language.Python };
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of all timeslices of algorithm
|
||||
@@ -79,6 +79,11 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// </summary>
|
||||
public int AlgorithmHistoryDataPoints => 0;
|
||||
|
||||
/// <summary>
|
||||
/// Final status of the algorithm
|
||||
/// </summary>
|
||||
public AlgorithmStatus AlgorithmStatus => AlgorithmStatus.Completed;
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate what the expected statistics are from running the algorithm
|
||||
/// </summary>
|
||||
@@ -110,6 +115,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Estimated Strategy Capacity", "$26000000.00"},
|
||||
{"Lowest Capacity Asset", "SPY R735QTJ8XC9X"},
|
||||
{"Portfolio Turnover", "119.89%"},
|
||||
{"Drawdown Recovery", "0"},
|
||||
{"OrderListHash", "d06c26f557b83d8d42ac808fe2815a1e"}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
|| insightsCollection.Insights.Count(insight => insight.Symbol == _spy) != 1
|
||||
|| insightsCollection.Insights.Count(insight => insight.Symbol == _ibm) != 1)
|
||||
{
|
||||
throw new Exception("Unexpected insights were emitted");
|
||||
throw new RegressionTestException("Unexpected insights were emitted");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,7 +103,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate which languages this algorithm is written in.
|
||||
/// </summary>
|
||||
public Language[] Languages { get; } = { Language.CSharp, Language.Python };
|
||||
public List<Language> Languages { get; } = new() { Language.CSharp, Language.Python };
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of all timeslices of algorithm
|
||||
@@ -115,6 +115,11 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// </summary>
|
||||
public int AlgorithmHistoryDataPoints => 0;
|
||||
|
||||
/// <summary>
|
||||
/// Final status of the algorithm
|
||||
/// </summary>
|
||||
public AlgorithmStatus AlgorithmStatus => AlgorithmStatus.Completed;
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate what the expected statistics are from running the algorithm
|
||||
/// </summary>
|
||||
@@ -123,7 +128,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Total Orders", "9"},
|
||||
{"Average Win", "0.86%"},
|
||||
{"Average Loss", "-0.27%"},
|
||||
{"Compounding Annual Return", "184.364%"},
|
||||
{"Compounding Annual Return", "206.404%"},
|
||||
{"Drawdown", "1.700%"},
|
||||
{"Expectancy", "1.781"},
|
||||
{"Start Equity", "100000"},
|
||||
@@ -143,10 +148,11 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0.532"},
|
||||
{"Treynor Ratio", "-1.174"},
|
||||
{"Total Fees", "$14.78"},
|
||||
{"Estimated Strategy Capacity", "$47000000.00"},
|
||||
{"Estimated Strategy Capacity", "$120000000.00"},
|
||||
{"Lowest Capacity Asset", "IBM R735QTJ8XC9X"},
|
||||
{"Portfolio Turnover", "41.18%"},
|
||||
{"OrderListHash", "d929e7959f079ad4fed42e8f3b35e39e"}
|
||||
{"Drawdown Recovery", "0"},
|
||||
{"OrderListHash", "713c956deb193bed2290e9f379c0f9f9"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,10 +40,12 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
|
||||
var aapl = QuantConnect.Symbol.Create("AAPL", SecurityType.Equity, Market.USA);
|
||||
|
||||
_contract = OptionChainProvider.GetOptionContractList(aapl, Time)
|
||||
.OrderBy(symbol => symbol.ID.Symbol)
|
||||
.FirstOrDefault(optionContract => optionContract.ID.OptionRight == OptionRight.Call
|
||||
&& optionContract.ID.OptionStyle == OptionStyle.American);
|
||||
_contract = OptionChain(aapl)
|
||||
.OrderBy(symbol => symbol.ID.OptionRight)
|
||||
.ThenBy(symbol => symbol.ID.StrikePrice)
|
||||
.ThenBy(symbol => symbol.ID.Date)
|
||||
.ThenBy(symbol => symbol.ID)
|
||||
.FirstOrDefault(optionContract => optionContract.ID.OptionRight == OptionRight.Call);
|
||||
AddOptionContract(_contract);
|
||||
}
|
||||
|
||||
@@ -59,7 +61,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("Expect a single call to OnData where we removed the option and underlying");
|
||||
throw new RegressionTestException("Expect a single call to OnData where we removed the option and underlying");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -68,7 +70,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{
|
||||
if (!_hasRemoved)
|
||||
{
|
||||
throw new Exception("Expect a single call to OnData where we removed the option and underlying");
|
||||
throw new RegressionTestException("Expect a single call to OnData where we removed the option and underlying");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,17 +82,22 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate which languages this algorithm is written in.
|
||||
/// </summary>
|
||||
public Language[] Languages { get; } = { Language.CSharp };
|
||||
public List<Language> Languages { get; } = new() { Language.CSharp };
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of all timeslices of algorithm
|
||||
/// </summary>
|
||||
public long DataPoints => 24;
|
||||
public long DataPoints => 26;
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of the algorithm history
|
||||
/// </summary>
|
||||
public int AlgorithmHistoryDataPoints => 0;
|
||||
public int AlgorithmHistoryDataPoints => 1;
|
||||
|
||||
/// <summary>
|
||||
/// Final status of the algorithm
|
||||
/// </summary>
|
||||
public AlgorithmStatus AlgorithmStatus => AlgorithmStatus.Completed;
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate what the expected statistics are from running the algorithm
|
||||
@@ -123,6 +130,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Estimated Strategy Capacity", "$0"},
|
||||
{"Lowest Capacity Asset", ""},
|
||||
{"Portfolio Turnover", "0%"},
|
||||
{"Drawdown Recovery", "0"},
|
||||
{"OrderListHash", "d41d8cd98f00b204e9800998ecf8427e"}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -39,8 +39,8 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
|
||||
var aapl = AddEquity("AAPL").Symbol;
|
||||
|
||||
_contract = OptionChainProvider.GetOptionContractList(aapl, Time)
|
||||
.OrderBy(symbol => symbol.ID.Symbol)
|
||||
_contract = OptionChain(aapl)
|
||||
.OrderBy(x => x.ID.Symbol)
|
||||
.FirstOrDefault(optionContract => optionContract.ID.OptionRight == OptionRight.Call
|
||||
&& optionContract.ID.OptionStyle == OptionStyle.American);
|
||||
}
|
||||
@@ -49,7 +49,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{
|
||||
if (_hasRemoved)
|
||||
{
|
||||
throw new Exception("Expect a single call to OnData where we removed the option and underlying");
|
||||
throw new RegressionTestException("Expect a single call to OnData where we removed the option and underlying");
|
||||
}
|
||||
|
||||
_hasRemoved = true;
|
||||
@@ -65,7 +65,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{
|
||||
if (!_hasRemoved)
|
||||
{
|
||||
throw new Exception("We did not remove the option contract!");
|
||||
throw new RegressionTestException("We did not remove the option contract!");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,17 +77,22 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate which languages this algorithm is written in.
|
||||
/// </summary>
|
||||
public Language[] Languages { get; } = { Language.CSharp };
|
||||
public List<Language> Languages { get; } = new() { Language.CSharp };
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of all timeslices of algorithm
|
||||
/// </summary>
|
||||
public long DataPoints => 24;
|
||||
public long DataPoints => 25;
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of the algorithm history
|
||||
/// </summary>
|
||||
public int AlgorithmHistoryDataPoints => 0;
|
||||
public int AlgorithmHistoryDataPoints => 1;
|
||||
|
||||
/// <summary>
|
||||
/// Final status of the algorithm
|
||||
/// </summary>
|
||||
public AlgorithmStatus AlgorithmStatus => AlgorithmStatus.Completed;
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate what the expected statistics are from running the algorithm
|
||||
@@ -120,6 +125,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Estimated Strategy Capacity", "$0"},
|
||||
{"Lowest Capacity Asset", ""},
|
||||
{"Portfolio Turnover", "0%"},
|
||||
{"Drawdown Recovery", "0"},
|
||||
{"OrderListHash", "d41d8cd98f00b204e9800998ecf8427e"}
|
||||
};
|
||||
}
|
||||
|
||||
152
Algorithm.CSharp/AddBetaIndicatorNewAssetsRegressionAlgorithm.cs
Normal file
152
Algorithm.CSharp/AddBetaIndicatorNewAssetsRegressionAlgorithm.cs
Normal file
@@ -0,0 +1,152 @@
|
||||
/*
|
||||
* QUANTCONNECT.COM - Democratizing Finance, Empowering Individuals.
|
||||
* Lean Algorithmic Trading Engine v2.0. Copyright 2014 QuantConnect Corporation.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using QuantConnect.Data;
|
||||
using QuantConnect.Indicators;
|
||||
using QuantConnect.Interfaces;
|
||||
using QuantConnect.Orders;
|
||||
using QuantConnect.Brokerages;
|
||||
|
||||
|
||||
namespace QuantConnect.Algorithm.CSharp
|
||||
{
|
||||
/// <summary>
|
||||
/// Regression test to explain how Beta indicator works
|
||||
/// </summary>
|
||||
public class AddBetaIndicatorNewAssetsRegressionAlgorithm : QCAlgorithm, IRegressionAlgorithmDefinition
|
||||
{
|
||||
private Beta _beta;
|
||||
private SimpleMovingAverage _sma;
|
||||
private decimal _lastSMAValue;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
SetStartDate(2015, 05, 08);
|
||||
SetEndDate(2017, 06, 15);
|
||||
SetCash(10000);
|
||||
|
||||
AddCrypto("BTCUSD", Resolution.Daily);
|
||||
AddEquity("SPY", Resolution.Daily);
|
||||
|
||||
EnableAutomaticIndicatorWarmUp = true;
|
||||
_beta = B("BTCUSD", "SPY", 3, Resolution.Daily);
|
||||
_sma = SMA("SPY", 3, Resolution.Daily);
|
||||
_lastSMAValue = 0;
|
||||
|
||||
if (!_beta.IsReady)
|
||||
{
|
||||
throw new RegressionTestException("Beta indicator was expected to be ready");
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnData(Slice slice)
|
||||
{
|
||||
var price = Securities["BTCUSD"].Price;
|
||||
|
||||
if (!Portfolio.Invested)
|
||||
{
|
||||
var quantityToBuy = (int)(Portfolio.Cash * 0.05m / price);
|
||||
Buy("BTCUSD", quantityToBuy);
|
||||
}
|
||||
|
||||
if (Math.Abs(_beta.Current.Value) > 2)
|
||||
{
|
||||
Liquidate("BTCUSD");
|
||||
Log("Liquidated BTCUSD due to high Beta");
|
||||
}
|
||||
|
||||
Log($"Beta between BTCUSD and SPY is: {_beta.Current.Value}");
|
||||
}
|
||||
|
||||
public override void OnOrderEvent(OrderEvent orderEvent)
|
||||
{
|
||||
var order = Transactions.GetOrderById(orderEvent.OrderId);
|
||||
var goUpwards = _lastSMAValue < _sma.Current.Value;
|
||||
_lastSMAValue = _sma.Current.Value;
|
||||
|
||||
if (order.Status == OrderStatus.Filled)
|
||||
{
|
||||
if (order.Type == OrderType.Limit && Math.Abs(_beta.Current.Value - 1) < 0.2m && goUpwards)
|
||||
{
|
||||
Transactions.CancelOpenOrders(order.Symbol);
|
||||
}
|
||||
}
|
||||
|
||||
if (order.Status == OrderStatus.Canceled)
|
||||
{
|
||||
Log(orderEvent.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
public bool CanRunLocally { get; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate which languages this algorithm is written in.
|
||||
/// </summary>
|
||||
public virtual List<Language> Languages { get; } = new() { Language.CSharp };
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of all timeslices of algorithm
|
||||
/// </summary>
|
||||
public long DataPoints => 5798;
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of the algorithm history
|
||||
/// </summary>
|
||||
public int AlgorithmHistoryDataPoints => 26;
|
||||
|
||||
/// <summary>
|
||||
/// Final status of the algorithm
|
||||
/// </summary>
|
||||
public AlgorithmStatus AlgorithmStatus => AlgorithmStatus.Completed;
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate what the expected statistics are from running the algorithm
|
||||
/// </summary>
|
||||
public Dictionary<string, string> ExpectedStatistics => new Dictionary<string, string>
|
||||
{
|
||||
{"Total Orders", "436"},
|
||||
{"Average Win", "0.28%"},
|
||||
{"Average Loss", "-0.01%"},
|
||||
{"Compounding Annual Return", "1.925%"},
|
||||
{"Drawdown", "1.000%"},
|
||||
{"Expectancy", "1.649"},
|
||||
{"Start Equity", "10000.00"},
|
||||
{"End Equity", "10410.99"},
|
||||
{"Net Profit", "4.110%"},
|
||||
{"Sharpe Ratio", "0.332"},
|
||||
{"Sortino Ratio", "0.313"},
|
||||
{"Probabilistic Sharpe Ratio", "74.084%"},
|
||||
{"Loss Rate", "90%"},
|
||||
{"Win Rate", "10%"},
|
||||
{"Profit-Loss Ratio", "25.25"},
|
||||
{"Alpha", "0.003"},
|
||||
{"Beta", "0.001"},
|
||||
{"Annual Standard Deviation", "0.01"},
|
||||
{"Annual Variance", "0"},
|
||||
{"Information Ratio", "-0.495"},
|
||||
{"Tracking Error", "0.111"},
|
||||
{"Treynor Ratio", "2.716"},
|
||||
{"Total Fees", "$0.00"},
|
||||
{"Estimated Strategy Capacity", "$87000.00"},
|
||||
{"Lowest Capacity Asset", "BTCUSD 2XR"},
|
||||
{"Portfolio Turnover", "2.22%"},
|
||||
{"Drawdown Recovery", "139"},
|
||||
{"OrderListHash", "896ecc92440d51ed26644aac5b8706e4"}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -47,23 +47,23 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
|
||||
if (!_beta.IsReady)
|
||||
{
|
||||
throw new Exception("_beta indicator was expected to be ready");
|
||||
throw new RegressionTestException("Beta indicator was expected to be ready");
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnData(Slice data)
|
||||
public override void OnData(Slice slice)
|
||||
{
|
||||
if (!Portfolio.Invested)
|
||||
{
|
||||
var price = data["IBM"].Close;
|
||||
var price = slice["IBM"].Close;
|
||||
Buy("IBM", 10);
|
||||
LimitOrder("IBM", 10, price * 0.1m);
|
||||
StopMarketOrder("IBM", 10, price / 0.1m);
|
||||
}
|
||||
|
||||
|
||||
if (_beta.Current.Value < 0m || _beta.Current.Value > 2.80m)
|
||||
{
|
||||
throw new Exception($"_beta value was expected to be between 0 and 2.80 but was {_beta.Current.Value}");
|
||||
throw new RegressionTestException($"_beta value was expected to be between 0 and 2.80 but was {_beta.Current.Value}");
|
||||
}
|
||||
|
||||
Log($"Beta between IBM and SPY is: {_beta.Current.Value}");
|
||||
@@ -97,7 +97,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate which languages this algorithm is written in.
|
||||
/// </summary>
|
||||
public virtual Language[] Languages { get; } = { Language.CSharp};
|
||||
public virtual List<Language> Languages { get; } = new() { Language.CSharp };
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of all timeslices of algorithm
|
||||
@@ -109,6 +109,11 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// </summary>
|
||||
public int AlgorithmHistoryDataPoints => 11;
|
||||
|
||||
/// <summary>
|
||||
/// Final status of the algorithm
|
||||
/// </summary>
|
||||
public AlgorithmStatus AlgorithmStatus => AlgorithmStatus.Completed;
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate what the expected statistics are from running the algorithm
|
||||
/// </summary>
|
||||
@@ -140,6 +145,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Estimated Strategy Capacity", "$35000000.00"},
|
||||
{"Lowest Capacity Asset", "IBM R735QTJ8XC9X"},
|
||||
{"Portfolio Turnover", "1.51%"},
|
||||
{"Drawdown Recovery", "2"},
|
||||
{"OrderListHash", "1db1ce949db995bba20ed96ea5e2438a"}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -31,7 +31,6 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// </summary>
|
||||
public class AddFutureContractWithContinuousRegressionAlgorithm : QCAlgorithm, IRegressionAlgorithmDefinition
|
||||
{
|
||||
private Symbol _currentMappedSymbol;
|
||||
private Future _continuousContract;
|
||||
private Future _futureContract;
|
||||
private bool _ended;
|
||||
@@ -50,26 +49,26 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
contractDepthOffset: 0
|
||||
);
|
||||
|
||||
_futureContract = AddFutureContract(FutureChainProvider.GetFutureContractList(_continuousContract.Symbol, Time).First());
|
||||
_futureContract = AddFutureContract(FuturesChain(_continuousContract.Symbol).First());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// OnData event is the primary entry point for your algorithm. Each new data point will be pumped in here.
|
||||
/// </summary>
|
||||
/// <param name="data">Slice object keyed by symbol containing the stock data</param>
|
||||
public override void OnData(Slice data)
|
||||
/// <param name="slice">Slice object keyed by symbol containing the stock data</param>
|
||||
public override void OnData(Slice slice)
|
||||
{
|
||||
if (_ended)
|
||||
{
|
||||
throw new Exception($"Algorithm should of ended!");
|
||||
throw new RegressionTestException($"Algorithm should of ended!");
|
||||
}
|
||||
if (data.Keys.Count > 2)
|
||||
if (slice.Keys.Count > 2)
|
||||
{
|
||||
throw new Exception($"Getting data for more than 2 symbols! {string.Join(",", data.Keys.Select(symbol => symbol))}");
|
||||
throw new RegressionTestException($"Getting data for more than 2 symbols! {string.Join(",", slice.Keys.Select(symbol => symbol))}");
|
||||
}
|
||||
if (UniverseManager.Count != 3)
|
||||
{
|
||||
throw new Exception($"Expecting 3 universes (chain, continuous and user defined) but have {UniverseManager.Count}");
|
||||
throw new RegressionTestException($"Expecting 3 universes (chain, continuous and user defined) but have {UniverseManager.Count}");
|
||||
}
|
||||
|
||||
if (!Portfolio.Invested)
|
||||
@@ -99,7 +98,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
if (changes.AddedSecurities.Any(security => security.Symbol != _continuousContract.Symbol && security.Symbol != _futureContract.Symbol)
|
||||
|| changes.RemovedSecurities.Any(security => security.Symbol != _continuousContract.Symbol && security.Symbol != _futureContract.Symbol))
|
||||
{
|
||||
throw new Exception($"We got an unexpected security changes {changes}");
|
||||
throw new RegressionTestException($"We got an unexpected security changes {changes}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -111,50 +110,56 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate which languages this algorithm is written in.
|
||||
/// </summary>
|
||||
public Language[] Languages { get; } = { Language.CSharp };
|
||||
public List<Language> Languages { get; } = new() { Language.CSharp };
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of all timeslices of algorithm
|
||||
/// </summary>
|
||||
public long DataPoints => 74;
|
||||
public long DataPoints => 61;
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of the algorithm history
|
||||
/// </summary>
|
||||
public int AlgorithmHistoryDataPoints => 0;
|
||||
public int AlgorithmHistoryDataPoints => 1;
|
||||
|
||||
/// <summary>
|
||||
/// Final status of the algorithm
|
||||
/// </summary>
|
||||
public AlgorithmStatus AlgorithmStatus => AlgorithmStatus.Completed;
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate what the expected statistics are from running the algorithm
|
||||
/// </summary>
|
||||
public Dictionary<string, string> ExpectedStatistics => new Dictionary<string, string>
|
||||
{
|
||||
{"Total Orders", "3"},
|
||||
{"Total Orders", "4"},
|
||||
{"Average Win", "0%"},
|
||||
{"Average Loss", "-0.03%"},
|
||||
{"Compounding Annual Return", "-2.594%"},
|
||||
{"Drawdown", "0.000%"},
|
||||
{"Average Loss", "-0.10%"},
|
||||
{"Compounding Annual Return", "-14.232%"},
|
||||
{"Drawdown", "0.200%"},
|
||||
{"Expectancy", "-1"},
|
||||
{"Start Equity", "100000"},
|
||||
{"End Equity", "99966.4"},
|
||||
{"Net Profit", "-0.034%"},
|
||||
{"Sharpe Ratio", "-10.666"},
|
||||
{"End Equity", "99803.9"},
|
||||
{"Net Profit", "-0.196%"},
|
||||
{"Sharpe Ratio", "-7.95"},
|
||||
{"Sortino Ratio", "0"},
|
||||
{"Probabilistic Sharpe Ratio", "1.216%"},
|
||||
{"Loss Rate", "100%"},
|
||||
{"Win Rate", "0%"},
|
||||
{"Profit-Loss Ratio", "0"},
|
||||
{"Alpha", "-0.029"},
|
||||
{"Beta", "0.004"},
|
||||
{"Annual Standard Deviation", "0.003"},
|
||||
{"Alpha", "-0.128"},
|
||||
{"Beta", "0.026"},
|
||||
{"Annual Standard Deviation", "0.016"},
|
||||
{"Annual Variance", "0"},
|
||||
{"Information Ratio", "-0.768"},
|
||||
{"Tracking Error", "0.241"},
|
||||
{"Treynor Ratio", "-6.368"},
|
||||
{"Information Ratio", "-1.186"},
|
||||
{"Tracking Error", "0.237"},
|
||||
{"Treynor Ratio", "-4.747"},
|
||||
{"Total Fees", "$8.60"},
|
||||
{"Estimated Strategy Capacity", "$5500000.00"},
|
||||
{"Lowest Capacity Asset", "ES VMKLFZIH2MTD"},
|
||||
{"Portfolio Turnover", "66.80%"},
|
||||
{"OrderListHash", "579e2e83dd7e5e7648c47e9eff132460"}
|
||||
{"Estimated Strategy Capacity", "$2000.00"},
|
||||
{"Lowest Capacity Asset", "ES VU1EHIDJYLMP"},
|
||||
{"Portfolio Turnover", "66.50%"},
|
||||
{"Drawdown Recovery", "0"},
|
||||
{"OrderListHash", "4720516462fcabb4db1aead46051cb4a"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,9 +66,9 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnData(Slice data)
|
||||
public override void OnData(Slice slice)
|
||||
{
|
||||
if (!data.HasData)
|
||||
if (!slice.HasData)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -76,7 +76,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
_onDataReached = true;
|
||||
|
||||
var hasOptionQuoteBars = false;
|
||||
foreach (var qb in data.QuoteBars.Values)
|
||||
foreach (var qb in slice.QuoteBars.Values)
|
||||
{
|
||||
if (qb.Symbol.SecurityType != SecurityType.FutureOption)
|
||||
{
|
||||
@@ -99,7 +99,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
return;
|
||||
}
|
||||
|
||||
if (data.ContainsKey(_es20h20) && data.ContainsKey(_es19m20))
|
||||
if (slice.ContainsKey(_es20h20) && slice.ContainsKey(_es19m20))
|
||||
{
|
||||
SetHoldings(_es20h20, 0.2);
|
||||
SetHoldings(_es19m20, 0.2);
|
||||
@@ -114,7 +114,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
|
||||
if (!_onDataReached)
|
||||
{
|
||||
throw new Exception("OnData() was never called.");
|
||||
throw new RegressionTestException("OnData() was never called.");
|
||||
}
|
||||
if (_symbolsReceived.Count != _expectedSymbolsReceived.Count)
|
||||
{
|
||||
@@ -132,7 +132,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
|
||||
if (missingSymbols.Count > 0)
|
||||
{
|
||||
throw new Exception($"Symbols: \"{string.Join(", ", missingSymbols)}\" were not found in OnData");
|
||||
throw new RegressionTestException($"Symbols: \"{string.Join(", ", missingSymbols)}\" were not found in OnData");
|
||||
}
|
||||
|
||||
foreach (var expectedSymbol in _expectedSymbolsReceived)
|
||||
@@ -146,7 +146,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
|
||||
if (nonDupeDataCount < 1000)
|
||||
{
|
||||
throw new Exception($"Received too few data points. Expected >=1000, found {nonDupeDataCount} for {expectedSymbol}");
|
||||
throw new RegressionTestException($"Received too few data points. Expected >=1000, found {nonDupeDataCount} for {expectedSymbol}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -159,17 +159,22 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate which languages this algorithm is written in.
|
||||
/// </summary>
|
||||
public Language[] Languages { get; } = { Language.CSharp, Language.Python };
|
||||
public List<Language> Languages { get; } = new() { Language.CSharp, Language.Python };
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of all timeslices of algorithm
|
||||
/// </summary>
|
||||
public long DataPoints => 311879;
|
||||
public long DataPoints => 311881;
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of the algorithm history
|
||||
/// </summary>
|
||||
public int AlgorithmHistoryDataPoints => 0;
|
||||
public int AlgorithmHistoryDataPoints => 2;
|
||||
|
||||
/// <summary>
|
||||
/// Final status of the algorithm
|
||||
/// </summary>
|
||||
public AlgorithmStatus AlgorithmStatus => AlgorithmStatus.Completed;
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate what the expected statistics are from running the algorithm
|
||||
@@ -202,6 +207,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Estimated Strategy Capacity", "$22000000.00"},
|
||||
{"Lowest Capacity Asset", "ES XFH59UK0MYO1"},
|
||||
{"Portfolio Turnover", "122.11%"},
|
||||
{"Drawdown Recovery", "0"},
|
||||
{"OrderListHash", "d744fa8beaa60546c84924ed68d945d9"}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -40,16 +40,16 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
});
|
||||
}
|
||||
|
||||
public override void OnData(Slice data)
|
||||
public override void OnData(Slice slice)
|
||||
{
|
||||
if (!_addedOptions)
|
||||
{
|
||||
_addedOptions = true;
|
||||
foreach (var futuresContracts in data.FutureChains.Values)
|
||||
foreach (var futuresContracts in slice.FutureChains.Values)
|
||||
{
|
||||
foreach (var contract in futuresContracts)
|
||||
{
|
||||
var option_contract_symbols = OptionChainProvider.GetOptionContractList(contract.Symbol, Time).ToList();
|
||||
var option_contract_symbols = OptionChain(contract.Symbol).ToList();
|
||||
if(option_contract_symbols.Count == 0)
|
||||
{
|
||||
continue;
|
||||
@@ -70,7 +70,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (var chain in data.OptionChains.Values)
|
||||
foreach (var chain in slice.OptionChains.Values)
|
||||
{
|
||||
foreach (var option in chain.Contracts.Keys)
|
||||
{
|
||||
@@ -88,17 +88,22 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate which languages this algorithm is written in.
|
||||
/// </summary>
|
||||
public Language[] Languages { get; } = { Language.CSharp };
|
||||
public List<Language> Languages { get; } = new() { Language.CSharp };
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of all timeslices of algorithm
|
||||
/// </summary>
|
||||
public long DataPoints => 12170;
|
||||
public long DataPoints => 9922;
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of the algorithm history
|
||||
/// </summary>
|
||||
public int AlgorithmHistoryDataPoints => 0;
|
||||
public int AlgorithmHistoryDataPoints => 2;
|
||||
|
||||
/// <summary>
|
||||
/// Final status of the algorithm
|
||||
/// </summary>
|
||||
public AlgorithmStatus AlgorithmStatus => AlgorithmStatus.Completed;
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate what the expected statistics are from running the algorithm
|
||||
@@ -108,7 +113,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Total Orders", "20"},
|
||||
{"Average Win", "0%"},
|
||||
{"Average Loss", "0%"},
|
||||
{"Compounding Annual Return", "386219349.202%"},
|
||||
{"Compounding Annual Return", "88398927.578%"},
|
||||
{"Drawdown", "5.200%"},
|
||||
{"Expectancy", "0"},
|
||||
{"Start Equity", "100000"},
|
||||
@@ -129,9 +134,10 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Treynor Ratio", "68696.045"},
|
||||
{"Total Fees", "$35.70"},
|
||||
{"Estimated Strategy Capacity", "$2600000.00"},
|
||||
{"Lowest Capacity Asset", "ES 31C3JQS9D84PW|ES XCZJLC9NOB29"},
|
||||
{"Lowest Capacity Asset", "ES 31C3JQS9DCF1G|ES XCZJLC9NOB29"},
|
||||
{"Portfolio Turnover", "495.15%"},
|
||||
{"OrderListHash", "85257286f088992d599c1ad0799a6237"}
|
||||
{"Drawdown Recovery", "0"},
|
||||
{"OrderListHash", "af830085995d0b8fa0d33a6e80dd1241"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,145 @@
|
||||
/*
|
||||
* QUANTCONNECT.COM - Democratizing Finance, Empowering Individuals.
|
||||
* Lean Algorithmic Trading Engine v2.0. Copyright 2014 QuantConnect Corporation.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using QuantConnect.Data.UniverseSelection;
|
||||
using QuantConnect.Interfaces;
|
||||
using QuantConnect.Securities;
|
||||
using QuantConnect.Securities.Future;
|
||||
using QuantConnect.Securities.Option;
|
||||
|
||||
namespace QuantConnect.Algorithm.CSharp
|
||||
{
|
||||
/// <summary>
|
||||
/// Algorithm asserting AddFutureOptionContract does not throw even when the underlying security configurations are internal
|
||||
/// </summary>
|
||||
public class AddFutureOptionContractWithInternalMappedUnderlyingRegressionAlgorithm : QCAlgorithm, IRegressionAlgorithmDefinition
|
||||
{
|
||||
private Future _continuousContract;
|
||||
private Option _fopContract;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
SetStartDate(2020, 01, 04);
|
||||
SetEndDate(2020, 01 , 06);
|
||||
|
||||
_continuousContract = AddFuture(Futures.Indices.SP500EMini,
|
||||
dataNormalizationMode: DataNormalizationMode.BackwardsRatio,
|
||||
dataMappingMode: DataMappingMode.LastTradingDay,
|
||||
contractDepthOffset: 0);
|
||||
}
|
||||
|
||||
public override void OnSecuritiesChanged(SecurityChanges changes)
|
||||
{
|
||||
if (changes.AddedSecurities.Any(security => security.Symbol == _continuousContract.Symbol))
|
||||
{
|
||||
if (SubscriptionManager.SubscriptionDataConfigService.GetSubscriptionDataConfigs(_continuousContract.Mapped).Count != 0 ||
|
||||
SubscriptionManager.SubscriptionDataConfigService.GetSubscriptionDataConfigs(_continuousContract.Mapped, includeInternalConfigs: true).Count == 0)
|
||||
{
|
||||
throw new RegressionTestException("Continuous future underlying should only have internal subscription configs");
|
||||
}
|
||||
|
||||
var contract = OptionChain(_continuousContract.Mapped).FirstOrDefault()?.Symbol;
|
||||
|
||||
try
|
||||
{
|
||||
_fopContract = AddFutureOptionContract(contract);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new RegressionTestException($"Failed to add future option contract {contract}", e);
|
||||
}
|
||||
}
|
||||
else if (_fopContract != null && changes.AddedSecurities.Any(security => security.Symbol == _fopContract.Symbol))
|
||||
{
|
||||
var underlyingSubscriptions = SubscriptionManager.SubscriptionDataConfigService.GetSubscriptionDataConfigs(_fopContract.Symbol.Underlying);
|
||||
if (underlyingSubscriptions.Any(x => x.DataNormalizationMode == DataNormalizationMode.Raw))
|
||||
{
|
||||
throw new RegressionTestException("Future option underlying should not have raw data normalization mode");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnEndOfAlgorithm()
|
||||
{
|
||||
if (_fopContract == null)
|
||||
{
|
||||
throw new RegressionTestException("Failed to add future option contract");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate if the open source Lean repository has the required data to run this algorithm.
|
||||
/// </summary>
|
||||
public bool CanRunLocally { get; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate which languages this algorithm is written in.
|
||||
/// </summary>
|
||||
public List<Language> Languages { get; } = new() { Language.CSharp };
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of all timeslices of algorithm
|
||||
/// </summary>
|
||||
public long DataPoints => 3181;
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of the algorithm history
|
||||
/// </summary>
|
||||
public int AlgorithmHistoryDataPoints => 1;
|
||||
|
||||
/// <summary>
|
||||
/// Final status of the algorithm
|
||||
/// </summary>
|
||||
public AlgorithmStatus AlgorithmStatus => AlgorithmStatus.Completed;
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate what the expected statistics are from running the algorithm
|
||||
/// </summary>
|
||||
public Dictionary<string, string> ExpectedStatistics => new Dictionary<string, string>
|
||||
{
|
||||
{"Total Orders", "0"},
|
||||
{"Average Win", "0%"},
|
||||
{"Average Loss", "0%"},
|
||||
{"Compounding Annual Return", "0%"},
|
||||
{"Drawdown", "0%"},
|
||||
{"Expectancy", "0"},
|
||||
{"Start Equity", "100000"},
|
||||
{"End Equity", "100000"},
|
||||
{"Net Profit", "0%"},
|
||||
{"Sharpe Ratio", "0"},
|
||||
{"Sortino Ratio", "0"},
|
||||
{"Probabilistic Sharpe Ratio", "0%"},
|
||||
{"Loss Rate", "0%"},
|
||||
{"Win Rate", "0%"},
|
||||
{"Profit-Loss Ratio", "0"},
|
||||
{"Alpha", "0"},
|
||||
{"Beta", "0"},
|
||||
{"Annual Standard Deviation", "0"},
|
||||
{"Annual Variance", "0"},
|
||||
{"Information Ratio", "-14.395"},
|
||||
{"Tracking Error", "0.043"},
|
||||
{"Treynor Ratio", "0"},
|
||||
{"Total Fees", "$0.00"},
|
||||
{"Estimated Strategy Capacity", "$0"},
|
||||
{"Lowest Capacity Asset", ""},
|
||||
{"Portfolio Turnover", "0%"},
|
||||
{"Drawdown Recovery", "0"},
|
||||
{"OrderListHash", "d41d8cd98f00b204e9800998ecf8427e"}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -55,10 +55,10 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{
|
||||
_optionFilterRan = true;
|
||||
|
||||
var expiry = new HashSet<DateTime>(optionContracts.Select(x => x.Underlying.ID.Date)).SingleOrDefault();
|
||||
// Cast to IEnumerable<Symbol> because OptionFilterContract overrides some LINQ operators like `Select` and `Where`
|
||||
var expiry = new HashSet<DateTime>(optionContracts.Select(x => x.Symbol.Underlying.ID.Date)).SingleOrDefault();
|
||||
// Cast to List<Symbol> because OptionFilterContract overrides some LINQ operators like `Select` and `Where`
|
||||
// and cause it to mutate the underlying Symbol collection when using those operators.
|
||||
var symbol = new HashSet<Symbol>(((IEnumerable<Symbol>)optionContracts).Select(x => x.Underlying)).SingleOrDefault();
|
||||
var symbol = new HashSet<Symbol>(((List<Symbol>)optionContracts).Select(x => x.Underlying)).SingleOrDefault();
|
||||
|
||||
if (expiry == null || symbol == null)
|
||||
{
|
||||
@@ -75,9 +75,9 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
});
|
||||
}
|
||||
|
||||
public override void OnData(Slice data)
|
||||
public override void OnData(Slice slice)
|
||||
{
|
||||
if (!data.HasData)
|
||||
if (!slice.HasData)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -85,7 +85,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
_onDataReached = true;
|
||||
|
||||
var hasOptionQuoteBars = false;
|
||||
foreach (var qb in data.QuoteBars.Values)
|
||||
foreach (var qb in slice.QuoteBars.Values)
|
||||
{
|
||||
if (qb.Symbol.SecurityType != SecurityType.FutureOption)
|
||||
{
|
||||
@@ -108,7 +108,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (var chain in data.OptionChains.Values)
|
||||
foreach (var chain in slice.OptionChains.Values.OrderBy(x => x.Symbol.Underlying.ID.Date))
|
||||
{
|
||||
var futureInvested = false;
|
||||
var optionInvested = false;
|
||||
@@ -122,7 +122,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
|
||||
var future = option.Underlying;
|
||||
|
||||
if (!optionInvested && data.ContainsKey(option))
|
||||
if (!optionInvested && slice.ContainsKey(option))
|
||||
{
|
||||
var optionContract = Securities[option];
|
||||
var marginModel = optionContract.BuyingPowerModel as FuturesOptionsMarginModel;
|
||||
@@ -131,16 +131,16 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
|| marginModel.MaintenanceIntradayMarginRequirement == 0
|
||||
|| marginModel.MaintenanceOvernightMarginRequirement == 0)
|
||||
{
|
||||
throw new Exception("Unexpected margin requirements");
|
||||
throw new RegressionTestException("Unexpected margin requirements");
|
||||
}
|
||||
|
||||
if (marginModel.GetInitialMarginRequirement(optionContract, 1) == 0)
|
||||
{
|
||||
throw new Exception("Unexpected Initial Margin requirement");
|
||||
throw new RegressionTestException("Unexpected Initial Margin requirement");
|
||||
}
|
||||
if (marginModel.GetMaintenanceMargin(optionContract) != 0)
|
||||
{
|
||||
throw new Exception("Unexpected Maintenance Margin requirement");
|
||||
throw new RegressionTestException("Unexpected Maintenance Margin requirement");
|
||||
}
|
||||
|
||||
MarketOrder(option, 1);
|
||||
@@ -149,10 +149,10 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
|
||||
if (marginModel.GetMaintenanceMargin(optionContract) == 0)
|
||||
{
|
||||
throw new Exception("Unexpected Maintenance Margin requirement");
|
||||
throw new RegressionTestException("Unexpected Maintenance Margin requirement");
|
||||
}
|
||||
}
|
||||
if (!futureInvested && data.ContainsKey(future))
|
||||
if (!futureInvested && slice.ContainsKey(future))
|
||||
{
|
||||
MarketOrder(future, 1);
|
||||
_invested = true;
|
||||
@@ -170,7 +170,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
}
|
||||
if (!_onDataReached)
|
||||
{
|
||||
throw new Exception("OnData() was never called.");
|
||||
throw new RegressionTestException("OnData() was never called.");
|
||||
}
|
||||
if (_symbolsReceived.Count != _expectedSymbolsReceived.Count)
|
||||
{
|
||||
@@ -188,7 +188,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
|
||||
if (missingSymbols.Count > 0)
|
||||
{
|
||||
throw new Exception($"Symbols: \"{string.Join(", ", missingSymbols)}\" were not found in OnData");
|
||||
throw new RegressionTestException($"Symbols: \"{string.Join(", ", missingSymbols)}\" were not found in OnData");
|
||||
}
|
||||
|
||||
foreach (var expectedSymbol in _expectedSymbolsReceived)
|
||||
@@ -202,7 +202,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
|
||||
if (nonDupeDataCount < 1000)
|
||||
{
|
||||
throw new Exception($"Received too few data points. Expected >=1000, found {nonDupeDataCount} for {expectedSymbol}");
|
||||
throw new RegressionTestException($"Received too few data points. Expected >=1000, found {nonDupeDataCount} for {expectedSymbol}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -215,18 +215,23 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate which languages this algorithm is written in.
|
||||
/// </summary>
|
||||
public Language[] Languages { get; } = { Language.CSharp, Language.Python };
|
||||
public List<Language> Languages { get; } = new() { Language.CSharp, Language.Python };
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of all timeslices of algorithm
|
||||
/// </summary>
|
||||
public long DataPoints => 608378;
|
||||
public long DataPoints => 319494;
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of the algorithm history
|
||||
/// </summary>
|
||||
public int AlgorithmHistoryDataPoints => 0;
|
||||
|
||||
/// <summary>
|
||||
/// Final status of the algorithm
|
||||
/// </summary>
|
||||
public AlgorithmStatus AlgorithmStatus => AlgorithmStatus.Completed;
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate what the expected statistics are from running the algorithm
|
||||
/// </summary>
|
||||
@@ -235,30 +240,31 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Total Orders", "2"},
|
||||
{"Average Win", "0%"},
|
||||
{"Average Loss", "0%"},
|
||||
{"Compounding Annual Return", "347.065%"},
|
||||
{"Drawdown", "0.900%"},
|
||||
{"Compounding Annual Return", "430.834%"},
|
||||
{"Drawdown", "4.200%"},
|
||||
{"Expectancy", "0"},
|
||||
{"Start Equity", "100000"},
|
||||
{"End Equity", "101950.53"},
|
||||
{"Net Profit", "1.951%"},
|
||||
{"Sharpe Ratio", "15.402"},
|
||||
{"End Equity", "102313.03"},
|
||||
{"Net Profit", "2.313%"},
|
||||
{"Sharpe Ratio", "17.721"},
|
||||
{"Sortino Ratio", "0"},
|
||||
{"Probabilistic Sharpe Ratio", "95.977%"},
|
||||
{"Loss Rate", "0%"},
|
||||
{"Win Rate", "0%"},
|
||||
{"Profit-Loss Ratio", "0"},
|
||||
{"Alpha", "1.886"},
|
||||
{"Beta", "1.066"},
|
||||
{"Annual Standard Deviation", "0.155"},
|
||||
{"Annual Variance", "0.024"},
|
||||
{"Information Ratio", "13.528"},
|
||||
{"Tracking Error", "0.142"},
|
||||
{"Treynor Ratio", "2.237"},
|
||||
{"Alpha", "2.663"},
|
||||
{"Beta", "1.264"},
|
||||
{"Annual Standard Deviation", "0.184"},
|
||||
{"Annual Variance", "0.034"},
|
||||
{"Information Ratio", "16.514"},
|
||||
{"Tracking Error", "0.169"},
|
||||
{"Treynor Ratio", "2.574"},
|
||||
{"Total Fees", "$3.57"},
|
||||
{"Estimated Strategy Capacity", "$760000.00"},
|
||||
{"Lowest Capacity Asset", "ES XCZJLDQX2SRO|ES XCZJLC9NOB29"},
|
||||
{"Portfolio Turnover", "32.31%"},
|
||||
{"OrderListHash", "7a04f66a30d793bf187c2695781ad3ee"}
|
||||
{"Estimated Strategy Capacity", "$28000000.00"},
|
||||
{"Lowest Capacity Asset", "ES XCZJLCA62LNO|ES XCZJLC9NOB29"},
|
||||
{"Portfolio Turnover", "33.84%"},
|
||||
{"Drawdown Recovery", "0"},
|
||||
{"OrderListHash", "7c82013ecabca41591e0253a477025dd"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,131 @@
|
||||
/*
|
||||
* QUANTCONNECT.COM - Democratizing Finance, Empowering Individuals.
|
||||
* Lean Algorithmic Trading Engine v2.0. Copyright 2014 QuantConnect Corporation.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
using System.Collections.Generic;
|
||||
using QuantConnect.Algorithm.Framework.Selection;
|
||||
using QuantConnect.Interfaces;
|
||||
using System;
|
||||
using QuantConnect.Securities;
|
||||
using QuantConnect.Data.UniverseSelection;
|
||||
|
||||
namespace QuantConnect.Algorithm.CSharp
|
||||
{
|
||||
/// <summary>
|
||||
/// This example demonstrates how to use the FutureUniverseSelectionModel to select futures contracts for a given underlying asset.
|
||||
/// The model is set to update daily, and the algorithm ensures that the selected contracts meet specific criteria.
|
||||
/// This also includes a check to ensure that only future contracts are added to the algorithm's universe.
|
||||
/// </summary>
|
||||
public class AddFutureUniverseSelectionModelRegressionAlgorithm : QCAlgorithm, IRegressionAlgorithmDefinition
|
||||
{
|
||||
public override void Initialize()
|
||||
{
|
||||
SetStartDate(2013, 10, 08);
|
||||
SetEndDate(2013, 10, 10);
|
||||
|
||||
SetUniverseSelection(new FutureUniverseSelectionModel(
|
||||
TimeSpan.FromDays(1),
|
||||
time => new List<Symbol> {
|
||||
QuantConnect.Symbol.Create(Futures.Indices.SP500EMini, SecurityType.Future, Market.CME)
|
||||
}
|
||||
));
|
||||
}
|
||||
|
||||
public override void OnSecuritiesChanged(SecurityChanges changes)
|
||||
{
|
||||
if (changes.AddedSecurities.Count > 0)
|
||||
{
|
||||
foreach (var security in changes.AddedSecurities)
|
||||
{
|
||||
if (security.Symbol.SecurityType != SecurityType.Future)
|
||||
{
|
||||
throw new RegressionTestException($"Expected future security, but found '{security.Symbol.SecurityType}'");
|
||||
}
|
||||
if (security.Symbol.ID.Symbol != "ES")
|
||||
{
|
||||
throw new RegressionTestException($"Expected future symbol 'ES', but found '{security.Symbol.ID.Symbol}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnEndOfAlgorithm()
|
||||
{
|
||||
if (ActiveSecurities.Count == 0)
|
||||
{
|
||||
throw new RegressionTestException("No active securities found. Expected at least one active security");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate if the open source Lean repository has the required data to run this algorithm.
|
||||
/// </summary>
|
||||
public bool CanRunLocally { get; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate which languages this algorithm is written in.
|
||||
/// </summary>
|
||||
public List<Language> Languages { get; } = new() { Language.CSharp, Language.Python };
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of all timeslices of algorithm
|
||||
/// </summary>
|
||||
public long DataPoints => 26094;
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of the algorithm history
|
||||
/// </summary>
|
||||
public int AlgorithmHistoryDataPoints => 0;
|
||||
|
||||
/// <summary>
|
||||
/// Final status of the algorithm
|
||||
/// </summary>
|
||||
public AlgorithmStatus AlgorithmStatus => AlgorithmStatus.Completed;
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate what the expected statistics are from running the algorithm
|
||||
/// </summary>
|
||||
public Dictionary<string, string> ExpectedStatistics => new Dictionary<string, string>
|
||||
{
|
||||
{"Total Orders", "0"},
|
||||
{"Average Win", "0%"},
|
||||
{"Average Loss", "0%"},
|
||||
{"Compounding Annual Return", "0%"},
|
||||
{"Drawdown", "0%"},
|
||||
{"Expectancy", "0"},
|
||||
{"Start Equity", "100000"},
|
||||
{"End Equity", "100000"},
|
||||
{"Net Profit", "0%"},
|
||||
{"Sharpe Ratio", "0"},
|
||||
{"Sortino Ratio", "0"},
|
||||
{"Probabilistic Sharpe Ratio", "0%"},
|
||||
{"Loss Rate", "0%"},
|
||||
{"Win Rate", "0%"},
|
||||
{"Profit-Loss Ratio", "0"},
|
||||
{"Alpha", "0"},
|
||||
{"Beta", "0"},
|
||||
{"Annual Standard Deviation", "0"},
|
||||
{"Annual Variance", "0"},
|
||||
{"Information Ratio", "-66.775"},
|
||||
{"Tracking Error", "0.243"},
|
||||
{"Treynor Ratio", "0"},
|
||||
{"Total Fees", "$0.00"},
|
||||
{"Estimated Strategy Capacity", "$0"},
|
||||
{"Lowest Capacity Asset", ""},
|
||||
{"Portfolio Turnover", "0%"},
|
||||
{"Drawdown Recovery", "0"},
|
||||
{"OrderListHash", "d41d8cd98f00b204e9800998ecf8427e"}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -42,12 +42,12 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
AddUniverse("my-daily-universe-name", time => new List<string> { "AAPL" });
|
||||
}
|
||||
|
||||
public override void OnData(Slice data)
|
||||
public override void OnData(Slice slice)
|
||||
{
|
||||
if (_option == null)
|
||||
{
|
||||
var option = OptionChainProvider.GetOptionContractList(_twx, Time)
|
||||
.OrderBy(symbol => symbol.ID.Symbol)
|
||||
var option = OptionChain(_twx)
|
||||
.OrderBy(x => x.ID.Symbol)
|
||||
.FirstOrDefault(optionContract => optionContract.ID.Date == _expiration
|
||||
&& optionContract.ID.OptionRight == OptionRight.Call
|
||||
&& optionContract.ID.OptionStyle == OptionStyle.American);
|
||||
@@ -68,11 +68,11 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
|
||||
if (!config.Any())
|
||||
{
|
||||
throw new Exception($"Was expecting configurations for {symbol}");
|
||||
throw new RegressionTestException($"Was expecting configurations for {symbol}");
|
||||
}
|
||||
if (config.Any(dataConfig => dataConfig.DataNormalizationMode != DataNormalizationMode.Raw))
|
||||
{
|
||||
throw new Exception($"Was expecting DataNormalizationMode.Raw configurations for {symbol}");
|
||||
throw new RegressionTestException($"Was expecting DataNormalizationMode.Raw configurations for {symbol}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -81,14 +81,14 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{
|
||||
if (SubscriptionManager.SubscriptionDataConfigService.GetSubscriptionDataConfigs(_option).Any())
|
||||
{
|
||||
throw new Exception($"Unexpected configurations for {_option} after it has been delisted");
|
||||
throw new RegressionTestException($"Unexpected configurations for {_option} after it has been delisted");
|
||||
}
|
||||
|
||||
if (Securities[_twx].Invested)
|
||||
{
|
||||
if (!SubscriptionManager.SubscriptionDataConfigService.GetSubscriptionDataConfigs(_twx).Any())
|
||||
{
|
||||
throw new Exception($"Was expecting configurations for {_twx}");
|
||||
throw new RegressionTestException($"Was expecting configurations for {_twx}");
|
||||
}
|
||||
|
||||
// first we liquidate the option exercised position
|
||||
@@ -99,7 +99,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{
|
||||
if (SubscriptionManager.SubscriptionDataConfigService.GetSubscriptionDataConfigs(_twx).Any())
|
||||
{
|
||||
throw new Exception($"Unexpected configurations for {_twx} after it has been liquidated");
|
||||
throw new RegressionTestException($"Unexpected configurations for {_twx} after it has been liquidated");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -112,17 +112,22 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate which languages this algorithm is written in.
|
||||
/// </summary>
|
||||
public Language[] Languages { get; } = { Language.CSharp, Language.Python };
|
||||
public List<Language> Languages { get; } = new() { Language.CSharp, Language.Python };
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of all timeslices of algorithm
|
||||
/// </summary>
|
||||
public long DataPoints => 37597;
|
||||
public long DataPoints => 37598;
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of the algorithm history
|
||||
/// </summary>
|
||||
public int AlgorithmHistoryDataPoints => 0;
|
||||
public int AlgorithmHistoryDataPoints => 1;
|
||||
|
||||
/// <summary>
|
||||
/// Final status of the algorithm
|
||||
/// </summary>
|
||||
public AlgorithmStatus AlgorithmStatus => AlgorithmStatus.Completed;
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate what the expected statistics are from running the algorithm
|
||||
@@ -153,9 +158,10 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Treynor Ratio", "2.01"},
|
||||
{"Total Fees", "$2.00"},
|
||||
{"Estimated Strategy Capacity", "$5700000.00"},
|
||||
{"Lowest Capacity Asset", "AOL VRKS95ENLBYE|AOL R735QTJ8XC9X"},
|
||||
{"Lowest Capacity Asset", "AOL VRKS95ENPM9Y|AOL R735QTJ8XC9X"},
|
||||
{"Portfolio Turnover", "0.55%"},
|
||||
{"OrderListHash", "24191a4a3bf11c07622a21266618193d"}
|
||||
{"Drawdown Recovery", "0"},
|
||||
{"OrderListHash", "d314aef81752b6583fd58f9e49054cd4"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,12 +13,12 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using QuantConnect.Data;
|
||||
using QuantConnect.Data.UniverseSelection;
|
||||
using QuantConnect.Interfaces;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace QuantConnect.Algorithm.CSharp
|
||||
{
|
||||
@@ -50,7 +50,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
enumerable => new[] { Time.Date <= new DateTime(2014, 6, 5) ? _twx : _aapl });
|
||||
}
|
||||
|
||||
public override void OnData(Slice data)
|
||||
public override void OnData(Slice slice)
|
||||
{
|
||||
if (_option != null && Securities[_option].Price != 0 && !_traded)
|
||||
{
|
||||
@@ -66,7 +66,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
// assert underlying still there after the universe selection removed it, still used by the manually added option contract
|
||||
if (!configs.Any())
|
||||
{
|
||||
throw new Exception($"Was expecting configurations for {_twx}" +
|
||||
throw new RegressionTestException($"Was expecting configurations for {_twx}" +
|
||||
$" even after it has been deselected from coarse universe because we still have the option contract.");
|
||||
}
|
||||
}
|
||||
@@ -83,7 +83,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
var configs = SubscriptionManager.SubscriptionDataConfigService.GetSubscriptionDataConfigs(symbol);
|
||||
if (configs.Any())
|
||||
{
|
||||
throw new Exception($"Unexpected configuration for {symbol} after it has been deselected from coarse universe and option contract is removed.");
|
||||
throw new RegressionTestException($"Unexpected configuration for {symbol} after it has been deselected from coarse universe and option contract is removed.");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -94,11 +94,11 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{
|
||||
if (_securityChanges.RemovedSecurities.Intersect(changes.RemovedSecurities).Any())
|
||||
{
|
||||
throw new Exception($"SecurityChanges.RemovedSecurities intersect {changes.RemovedSecurities}. We expect no duplicate!");
|
||||
throw new RegressionTestException($"SecurityChanges.RemovedSecurities intersect {changes.RemovedSecurities}. We expect no duplicate!");
|
||||
}
|
||||
if (_securityChanges.AddedSecurities.Intersect(changes.AddedSecurities).Any())
|
||||
{
|
||||
throw new Exception($"SecurityChanges.AddedSecurities intersect {changes.RemovedSecurities}. We expect no duplicate!");
|
||||
throw new RegressionTestException($"SecurityChanges.AddedSecurities intersect {changes.RemovedSecurities}. We expect no duplicate!");
|
||||
}
|
||||
// keep track of all removed and added securities
|
||||
_securityChanges += changes;
|
||||
@@ -110,24 +110,24 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
|
||||
foreach (var addedSecurity in changes.AddedSecurities)
|
||||
{
|
||||
var option = OptionChainProvider.GetOptionContractList(addedSecurity.Symbol, Time)
|
||||
.OrderBy(symbol => symbol.ID.Symbol)
|
||||
var option = OptionChain(addedSecurity.Symbol)
|
||||
.OrderBy(contractData => contractData.ID.Symbol)
|
||||
.First(optionContract => optionContract.ID.Date == _expiration
|
||||
&& optionContract.ID.OptionRight == OptionRight.Call
|
||||
&& optionContract.ID.OptionStyle == OptionStyle.American);
|
||||
AddOptionContract(option);
|
||||
|
||||
foreach (var symbol in new[] { option, option.Underlying })
|
||||
foreach (var symbol in new[] { option.Symbol, option.UnderlyingSymbol })
|
||||
{
|
||||
var config = SubscriptionManager.SubscriptionDataConfigService.GetSubscriptionDataConfigs(symbol).ToList();
|
||||
|
||||
if (!config.Any())
|
||||
{
|
||||
throw new Exception($"Was expecting configurations for {symbol}");
|
||||
throw new RegressionTestException($"Was expecting configurations for {symbol}");
|
||||
}
|
||||
if (config.Any(dataConfig => dataConfig.DataNormalizationMode != DataNormalizationMode.Raw))
|
||||
{
|
||||
throw new Exception($"Was expecting DataNormalizationMode.Raw configurations for {symbol}");
|
||||
throw new RegressionTestException($"Was expecting DataNormalizationMode.Raw configurations for {symbol}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -143,16 +143,16 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{
|
||||
if (SubscriptionManager.Subscriptions.Any(dataConfig => dataConfig.Symbol == _twx || dataConfig.Symbol.Underlying == _twx))
|
||||
{
|
||||
throw new Exception($"Was NOT expecting any configurations for {_twx} or it's options, since we removed the contract");
|
||||
throw new RegressionTestException($"Was NOT expecting any configurations for {_twx} or it's options, since we removed the contract");
|
||||
}
|
||||
|
||||
if (SubscriptionManager.Subscriptions.All(dataConfig => dataConfig.Symbol != _aapl))
|
||||
{
|
||||
throw new Exception($"Was expecting configurations for {_aapl}");
|
||||
throw new RegressionTestException($"Was expecting configurations for {_aapl}");
|
||||
}
|
||||
if (SubscriptionManager.Subscriptions.All(dataConfig => dataConfig.Symbol.Underlying != _aapl))
|
||||
{
|
||||
throw new Exception($"Was expecting options configurations for {_aapl}");
|
||||
throw new RegressionTestException($"Was expecting options configurations for {_aapl}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -164,17 +164,22 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate which languages this algorithm is written in.
|
||||
/// </summary>
|
||||
public Language[] Languages { get; } = { Language.CSharp, Language.Python };
|
||||
public List<Language> Languages { get; } = new() { Language.CSharp, Language.Python };
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of all timeslices of algorithm
|
||||
/// </summary>
|
||||
public long DataPoints => 5798;
|
||||
public long DataPoints => 5800;
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of the algorithm history
|
||||
/// </summary>
|
||||
public int AlgorithmHistoryDataPoints => 0;
|
||||
public int AlgorithmHistoryDataPoints => 2;
|
||||
|
||||
/// <summary>
|
||||
/// Final status of the algorithm
|
||||
/// </summary>
|
||||
public AlgorithmStatus AlgorithmStatus => AlgorithmStatus.Completed;
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate what the expected statistics are from running the algorithm
|
||||
@@ -205,9 +210,10 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Treynor Ratio", "0.335"},
|
||||
{"Total Fees", "$2.00"},
|
||||
{"Estimated Strategy Capacity", "$2800000.00"},
|
||||
{"Lowest Capacity Asset", "AOL VRKS95ENLBYE|AOL R735QTJ8XC9X"},
|
||||
{"Lowest Capacity Asset", "AOL VRKS95ENPM9Y|AOL R735QTJ8XC9X"},
|
||||
{"Portfolio Turnover", "1.14%"},
|
||||
{"OrderListHash", "cde7b518b7ad6d86cff6e5e092d9a413"}
|
||||
{"Drawdown Recovery", "0"},
|
||||
{"OrderListHash", "e33b98d8e94ed92d0441fc6fe0d461fb"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,12 +39,12 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
UniverseSettings.MinimumTimeInUniverse = TimeSpan.Zero;
|
||||
UniverseSettings.FillForward = false;
|
||||
|
||||
AddEquity("SPY", Resolution.Daily);
|
||||
AddEquity("SPY", Resolution.Hour);
|
||||
|
||||
var aapl = QuantConnect.Symbol.Create("AAPL", SecurityType.Equity, Market.USA);
|
||||
|
||||
_contract = OptionChainProvider.GetOptionContractList(aapl, Time)
|
||||
.OrderBy(symbol => symbol.ID.Symbol)
|
||||
_contract = OptionChain(aapl)
|
||||
.OrderBy(x => x.ID.StrikePrice)
|
||||
.FirstOrDefault(optionContract => optionContract.ID.OptionRight == OptionRight.Call
|
||||
&& optionContract.ID.OptionStyle == OptionStyle.American);
|
||||
AddOptionContract(_contract);
|
||||
@@ -56,7 +56,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{
|
||||
if (!_reAdded && slice.ContainsKey(_contract) && slice.ContainsKey(_contract.Underlying))
|
||||
{
|
||||
throw new Exception("Getting data for removed option and underlying!");
|
||||
throw new RegressionTestException("Getting data for removed option and underlying!");
|
||||
}
|
||||
|
||||
if (!Portfolio.Invested && _reAdded)
|
||||
@@ -95,11 +95,11 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{
|
||||
if (!_hasRemoved)
|
||||
{
|
||||
throw new Exception("We did not remove the option contract!");
|
||||
throw new RegressionTestException("We did not remove the option contract!");
|
||||
}
|
||||
if (!_reAdded)
|
||||
{
|
||||
throw new Exception("We did not re add the option contract!");
|
||||
throw new RegressionTestException("We did not re add the option contract!");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -111,17 +111,22 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate which languages this algorithm is written in.
|
||||
/// </summary>
|
||||
public Language[] Languages { get; } = { Language.CSharp };
|
||||
public List<Language> Languages { get; } = new() { Language.CSharp };
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of all timeslices of algorithm
|
||||
/// </summary>
|
||||
public long DataPoints => 4677;
|
||||
public long DataPoints => 3818;
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of the algorithm history
|
||||
/// </summary>
|
||||
public int AlgorithmHistoryDataPoints => 0;
|
||||
public int AlgorithmHistoryDataPoints => 1;
|
||||
|
||||
/// <summary>
|
||||
/// Final status of the algorithm
|
||||
/// </summary>
|
||||
public AlgorithmStatus AlgorithmStatus => AlgorithmStatus.Completed;
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate what the expected statistics are from running the algorithm
|
||||
@@ -130,13 +135,13 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{
|
||||
{"Total Orders", "2"},
|
||||
{"Average Win", "0%"},
|
||||
{"Average Loss", "-0.05%"},
|
||||
{"Compounding Annual Return", "-4.548%"},
|
||||
{"Drawdown", "0.100%"},
|
||||
{"Average Loss", "-0.50%"},
|
||||
{"Compounding Annual Return", "-39.406%"},
|
||||
{"Drawdown", "0.700%"},
|
||||
{"Expectancy", "-1"},
|
||||
{"Start Equity", "100000"},
|
||||
{"End Equity", "99949"},
|
||||
{"Net Profit", "-0.051%"},
|
||||
{"End Equity", "99498"},
|
||||
{"Net Profit", "-0.502%"},
|
||||
{"Sharpe Ratio", "0"},
|
||||
{"Sortino Ratio", "0"},
|
||||
{"Probabilistic Sharpe Ratio", "0%"},
|
||||
@@ -151,10 +156,11 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0.008"},
|
||||
{"Treynor Ratio", "0"},
|
||||
{"Total Fees", "$2.00"},
|
||||
{"Estimated Strategy Capacity", "$30000.00"},
|
||||
{"Lowest Capacity Asset", "AAPL VXBK4Q9ZIFD2|AAPL R735QTJ8XC9X"},
|
||||
{"Portfolio Turnover", "0.07%"},
|
||||
{"OrderListHash", "c763192f852f447453941500d362dbf1"}
|
||||
{"Estimated Strategy Capacity", "$5000000.00"},
|
||||
{"Lowest Capacity Asset", "AAPL VXBK4R62H7S6|AAPL R735QTJ8XC9X"},
|
||||
{"Portfolio Turnover", "22.70%"},
|
||||
{"Drawdown Recovery", "0"},
|
||||
{"OrderListHash", "71511e4929377cd55fbf5e7e9555c248"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,146 @@
|
||||
/*
|
||||
* QUANTCONNECT.COM - Democratizing Finance, Empowering Individuals.
|
||||
* Lean Algorithmic Trading Engine v2.0. Copyright 2014 QuantConnect Corporation.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
using System.Collections.Generic;
|
||||
using QuantConnect.Algorithm.Framework.Selection;
|
||||
using QuantConnect.Interfaces;
|
||||
using System;
|
||||
using QuantConnect.Data.UniverseSelection;
|
||||
|
||||
namespace QuantConnect.Algorithm.CSharp
|
||||
{
|
||||
/// <summary>
|
||||
/// This example demonstrates how to use the OptionUniverseSelectionModel to select options contracts based on specified conditions.
|
||||
/// The model is updated daily and selects different options based on the current date.
|
||||
/// The algorithm ensures that only valid option contracts are selected for the universe.
|
||||
/// </summary>
|
||||
public class AddOptionUniverseSelectionModelRegressionAlgorithm : QCAlgorithm, IRegressionAlgorithmDefinition
|
||||
{
|
||||
private int _optionCount;
|
||||
public override void Initialize()
|
||||
{
|
||||
SetStartDate(2014, 06, 05);
|
||||
SetEndDate(2014, 06, 06);
|
||||
|
||||
UniverseSettings.Resolution = Resolution.Minute;
|
||||
SetUniverseSelection(new OptionUniverseSelectionModel(
|
||||
TimeSpan.FromDays(1),
|
||||
SelectOptionChainSymbols
|
||||
));
|
||||
}
|
||||
|
||||
private static IEnumerable<Symbol> SelectOptionChainSymbols(DateTime utcTime)
|
||||
{
|
||||
var newYorkTime = utcTime.ConvertFromUtc(TimeZones.NewYork);
|
||||
if (newYorkTime.Date < new DateTime(2014, 06, 06))
|
||||
{
|
||||
yield return QuantConnect.Symbol.Create("TWX", SecurityType.Option, Market.USA);
|
||||
}
|
||||
|
||||
if (newYorkTime.Date >= new DateTime(2014, 06, 06))
|
||||
{
|
||||
yield return QuantConnect.Symbol.Create("AAPL", SecurityType.Option, Market.USA);
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnSecuritiesChanged(SecurityChanges changes)
|
||||
{
|
||||
if (changes.AddedSecurities.Count > 0)
|
||||
{
|
||||
foreach (var security in changes.AddedSecurities)
|
||||
{
|
||||
var symbol = security.Symbol.Underlying == null ? security.Symbol : security.Symbol.Underlying;
|
||||
if (symbol != "AAPL" && symbol != "TWX")
|
||||
{
|
||||
throw new RegressionTestException($"Unexpected security {security.Symbol}");
|
||||
}
|
||||
_optionCount += (security.Symbol.SecurityType == SecurityType.Option) ? 1 : 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnEndOfAlgorithm()
|
||||
{
|
||||
if (ActiveSecurities.Count == 0)
|
||||
{
|
||||
throw new RegressionTestException("No active securities found. Expected at least one active security");
|
||||
}
|
||||
if (_optionCount == 0)
|
||||
{
|
||||
throw new RegressionTestException("The option count should be greater than 0");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate if the open source Lean repository has the required data to run this algorithm.
|
||||
/// </summary>
|
||||
public bool CanRunLocally { get; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate which languages this algorithm is written in.
|
||||
/// </summary>
|
||||
public List<Language> Languages { get; } = new() { Language.CSharp, Language.Python };
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of all timeslices of algorithm
|
||||
/// </summary>
|
||||
public long DataPoints => 2349547;
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of the algorithm history
|
||||
/// </summary>
|
||||
public int AlgorithmHistoryDataPoints => 0;
|
||||
|
||||
/// <summary>
|
||||
/// Final status of the algorithm
|
||||
/// </summary>
|
||||
public AlgorithmStatus AlgorithmStatus => AlgorithmStatus.Completed;
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate what the expected statistics are from running the algorithm
|
||||
/// </summary>
|
||||
public Dictionary<string, string> ExpectedStatistics => new Dictionary<string, string>
|
||||
{
|
||||
{"Total Orders", "0"},
|
||||
{"Average Win", "0%"},
|
||||
{"Average Loss", "0%"},
|
||||
{"Compounding Annual Return", "0%"},
|
||||
{"Drawdown", "0%"},
|
||||
{"Expectancy", "0"},
|
||||
{"Start Equity", "100000"},
|
||||
{"End Equity", "100000"},
|
||||
{"Net Profit", "0%"},
|
||||
{"Sharpe Ratio", "0"},
|
||||
{"Sortino Ratio", "0"},
|
||||
{"Probabilistic Sharpe Ratio", "0%"},
|
||||
{"Loss Rate", "0%"},
|
||||
{"Win Rate", "0%"},
|
||||
{"Profit-Loss Ratio", "0"},
|
||||
{"Alpha", "0"},
|
||||
{"Beta", "0"},
|
||||
{"Annual Standard Deviation", "0"},
|
||||
{"Annual Variance", "0"},
|
||||
{"Information Ratio", "0"},
|
||||
{"Tracking Error", "0"},
|
||||
{"Treynor Ratio", "0"},
|
||||
{"Total Fees", "$0.00"},
|
||||
{"Estimated Strategy Capacity", "$0"},
|
||||
{"Lowest Capacity Asset", ""},
|
||||
{"Portfolio Turnover", "0%"},
|
||||
{"Drawdown Recovery", "0"},
|
||||
{"OrderListHash", "d41d8cd98f00b204e9800998ecf8427e"}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -13,7 +13,6 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using QuantConnect.Data.UniverseSelection;
|
||||
@@ -59,19 +58,9 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
var changeOptions = changes.AddedSecurities.Concat(changes.RemovedSecurities)
|
||||
.Where(s => s.Type == SecurityType.Option);
|
||||
|
||||
// Susbtract one minute to get the actual market open. If market open is at 9:30am, this will be invoked at 9:31am
|
||||
var expectedTime = Time.TimeOfDay - TimeSpan.FromMinutes(1);
|
||||
var allOptionsWereChangedOnMarketOpen = changeOptions.All(s =>
|
||||
if (Time != Time.Date)
|
||||
{
|
||||
var firstMarketSegment = s.Exchange.Hours.MarketHours[Time.DayOfWeek].Segments
|
||||
.First(segment => segment.State == MarketHoursState.Market);
|
||||
|
||||
return firstMarketSegment.Start == expectedTime;
|
||||
});
|
||||
|
||||
if (!allOptionsWereChangedOnMarketOpen)
|
||||
{
|
||||
throw new Exception("Expected options filter to be run only on market open");
|
||||
throw new RegressionTestException($"Expected options filter to be run only at midnight. Actual was {Time}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,18 +72,23 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate which languages this algorithm is written in.
|
||||
/// </summary>
|
||||
public Language[] Languages { get; } = { Language.CSharp };
|
||||
public List<Language> Languages { get; } = new() { Language.CSharp };
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of all time slices of algorithm
|
||||
/// </summary>
|
||||
public long DataPoints => 5952220;
|
||||
public long DataPoints => 470217;
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of the algorithm history
|
||||
/// </summary>
|
||||
public int AlgorithmHistoryDataPoints => 0;
|
||||
|
||||
/// <summary>
|
||||
/// Final status of the algorithm
|
||||
/// </summary>
|
||||
public AlgorithmStatus AlgorithmStatus => AlgorithmStatus.Completed;
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate what the expected statistics are from running the algorithm
|
||||
/// </summary>
|
||||
@@ -126,6 +120,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Estimated Strategy Capacity", "$0"},
|
||||
{"Lowest Capacity Asset", ""},
|
||||
{"Portfolio Turnover", "0%"},
|
||||
{"Drawdown Recovery", "0"},
|
||||
{"OrderListHash", "d41d8cd98f00b204e9800998ecf8427e"}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -29,20 +29,21 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
public class AddRemoveOptionUniverseRegressionAlgorithm : QCAlgorithm, IRegressionAlgorithmDefinition
|
||||
{
|
||||
private const string UnderlyingTicker = "GOOG";
|
||||
public readonly Symbol Underlying = QuantConnect.Symbol.Create(UnderlyingTicker, SecurityType.Equity, Market.USA);
|
||||
public readonly Symbol OptionChainSymbol = QuantConnect.Symbol.Create(UnderlyingTicker, SecurityType.Option, Market.USA);
|
||||
private readonly Symbol Underlying = QuantConnect.Symbol.Create(UnderlyingTicker, SecurityType.Equity, Market.USA);
|
||||
private readonly Symbol OptionChainSymbol = QuantConnect.Symbol.Create(UnderlyingTicker, SecurityType.Option, Market.USA);
|
||||
private readonly HashSet<Symbol> _expectedSecurities = new HashSet<Symbol>();
|
||||
private readonly HashSet<Symbol> _expectedData = new HashSet<Symbol>();
|
||||
private readonly HashSet<Symbol> _expectedUniverses = new HashSet<Symbol>();
|
||||
private bool _expectUniverseSubscription;
|
||||
private DateTime _universeSubscriptionTime;
|
||||
|
||||
// order of expected contract additions as price moves
|
||||
private int _expectedContractIndex;
|
||||
private readonly List<Symbol> _expectedContracts = new List<Symbol>
|
||||
{
|
||||
SymbolRepresentation.ParseOptionTickerOSI("GOOG 151224P00747500"),
|
||||
SymbolRepresentation.ParseOptionTickerOSI("GOOG 151224P00750000"),
|
||||
SymbolRepresentation.ParseOptionTickerOSI("GOOG 151224P00752500")
|
||||
SymbolRepresentation.ParseOptionTickerOSI("GOOG 151224P00752500"),
|
||||
SymbolRepresentation.ParseOptionTickerOSI("GOOG 151224P00755000")
|
||||
};
|
||||
|
||||
public override void Initialize()
|
||||
@@ -59,16 +60,16 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
_expectedUniverses.Add(UserDefinedUniverse.CreateSymbol(SecurityType.Equity, Market.USA));
|
||||
}
|
||||
|
||||
public override void OnData(Slice data)
|
||||
public override void OnData(Slice slice)
|
||||
{
|
||||
// verify expectations
|
||||
if (SubscriptionManager.Subscriptions.Count(x => x.Symbol == OptionChainSymbol)
|
||||
!= (_expectUniverseSubscription ? 1 : 0))
|
||||
{
|
||||
Log($"SubscriptionManager.Subscriptions: {string.Join(" -- ", SubscriptionManager.Subscriptions)}");
|
||||
throw new Exception($"Unexpected {OptionChainSymbol} subscription presence");
|
||||
throw new RegressionTestException($"Unexpected {OptionChainSymbol} subscription presence");
|
||||
}
|
||||
if (!data.ContainsKey(Underlying))
|
||||
if (Time != _universeSubscriptionTime && !slice.ContainsKey(Underlying))
|
||||
{
|
||||
// TODO : In fact, we're unable to properly detect whether or not we auto-added or it was manually added
|
||||
// this is because when we auto-add the underlying we don't mark it as an internal security like we do with other auto adds
|
||||
@@ -77,42 +78,42 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
// of the internal flag's purpose, so kicking this issue for now with a big fat note here about it :) to be considerd for any future
|
||||
// refactorings of how we manage subscription/security data and track various aspects about the security (thinking a flags enum with
|
||||
// things like manually added, auto added, internal, and any other boolean state we need to track against a single security)
|
||||
throw new Exception("The underlying equity data should NEVER be removed in this algorithm because it was manually added");
|
||||
throw new RegressionTestException("The underlying equity data should NEVER be removed in this algorithm because it was manually added");
|
||||
}
|
||||
if (_expectedSecurities.AreDifferent(Securities.Total.Select(x => x.Symbol).ToHashSet()))
|
||||
{
|
||||
var expected = string.Join(Environment.NewLine, _expectedSecurities.OrderBy(s => s.ToString()));
|
||||
var actual = string.Join(Environment.NewLine, Securities.Keys.OrderBy(s => s.ToString()));
|
||||
throw new Exception($"{Time}:: Detected differences in expected and actual securities{Environment.NewLine}Expected:{Environment.NewLine}{expected}{Environment.NewLine}Actual:{Environment.NewLine}{actual}");
|
||||
throw new RegressionTestException($"{Time}:: Detected differences in expected and actual securities{Environment.NewLine}Expected:{Environment.NewLine}{expected}{Environment.NewLine}Actual:{Environment.NewLine}{actual}");
|
||||
}
|
||||
if (_expectedUniverses.AreDifferent(UniverseManager.Keys.ToHashSet()))
|
||||
{
|
||||
var expected = string.Join(Environment.NewLine, _expectedUniverses.OrderBy(s => s.ToString()));
|
||||
var actual = string.Join(Environment.NewLine, UniverseManager.Keys.OrderBy(s => s.ToString()));
|
||||
throw new Exception($"{Time}:: Detected differences in expected and actual universes{Environment.NewLine}Expected:{Environment.NewLine}{expected}{Environment.NewLine}Actual:{Environment.NewLine}{actual}");
|
||||
throw new RegressionTestException($"{Time}:: Detected differences in expected and actual universes{Environment.NewLine}Expected:{Environment.NewLine}{expected}{Environment.NewLine}Actual:{Environment.NewLine}{actual}");
|
||||
}
|
||||
if (_expectedData.AreDifferent(data.Keys.ToHashSet()))
|
||||
if (Time != _universeSubscriptionTime && _expectedData.AreDifferent(slice.Keys.ToHashSet()))
|
||||
{
|
||||
var expected = string.Join(Environment.NewLine, _expectedData.OrderBy(s => s.ToString()));
|
||||
var actual = string.Join(Environment.NewLine, data.Keys.OrderBy(s => s.ToString()));
|
||||
throw new Exception($"{Time}:: Detected differences in expected and actual slice data keys{Environment.NewLine}Expected:{Environment.NewLine}{expected}{Environment.NewLine}Actual:{Environment.NewLine}{actual}");
|
||||
var actual = string.Join(Environment.NewLine, slice.Keys.OrderBy(s => s.ToString()));
|
||||
throw new RegressionTestException($"{Time}:: Detected differences in expected and actual slice data keys{Environment.NewLine}Expected:{Environment.NewLine}{expected}{Environment.NewLine}Actual:{Environment.NewLine}{actual}");
|
||||
}
|
||||
|
||||
// 10AM add GOOG option chain
|
||||
if (Time.TimeOfDay.Hours == 10 && Time.TimeOfDay.Minutes == 0)
|
||||
if (Time.TimeOfDay.Hours == 10 && Time.TimeOfDay.Minutes == 0 && !_expectUniverseSubscription)
|
||||
{
|
||||
if (Securities.ContainsKey(OptionChainSymbol))
|
||||
{
|
||||
throw new Exception("The option chain security should not have been added yet");
|
||||
throw new RegressionTestException("The option chain security should not have been added yet");
|
||||
}
|
||||
|
||||
var googOptionChain = AddOption(UnderlyingTicker);
|
||||
googOptionChain.SetFilter(u =>
|
||||
{
|
||||
// we added the universe at 10, the universe selection data should not be from before
|
||||
if (u.Underlying.EndTime.Hour < 10)
|
||||
if (u.LocalTime.Hour < 10)
|
||||
{
|
||||
throw new Exception($"Unexpected underlying data point {u.Underlying.EndTime} {u.Underlying}");
|
||||
throw new RegressionTestException($"Unexpected selection time {u.LocalTime}");
|
||||
}
|
||||
// find first put above market price
|
||||
return u.IncludeWeeklys()
|
||||
@@ -124,6 +125,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
_expectedSecurities.Add(OptionChainSymbol);
|
||||
_expectedUniverses.Add(OptionChainSymbol);
|
||||
_expectUniverseSubscription = true;
|
||||
_universeSubscriptionTime = Time;
|
||||
}
|
||||
|
||||
// 11:30AM remove GOOG option chain
|
||||
@@ -151,7 +153,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
var expectedContract = _expectedContracts[_expectedContractIndex];
|
||||
if (added.Symbol != expectedContract)
|
||||
{
|
||||
throw new Exception($"Expected option contract {expectedContract} to be added but received {added.Symbol}");
|
||||
throw new RegressionTestException($"Expected option contract {expectedContract.Value} to be added but received {added.Symbol}");
|
||||
}
|
||||
|
||||
_expectedContractIndex++;
|
||||
@@ -172,7 +174,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
// receive removed event next timestep at 11:31AM
|
||||
if (Time.TimeOfDay.Hours != 11 || Time.TimeOfDay.Minutes != 31)
|
||||
{
|
||||
throw new Exception($"Expected option contracts to be removed at 11:31AM, instead removed at: {Time}");
|
||||
throw new RegressionTestException($"Expected option contracts to be removed at 11:31AM, instead removed at: {Time}");
|
||||
}
|
||||
|
||||
if (changes.RemovedSecurities
|
||||
@@ -180,13 +182,13 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
.ToHashSet(s => s.Symbol)
|
||||
.AreDifferent(_expectedContracts.ToHashSet()))
|
||||
{
|
||||
throw new Exception("Expected removed securities to equal expected contracts added");
|
||||
throw new RegressionTestException("Expected removed securities to equal expected contracts added");
|
||||
}
|
||||
}
|
||||
|
||||
if (Securities.ContainsKey(Underlying))
|
||||
{
|
||||
Console.WriteLine($"{Time:o}:: PRICE:: {Securities[Underlying].Price} CHANGES:: {changes}");
|
||||
Log($"{Time:o}:: PRICE:: {Securities[Underlying].Price} CHANGES:: {changes}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -198,18 +200,23 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate which languages this algorithm is written in.
|
||||
/// </summary>
|
||||
public Language[] Languages { get; } = { Language.CSharp };
|
||||
public List<Language> Languages { get; } = new() { Language.CSharp };
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of all timeslices of algorithm
|
||||
/// </summary>
|
||||
public long DataPoints => 200807;
|
||||
public long DataPoints => 3502;
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of the algorithm history
|
||||
/// </summary>
|
||||
public int AlgorithmHistoryDataPoints => 0;
|
||||
|
||||
/// <summary>
|
||||
/// Final status of the algorithm
|
||||
/// </summary>
|
||||
public AlgorithmStatus AlgorithmStatus => AlgorithmStatus.Completed;
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate what the expected statistics are from running the algorithm
|
||||
/// </summary>
|
||||
@@ -222,7 +229,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Drawdown", "0%"},
|
||||
{"Expectancy", "0"},
|
||||
{"Start Equity", "100000"},
|
||||
{"End Equity", "99079"},
|
||||
{"End Equity", "98784"},
|
||||
{"Net Profit", "0%"},
|
||||
{"Sharpe Ratio", "0"},
|
||||
{"Sortino Ratio", "0"},
|
||||
@@ -238,10 +245,11 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0"},
|
||||
{"Treynor Ratio", "0"},
|
||||
{"Total Fees", "$6.00"},
|
||||
{"Estimated Strategy Capacity", "$3000.00"},
|
||||
{"Lowest Capacity Asset", "GOOCV 305RBR0BSWIX2|GOOCV VP83T1ZUHROL"},
|
||||
{"Portfolio Turnover", "1.49%"},
|
||||
{"OrderListHash", "bd115ec8bb7734b1561d6a6cc6c00039"}
|
||||
{"Estimated Strategy Capacity", "$4000.00"},
|
||||
{"Lowest Capacity Asset", "GOOCV 305RBQ2BZGA4M|GOOCV VP83T1ZUHROL"},
|
||||
{"Portfolio Turnover", "2.58%"},
|
||||
{"Drawdown Recovery", "0"},
|
||||
{"OrderListHash", "f418de0673fc166487daf80991dfe3a0"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,8 +41,8 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// OnData event is the primary entry point for your algorithm. Each new data point will be pumped in here.
|
||||
/// </summary>
|
||||
/// <param name="data">Slice object keyed by symbol containing the stock data</param>
|
||||
public override void OnData(Slice data)
|
||||
/// <param name="slice">Slice object keyed by symbol containing the stock data</param>
|
||||
public override void OnData(Slice slice)
|
||||
{
|
||||
if (!Portfolio.Invested)
|
||||
{
|
||||
@@ -59,9 +59,9 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
|
||||
var ticket = MarketOrder("AIG", 1);
|
||||
|
||||
if (ticket.Status != OrderStatus.Invalid)
|
||||
if (ticket.Status != OrderStatus.Invalid || aig.HasData || aig.Price != 0)
|
||||
{
|
||||
throw new Exception("Expected order to always be invalid because there is no data yet!");
|
||||
throw new RegressionTestException("Expected order to always be invalid because there is no data yet!");
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -78,18 +78,23 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate which languages this algorithm is written in.
|
||||
/// </summary>
|
||||
public Language[] Languages { get; } = { Language.CSharp };
|
||||
public List<Language> Languages { get; } = new() { Language.CSharp };
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of all timeslices of algorithm
|
||||
/// </summary>
|
||||
public long DataPoints => 11202;
|
||||
public long DataPoints => 15042;
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of the algorithm history
|
||||
/// </summary>
|
||||
public int AlgorithmHistoryDataPoints => 0;
|
||||
|
||||
/// <summary>
|
||||
/// Final status of the algorithm
|
||||
/// </summary>
|
||||
public AlgorithmStatus AlgorithmStatus => AlgorithmStatus.Completed;
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate what the expected statistics are from running the algorithm
|
||||
/// </summary>
|
||||
@@ -121,6 +126,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Estimated Strategy Capacity", "$830000.00"},
|
||||
{"Lowest Capacity Asset", "SPY R735QTJ8XC9X"},
|
||||
{"Portfolio Turnover", "20.49%"},
|
||||
{"Drawdown Recovery", "2"},
|
||||
{"OrderListHash", "6ebe462373e2ecc22de8eb2fe114d704"}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// OnData event is the primary entry point for your algorithm. Each new data point will be pumped in here.
|
||||
/// </summary>
|
||||
/// <param name="data">Slice object keyed by symbol containing the stock data</param>
|
||||
public override void OnData(Slice data)
|
||||
public override void OnData(Slice slice)
|
||||
{
|
||||
if (lastAction.Date == Time.Date) return;
|
||||
|
||||
@@ -105,18 +105,23 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate which languages this algorithm is written in.
|
||||
/// </summary>
|
||||
public Language[] Languages { get; } = { Language.CSharp, Language.Python };
|
||||
public List<Language> Languages { get; } = new() { Language.CSharp, Language.Python };
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of all timeslices of algorithm
|
||||
/// </summary>
|
||||
public long DataPoints => 7063;
|
||||
public long DataPoints => 7065;
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of the algorithm history
|
||||
/// </summary>
|
||||
public int AlgorithmHistoryDataPoints => 0;
|
||||
|
||||
/// <summary>
|
||||
/// Final status of the algorithm
|
||||
/// </summary>
|
||||
public AlgorithmStatus AlgorithmStatus => AlgorithmStatus.Completed;
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate what the expected statistics are from running the algorithm
|
||||
/// </summary>
|
||||
@@ -148,7 +153,8 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Estimated Strategy Capacity", "$4700000.00"},
|
||||
{"Lowest Capacity Asset", "AIG R735QTJ8XC9X"},
|
||||
{"Portfolio Turnover", "29.88%"},
|
||||
{"OrderListHash", "6061ecfbb89eb365dff913410d279b7c"}
|
||||
{"Drawdown Recovery", "2"},
|
||||
{"OrderListHash", "f04b3521256c7d6740966bc3df34e7b1"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate which languages this algorithm is written in.
|
||||
/// </summary>
|
||||
public Language[] Languages { get; } = { Language.CSharp, Language.Python };
|
||||
public List<Language> Languages { get; } = new() { Language.CSharp, Language.Python };
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of all timeslices of algorithm
|
||||
@@ -69,6 +69,11 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// </summary>
|
||||
public int AlgorithmHistoryDataPoints => 0;
|
||||
|
||||
/// <summary>
|
||||
/// Final status of the algorithm
|
||||
/// </summary>
|
||||
public AlgorithmStatus AlgorithmStatus => AlgorithmStatus.Completed;
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate what the expected statistics are from running the algorithm
|
||||
/// </summary>
|
||||
@@ -100,6 +105,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Estimated Strategy Capacity", "$38000000.00"},
|
||||
{"Lowest Capacity Asset", "SPY R735QTJ8XC9X"},
|
||||
{"Portfolio Turnover", "59.74%"},
|
||||
{"Drawdown Recovery", "3"},
|
||||
{"OrderListHash", "5d7657ec9954875eca633bed711085d3"}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -41,8 +41,8 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
|
||||
var aapl = QuantConnect.Symbol.Create("AAPL", SecurityType.Equity, Market.USA);
|
||||
|
||||
var contracts = OptionChainProvider.GetOptionContractList(aapl, Time)
|
||||
.OrderBy(symbol => symbol.ID.Symbol)
|
||||
var contracts = OptionChain(aapl)
|
||||
.OrderBy(x => x.ID.StrikePrice)
|
||||
.Where(optionContract => optionContract.ID.OptionRight == OptionRight.Call
|
||||
&& optionContract.ID.OptionStyle == OptionStyle.American)
|
||||
.Take(2)
|
||||
@@ -69,7 +69,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
SubscriptionManager.SubscriptionDataConfigService.GetSubscriptionDataConfigs("AAPL");
|
||||
if (subscriptions.Count == 0)
|
||||
{
|
||||
throw new Exception("No configuration for underlying was found!");
|
||||
throw new RegressionTestException("No configuration for underlying was found!");
|
||||
}
|
||||
|
||||
if (!Portfolio.Invested)
|
||||
@@ -84,7 +84,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{
|
||||
if (!_hasRemoved)
|
||||
{
|
||||
throw new Exception("Expect a single call to OnData where we removed the option and underlying");
|
||||
throw new RegressionTestException("Expect a single call to OnData where we removed the option and underlying");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,17 +96,22 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate which languages this algorithm is written in.
|
||||
/// </summary>
|
||||
public Language[] Languages { get; } = { Language.CSharp };
|
||||
public List<Language> Languages { get; } = new() { Language.CSharp };
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of all timeslices of algorithm
|
||||
/// </summary>
|
||||
public long DataPoints => 1578;
|
||||
public long DataPoints => 1579;
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of the algorithm history
|
||||
/// </summary>
|
||||
public int AlgorithmHistoryDataPoints => 0;
|
||||
public int AlgorithmHistoryDataPoints => 1;
|
||||
|
||||
/// <summary>
|
||||
/// Final status of the algorithm
|
||||
/// </summary>
|
||||
public AlgorithmStatus AlgorithmStatus => AlgorithmStatus.Completed;
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate what the expected statistics are from running the algorithm
|
||||
@@ -120,7 +125,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Drawdown", "0%"},
|
||||
{"Expectancy", "0"},
|
||||
{"Start Equity", "100000"},
|
||||
{"End Equity", "99930"},
|
||||
{"End Equity", "99238"},
|
||||
{"Net Profit", "0%"},
|
||||
{"Sharpe Ratio", "0"},
|
||||
{"Sortino Ratio", "0"},
|
||||
@@ -136,10 +141,11 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0"},
|
||||
{"Treynor Ratio", "0"},
|
||||
{"Total Fees", "$2.00"},
|
||||
{"Estimated Strategy Capacity", "$230000.00"},
|
||||
{"Lowest Capacity Asset", "AAPL VXBK4QQIRLZA|AAPL R735QTJ8XC9X"},
|
||||
{"Portfolio Turnover", "0.25%"},
|
||||
{"OrderListHash", "5906f39bc46c238374cb8c7245dd66f8"}
|
||||
{"Estimated Strategy Capacity", "$6200000.00"},
|
||||
{"Lowest Capacity Asset", "AAPL VXBK4QA5IWKM|AAPL R735QTJ8XC9X"},
|
||||
{"Portfolio Turnover", "90.27%"},
|
||||
{"Drawdown Recovery", "0"},
|
||||
{"OrderListHash", "a332b93ff5e2dfe89258c450a64c7125"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,14 +57,14 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{
|
||||
if (UniverseManager.Count != 3)
|
||||
{
|
||||
throw new Exception("Unexpected universe count");
|
||||
throw new RegressionTestException("Unexpected universe count");
|
||||
}
|
||||
if (UniverseManager.ActiveSecurities.Count != 3
|
||||
|| UniverseManager.ActiveSecurities.Keys.All(symbol => symbol.Value != "SPY")
|
||||
|| UniverseManager.ActiveSecurities.Keys.All(symbol => symbol.Value != "AAPL")
|
||||
|| UniverseManager.ActiveSecurities.Keys.All(symbol => symbol.Value != "FB"))
|
||||
{
|
||||
throw new Exception("Unexpected active securities");
|
||||
throw new RegressionTestException("Unexpected active securities");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,50 +76,56 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate which languages this algorithm is written in.
|
||||
/// </summary>
|
||||
public Language[] Languages { get; } = { Language.CSharp, Language.Python };
|
||||
public List<Language> Languages { get; } = new() { Language.CSharp, Language.Python };
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of all timeslices of algorithm
|
||||
/// </summary>
|
||||
public long DataPoints => 53;
|
||||
public long DataPoints => 50;
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of the algorithm history
|
||||
/// </summary>
|
||||
public int AlgorithmHistoryDataPoints => 0;
|
||||
|
||||
/// <summary>
|
||||
/// Final status of the algorithm
|
||||
/// </summary>
|
||||
public AlgorithmStatus AlgorithmStatus => AlgorithmStatus.Completed;
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate what the expected statistics are from running the algorithm
|
||||
/// </summary>
|
||||
public Dictionary<string, string> ExpectedStatistics => new Dictionary<string, string>
|
||||
{
|
||||
{"Total Orders", "10"},
|
||||
{"Average Win", "0%"},
|
||||
{"Average Loss", "-0.01%"},
|
||||
{"Compounding Annual Return", "-14.233%"},
|
||||
{"Drawdown", "3.300%"},
|
||||
{"Expectancy", "-1"},
|
||||
{"Total Orders", "6"},
|
||||
{"Average Win", "0.01%"},
|
||||
{"Average Loss", "0%"},
|
||||
{"Compounding Annual Return", "1296.838%"},
|
||||
{"Drawdown", "0.400%"},
|
||||
{"Expectancy", "0"},
|
||||
{"Start Equity", "100000"},
|
||||
{"End Equity", "99831.88"},
|
||||
{"Net Profit", "-0.168%"},
|
||||
{"Sharpe Ratio", "62.464"},
|
||||
{"End Equity", "102684.23"},
|
||||
{"Net Profit", "2.684%"},
|
||||
{"Sharpe Ratio", "34.319"},
|
||||
{"Sortino Ratio", "0"},
|
||||
{"Probabilistic Sharpe Ratio", "0%"},
|
||||
{"Loss Rate", "100%"},
|
||||
{"Win Rate", "0%"},
|
||||
{"Loss Rate", "0%"},
|
||||
{"Win Rate", "100%"},
|
||||
{"Profit-Loss Ratio", "0"},
|
||||
{"Alpha", "1.117"},
|
||||
{"Beta", "1.19"},
|
||||
{"Annual Standard Deviation", "0.213"},
|
||||
{"Annual Variance", "0.046"},
|
||||
{"Information Ratio", "70.778"},
|
||||
{"Tracking Error", "0.043"},
|
||||
{"Treynor Ratio", "11.2"},
|
||||
{"Total Fees", "$22.21"},
|
||||
{"Estimated Strategy Capacity", "$340000000.00"},
|
||||
{"Alpha", "-5.738"},
|
||||
{"Beta", "1.381"},
|
||||
{"Annual Standard Deviation", "0.246"},
|
||||
{"Annual Variance", "0.06"},
|
||||
{"Information Ratio", "-26.937"},
|
||||
{"Tracking Error", "0.068"},
|
||||
{"Treynor Ratio", "6.106"},
|
||||
{"Total Fees", "$18.61"},
|
||||
{"Estimated Strategy Capacity", "$980000000.00"},
|
||||
{"Lowest Capacity Asset", "FB V6OIPNZEM8V9"},
|
||||
{"Portfolio Turnover", "26.92%"},
|
||||
{"OrderListHash", "3832790c7dd9d50805b6206129b01110"}
|
||||
{"Portfolio Turnover", "25.56%"},
|
||||
{"Drawdown Recovery", "1"},
|
||||
{"OrderListHash", "5ee20c8556d706ab0a63ae41b6579c62"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,14 +68,14 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{
|
||||
if (UniverseManager.Count != 3)
|
||||
{
|
||||
throw new Exception("Unexpected universe count");
|
||||
throw new RegressionTestException("Unexpected universe count");
|
||||
}
|
||||
if (UniverseManager.ActiveSecurities.Count != 3
|
||||
|| UniverseManager.ActiveSecurities.Keys.All(symbol => symbol.Value != "SPY")
|
||||
|| UniverseManager.ActiveSecurities.Keys.All(symbol => symbol.Value != "AAPL")
|
||||
|| UniverseManager.ActiveSecurities.Keys.All(symbol => symbol.Value != "FB"))
|
||||
{
|
||||
throw new Exception("Unexpected active securities");
|
||||
throw new RegressionTestException("Unexpected active securities");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -87,50 +87,56 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate which languages this algorithm is written in.
|
||||
/// </summary>
|
||||
public Language[] Languages { get; } = { Language.CSharp };
|
||||
public List<Language> Languages { get; } = new() { Language.CSharp };
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of all timeslices of algorithm
|
||||
/// </summary>
|
||||
public long DataPoints => 234018;
|
||||
public long DataPoints => 234015;
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of the algorithm history
|
||||
/// </summary>
|
||||
public int AlgorithmHistoryDataPoints => 0;
|
||||
|
||||
/// <summary>
|
||||
/// Final status of the algorithm
|
||||
/// </summary>
|
||||
public AlgorithmStatus AlgorithmStatus => AlgorithmStatus.Completed;
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate what the expected statistics are from running the algorithm
|
||||
/// </summary>
|
||||
public Dictionary<string, string> ExpectedStatistics => new Dictionary<string, string>
|
||||
{
|
||||
{"Total Orders", "23"},
|
||||
{"Average Win", "0.00%"},
|
||||
{"Total Orders", "21"},
|
||||
{"Average Win", "0.01%"},
|
||||
{"Average Loss", "-0.01%"},
|
||||
{"Compounding Annual Return", "-75.275%"},
|
||||
{"Drawdown", "5.800%"},
|
||||
{"Expectancy", "-0.609"},
|
||||
{"Compounding Annual Return", "-77.566%"},
|
||||
{"Drawdown", "6.000%"},
|
||||
{"Expectancy", "-0.811"},
|
||||
{"Start Equity", "100000"},
|
||||
{"End Equity", "94419.21"},
|
||||
{"Net Profit", "-5.581%"},
|
||||
{"Sharpe Ratio", "-3.288"},
|
||||
{"Sortino Ratio", "-3.828"},
|
||||
{"Probabilistic Sharpe Ratio", "5.546%"},
|
||||
{"Loss Rate", "73%"},
|
||||
{"Win Rate", "27%"},
|
||||
{"Profit-Loss Ratio", "0.43"},
|
||||
{"Alpha", "-0.495"},
|
||||
{"Beta", "1.484"},
|
||||
{"Annual Standard Deviation", "0.196"},
|
||||
{"Annual Variance", "0.039"},
|
||||
{"Information Ratio", "-3.843"},
|
||||
{"Tracking Error", "0.141"},
|
||||
{"Treynor Ratio", "-0.435"},
|
||||
{"Total Fees", "$31.25"},
|
||||
{"Estimated Strategy Capacity", "$550000000.00"},
|
||||
{"End Equity", "94042.73"},
|
||||
{"Net Profit", "-5.957%"},
|
||||
{"Sharpe Ratio", "-3.345"},
|
||||
{"Sortino Ratio", "-3.766"},
|
||||
{"Probabilistic Sharpe Ratio", "4.557%"},
|
||||
{"Loss Rate", "89%"},
|
||||
{"Win Rate", "11%"},
|
||||
{"Profit-Loss Ratio", "0.70"},
|
||||
{"Alpha", "-0.519"},
|
||||
{"Beta", "1.491"},
|
||||
{"Annual Standard Deviation", "0.2"},
|
||||
{"Annual Variance", "0.04"},
|
||||
{"Information Ratio", "-3.878"},
|
||||
{"Tracking Error", "0.147"},
|
||||
{"Treynor Ratio", "-0.449"},
|
||||
{"Total Fees", "$29.11"},
|
||||
{"Estimated Strategy Capacity", "$680000000.00"},
|
||||
{"Lowest Capacity Asset", "AAPL R735QTJ8XC9X"},
|
||||
{"Portfolio Turnover", "7.33%"},
|
||||
{"OrderListHash", "2add92a1f922c6730d8c20ff65934a46"}
|
||||
{"Portfolio Turnover", "7.48%"},
|
||||
{"Drawdown Recovery", "0"},
|
||||
{"OrderListHash", "2c814c55e7d7c56482411c065b861b33"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,21 +63,21 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// OnData event is the primary entry point for your algorithm. Each new data point will be pumped in here.
|
||||
/// </summary>
|
||||
/// <param name="data">Slice object keyed by symbol containing the stock data</param>
|
||||
public override void OnData(Slice data)
|
||||
public override void OnData(Slice slice)
|
||||
{
|
||||
if (!Portfolio.Invested)
|
||||
{
|
||||
SetHoldings(_aapl, 1);
|
||||
}
|
||||
|
||||
if (data.Splits.ContainsKey(_aapl))
|
||||
if (slice.Splits.ContainsKey(_aapl))
|
||||
{
|
||||
Log(data.Splits[_aapl].ToString());
|
||||
Log(slice.Splits[_aapl].ToString());
|
||||
}
|
||||
|
||||
if (data.Bars.ContainsKey(_aapl))
|
||||
if (slice.Bars.ContainsKey(_aapl))
|
||||
{
|
||||
var aaplData = data.Bars[_aapl];
|
||||
var aaplData = slice.Bars[_aapl];
|
||||
|
||||
// Assert our volume matches what we expect
|
||||
if (_expectedAdjustedVolume.MoveNext() && _expectedAdjustedVolume.Current != aaplData.Volume)
|
||||
@@ -99,9 +99,9 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
}
|
||||
}
|
||||
|
||||
if (data.QuoteBars.ContainsKey(_aapl))
|
||||
if (slice.QuoteBars.ContainsKey(_aapl))
|
||||
{
|
||||
var aaplQuoteData = data.QuoteBars[_aapl];
|
||||
var aaplQuoteData = slice.QuoteBars[_aapl];
|
||||
|
||||
// Assert our askSize matches what we expect
|
||||
if (_expectedAdjustedAskSize.MoveNext() && _expectedAdjustedAskSize.Current != aaplQuoteData.LastAskSize)
|
||||
@@ -151,7 +151,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate which languages this algorithm is written in.
|
||||
/// </summary>
|
||||
public Language[] Languages { get; } = { Language.CSharp };
|
||||
public List<Language> Languages { get; } = new() { Language.CSharp };
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of all timeslices of algorithm
|
||||
@@ -163,6 +163,11 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// </summary>
|
||||
public int AlgorithmHistoryDataPoints => 0;
|
||||
|
||||
/// <summary>
|
||||
/// Final status of the algorithm
|
||||
/// </summary>
|
||||
public AlgorithmStatus AlgorithmStatus => AlgorithmStatus.Completed;
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate what the expected statistics are from running the algorithm
|
||||
/// </summary>
|
||||
@@ -194,6 +199,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Estimated Strategy Capacity", "$42000000.00"},
|
||||
{"Lowest Capacity Asset", "AAPL R735QTJ8XC9X"},
|
||||
{"Portfolio Turnover", "99.56%"},
|
||||
{"Drawdown Recovery", "0"},
|
||||
{"OrderListHash", "60f03c8c589a4f814dc4e8945df23207"}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -34,25 +34,25 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
|
||||
if (AlgorithmMode != AlgorithmMode.Backtesting)
|
||||
{
|
||||
throw new Exception($"Algorithm mode is not backtesting. Actual: {AlgorithmMode}");
|
||||
throw new RegressionTestException($"Algorithm mode is not backtesting. Actual: {AlgorithmMode}");
|
||||
}
|
||||
|
||||
if (LiveMode)
|
||||
{
|
||||
throw new Exception("Algorithm should not be live");
|
||||
throw new RegressionTestException("Algorithm should not be live");
|
||||
}
|
||||
|
||||
if (DeploymentTarget != DeploymentTarget.LocalPlatform)
|
||||
{
|
||||
throw new Exception($"Algorithm deployment target is not local. Actual{DeploymentTarget}");
|
||||
throw new RegressionTestException($"Algorithm deployment target is not local. Actual{DeploymentTarget}");
|
||||
}
|
||||
|
||||
// For a live deployment these checks should pass:
|
||||
//if (AlgorithmMode != AlgorithmMode.Live) throw new Exception("Algorithm mode is not live");
|
||||
//if (!LiveMode) throw new Exception("Algorithm should be live");
|
||||
//if (AlgorithmMode != AlgorithmMode.Live) throw new RegressionTestException("Algorithm mode is not live");
|
||||
//if (!LiveMode) throw new RegressionTestException("Algorithm should be live");
|
||||
|
||||
// For a cloud deployment these checks should pass:
|
||||
//if (DeploymentTarget != DeploymentTarget.CloudPlatform) throw new Exception("Algorithm deployment target is not cloud");
|
||||
//if (DeploymentTarget != DeploymentTarget.CloudPlatform) throw new RegressionTestException("Algorithm deployment target is not cloud");
|
||||
|
||||
Quit();
|
||||
}
|
||||
@@ -65,7 +65,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate which languages this algorithm is written in.
|
||||
/// </summary>
|
||||
public Language[] Languages { get; } = { Language.CSharp, Language.Python };
|
||||
public List<Language> Languages { get; } = new() { Language.CSharp, Language.Python };
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of all timeslices of algorithm
|
||||
@@ -77,6 +77,11 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// </summary>
|
||||
public int AlgorithmHistoryDataPoints => 0;
|
||||
|
||||
/// <summary>
|
||||
/// Final status of the algorithm
|
||||
/// </summary>
|
||||
public AlgorithmStatus AlgorithmStatus => AlgorithmStatus.Completed;
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate what the expected statistics are from running the algorithm
|
||||
/// </summary>
|
||||
@@ -108,6 +113,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Estimated Strategy Capacity", "$0"},
|
||||
{"Lowest Capacity Asset", ""},
|
||||
{"Portfolio Turnover", "0%"},
|
||||
{"Drawdown Recovery", "0"},
|
||||
{"OrderListHash", "d41d8cd98f00b204e9800998ecf8427e"}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -100,7 +100,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
SetBrokerageModel(new AllShortableSymbolsRegressionAlgorithmBrokerageModel());
|
||||
}
|
||||
|
||||
public override void OnData(Slice data)
|
||||
public override void OnData(Slice slice)
|
||||
{
|
||||
if (Time.Date == _lastTradeDate)
|
||||
{
|
||||
@@ -112,7 +112,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
var shortableQuantity = security.ShortableProvider.ShortableQuantity(symbol, Time);
|
||||
if (shortableQuantity == null)
|
||||
{
|
||||
throw new Exception($"Expected {symbol} to be shortable on {Time:yyyy-MM-dd}");
|
||||
throw new RegressionTestException($"Expected {symbol} to be shortable on {Time:yyyy-MM-dd}");
|
||||
}
|
||||
|
||||
// Buy at least once into all Symbols. Since daily data will always use
|
||||
@@ -137,11 +137,11 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
var gme = QuantConnect.Symbol.Create("GME", SecurityType.Equity, Market.USA);
|
||||
if (!shortableSymbols.ContainsKey(gme))
|
||||
{
|
||||
throw new Exception("Expected unmapped GME in shortable symbols list on 2014-03-27");
|
||||
throw new RegressionTestException("Expected unmapped GME in shortable symbols list on 2014-03-27");
|
||||
}
|
||||
if (!coarse.Select(x => x.Symbol.Value).Contains("GME"))
|
||||
{
|
||||
throw new Exception("Expected mapped GME in coarse symbols on 2014-03-27");
|
||||
throw new RegressionTestException("Expected mapped GME in coarse symbols on 2014-03-27");
|
||||
}
|
||||
|
||||
expectedMissing = 1;
|
||||
@@ -150,7 +150,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
var missing = _expectedSymbols[Time.Date].Except(selectedSymbols).ToList();
|
||||
if (missing.Count != expectedMissing)
|
||||
{
|
||||
throw new Exception($"Expected Symbols selected on {Time.Date:yyyy-MM-dd} to match expected Symbols, but the following Symbols were missing: {string.Join(", ", missing.Select(s => s.ToString()))}");
|
||||
throw new RegressionTestException($"Expected Symbols selected on {Time.Date:yyyy-MM-dd} to match expected Symbols, but the following Symbols were missing: {string.Join(", ", missing.Select(s => s.ToString()))}");
|
||||
}
|
||||
|
||||
_coarseSelected[Time.Date] = true;
|
||||
@@ -233,50 +233,56 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate which languages this algorithm is written in.
|
||||
/// </summary>
|
||||
public Language[] Languages { get; } = { Language.CSharp, Language.Python };
|
||||
public List<Language> Languages { get; } = new() { Language.CSharp, Language.Python };
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of all timeslices of algorithm
|
||||
/// </summary>
|
||||
public long DataPoints => 37748;
|
||||
public long DataPoints => 36573;
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of the algorithm history
|
||||
/// </summary>
|
||||
public int AlgorithmHistoryDataPoints => 0;
|
||||
|
||||
/// <summary>
|
||||
/// Final status of the algorithm
|
||||
/// </summary>
|
||||
public AlgorithmStatus AlgorithmStatus => AlgorithmStatus.Completed;
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate what the expected statistics are from running the algorithm
|
||||
/// </summary>
|
||||
public Dictionary<string, string> ExpectedStatistics => new Dictionary<string, string>
|
||||
{
|
||||
{"Total Orders", "5"},
|
||||
{"Total Orders", "8"},
|
||||
{"Average Win", "0%"},
|
||||
{"Average Loss", "0%"},
|
||||
{"Compounding Annual Return", "19.147%"},
|
||||
{"Drawdown", "0%"},
|
||||
{"Compounding Annual Return", "11.027%"},
|
||||
{"Drawdown", "0.000%"},
|
||||
{"Expectancy", "0"},
|
||||
{"Start Equity", "10000000"},
|
||||
{"End Equity", "10019217.27"},
|
||||
{"Net Profit", "0.192%"},
|
||||
{"Sharpe Ratio", "15.743"},
|
||||
{"End Equity", "10011469.88"},
|
||||
{"Net Profit", "0.115%"},
|
||||
{"Sharpe Ratio", "11.963"},
|
||||
{"Sortino Ratio", "0"},
|
||||
{"Probabilistic Sharpe Ratio", "0%"},
|
||||
{"Loss Rate", "0%"},
|
||||
{"Win Rate", "0%"},
|
||||
{"Profit-Loss Ratio", "0"},
|
||||
{"Alpha", "0.17"},
|
||||
{"Beta", "0.037"},
|
||||
{"Annual Standard Deviation", "0.01"},
|
||||
{"Alpha", "0.07"},
|
||||
{"Beta", "-0.077"},
|
||||
{"Annual Standard Deviation", "0.008"},
|
||||
{"Annual Variance", "0"},
|
||||
{"Information Ratio", "5"},
|
||||
{"Tracking Error", "0.094"},
|
||||
{"Treynor Ratio", "4.278"},
|
||||
{"Total Fees", "$307.50"},
|
||||
{"Estimated Strategy Capacity", "$2600000.00"},
|
||||
{"Lowest Capacity Asset", "GOOCV VP83T1ZUHROL"},
|
||||
{"Portfolio Turnover", "10.61%"},
|
||||
{"OrderListHash", "854d4ba6a4ae39f9be2f9a10c8544fe5"}
|
||||
{"Information Ratio", "3.876"},
|
||||
{"Tracking Error", "0.105"},
|
||||
{"Treynor Ratio", "-1.215"},
|
||||
{"Total Fees", "$282.50"},
|
||||
{"Estimated Strategy Capacity", "$61000000000.00"},
|
||||
{"Lowest Capacity Asset", "NB R735QTJ8XC9X"},
|
||||
{"Portfolio Turnover", "3.62%"},
|
||||
{"Drawdown Recovery", "0"},
|
||||
{"OrderListHash", "0ea806c53bfa2bdca2504ba7155ef130"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,7 +80,7 @@ namespace QuantConnect.Algorithm.CSharp.Alphas
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate which languages this algorithm is written in.
|
||||
/// </summary>
|
||||
public Language[] Languages { get; } = { Language.CSharp, Language.Python };
|
||||
public List<Language> Languages { get; } = new() { Language.CSharp, Language.Python };
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of all timeslices of algorithm
|
||||
@@ -92,6 +92,11 @@ namespace QuantConnect.Algorithm.CSharp.Alphas
|
||||
/// </summary>
|
||||
public int AlgorithmHistoryDataPoints => 0;
|
||||
|
||||
/// <summary>
|
||||
/// Final status of the algorithm
|
||||
/// </summary>
|
||||
public AlgorithmStatus AlgorithmStatus => AlgorithmStatus.Completed;
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate what the expected statistics are from running the algorithm
|
||||
/// </summary>
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
SetStartDate(2013, 1, 07);
|
||||
SetEndDate(2013, 12, 11);
|
||||
|
||||
EnableAutomaticIndicatorWarmUp = true;
|
||||
Settings.AutomaticIndicatorWarmUp = true;
|
||||
AddEquity("SPY", Resolution.Daily);
|
||||
_arima = ARIMA("SPY", 1, 1, 1, 50);
|
||||
_ar = ARIMA("SPY", 1, 1, 0, 50);
|
||||
@@ -71,7 +71,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate which languages this algorithm is written in.
|
||||
/// </summary>
|
||||
public Language[] Languages { get; } = { Language.CSharp, Language.Python };
|
||||
public List<Language> Languages { get; } = new() { Language.CSharp, Language.Python };
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of all timeslices of algorithm
|
||||
@@ -83,38 +83,44 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// </summary>
|
||||
public int AlgorithmHistoryDataPoints => 100;
|
||||
|
||||
/// <summary>
|
||||
/// Final status of the algorithm
|
||||
/// </summary>
|
||||
public AlgorithmStatus AlgorithmStatus => AlgorithmStatus.Completed;
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate what the expected statistics are from running the algorithm
|
||||
/// </summary>
|
||||
public Dictionary<string, string> ExpectedStatistics => new Dictionary<string, string>
|
||||
{
|
||||
{"Total Orders", "52"},
|
||||
{"Total Orders", "53"},
|
||||
{"Average Win", "0.00%"},
|
||||
{"Average Loss", "0.00%"},
|
||||
{"Compounding Annual Return", "0.096%"},
|
||||
{"Compounding Annual Return", "0.076%"},
|
||||
{"Drawdown", "0.100%"},
|
||||
{"Expectancy", "3.321"},
|
||||
{"Expectancy", "2.933"},
|
||||
{"Start Equity", "100000"},
|
||||
{"End Equity", "100089.09"},
|
||||
{"Net Profit", "0.089%"},
|
||||
{"Sharpe Ratio", "-8.214"},
|
||||
{"Sortino Ratio", "-9.025"},
|
||||
{"Probabilistic Sharpe Ratio", "40.893%"},
|
||||
{"Loss Rate", "24%"},
|
||||
{"Win Rate", "76%"},
|
||||
{"Profit-Loss Ratio", "4.67"},
|
||||
{"End Equity", "100070.90"},
|
||||
{"Net Profit", "0.071%"},
|
||||
{"Sharpe Ratio", "-9.164"},
|
||||
{"Sortino Ratio", "-9.852"},
|
||||
{"Probabilistic Sharpe Ratio", "36.417%"},
|
||||
{"Loss Rate", "27%"},
|
||||
{"Win Rate", "73%"},
|
||||
{"Profit-Loss Ratio", "4.41"},
|
||||
{"Alpha", "-0.008"},
|
||||
{"Beta", "0.008"},
|
||||
{"Annual Standard Deviation", "0.001"},
|
||||
{"Annual Variance", "0"},
|
||||
{"Information Ratio", "-1.961"},
|
||||
{"Tracking Error", "0.092"},
|
||||
{"Treynor Ratio", "-0.826"},
|
||||
{"Total Fees", "$52.00"},
|
||||
{"Estimated Strategy Capacity", "$32000000000.00"},
|
||||
{"Treynor Ratio", "-0.911"},
|
||||
{"Total Fees", "$53.00"},
|
||||
{"Estimated Strategy Capacity", "$16000000000.00"},
|
||||
{"Lowest Capacity Asset", "SPY R735QTJ8XC9X"},
|
||||
{"Portfolio Turnover", "0.02%"},
|
||||
{"OrderListHash", "fab920b5fc92a6e14d8128564249fbfa"}
|
||||
{"Drawdown Recovery", "50"},
|
||||
{"OrderListHash", "685c37df6e4c49b75792c133be189094"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,12 +33,12 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
public override void Initialize()
|
||||
{
|
||||
UniverseSettings.DataNormalizationMode = DataNormalizationMode.Raw;
|
||||
EnableAutomaticIndicatorWarmUp = true;
|
||||
Settings.AutomaticIndicatorWarmUp = true;
|
||||
SetStartDate(2013, 10, 08);
|
||||
SetEndDate(2013, 10, 10);
|
||||
|
||||
var SP500 = QuantConnect.Symbol.Create(Futures.Indices.SP500EMini, SecurityType.Future, Market.CME);
|
||||
_symbol = FutureChainProvider.GetFutureContractList(SP500, StartDate).First();
|
||||
_symbol = FuturesChain(SP500).OrderBy(x => x.Symbol.ID.Date).First();
|
||||
|
||||
// Test case: custom IndicatorBase<QuoteBar> indicator using Future unsubscribed symbol
|
||||
var indicator1 = new CustomIndicator();
|
||||
@@ -82,7 +82,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
|
||||
if (!sma11.Current.Equals(sma1.Current))
|
||||
{
|
||||
throw new Exception("Expected SMAs warmed up before and after adding the Future to the algorithm to have the same current value. " +
|
||||
throw new RegressionTestException("Expected SMAs warmed up before and after adding the Future to the algorithm to have the same current value. " +
|
||||
"The result of 'WarmUpIndicator' shouldn't change if the symbol is or isn't subscribed");
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
|
||||
if (!smaSpy.Current.Equals(sma.Current))
|
||||
{
|
||||
throw new Exception("Expected SMAs warmed up before and after adding the Equity to the algorithm to have the same current value. " +
|
||||
throw new RegressionTestException("Expected SMAs warmed up before and after adding the Equity to the algorithm to have the same current value. " +
|
||||
"The result of 'WarmUpIndicator' shouldn't change if the symbol is or isn't subscribed");
|
||||
}
|
||||
}
|
||||
@@ -103,7 +103,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{
|
||||
if (indicator.IsReady != isReady)
|
||||
{
|
||||
throw new Exception($"Expected indicator state, expected {isReady} but was {indicator.IsReady}");
|
||||
throw new RegressionTestException($"Expected indicator state, expected {isReady} but was {indicator.IsReady}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -111,7 +111,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// OnData event is the primary entry point for your algorithm. Each new data point will be pumped in here.
|
||||
/// </summary>
|
||||
/// <param name="data">Slice object keyed by symbol containing the stock data</param>
|
||||
public override void OnData(Slice data)
|
||||
public override void OnData(Slice slice)
|
||||
{
|
||||
if (!Portfolio.Invested)
|
||||
{
|
||||
@@ -141,7 +141,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate which languages this algorithm is written in.
|
||||
/// </summary>
|
||||
public Language[] Languages { get; } = { Language.CSharp };
|
||||
public List<Language> Languages { get; } = new() { Language.CSharp };
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of all timeslices of algorithm
|
||||
@@ -151,7 +151,12 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// Data Points count of the algorithm history
|
||||
/// </summary>
|
||||
public int AlgorithmHistoryDataPoints => 84;
|
||||
public int AlgorithmHistoryDataPoints => 85;
|
||||
|
||||
/// <summary>
|
||||
/// Final status of the algorithm
|
||||
/// </summary>
|
||||
public AlgorithmStatus AlgorithmStatus => AlgorithmStatus.Completed;
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate what the expected statistics are from running the algorithm
|
||||
@@ -184,6 +189,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Estimated Strategy Capacity", "$200000000.00"},
|
||||
{"Lowest Capacity Asset", "ES VMKLFZIH2MTD"},
|
||||
{"Portfolio Turnover", "351.80%"},
|
||||
{"Drawdown Recovery", "1"},
|
||||
{"OrderListHash", "dfd9a280d3c6470b305c03e0b72c234e"}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -0,0 +1,127 @@
|
||||
/*
|
||||
* QUANTCONNECT.COM - Democratizing Finance, Empowering Individuals.
|
||||
* Lean Algorithmic Trading Engine v2.0. Copyright 2014 QuantConnect Corporation.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using QuantConnect.Indicators;
|
||||
using QuantConnect.Interfaces;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace QuantConnect.Algorithm.CSharp
|
||||
{
|
||||
/// <summary>
|
||||
/// Regression algorithm asserting the behavior of the AutomaticIndicatorWarmUp on option greeks
|
||||
/// </summary>
|
||||
public class AutomaticIndicatorWarmupOptionIndicatorsMirrorContractsRegressionAlgorithm : QCAlgorithm, IRegressionAlgorithmDefinition
|
||||
{
|
||||
public override void Initialize()
|
||||
{
|
||||
SetStartDate(2015, 12, 24);
|
||||
SetEndDate(2015, 12, 24);
|
||||
|
||||
Settings.AutomaticIndicatorWarmUp = true;
|
||||
|
||||
var underlying = "GOOG";
|
||||
var resolution = Resolution.Minute;
|
||||
|
||||
var expiration = new DateTime(2015, 12, 24);
|
||||
var strike = 650m;
|
||||
|
||||
var equity = AddEquity(underlying, resolution).Symbol;
|
||||
var option = QuantConnect.Symbol.CreateOption(underlying, Market.USA, OptionStyle.American, OptionRight.Put, strike, expiration);
|
||||
AddOptionContract(option, resolution);
|
||||
// add the call counter side of the mirrored pair
|
||||
var mirrorOption = QuantConnect.Symbol.CreateOption(underlying, Market.USA, OptionStyle.American, OptionRight.Call, strike, expiration);
|
||||
AddOptionContract(mirrorOption, resolution);
|
||||
|
||||
var impliedVolatility = IV(option, mirrorOption);
|
||||
var delta = D(option, mirrorOption, optionModel: OptionPricingModelType.BinomialCoxRossRubinstein, ivModel: OptionPricingModelType.BlackScholes);
|
||||
var gamma = G(option, mirrorOption, optionModel: OptionPricingModelType.ForwardTree, ivModel: OptionPricingModelType.BlackScholes);
|
||||
var vega = V(option, mirrorOption, optionModel: OptionPricingModelType.ForwardTree, ivModel: OptionPricingModelType.BlackScholes);
|
||||
var theta = T(option, mirrorOption, optionModel: OptionPricingModelType.ForwardTree, ivModel: OptionPricingModelType.BlackScholes);
|
||||
var rho = R(option, mirrorOption, optionModel: OptionPricingModelType.ForwardTree, ivModel: OptionPricingModelType.BlackScholes);
|
||||
|
||||
if (impliedVolatility == 0m || delta == 0m || gamma == 0m || vega == 0m || theta == 0m || rho == 0m)
|
||||
{
|
||||
throw new RegressionTestException("Expected IV/greeks calculated");
|
||||
}
|
||||
if (!impliedVolatility.IsReady || !delta.IsReady || !gamma.IsReady || !vega.IsReady || !theta.IsReady || !rho.IsReady)
|
||||
{
|
||||
throw new RegressionTestException("Expected IV/greeks to be ready");
|
||||
}
|
||||
|
||||
Quit($"Implied Volatility: {impliedVolatility}, Delta: {delta}, Gamma: {gamma}, Vega: {vega}, Theta: {theta}, Rho: {rho}");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate if the open source Lean repository has the required data to run this algorithm.
|
||||
/// </summary>
|
||||
public bool CanRunLocally => true;
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate which languages this algorithm is written in.
|
||||
/// </summary>
|
||||
public List<Language> Languages { get; } = new() { Language.CSharp };
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of all timeslices of algorithm
|
||||
/// </summary>
|
||||
public long DataPoints => 0;
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of the algorithm history
|
||||
/// </summary>
|
||||
public int AlgorithmHistoryDataPoints => 18;
|
||||
|
||||
/// <summary>
|
||||
/// Final status of the algorithm
|
||||
/// </summary>
|
||||
public AlgorithmStatus AlgorithmStatus => AlgorithmStatus.Completed;
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate what the expected statistics are from running the algorithm
|
||||
/// </summary>
|
||||
public Dictionary<string, string> ExpectedStatistics => new Dictionary<string, string>
|
||||
{
|
||||
{"Total Orders", "0"},
|
||||
{"Average Win", "0%"},
|
||||
{"Average Loss", "0%"},
|
||||
{"Compounding Annual Return", "0%"},
|
||||
{"Drawdown", "0%"},
|
||||
{"Expectancy", "0"},
|
||||
{"Start Equity", "100000"},
|
||||
{"End Equity", "100000"},
|
||||
{"Net Profit", "0%"},
|
||||
{"Sharpe Ratio", "0"},
|
||||
{"Sortino Ratio", "0"},
|
||||
{"Probabilistic Sharpe Ratio", "0%"},
|
||||
{"Loss Rate", "0%"},
|
||||
{"Win Rate", "0%"},
|
||||
{"Profit-Loss Ratio", "0"},
|
||||
{"Alpha", "0"},
|
||||
{"Beta", "0"},
|
||||
{"Annual Standard Deviation", "0"},
|
||||
{"Annual Variance", "0"},
|
||||
{"Information Ratio", "0"},
|
||||
{"Tracking Error", "0"},
|
||||
{"Treynor Ratio", "0"},
|
||||
{"Total Fees", "$0.00"},
|
||||
{"Estimated Strategy Capacity", "$0"},
|
||||
{"Lowest Capacity Asset", ""},
|
||||
{"Portfolio Turnover", "0%"},
|
||||
{"Drawdown Recovery", "0"},
|
||||
{"OrderListHash", "d41d8cd98f00b204e9800998ecf8427e"}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -34,14 +34,14 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
SetStartDate(2013, 10, 07);
|
||||
SetEndDate(2013, 10, 11);
|
||||
|
||||
EnableAutomaticIndicatorWarmUp = true;
|
||||
Settings.AutomaticIndicatorWarmUp = true;
|
||||
|
||||
// Test case 1
|
||||
_spy = AddEquity("SPY").Symbol;
|
||||
var sma = SMA(_spy, 10);
|
||||
if (!sma.IsReady)
|
||||
{
|
||||
throw new Exception("Expected SMA to be warmed up");
|
||||
throw new RegressionTestException("Expected SMA to be warmed up");
|
||||
}
|
||||
|
||||
// Test case 2
|
||||
@@ -50,20 +50,20 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
|
||||
if (indicator.IsReady)
|
||||
{
|
||||
throw new Exception("Expected CustomIndicator Not to be warmed up");
|
||||
throw new RegressionTestException("Expected CustomIndicator Not to be warmed up");
|
||||
}
|
||||
WarmUpIndicator(_spy, indicator);
|
||||
if (!indicator.IsReady)
|
||||
{
|
||||
throw new Exception("Expected CustomIndicator to be warmed up");
|
||||
throw new RegressionTestException("Expected CustomIndicator to be warmed up");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// OnData event is the primary entry point for your algorithm. Each new data point will be pumped in here.
|
||||
/// </summary>
|
||||
/// <param name="data">Slice object keyed by symbol containing the stock data</param>
|
||||
public override void OnData(Slice data)
|
||||
/// <param name="slice">Slice object keyed by symbol containing the stock data</param>
|
||||
public override void OnData(Slice slice)
|
||||
{
|
||||
if (!Portfolio.Invested)
|
||||
{
|
||||
@@ -72,7 +72,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
// we expect 1 consolidator per indicator
|
||||
if (subscription.Consolidators.Count != 2)
|
||||
{
|
||||
throw new Exception($"Unexpected consolidator count for subscription: {subscription.Consolidators.Count}");
|
||||
throw new RegressionTestException($"Unexpected consolidator count for subscription: {subscription.Consolidators.Count}");
|
||||
}
|
||||
SetHoldings(_spy, 1);
|
||||
}
|
||||
@@ -88,7 +88,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{
|
||||
if (_previous != null && input.EndTime == _previous.EndTime)
|
||||
{
|
||||
throw new Exception($"Unexpected indicator double data point call: {_previous}");
|
||||
throw new RegressionTestException($"Unexpected indicator double data point call: {_previous}");
|
||||
}
|
||||
_previous = input;
|
||||
return base.ComputeNextValue(window, input);
|
||||
@@ -103,7 +103,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate which languages this algorithm is written in.
|
||||
/// </summary>
|
||||
public Language[] Languages { get; } = { Language.CSharp };
|
||||
public List<Language> Languages { get; } = new() { Language.CSharp };
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of all timeslices of algorithm
|
||||
@@ -115,6 +115,11 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// </summary>
|
||||
public int AlgorithmHistoryDataPoints => 40;
|
||||
|
||||
/// <summary>
|
||||
/// Final status of the algorithm
|
||||
/// </summary>
|
||||
public AlgorithmStatus AlgorithmStatus => AlgorithmStatus.Completed;
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate what the expected statistics are from running the algorithm
|
||||
/// </summary>
|
||||
@@ -146,6 +151,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Estimated Strategy Capacity", "$56000000.00"},
|
||||
{"Lowest Capacity Asset", "SPY R735QTJ8XC9X"},
|
||||
{"Portfolio Turnover", "19.93%"},
|
||||
{"Drawdown Recovery", "3"},
|
||||
{"OrderListHash", "3da9fa60bf95b9ed148b95e02e0cfc9e"}
|
||||
};
|
||||
}
|
||||
|
||||
137
Algorithm.CSharp/AutomaticSeedBaseRegressionAlgorithm.cs
Normal file
137
Algorithm.CSharp/AutomaticSeedBaseRegressionAlgorithm.cs
Normal file
@@ -0,0 +1,137 @@
|
||||
/*
|
||||
* QUANTCONNECT.COM - Democratizing Finance, Empowering Individuals.
|
||||
* Lean Algorithmic Trading Engine v2.0. Copyright 2014 QuantConnect Corporation.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using QuantConnect.Interfaces;
|
||||
using QuantConnect.Data.UniverseSelection;
|
||||
using QuantConnect.Data.Market;
|
||||
using QuantConnect.Securities;
|
||||
|
||||
namespace QuantConnect.Algorithm.CSharp
|
||||
{
|
||||
/// <summary>
|
||||
/// Regression algorithm asserting that security are automatically seeded by default
|
||||
/// </summary>
|
||||
public abstract class AutomaticSeedBaseRegressionAlgorithm : QCAlgorithm, IRegressionAlgorithmDefinition
|
||||
{
|
||||
protected virtual bool ShouldHaveTradeData { get; }
|
||||
protected virtual bool ShouldHaveQuoteData { get; }
|
||||
protected virtual bool ShouldHaveOpenInterestData { get; }
|
||||
|
||||
public override void OnSecuritiesChanged(SecurityChanges changes)
|
||||
{
|
||||
var gotTrades = false;
|
||||
var gotQuotes = false;
|
||||
var gotOpenInterest = false;
|
||||
|
||||
foreach (var addedSecurity in changes.AddedSecurities.Where(x => !x.Symbol.IsCanonical() || x.Symbol.SecurityType == SecurityType.Future))
|
||||
{
|
||||
if (addedSecurity.Price == 0)
|
||||
{
|
||||
throw new RegressionTestException("Security was not seeded");
|
||||
}
|
||||
|
||||
if (!addedSecurity.HasData)
|
||||
{
|
||||
throw new RegressionTestException("Security does not have TradeBar or QuoteBar or OpenInterest data");
|
||||
}
|
||||
|
||||
gotTrades |= addedSecurity.Cache.GetData<TradeBar>() != null;
|
||||
gotQuotes |= addedSecurity.Cache.GetData<QuoteBar>() != null;
|
||||
gotOpenInterest |= addedSecurity.Cache.GetData<OpenInterest>() != null;
|
||||
}
|
||||
|
||||
if (changes.AddedSecurities.Count > 0)
|
||||
{
|
||||
if (ShouldHaveTradeData && !gotTrades)
|
||||
{
|
||||
throw new RegressionTestException("No contract had TradeBar data");
|
||||
}
|
||||
|
||||
if (ShouldHaveQuoteData && !gotQuotes)
|
||||
{
|
||||
throw new RegressionTestException("No contract had QuoteBar data");
|
||||
}
|
||||
|
||||
if (ShouldHaveOpenInterestData && !gotOpenInterest)
|
||||
{
|
||||
throw new RegressionTestException("No contract had OpenInterest data");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate if the open source Lean repository has the required data to run this algorithm.
|
||||
/// </summary>
|
||||
public bool CanRunLocally { get; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate which languages this algorithm is written in.
|
||||
/// </summary>
|
||||
public List<Language> Languages { get; } = new() { Language.CSharp };
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of all timeslices of algorithm
|
||||
/// </summary>
|
||||
public abstract long DataPoints { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of the algorithm history
|
||||
/// </summary>
|
||||
public abstract int AlgorithmHistoryDataPoints { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Final status of the algorithm
|
||||
/// </summary>
|
||||
public AlgorithmStatus AlgorithmStatus => AlgorithmStatus.Completed;
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate what the expected statistics are from running the algorithm
|
||||
/// </summary>
|
||||
public virtual Dictionary<string, string> ExpectedStatistics => new Dictionary<string, string>
|
||||
{
|
||||
{"Total Orders", "0"},
|
||||
{"Average Win", "0%"},
|
||||
{"Average Loss", "0%"},
|
||||
{"Compounding Annual Return", "0%"},
|
||||
{"Drawdown", "0%"},
|
||||
{"Expectancy", "0"},
|
||||
{"Start Equity", "100000"},
|
||||
{"End Equity", "100000"},
|
||||
{"Net Profit", "0%"},
|
||||
{"Sharpe Ratio", "0"},
|
||||
{"Sortino Ratio", "0"},
|
||||
{"Probabilistic Sharpe Ratio", "0%"},
|
||||
{"Loss Rate", "0%"},
|
||||
{"Win Rate", "0%"},
|
||||
{"Profit-Loss Ratio", "0"},
|
||||
{"Alpha", "0"},
|
||||
{"Beta", "0"},
|
||||
{"Annual Standard Deviation", "0"},
|
||||
{"Annual Variance", "0"},
|
||||
{"Information Ratio", "0"},
|
||||
{"Tracking Error", "0"},
|
||||
{"Treynor Ratio", "0"},
|
||||
{"Total Fees", "$0.00"},
|
||||
{"Estimated Strategy Capacity", "$0"},
|
||||
{"Lowest Capacity Asset", ""},
|
||||
{"Portfolio Turnover", "0%"},
|
||||
{"Drawdown Recovery", "0"},
|
||||
{"OrderListHash", "d41d8cd98f00b204e9800998ecf8427e"}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -54,7 +54,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{
|
||||
if (!delistings.ContainsKey("AAA.1"))
|
||||
{
|
||||
throw new Exception("Unexpected OnDelistings call");
|
||||
throw new RegressionTestException("Unexpected OnDelistings call");
|
||||
}
|
||||
_onDelistingsCalled = true;
|
||||
}
|
||||
@@ -63,7 +63,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{
|
||||
if (!symbolsChanged.ContainsKey("SPWR"))
|
||||
{
|
||||
throw new Exception("Unexpected OnSymbolChangedEvents call");
|
||||
throw new RegressionTestException("Unexpected OnSymbolChangedEvents call");
|
||||
}
|
||||
_onSymbolChangedEvents = true;
|
||||
}
|
||||
@@ -72,7 +72,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{
|
||||
if (!splits.ContainsKey("AAPL"))
|
||||
{
|
||||
throw new Exception("Unexpected OnSplits call");
|
||||
throw new RegressionTestException("Unexpected OnSplits call");
|
||||
}
|
||||
_onSplits = true;
|
||||
}
|
||||
@@ -81,7 +81,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{
|
||||
if (!dividends.ContainsKey("AAPL"))
|
||||
{
|
||||
throw new Exception("Unexpected OnDividends call");
|
||||
throw new RegressionTestException("Unexpected OnDividends call");
|
||||
}
|
||||
_onDividends = true;
|
||||
}
|
||||
@@ -90,19 +90,19 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{
|
||||
if (!_onDelistingsCalled)
|
||||
{
|
||||
throw new Exception("OnDelistings was not called!");
|
||||
throw new RegressionTestException("OnDelistings was not called!");
|
||||
}
|
||||
if (!_onSymbolChangedEvents)
|
||||
{
|
||||
throw new Exception("OnSymbolChangedEvents was not called!");
|
||||
throw new RegressionTestException("OnSymbolChangedEvents was not called!");
|
||||
}
|
||||
if (!_onSplits)
|
||||
{
|
||||
throw new Exception("OnSplits was not called!");
|
||||
throw new RegressionTestException("OnSplits was not called!");
|
||||
}
|
||||
if (!_onDividends)
|
||||
{
|
||||
throw new Exception("OnDividends was not called!");
|
||||
throw new RegressionTestException("OnDividends was not called!");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -114,18 +114,23 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate which languages this algorithm is written in.
|
||||
/// </summary>
|
||||
public Language[] Languages { get; } = { Language.CSharp, Language.Python };
|
||||
public List<Language> Languages { get; } = new() { Language.CSharp, Language.Python };
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of all timeslices of algorithm
|
||||
/// </summary>
|
||||
public long DataPoints => 126221;
|
||||
public long DataPoints => 126222;
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of the algorithm history
|
||||
/// </summary>
|
||||
public int AlgorithmHistoryDataPoints => 0;
|
||||
|
||||
/// <summary>
|
||||
/// Final status of the algorithm
|
||||
/// </summary>
|
||||
public AlgorithmStatus AlgorithmStatus => AlgorithmStatus.Completed;
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate what the expected statistics are from running the algorithm
|
||||
/// </summary>
|
||||
@@ -157,6 +162,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Estimated Strategy Capacity", "$0"},
|
||||
{"Lowest Capacity Asset", ""},
|
||||
{"Portfolio Turnover", "0%"},
|
||||
{"Drawdown Recovery", "0"},
|
||||
{"OrderListHash", "d41d8cd98f00b204e9800998ecf8427e"}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -0,0 +1,156 @@
|
||||
/*
|
||||
* QUANTCONNECT.COM - Democratizing Finance, Empowering Individuals.
|
||||
* Lean Algorithmic Trading Engine v2.0. Copyright 2014 QuantConnect Corporation.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
using System.Collections.Generic;
|
||||
using QuantConnect.Data;
|
||||
using QuantConnect.Interfaces;
|
||||
using QuantConnect.Orders;
|
||||
|
||||
namespace QuantConnect.Algorithm.CSharp
|
||||
{
|
||||
/// <summary>
|
||||
/// Regression algorithm asserting that in backtesting, orders are submitted in the same time step even when asynchronous
|
||||
/// </summary>
|
||||
public class BacktestingAsynchronousOrdersRegressionAlgorithm : QCAlgorithm, IRegressionAlgorithmDefinition
|
||||
{
|
||||
private Symbol _symbol;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
SetStartDate(2013, 10, 07);
|
||||
SetEndDate(2013, 10, 08);
|
||||
SetCash(100000);
|
||||
|
||||
_symbol = AddEquity("SPY").Symbol;
|
||||
}
|
||||
|
||||
public override void OnData(Slice slice)
|
||||
{
|
||||
if (!Portfolio.Invested)
|
||||
{
|
||||
var marketOrderTicket = MarketOrder(_symbol, 100, asynchronous: false);
|
||||
AssertMarketOrderStatus(marketOrderTicket);
|
||||
|
||||
var asyncMarketOrderTicket = MarketOrder(_symbol, -100, asynchronous: true);
|
||||
AssertMarketOrderStatus(asyncMarketOrderTicket);
|
||||
|
||||
var limitPrice = Securities[_symbol].Price * 0.95m;
|
||||
var limitOrderTicket = LimitOrder(_symbol, 100, limitPrice, asynchronous: false);
|
||||
AssertLimitOrderStatus(limitOrderTicket);
|
||||
|
||||
var asyncLimitOrderTicket = LimitOrder(_symbol, -100, limitPrice, asynchronous: true);
|
||||
AssertLimitOrderStatus(asyncLimitOrderTicket);
|
||||
}
|
||||
}
|
||||
|
||||
private static void AssertMarketOrderStatus(OrderTicket ticket)
|
||||
{
|
||||
// In backtesting the order should be submitted and filled right away.
|
||||
// Note that OrderSet event will not be fired if there is an error when processing the order submission,
|
||||
// but this is a happy case
|
||||
if (!ticket.OrderSet.WaitOne(0))
|
||||
{
|
||||
throw new RegressionTestException("Order was not submitted immediately in backtesting mode");
|
||||
}
|
||||
if (!ticket.OrderClosed.WaitOne(0))
|
||||
{
|
||||
throw new RegressionTestException("Order was not filled immediately in backtesting mode");
|
||||
}
|
||||
if (ticket.Status != OrderStatus.Filled)
|
||||
{
|
||||
throw new RegressionTestException($"Order status is not filled: {ticket.Status}");
|
||||
}
|
||||
}
|
||||
|
||||
private static void AssertLimitOrderStatus(OrderTicket ticket)
|
||||
{
|
||||
// In backtesting the order should be submitted right away but not filled since price hasn't moved even when asynchronous
|
||||
// Note that OrderSet event will not be fired if there is an error when processing the order submission,
|
||||
// but this is a happy case
|
||||
if (!ticket.OrderSet.WaitOne(0))
|
||||
{
|
||||
throw new RegressionTestException("Asynchronous limit order was not submitted immediately in backtesting mode");
|
||||
}
|
||||
if (ticket.OrderClosed.WaitOne(0))
|
||||
{
|
||||
throw new RegressionTestException("Asynchronous limit order was filled immediately in backtesting mode when it shouldn't");
|
||||
}
|
||||
if (ticket.Status != OrderStatus.Submitted)
|
||||
{
|
||||
throw new RegressionTestException($"Order status is not submitted: {ticket.Status}");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate if the open source Lean repository has the required data to run this algorithm.
|
||||
/// </summary>
|
||||
public bool CanRunLocally { get; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate which languages this algorithm is written in.
|
||||
/// </summary>
|
||||
public List<Language> Languages { get; } = new() { Language.CSharp };
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of all timeslices of algorithm
|
||||
/// </summary>
|
||||
public long DataPoints => 1582;
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of the algorithm history
|
||||
/// </summary>
|
||||
public int AlgorithmHistoryDataPoints => 0;
|
||||
|
||||
/// <summary>
|
||||
/// Final status of the algorithm
|
||||
/// </summary>
|
||||
public AlgorithmStatus AlgorithmStatus => AlgorithmStatus.Completed;
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate what the expected statistics are from running the algorithm
|
||||
/// </summary>
|
||||
public Dictionary<string, string> ExpectedStatistics => new Dictionary<string, string>
|
||||
{
|
||||
{"Total Orders", "4"},
|
||||
{"Average Win", "0%"},
|
||||
{"Average Loss", "0%"},
|
||||
{"Compounding Annual Return", "0%"},
|
||||
{"Drawdown", "0%"},
|
||||
{"Expectancy", "0"},
|
||||
{"Start Equity", "100000"},
|
||||
{"End Equity", "100168.20"},
|
||||
{"Net Profit", "0%"},
|
||||
{"Sharpe Ratio", "0"},
|
||||
{"Sortino Ratio", "0"},
|
||||
{"Probabilistic Sharpe Ratio", "0%"},
|
||||
{"Loss Rate", "0%"},
|
||||
{"Win Rate", "0%"},
|
||||
{"Profit-Loss Ratio", "0"},
|
||||
{"Alpha", "0"},
|
||||
{"Beta", "0"},
|
||||
{"Annual Standard Deviation", "0"},
|
||||
{"Annual Variance", "0"},
|
||||
{"Information Ratio", "0"},
|
||||
{"Tracking Error", "0"},
|
||||
{"Treynor Ratio", "0"},
|
||||
{"Total Fees", "$3.00"},
|
||||
{"Estimated Strategy Capacity", "$22000000.00"},
|
||||
{"Lowest Capacity Asset", "SPY R735QTJ8XC9X"},
|
||||
{"Portfolio Turnover", "21.72%"},
|
||||
{"Drawdown Recovery", "0"},
|
||||
{"OrderListHash", "65f010e904a929e5383f0920a3c5b797"}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -151,12 +151,12 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
case OrderStatus.PartiallyFilled:
|
||||
if (order.LastFillTime == null)
|
||||
{
|
||||
throw new Exception("LastFillTime should not be null");
|
||||
throw new RegressionTestException("LastFillTime should not be null");
|
||||
}
|
||||
|
||||
if (order.Quantity / 2 != orderEvent.FillQuantity)
|
||||
{
|
||||
throw new Exception("Order size should be half");
|
||||
throw new RegressionTestException("Order size should be half");
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -164,7 +164,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
case OrderStatus.Filled:
|
||||
if (order.SecurityType == SecurityType.Equity && order.CreatedTime == order.LastFillTime)
|
||||
{
|
||||
throw new Exception("Order should not finish during the CreatedTime bar");
|
||||
throw new RegressionTestException("Order should not finish during the CreatedTime bar");
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -182,12 +182,12 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
// If the option price isn't the same as the strike price, its incorrect
|
||||
if (order.Price != _optionStrikePrice)
|
||||
{
|
||||
throw new Exception("OptionExercise order price should be strike price!!");
|
||||
throw new RegressionTestException("OptionExercise order price should be strike price!!");
|
||||
}
|
||||
|
||||
if (orderEvent.Quantity != -1)
|
||||
{
|
||||
throw new Exception("OrderEvent Quantity should be -1");
|
||||
throw new RegressionTestException("OrderEvent Quantity should be -1");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -198,14 +198,14 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{
|
||||
if (!Portfolio.ContainsKey(_optionBuy.Symbol) || !Portfolio.ContainsKey(_optionBuy.Symbol.Underlying) || !Portfolio.ContainsKey(_equityBuy.Symbol))
|
||||
{
|
||||
throw new Exception("Portfolio does not contain the Symbols we purchased");
|
||||
throw new RegressionTestException("Portfolio does not contain the Symbols we purchased");
|
||||
}
|
||||
|
||||
//Check option holding, should not be invested since it expired, profit should be -400
|
||||
var optionHolding = Portfolio[_optionBuy.Symbol];
|
||||
if (optionHolding.Invested || optionHolding.Profit != -400)
|
||||
{
|
||||
throw new Exception("Options holding does not match expected outcome");
|
||||
throw new RegressionTestException("Options holding does not match expected outcome");
|
||||
}
|
||||
|
||||
//Check the option underlying symbol since we should have bought it at exercise
|
||||
@@ -213,7 +213,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
var optionExerciseHolding = Portfolio[_optionBuy.Symbol.Underlying];
|
||||
if (!optionExerciseHolding.Invested || optionExerciseHolding.Quantity != 100 || optionExerciseHolding.AveragePrice != _optionBuy.Symbol.ID.StrikePrice)
|
||||
{
|
||||
throw new Exception("Equity holding for exercised option does not match expected outcome");
|
||||
throw new RegressionTestException("Equity holding for exercised option does not match expected outcome");
|
||||
}
|
||||
|
||||
//Check equity holding, should be invested, profit should be
|
||||
@@ -221,7 +221,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
var equityHolding = Portfolio[_equityBuy.Symbol];
|
||||
if (!equityHolding.Invested || equityHolding.Quantity != 52 || equityHolding.AveragePrice != _equityBuy.AverageFillPrice)
|
||||
{
|
||||
throw new Exception("Equity holding does not match expected outcome");
|
||||
throw new RegressionTestException("Equity holding does not match expected outcome");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -291,18 +291,23 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate which languages this algorithm is written in.
|
||||
/// </summary>
|
||||
public Language[] Languages { get; } = { Language.CSharp };
|
||||
public List<Language> Languages { get; } = new() { Language.CSharp };
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of all timeslices of algorithm
|
||||
/// </summary>
|
||||
public long DataPoints => 1267414;
|
||||
public long DataPoints => 27071;
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of the algorithm history
|
||||
/// </summary>
|
||||
public int AlgorithmHistoryDataPoints => 0;
|
||||
|
||||
/// <summary>
|
||||
/// Final status of the algorithm
|
||||
/// </summary>
|
||||
public AlgorithmStatus AlgorithmStatus => AlgorithmStatus.Completed;
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate what the expected statistics are from running the algorithm
|
||||
/// </summary>
|
||||
@@ -311,7 +316,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Total Orders", "3"},
|
||||
{"Average Win", "0%"},
|
||||
{"Average Loss", "-0.40%"},
|
||||
{"Compounding Annual Return", "-22.717%"},
|
||||
{"Compounding Annual Return", "-21.378%"},
|
||||
{"Drawdown", "0.400%"},
|
||||
{"Expectancy", "-1"},
|
||||
{"Start Equity", "100000"},
|
||||
@@ -334,7 +339,8 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Estimated Strategy Capacity", "$0"},
|
||||
{"Lowest Capacity Asset", "GOOCV VP83T1ZUHROL"},
|
||||
{"Portfolio Turnover", "17.02%"},
|
||||
{"OrderListHash", "b1e5e72fb766ab894204bc4b1300912b"}
|
||||
{"Drawdown Recovery", "0"},
|
||||
{"OrderListHash", "1be5073f2cf8802ffa163f7dab7d040e"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
var insightsCount = Insights.GetInsights(insight => insight.IsActive(UtcTime)).Count;
|
||||
if (insightsCount != 0)
|
||||
{
|
||||
throw new Exception($"The number of active insights should be 0. Actual: {insightsCount}");
|
||||
throw new RegressionTestException($"The number of active insights should be 0. Actual: {insightsCount}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate which languages this algorithm is written in.
|
||||
/// </summary>
|
||||
public virtual Language[] Languages { get; } = { Language.CSharp, Language.Python };
|
||||
public virtual List<Language> Languages { get; } = new() { Language.CSharp, Language.Python };
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of all timeslices of algorithm
|
||||
@@ -87,6 +87,11 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// </summary>
|
||||
public virtual int AlgorithmHistoryDataPoints => 0;
|
||||
|
||||
/// <summary>
|
||||
/// Final status of the algorithm
|
||||
/// </summary>
|
||||
public AlgorithmStatus AlgorithmStatus => AlgorithmStatus.Completed;
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate what the expected statistics are from running the algorithm
|
||||
/// </summary>
|
||||
|
||||
@@ -49,7 +49,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
|
||||
/// OnData event is the primary entry point for your algorithm. Each new data point will be pumped in here.
|
||||
/// Slice object keyed by symbol containing the stock data
|
||||
public override void OnData(Slice data)
|
||||
public override void OnData(Slice slice)
|
||||
{
|
||||
if (!Portfolio.Invested)
|
||||
{
|
||||
@@ -63,4 +63,4 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// OnData event is the primary entry point for your algorithm. Each new data point will be pumped in here.
|
||||
/// </summary>
|
||||
/// <param name="data">Slice object keyed by symbol containing the stock data</param>
|
||||
public override void OnData(Slice data)
|
||||
public override void OnData(Slice slice)
|
||||
{
|
||||
if (!Portfolio.Invested)
|
||||
{
|
||||
@@ -67,7 +67,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate which languages this algorithm is written in.
|
||||
/// </summary>
|
||||
public Language[] Languages { get; } = { Language.CSharp, Language.Python };
|
||||
public List<Language> Languages { get; } = new() { Language.CSharp, Language.Python };
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of all timeslices of algorithm
|
||||
@@ -77,7 +77,12 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// Data Points count of the algorithm history
|
||||
/// </summary>
|
||||
public int AlgorithmHistoryDataPoints => 120;
|
||||
public int AlgorithmHistoryDataPoints => 15;
|
||||
|
||||
/// <summary>
|
||||
/// Final status of the algorithm
|
||||
/// </summary>
|
||||
public AlgorithmStatus AlgorithmStatus => AlgorithmStatus.Completed;
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate what the expected statistics are from running the algorithm
|
||||
@@ -110,6 +115,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Estimated Strategy Capacity", "€85000.00"},
|
||||
{"Lowest Capacity Asset", "BTCEUR 2XR"},
|
||||
{"Portfolio Turnover", "107.64%"},
|
||||
{"Drawdown Recovery", "0"},
|
||||
{"OrderListHash", "6819dc936b86af6e4b89b6017b7d5284"}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate which languages this algorithm is written in.
|
||||
/// </summary>
|
||||
public Language[] Languages { get; } = { Language.CSharp, Language.Python };
|
||||
public List<Language> Languages { get; } = new() { Language.CSharp, Language.Python };
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of all timeslices of algorithm
|
||||
@@ -47,7 +47,12 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// Data Points count of the algorithm history
|
||||
/// </summary>
|
||||
public int AlgorithmHistoryDataPoints => 120;
|
||||
public int AlgorithmHistoryDataPoints => 15;
|
||||
|
||||
/// <summary>
|
||||
/// Final status of the algorithm
|
||||
/// </summary>
|
||||
public AlgorithmStatus AlgorithmStatus => AlgorithmStatus.Completed;
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate what the expected statistics are from running the algorithm
|
||||
@@ -80,6 +85,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Estimated Strategy Capacity", "€85000.00"},
|
||||
{"Lowest Capacity Asset", "BTCEUR 2XR"},
|
||||
{"Portfolio Turnover", "107.64%"},
|
||||
{"Drawdown Recovery", "0"},
|
||||
{"OrderListHash", "3d450fd418a0e845b3eaaac17fcd13fc"}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// OnData event is the primary entry point for your algorithm. Each new data point will be pumped in here.
|
||||
/// </summary>
|
||||
/// <param name="data">Slice object keyed by symbol containing the stock data</param>
|
||||
public override void OnData(Slice data)
|
||||
public override void OnData(Slice slice)
|
||||
{
|
||||
if (!Portfolio.Invested)
|
||||
{
|
||||
@@ -70,7 +70,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate which languages this algorithm is written in.
|
||||
/// </summary>
|
||||
public Language[] Languages { get; } = { Language.CSharp, Language.Python };
|
||||
public List<Language> Languages { get; } = new() { Language.CSharp, Language.Python };
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of all timeslices of algorithm
|
||||
@@ -82,6 +82,11 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// </summary>
|
||||
public int AlgorithmHistoryDataPoints => 0;
|
||||
|
||||
/// <summary>
|
||||
/// Final status of the algorithm
|
||||
/// </summary>
|
||||
public AlgorithmStatus AlgorithmStatus => AlgorithmStatus.Completed;
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate what the expected statistics are from running the algorithm
|
||||
/// </summary>
|
||||
@@ -113,6 +118,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Estimated Strategy Capacity", "$56000000.00"},
|
||||
{"Lowest Capacity Asset", "SPY R735QTJ8XC9X"},
|
||||
{"Portfolio Turnover", "19.93%"},
|
||||
{"Drawdown Recovery", "3"},
|
||||
{"OrderListHash", "3da9fa60bf95b9ed148b95e02e0cfc9e"}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -44,8 +44,8 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// OnData event is the primary entry point for your algorithm. Each new data point will be pumped in here.
|
||||
/// </summary>
|
||||
/// <param name="data">Slice object keyed by symbol containing the stock data</param>
|
||||
public override void OnData(Slice data)
|
||||
/// <param name="slice">Slice object keyed by symbol containing the stock data</param>
|
||||
public override void OnData(Slice slice)
|
||||
{
|
||||
if (!Portfolio.Invested)
|
||||
{
|
||||
@@ -64,7 +64,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate which languages this algorithm is written in.
|
||||
/// </summary>
|
||||
public Language[] Languages { get; } = { Language.CSharp, Language.Python };
|
||||
public List<Language> Languages { get; } = new() { Language.CSharp, Language.Python };
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of all timeslices of algorithm
|
||||
@@ -76,6 +76,11 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// </summary>
|
||||
public int AlgorithmHistoryDataPoints => 0;
|
||||
|
||||
/// <summary>
|
||||
/// Final status of the algorithm
|
||||
/// </summary>
|
||||
public AlgorithmStatus AlgorithmStatus => AlgorithmStatus.Completed;
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate what the expected statistics are from running the algorithm
|
||||
/// </summary>
|
||||
@@ -107,6 +112,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Estimated Strategy Capacity", "$150000000.00"},
|
||||
{"Lowest Capacity Asset", "SPY R735QTJ8XC9X"},
|
||||
{"Portfolio Turnover", "4.98%"},
|
||||
{"Drawdown Recovery", "3"},
|
||||
{"OrderListHash", "8774049eb5141a2b6956d9432426f837"}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@ using QuantConnect.Data;
|
||||
using QuantConnect.Orders;
|
||||
using QuantConnect.Interfaces;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using QuantConnect.Data.UniverseSelection;
|
||||
using QuantConnect.Indicators;
|
||||
using QuantConnect.Securities;
|
||||
@@ -59,14 +58,14 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// OnData event is the primary entry point for your algorithm. Each new data point will be pumped in here.
|
||||
/// </summary>
|
||||
/// <param name="data">Slice object keyed by symbol containing the stock data</param>
|
||||
public override void OnData(Slice data)
|
||||
public override void OnData(Slice slice)
|
||||
{
|
||||
foreach (var changedEvent in data.SymbolChangedEvents.Values)
|
||||
foreach (var changedEvent in slice.SymbolChangedEvents.Values)
|
||||
{
|
||||
Debug($"{Time} - SymbolChanged event: {changedEvent}");
|
||||
if (Time.TimeOfDay != TimeSpan.Zero)
|
||||
{
|
||||
throw new Exception($"{Time} unexpected symbol changed event {changedEvent}!");
|
||||
throw new RegressionTestException($"{Time} unexpected symbol changed event {changedEvent}!");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -113,50 +112,56 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate which languages this algorithm is written in.
|
||||
/// </summary>
|
||||
public Language[] Languages { get; } = { Language.CSharp, Language.Python };
|
||||
public List<Language> Languages { get; } = new() { Language.CSharp, Language.Python };
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of all timeslices of algorithm
|
||||
/// </summary>
|
||||
public long DataPoints => 713395;
|
||||
public long DataPoints => 162575;
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of the algorithm history
|
||||
/// </summary>
|
||||
public int AlgorithmHistoryDataPoints => 0;
|
||||
|
||||
/// <summary>
|
||||
/// Final status of the algorithm
|
||||
/// </summary>
|
||||
public AlgorithmStatus AlgorithmStatus => AlgorithmStatus.Completed;
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate what the expected statistics are from running the algorithm
|
||||
/// </summary>
|
||||
public Dictionary<string, string> ExpectedStatistics => new Dictionary<string, string>
|
||||
{
|
||||
{"Total Orders", "5"},
|
||||
{"Average Win", "2.90%"},
|
||||
{"Average Win", "2.48%"},
|
||||
{"Average Loss", "0%"},
|
||||
{"Compounding Annual Return", "13.087%"},
|
||||
{"Drawdown", "1.100%"},
|
||||
{"Compounding Annual Return", "11.325%"},
|
||||
{"Drawdown", "1.500%"},
|
||||
{"Expectancy", "0"},
|
||||
{"Start Equity", "100000"},
|
||||
{"End Equity", "106387.1"},
|
||||
{"Net Profit", "6.387%"},
|
||||
{"Sharpe Ratio", "1.532"},
|
||||
{"Sortino Ratio", "871.704"},
|
||||
{"Probabilistic Sharpe Ratio", "90.613%"},
|
||||
{"End Equity", "105549.6"},
|
||||
{"Net Profit", "5.550%"},
|
||||
{"Sharpe Ratio", "1.332"},
|
||||
{"Sortino Ratio", "879.904"},
|
||||
{"Probabilistic Sharpe Ratio", "79.894%"},
|
||||
{"Loss Rate", "0%"},
|
||||
{"Win Rate", "100%"},
|
||||
{"Profit-Loss Ratio", "0"},
|
||||
{"Alpha", "0.088"},
|
||||
{"Beta", "-0.022"},
|
||||
{"Annual Standard Deviation", "0.054"},
|
||||
{"Alpha", "0.075"},
|
||||
{"Beta", "-0.017"},
|
||||
{"Annual Standard Deviation", "0.053"},
|
||||
{"Annual Variance", "0.003"},
|
||||
{"Information Ratio", "-1.35"},
|
||||
{"Tracking Error", "0.1"},
|
||||
{"Treynor Ratio", "-3.781"},
|
||||
{"Information Ratio", "-1.48"},
|
||||
{"Tracking Error", "0.099"},
|
||||
{"Treynor Ratio", "-4.187"},
|
||||
{"Total Fees", "$10.75"},
|
||||
{"Estimated Strategy Capacity", "$1100000000.00"},
|
||||
{"Estimated Strategy Capacity", "$7100000.00"},
|
||||
{"Lowest Capacity Asset", "ES VMKLFZIH2MTD"},
|
||||
{"Portfolio Turnover", "2.32%"},
|
||||
{"OrderListHash", "2f6afca6b20a56eea9dd327dcb401682"}
|
||||
{"Portfolio Turnover", "2.33%"},
|
||||
{"Drawdown Recovery", "37"},
|
||||
{"OrderListHash", "223735440010fcec5889bb7becacfa82"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,15 +59,15 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// OnData event is the primary entry point for your algorithm. Each new data point will be pumped in here.
|
||||
/// </summary>
|
||||
/// <param name="data">Slice object keyed by symbol containing the stock data</param>
|
||||
public override void OnData(Slice data)
|
||||
/// <param name="slice">Slice object keyed by symbol containing the stock data</param>
|
||||
public override void OnData(Slice slice)
|
||||
{
|
||||
foreach (var changedEvent in data.SymbolChangedEvents.Values)
|
||||
foreach (var changedEvent in slice.SymbolChangedEvents.Values)
|
||||
{
|
||||
Debug($"{Time} - SymbolChanged event: {changedEvent}");
|
||||
if (Time.TimeOfDay != TimeSpan.Zero)
|
||||
{
|
||||
throw new Exception($"{Time} unexpected symbol changed event {changedEvent}!");
|
||||
throw new RegressionTestException($"{Time} unexpected symbol changed event {changedEvent}!");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -118,50 +118,56 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate which languages this algorithm is written in.
|
||||
/// </summary>
|
||||
public Language[] Languages { get; } = { Language.CSharp, Language.Python };
|
||||
public List<Language> Languages { get; } = new() { Language.CSharp, Language.Python };
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of all timeslices of algorithm
|
||||
/// </summary>
|
||||
public long DataPoints => 2217325;
|
||||
public long DataPoints => 504530;
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of the algorithm history
|
||||
/// </summary>
|
||||
public int AlgorithmHistoryDataPoints => 0;
|
||||
|
||||
/// <summary>
|
||||
/// Final status of the algorithm
|
||||
/// </summary>
|
||||
public AlgorithmStatus AlgorithmStatus => AlgorithmStatus.Completed;
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate what the expected statistics are from running the algorithm
|
||||
/// </summary>
|
||||
public Dictionary<string, string> ExpectedStatistics => new Dictionary<string, string>
|
||||
{
|
||||
{"Total Orders", "5"},
|
||||
{"Average Win", "4.45%"},
|
||||
{"Average Loss", "-0.26%"},
|
||||
{"Compounding Annual Return", "8.423%"},
|
||||
{"Drawdown", "0.800%"},
|
||||
{"Expectancy", "8.202"},
|
||||
{"Average Win", "2.86%"},
|
||||
{"Average Loss", "0%"},
|
||||
{"Compounding Annual Return", "12.959%"},
|
||||
{"Drawdown", "1.100%"},
|
||||
{"Expectancy", "0"},
|
||||
{"Start Equity", "100000"},
|
||||
{"End Equity", "104162.1"},
|
||||
{"Net Profit", "4.162%"},
|
||||
{"Sharpe Ratio", "0.951"},
|
||||
{"Sortino Ratio", "2.8"},
|
||||
{"Probabilistic Sharpe Ratio", "53.568%"},
|
||||
{"Loss Rate", "50%"},
|
||||
{"Win Rate", "50%"},
|
||||
{"Profit-Loss Ratio", "17.40"},
|
||||
{"Alpha", "0.053"},
|
||||
{"Beta", "-0.005"},
|
||||
{"Annual Standard Deviation", "0.054"},
|
||||
{"End Equity", "106337.1"},
|
||||
{"Net Profit", "6.337%"},
|
||||
{"Sharpe Ratio", "1.41"},
|
||||
{"Sortino Ratio", "1.242"},
|
||||
{"Probabilistic Sharpe Ratio", "77.992%"},
|
||||
{"Loss Rate", "0%"},
|
||||
{"Win Rate", "100%"},
|
||||
{"Profit-Loss Ratio", "0"},
|
||||
{"Alpha", "0.071"},
|
||||
{"Beta", "0.054"},
|
||||
{"Annual Standard Deviation", "0.059"},
|
||||
{"Annual Variance", "0.003"},
|
||||
{"Information Ratio", "-1.681"},
|
||||
{"Tracking Error", "0.099"},
|
||||
{"Treynor Ratio", "-10.255"},
|
||||
{"Information Ratio", "-1.392"},
|
||||
{"Tracking Error", "0.097"},
|
||||
{"Treynor Ratio", "1.518"},
|
||||
{"Total Fees", "$10.75"},
|
||||
{"Estimated Strategy Capacity", "$190000000.00"},
|
||||
{"Estimated Strategy Capacity", "$890000000.00"},
|
||||
{"Lowest Capacity Asset", "ES VMKLFZIH2MTD"},
|
||||
{"Portfolio Turnover", "2.34%"},
|
||||
{"OrderListHash", "f34d9277d1d81a8125879f5ff8202626"}
|
||||
{"Portfolio Turnover", "2.32%"},
|
||||
{"Drawdown Recovery", "34"},
|
||||
{"OrderListHash", "1504a8892da8d8c0650018732f315753"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,8 +79,8 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// OnData event is the primary entry point for your algorithm. Each new data point will be pumped in here.
|
||||
/// </summary>
|
||||
/// <param name="data">Slice object keyed by symbol containing the stock data</param>
|
||||
public override void OnData(Slice data)
|
||||
/// <param name="slice">Slice object keyed by symbol containing the stock data</param>
|
||||
public override void OnData(Slice slice)
|
||||
{
|
||||
if (Portfolio.CashBook["EUR"].ConversionRate == 0
|
||||
|| Portfolio.CashBook["BTC"].ConversionRate == 0
|
||||
@@ -92,7 +92,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
Log($"LTC conversion rate: {Portfolio.CashBook["LTC"].ConversionRate}");
|
||||
Log($"ETH conversion rate: {Portfolio.CashBook["ETH"].ConversionRate}");
|
||||
|
||||
throw new Exception("Conversion rate is 0");
|
||||
throw new RegressionTestException("Conversion rate is 0");
|
||||
}
|
||||
if (Time.Hour == 1 && Time.Minute == 0)
|
||||
{
|
||||
@@ -167,11 +167,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{
|
||||
if (Portfolio.CashBook["LTC"].Amount > 0)
|
||||
{
|
||||
// The following two statements currently behave differently if we have initial holdings:
|
||||
// https://github.com/QuantConnect/Lean/issues/1860
|
||||
|
||||
Liquidate("LTCUSD");
|
||||
// SetHoldings("LTCUSD", 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -196,7 +192,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate which languages this algorithm is written in.
|
||||
/// </summary>
|
||||
public Language[] Languages { get; } = { Language.CSharp, Language.Python };
|
||||
public List<Language> Languages { get; } = new() { Language.CSharp, Language.Python };
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of all timeslices of algorithm
|
||||
@@ -206,7 +202,12 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// Data Points count of the algorithm history
|
||||
/// </summary>
|
||||
public int AlgorithmHistoryDataPoints => 240;
|
||||
public int AlgorithmHistoryDataPoints => 35;
|
||||
|
||||
/// <summary>
|
||||
/// Final status of the algorithm
|
||||
/// </summary>
|
||||
public AlgorithmStatus AlgorithmStatus => AlgorithmStatus.Completed;
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate what the expected statistics are from running the algorithm
|
||||
@@ -219,7 +220,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Compounding Annual Return", "0%"},
|
||||
{"Drawdown", "0%"},
|
||||
{"Expectancy", "0"},
|
||||
{"Start Equity", "31588.24"},
|
||||
{"Start Equity", "31592.84"},
|
||||
{"End Equity", "30866.71"},
|
||||
{"Net Profit", "0%"},
|
||||
{"Sharpe Ratio", "0"},
|
||||
@@ -239,6 +240,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Estimated Strategy Capacity", "$0"},
|
||||
{"Lowest Capacity Asset", "BTCEUR 2XR"},
|
||||
{"Portfolio Turnover", "118.08%"},
|
||||
{"Drawdown Recovery", "0"},
|
||||
{"OrderListHash", "26b9a07ace86b6a0e0eb2ff8c168cee0"}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -79,9 +79,9 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// OnData event is the primary entry point for your algorithm. Each new data point will be pumped in here.
|
||||
/// </summary>
|
||||
/// <param name="data">Slice object keyed by symbol containing the stock data</param>
|
||||
public override void OnData(Slice data)
|
||||
public override void OnData(Slice slice)
|
||||
{
|
||||
var interestRates = data.Get<MarginInterestRate>();
|
||||
var interestRates = slice.Get<MarginInterestRate>();
|
||||
foreach (var interestRate in interestRates)
|
||||
{
|
||||
_interestPerSymbol[interestRate.Key]++;
|
||||
@@ -89,7 +89,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
var cachedInterestRate = Securities[interestRate.Key].Cache.GetData<MarginInterestRate>();
|
||||
if (cachedInterestRate != interestRate.Value)
|
||||
{
|
||||
throw new Exception($"Unexpected cached margin interest rate for {interestRate.Key}!");
|
||||
throw new RegressionTestException($"Unexpected cached margin interest rate for {interestRate.Key}!");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -100,7 +100,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
var ticket = Buy(_btcUsd.Symbol, 50);
|
||||
if (ticket.Status != OrderStatus.Invalid)
|
||||
{
|
||||
throw new Exception($"Unexpected valid order {ticket}, should fail due to margin not sufficient");
|
||||
throw new RegressionTestException($"Unexpected valid order {ticket}, should fail due to margin not sufficient");
|
||||
}
|
||||
|
||||
Buy(_btcUsd.Symbol, 1);
|
||||
@@ -113,17 +113,17 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
|
||||
if (Math.Abs(btcUsdHoldings.TotalSaleVolume - holdingsValueBtcUsd) > 1)
|
||||
{
|
||||
throw new Exception($"Unexpected TotalSaleVolume {btcUsdHoldings.TotalSaleVolume}");
|
||||
throw new RegressionTestException($"Unexpected TotalSaleVolume {btcUsdHoldings.TotalSaleVolume}");
|
||||
}
|
||||
if (Math.Abs(btcUsdHoldings.AbsoluteHoldingsCost - holdingsValueBtcUsd) > 1)
|
||||
{
|
||||
throw new Exception($"Unexpected holdings cost {btcUsdHoldings.HoldingsCost}");
|
||||
throw new RegressionTestException($"Unexpected holdings cost {btcUsdHoldings.HoldingsCost}");
|
||||
}
|
||||
// margin used is based on the maintenance rate
|
||||
if (Math.Abs(btcUsdHoldings.AbsoluteHoldingsCost * 0.05m - marginUsed) > 1
|
||||
|| _btcUsd.BuyingPowerModel.GetMaintenanceMargin(_btcUsd) != marginUsed)
|
||||
{
|
||||
throw new Exception($"Unexpected margin used {marginUsed}");
|
||||
throw new RegressionTestException($"Unexpected margin used {marginUsed}");
|
||||
}
|
||||
|
||||
Buy(_adaUsdt.Symbol, 1000);
|
||||
@@ -136,28 +136,28 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
|
||||
if (Math.Abs(adaUsdtHoldings.TotalSaleVolume - holdingsValueUsdt) > 1)
|
||||
{
|
||||
throw new Exception($"Unexpected TotalSaleVolume {adaUsdtHoldings.TotalSaleVolume}");
|
||||
throw new RegressionTestException($"Unexpected TotalSaleVolume {adaUsdtHoldings.TotalSaleVolume}");
|
||||
}
|
||||
if (Math.Abs(adaUsdtHoldings.AbsoluteHoldingsCost - holdingsValueUsdt) > 1)
|
||||
{
|
||||
throw new Exception($"Unexpected holdings cost {adaUsdtHoldings.HoldingsCost}");
|
||||
throw new RegressionTestException($"Unexpected holdings cost {adaUsdtHoldings.HoldingsCost}");
|
||||
}
|
||||
if (Math.Abs(adaUsdtHoldings.AbsoluteHoldingsCost * 0.05m - marginUsed) > 1
|
||||
|| _adaUsdt.BuyingPowerModel.GetMaintenanceMargin(_adaUsdt) != marginUsed)
|
||||
{
|
||||
throw new Exception($"Unexpected margin used {marginUsed}");
|
||||
throw new RegressionTestException($"Unexpected margin used {marginUsed}");
|
||||
}
|
||||
|
||||
// position just opened should be just spread here
|
||||
var profit = Portfolio.TotalUnrealizedProfit;
|
||||
if ((5 - Math.Abs(profit)) < 0)
|
||||
{
|
||||
throw new Exception($"Unexpected TotalUnrealizedProfit {Portfolio.TotalUnrealizedProfit}");
|
||||
throw new RegressionTestException($"Unexpected TotalUnrealizedProfit {Portfolio.TotalUnrealizedProfit}");
|
||||
}
|
||||
|
||||
if (Portfolio.TotalProfit != 0)
|
||||
{
|
||||
throw new Exception($"Unexpected TotalProfit {Portfolio.TotalProfit}");
|
||||
throw new RegressionTestException($"Unexpected TotalProfit {Portfolio.TotalProfit}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -172,7 +172,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
|
||||
if (Math.Abs(btcUsdHoldings.AbsoluteHoldingsCost - 100 * 2) > 1)
|
||||
{
|
||||
throw new Exception($"Unexpected holdings cost {btcUsdHoldings.HoldingsCost}");
|
||||
throw new RegressionTestException($"Unexpected holdings cost {btcUsdHoldings.HoldingsCost}");
|
||||
}
|
||||
|
||||
Sell(_adaUsdt.Symbol, 3000);
|
||||
@@ -184,19 +184,19 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
|
||||
if (Math.Abs(adaUsdtHoldings.AbsoluteHoldingsCost - holdingsValueUsdt) > 1)
|
||||
{
|
||||
throw new Exception($"Unexpected holdings cost {adaUsdtHoldings.HoldingsCost}");
|
||||
throw new RegressionTestException($"Unexpected holdings cost {adaUsdtHoldings.HoldingsCost}");
|
||||
}
|
||||
|
||||
// position just opened should be just spread here
|
||||
var profit = Portfolio.TotalUnrealizedProfit;
|
||||
if ((5 - Math.Abs(profit)) < 0)
|
||||
{
|
||||
throw new Exception($"Unexpected TotalUnrealizedProfit {Portfolio.TotalUnrealizedProfit}");
|
||||
throw new RegressionTestException($"Unexpected TotalUnrealizedProfit {Portfolio.TotalUnrealizedProfit}");
|
||||
}
|
||||
// we barely did any difference on the previous trade
|
||||
if ((5 - Math.Abs(Portfolio.TotalProfit)) < 0)
|
||||
{
|
||||
throw new Exception($"Unexpected TotalProfit {Portfolio.TotalProfit}");
|
||||
throw new RegressionTestException($"Unexpected TotalProfit {Portfolio.TotalProfit}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -206,12 +206,12 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{
|
||||
if (_interestPerSymbol[_adaUsdt.Symbol] != 1)
|
||||
{
|
||||
throw new Exception($"Unexpected interest rate count {_interestPerSymbol[_adaUsdt.Symbol]}");
|
||||
throw new RegressionTestException($"Unexpected interest rate count {_interestPerSymbol[_adaUsdt.Symbol]}");
|
||||
}
|
||||
|
||||
if (_interestPerSymbol[_btcUsd.Symbol] != 3)
|
||||
{
|
||||
throw new Exception($"Unexpected interest rate count {_interestPerSymbol[_btcUsd.Symbol]}");
|
||||
throw new RegressionTestException($"Unexpected interest rate count {_interestPerSymbol[_btcUsd.Symbol]}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -228,7 +228,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate which languages this algorithm is written in.
|
||||
/// </summary>
|
||||
public Language[] Languages { get; } = { Language.CSharp, Language.Python };
|
||||
public List<Language> Languages { get; } = new() { Language.CSharp, Language.Python };
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of all timeslices of algorithm
|
||||
@@ -240,6 +240,11 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// </summary>
|
||||
public int AlgorithmHistoryDataPoints => 0;
|
||||
|
||||
/// <summary>
|
||||
/// Final status of the algorithm
|
||||
/// </summary>
|
||||
public AlgorithmStatus AlgorithmStatus => AlgorithmStatus.Completed;
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate what the expected statistics are from running the algorithm
|
||||
/// </summary>
|
||||
@@ -271,6 +276,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Estimated Strategy Capacity", "$500000000.00"},
|
||||
{"Lowest Capacity Asset", "ADAUSDT 18R"},
|
||||
{"Portfolio Turnover", "0.16%"},
|
||||
{"Drawdown Recovery", "0"},
|
||||
{"OrderListHash", "dcc4f964b5549c753123848c32eaee41"}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -74,9 +74,9 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// OnData event is the primary entry point for your algorithm. Each new data point will be pumped in here.
|
||||
/// </summary>
|
||||
/// <param name="data">Slice object keyed by symbol containing the stock data</param>
|
||||
public override void OnData(Slice data)
|
||||
public override void OnData(Slice slice)
|
||||
{
|
||||
var interestRates = data.Get<MarginInterestRate>();
|
||||
var interestRates = slice.Get<MarginInterestRate>();
|
||||
foreach (var interestRate in interestRates)
|
||||
{
|
||||
_interestPerSymbol[interestRate.Key]++;
|
||||
@@ -84,7 +84,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
var cachedInterestRate = Securities[interestRate.Key].Cache.GetData<MarginInterestRate>();
|
||||
if (cachedInterestRate != interestRate.Value)
|
||||
{
|
||||
throw new Exception($"Unexpected cached margin interest rate for {interestRate.Key}!");
|
||||
throw new RegressionTestException($"Unexpected cached margin interest rate for {interestRate.Key}!");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -95,7 +95,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
var ticket = Buy(_adaUsdt.Symbol, 100000);
|
||||
if(ticket.Status != OrderStatus.Invalid)
|
||||
{
|
||||
throw new Exception($"Unexpected valid order {ticket}, should fail due to margin not sufficient");
|
||||
throw new RegressionTestException($"Unexpected valid order {ticket}, should fail due to margin not sufficient");
|
||||
}
|
||||
|
||||
Buy(_adaUsdt.Symbol, 1000);
|
||||
@@ -108,28 +108,28 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
|
||||
if (Math.Abs(adaUsdtHoldings.TotalSaleVolume - holdingsValueUsdt) > 1)
|
||||
{
|
||||
throw new Exception($"Unexpected TotalSaleVolume {adaUsdtHoldings.TotalSaleVolume}");
|
||||
throw new RegressionTestException($"Unexpected TotalSaleVolume {adaUsdtHoldings.TotalSaleVolume}");
|
||||
}
|
||||
if (Math.Abs(adaUsdtHoldings.AbsoluteHoldingsCost - holdingsValueUsdt) > 1)
|
||||
{
|
||||
throw new Exception($"Unexpected holdings cost {adaUsdtHoldings.HoldingsCost}");
|
||||
throw new RegressionTestException($"Unexpected holdings cost {adaUsdtHoldings.HoldingsCost}");
|
||||
}
|
||||
if (Math.Abs(adaUsdtHoldings.AbsoluteHoldingsCost * 0.05m - marginUsed) > 1
|
||||
|| _adaUsdt.BuyingPowerModel.GetMaintenanceMargin(_adaUsdt) != marginUsed)
|
||||
{
|
||||
throw new Exception($"Unexpected margin used {marginUsed}");
|
||||
throw new RegressionTestException($"Unexpected margin used {marginUsed}");
|
||||
}
|
||||
|
||||
// position just opened should be just spread here
|
||||
var profit = Portfolio.TotalUnrealizedProfit;
|
||||
if ((5 - Math.Abs(profit)) < 0)
|
||||
{
|
||||
throw new Exception($"Unexpected TotalUnrealizedProfit {Portfolio.TotalUnrealizedProfit}");
|
||||
throw new RegressionTestException($"Unexpected TotalUnrealizedProfit {Portfolio.TotalUnrealizedProfit}");
|
||||
}
|
||||
|
||||
if (Portfolio.TotalProfit != 0)
|
||||
{
|
||||
throw new Exception($"Unexpected TotalProfit {Portfolio.TotalProfit}");
|
||||
throw new RegressionTestException($"Unexpected TotalProfit {Portfolio.TotalProfit}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -147,19 +147,19 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
|
||||
if (Math.Abs(adaUsdtHoldings.AbsoluteHoldingsCost - holdingsValueUsdt) > 1)
|
||||
{
|
||||
throw new Exception($"Unexpected holdings cost {adaUsdtHoldings.HoldingsCost}");
|
||||
throw new RegressionTestException($"Unexpected holdings cost {adaUsdtHoldings.HoldingsCost}");
|
||||
}
|
||||
|
||||
// position just opened should be just spread here
|
||||
var profit = Portfolio.TotalUnrealizedProfit;
|
||||
if ((5 - Math.Abs(profit)) < 0)
|
||||
{
|
||||
throw new Exception($"Unexpected TotalUnrealizedProfit {Portfolio.TotalUnrealizedProfit}");
|
||||
throw new RegressionTestException($"Unexpected TotalUnrealizedProfit {Portfolio.TotalUnrealizedProfit}");
|
||||
}
|
||||
// we barely did any difference on the previous trade
|
||||
if ((5 - Math.Abs(Portfolio.TotalProfit)) < 0)
|
||||
{
|
||||
throw new Exception($"Unexpected TotalProfit {Portfolio.TotalProfit}");
|
||||
throw new RegressionTestException($"Unexpected TotalProfit {Portfolio.TotalProfit}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -174,7 +174,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{
|
||||
if (_interestPerSymbol[_adaUsdt.Symbol] != 1)
|
||||
{
|
||||
throw new Exception($"Unexpected interest rate count {_interestPerSymbol[_adaUsdt.Symbol]}");
|
||||
throw new RegressionTestException($"Unexpected interest rate count {_interestPerSymbol[_adaUsdt.Symbol]}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -191,7 +191,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate which languages this algorithm is written in.
|
||||
/// </summary>
|
||||
public Language[] Languages { get; } = { Language.CSharp, Language.Python };
|
||||
public List<Language> Languages { get; } = new() { Language.CSharp, Language.Python };
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of all timeslices of algorithm
|
||||
@@ -203,6 +203,11 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// </summary>
|
||||
public int AlgorithmHistoryDataPoints => 0;
|
||||
|
||||
/// <summary>
|
||||
/// Final status of the algorithm
|
||||
/// </summary>
|
||||
public AlgorithmStatus AlgorithmStatus => AlgorithmStatus.Completed;
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate what the expected statistics are from running the algorithm
|
||||
/// </summary>
|
||||
@@ -234,6 +239,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Estimated Strategy Capacity", "$370000000.00"},
|
||||
{"Lowest Capacity Asset", "ADAUSDT 18R"},
|
||||
{"Portfolio Turnover", "0.12%"},
|
||||
{"Drawdown Recovery", "0"},
|
||||
{"OrderListHash", "50a51d06d03a5355248a6bccef1ca521"}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -43,8 +43,8 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// OnData event is the primary entry point for your algorithm. Each new data point will be pumped in here.
|
||||
/// </summary>
|
||||
/// <param name="data">Slice object keyed by symbol containing the stock data</param>
|
||||
public override void OnData(Slice data)
|
||||
/// <param name="slice">Slice object keyed by symbol containing the stock data</param>
|
||||
public override void OnData(Slice slice)
|
||||
{
|
||||
if (!Portfolio.Invested)
|
||||
{
|
||||
@@ -61,18 +61,23 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate which languages this algorithm is written in.
|
||||
/// </summary>
|
||||
public Language[] Languages { get; } = { Language.CSharp, Language.Python };
|
||||
public List<Language> Languages { get; } = new() { Language.CSharp, Language.Python };
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of all timeslices of algorithm
|
||||
/// </summary>
|
||||
public long DataPoints => 73;
|
||||
public long DataPoints => 72;
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of the algorithm history
|
||||
/// </summary>
|
||||
public int AlgorithmHistoryDataPoints => 0;
|
||||
|
||||
/// <summary>
|
||||
/// Final status of the algorithm
|
||||
/// </summary>
|
||||
public AlgorithmStatus AlgorithmStatus => AlgorithmStatus.Completed;
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate what the expected statistics are from running the algorithm
|
||||
/// </summary>
|
||||
@@ -81,30 +86,31 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Total Orders", "1"},
|
||||
{"Average Win", "0%"},
|
||||
{"Average Loss", "0%"},
|
||||
{"Compounding Annual Return", "246.546%"},
|
||||
{"Drawdown", "1.200%"},
|
||||
{"Compounding Annual Return", "424.375%"},
|
||||
{"Drawdown", "0.800%"},
|
||||
{"Expectancy", "0"},
|
||||
{"Start Equity", "100000"},
|
||||
{"End Equity", "103463.69"},
|
||||
{"Net Profit", "3.464%"},
|
||||
{"Sharpe Ratio", "19.094"},
|
||||
{"Sortino Ratio", "0"},
|
||||
{"Probabilistic Sharpe Ratio", "97.754%"},
|
||||
{"End Equity", "104486.22"},
|
||||
{"Net Profit", "4.486%"},
|
||||
{"Sharpe Ratio", "17.304"},
|
||||
{"Sortino Ratio", "35.217"},
|
||||
{"Probabilistic Sharpe Ratio", "96.835%"},
|
||||
{"Loss Rate", "0%"},
|
||||
{"Win Rate", "0%"},
|
||||
{"Profit-Loss Ratio", "0"},
|
||||
{"Alpha", "-0.005"},
|
||||
{"Beta", "0.998"},
|
||||
{"Annual Standard Deviation", "0.138"},
|
||||
{"Annual Variance", "0.019"},
|
||||
{"Information Ratio", "-34.028"},
|
||||
{"Tracking Error", "0"},
|
||||
{"Treynor Ratio", "2.644"},
|
||||
{"Total Fees", "$3.45"},
|
||||
{"Estimated Strategy Capacity", "$970000000.00"},
|
||||
{"Alpha", "-0.249"},
|
||||
{"Beta", "1.015"},
|
||||
{"Annual Standard Deviation", "0.141"},
|
||||
{"Annual Variance", "0.02"},
|
||||
{"Information Ratio", "-19"},
|
||||
{"Tracking Error", "0.011"},
|
||||
{"Treynor Ratio", "2.403"},
|
||||
{"Total Fees", "$3.49"},
|
||||
{"Estimated Strategy Capacity", "$1200000000.00"},
|
||||
{"Lowest Capacity Asset", "SPY R735QTJ8XC9X"},
|
||||
{"Portfolio Turnover", "10.09%"},
|
||||
{"OrderListHash", "39a84b9f15bb4e8ead0f0ecb59f28562"}
|
||||
{"Portfolio Turnover", "10.01%"},
|
||||
{"Drawdown Recovery", "1"},
|
||||
{"OrderListHash", "70f21e930175a2ec9d465b21edc1b6d9"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
240
Algorithm.CSharp/BasicTemplateEurexFuturesAlgorithm.cs
Normal file
240
Algorithm.CSharp/BasicTemplateEurexFuturesAlgorithm.cs
Normal file
@@ -0,0 +1,240 @@
|
||||
/*
|
||||
* QUANTCONNECT.COM - Democratizing Finance, Empowering Individuals.
|
||||
* Lean Algorithmic Trading Engine v2.0. Copyright 2014 QuantConnect Corporation.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using QuantConnect.Data;
|
||||
using QuantConnect.Data.UniverseSelection;
|
||||
using QuantConnect.Interfaces;
|
||||
using QuantConnect.Orders;
|
||||
using QuantConnect.Securities;
|
||||
using QuantConnect.Securities.Future;
|
||||
|
||||
namespace QuantConnect.Algorithm.CSharp
|
||||
{
|
||||
/// <summary>
|
||||
/// This algorithm tests and demonstrates EUREX futures subscription and trading:
|
||||
/// - It tests contracts rollover by adding a continuous future and asserting that mapping happens at some point.
|
||||
/// - It tests basic trading by buying a contract and holding it until expiration.
|
||||
/// - It tests delisting and asserts the holdings are liquidated after that.
|
||||
/// </summary>
|
||||
public class BasicTemplateEurexFuturesAlgorithm : QCAlgorithm, IRegressionAlgorithmDefinition
|
||||
{
|
||||
private Future _continuousContract;
|
||||
private Symbol _mappedSymbol;
|
||||
private Symbol _contractToTrade;
|
||||
private int _mappingsCount;
|
||||
private decimal _boughtQuantity;
|
||||
private decimal _liquidatedQuantity;
|
||||
private bool _delisted;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
SetStartDate(2024, 5, 30);
|
||||
SetEndDate(2024, 6, 23);
|
||||
|
||||
SetAccountCurrency(Currencies.EUR);
|
||||
SetCash(1000000);
|
||||
|
||||
_continuousContract = AddFuture(Futures.Indices.EuroStoxx50, Resolution.Minute,
|
||||
dataNormalizationMode: DataNormalizationMode.BackwardsRatio,
|
||||
dataMappingMode: DataMappingMode.FirstDayMonth,
|
||||
contractDepthOffset: 0);
|
||||
_continuousContract.SetFilter(TimeSpan.Zero, TimeSpan.FromDays(180));
|
||||
_mappedSymbol = _continuousContract.Mapped;
|
||||
|
||||
var benchmark = AddIndex("SX5E");
|
||||
SetBenchmark(benchmark.Symbol);
|
||||
|
||||
var seeder = new FuncSecuritySeeder(GetLastKnownPrices);
|
||||
SetSecurityInitializer(security => seeder.SeedSecurity(security));
|
||||
}
|
||||
|
||||
public override void OnData(Slice slice)
|
||||
{
|
||||
foreach (var changedEvent in slice.SymbolChangedEvents.Values)
|
||||
{
|
||||
if (++_mappingsCount > 1)
|
||||
{
|
||||
throw new RegressionTestException($"{Time} - Unexpected number of symbol changed events (mappings): {_mappingsCount}. " +
|
||||
$"Expected only 1.");
|
||||
}
|
||||
|
||||
Debug($"{Time} - SymbolChanged event: {changedEvent}");
|
||||
|
||||
if (changedEvent.OldSymbol != _mappedSymbol.ID.ToString())
|
||||
{
|
||||
throw new RegressionTestException($"{Time} - Unexpected symbol changed event old symbol: {changedEvent}");
|
||||
}
|
||||
|
||||
if (changedEvent.NewSymbol != _continuousContract.Mapped.ID.ToString())
|
||||
{
|
||||
throw new RegressionTestException($"{Time} - Unexpected symbol changed event new symbol: {changedEvent}");
|
||||
}
|
||||
|
||||
// Let's trade the previous mapped contract, so we can hold it until expiration for testing
|
||||
// (will be sooner than the new mapped contract)
|
||||
_contractToTrade = _mappedSymbol;
|
||||
_mappedSymbol = _continuousContract.Mapped;
|
||||
}
|
||||
|
||||
// Let's trade after the mapping is done
|
||||
if (_contractToTrade != null && _boughtQuantity == 0 && Securities[_contractToTrade].Exchange.ExchangeOpen)
|
||||
{
|
||||
Buy(_contractToTrade, 1);
|
||||
}
|
||||
|
||||
if (_contractToTrade != null && slice.Delistings.TryGetValue(_contractToTrade, out var delisting))
|
||||
{
|
||||
if (delisting.Type == DelistingType.Delisted)
|
||||
{
|
||||
_delisted = true;
|
||||
|
||||
if (Portfolio.Invested)
|
||||
{
|
||||
throw new RegressionTestException($"{Time} - Portfolio should not be invested after the traded contract is delisted.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnOrderEvent(OrderEvent orderEvent)
|
||||
{
|
||||
if (orderEvent.Symbol != _contractToTrade)
|
||||
{
|
||||
throw new RegressionTestException($"{Time} - Unexpected order event symbol: {orderEvent.Symbol}. Expected {_contractToTrade}");
|
||||
}
|
||||
|
||||
if (orderEvent.Direction == OrderDirection.Buy)
|
||||
{
|
||||
if (orderEvent.Status == OrderStatus.Filled)
|
||||
{
|
||||
if (_boughtQuantity != 0 && _liquidatedQuantity != 0)
|
||||
{
|
||||
throw new RegressionTestException($"{Time} - Unexpected buy order event status: {orderEvent.Status}");
|
||||
}
|
||||
_boughtQuantity = orderEvent.Quantity;
|
||||
}
|
||||
}
|
||||
else if (orderEvent.Direction == OrderDirection.Sell)
|
||||
{
|
||||
if (orderEvent.Status == OrderStatus.Filled)
|
||||
{
|
||||
if (_boughtQuantity <= 0 && _liquidatedQuantity != 0)
|
||||
{
|
||||
throw new RegressionTestException($"{Time} - Unexpected sell order event status: {orderEvent.Status}");
|
||||
}
|
||||
_liquidatedQuantity = orderEvent.Quantity;
|
||||
|
||||
if (_liquidatedQuantity != -_boughtQuantity)
|
||||
{
|
||||
throw new RegressionTestException($"{Time} - Unexpected liquidated quantity: {_liquidatedQuantity}. Expected: {-_boughtQuantity}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnSecuritiesChanged(SecurityChanges changes)
|
||||
{
|
||||
foreach (var addedSecurity in changes.AddedSecurities)
|
||||
{
|
||||
if (addedSecurity.Symbol.SecurityType == SecurityType.Future && addedSecurity.Symbol.IsCanonical())
|
||||
{
|
||||
_mappedSymbol = _continuousContract.Mapped;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnEndOfAlgorithm()
|
||||
{
|
||||
if (_mappingsCount == 0)
|
||||
{
|
||||
throw new RegressionTestException($"Unexpected number of symbol changed events (mappings): {_mappingsCount}. Expected 1.");
|
||||
}
|
||||
|
||||
if (!_delisted)
|
||||
{
|
||||
throw new RegressionTestException("Contract was not delisted");
|
||||
}
|
||||
|
||||
// Make sure we traded and that the position was liquidated on delisting
|
||||
if (_boughtQuantity <= 0 || _liquidatedQuantity >= 0)
|
||||
{
|
||||
throw new RegressionTestException($"Unexpected sold quantity: {_boughtQuantity} and liquidated quantity: {_liquidatedQuantity}");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate if the open source Lean repository has the required data to run this algorithm.
|
||||
/// </summary>
|
||||
public bool CanRunLocally { get; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate which languages this algorithm is written in.
|
||||
/// </summary>
|
||||
public List<Language> Languages { get; } = new() { Language.CSharp, Language.Python };
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of all timeslices of algorithm
|
||||
/// </summary>
|
||||
public long DataPoints => 94326;
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of the algorithm history
|
||||
/// </summary>
|
||||
public int AlgorithmHistoryDataPoints => 0;
|
||||
|
||||
/// <summary>
|
||||
/// Final status of the algorithm
|
||||
/// </summary>
|
||||
public AlgorithmStatus AlgorithmStatus => AlgorithmStatus.Completed;
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate what the expected statistics are from running the algorithm
|
||||
/// </summary>
|
||||
public Dictionary<string, string> ExpectedStatistics => new Dictionary<string, string>
|
||||
{
|
||||
{"Total Orders", "2"},
|
||||
{"Average Win", "0%"},
|
||||
{"Average Loss", "-0.11%"},
|
||||
{"Compounding Annual Return", "-1.667%"},
|
||||
{"Drawdown", "0.100%"},
|
||||
{"Expectancy", "-1"},
|
||||
{"Start Equity", "1000000"},
|
||||
{"End Equity", "998849.48"},
|
||||
{"Net Profit", "-0.115%"},
|
||||
{"Sharpe Ratio", "-34.455"},
|
||||
{"Sortino Ratio", "-57.336"},
|
||||
{"Probabilistic Sharpe Ratio", "0.002%"},
|
||||
{"Loss Rate", "100%"},
|
||||
{"Win Rate", "0%"},
|
||||
{"Profit-Loss Ratio", "0"},
|
||||
{"Alpha", "0"},
|
||||
{"Beta", "0"},
|
||||
{"Annual Standard Deviation", "0.002"},
|
||||
{"Annual Variance", "0"},
|
||||
{"Information Ratio", "-6.176"},
|
||||
{"Tracking Error", "0.002"},
|
||||
{"Treynor Ratio", "0"},
|
||||
{"Total Fees", "€1.02"},
|
||||
{"Estimated Strategy Capacity", "€2300000000.00"},
|
||||
{"Lowest Capacity Asset", "FESX YJHOAMPYKRS5"},
|
||||
{"Portfolio Turnover", "0.40%"},
|
||||
{"Drawdown Recovery", "0"},
|
||||
{"OrderListHash", "ac9acc478ba1afe53993cdbb92f8ec6e"}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -13,6 +13,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
using QuantConnect.Data;
|
||||
using QuantConnect.Data.Market;
|
||||
|
||||
namespace QuantConnect.Algorithm.CSharp
|
||||
@@ -41,8 +42,8 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// OnData event is the primary entry point for your algorithm. Each new data point will be pumped in here.
|
||||
/// </summary>
|
||||
/// <param name="data">TradeBars IDictionary object with your stock data</param>
|
||||
public void OnData(TradeBars data)
|
||||
/// <param name="slice">Slice object keyed by symbol containing the stock data</param>
|
||||
public override void OnData(Slice slice)
|
||||
{
|
||||
if (!Portfolio.Invested)
|
||||
{
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
* QUANTCONNECT.COM - Democratizing Finance, Empowering Individuals.
|
||||
* Lean Algorithmic Trading Engine v2.0. Copyright 2014 QuantConnect Corporation.
|
||||
*
|
||||
@@ -59,14 +59,14 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// OnData event is the primary entry point for your algorithm. Each new data point will be pumped in here.
|
||||
/// </summary>
|
||||
/// <param name="data">Slice object keyed by symbol containing the stock data</param>
|
||||
public override void OnData(Slice data)
|
||||
public override void OnData(Slice slice)
|
||||
{
|
||||
if (!Portfolio.Invested)
|
||||
{
|
||||
SetHoldings("EURUSD", .5);
|
||||
SetHoldings("NZDUSD", .5);
|
||||
Log(string.Join(", ", data.Values));
|
||||
Log(string.Join(", ", slice.Values));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,7 +82,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate which languages this algorithm is written in.
|
||||
/// </summary>
|
||||
public virtual Language[] Languages { get; } = { Language.CSharp, Language.Python };
|
||||
public virtual List<Language> Languages { get; } = new() { Language.CSharp, Language.Python };
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of all timeslices of algorithm
|
||||
@@ -94,6 +94,11 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// </summary>
|
||||
public int AlgorithmHistoryDataPoints => 0;
|
||||
|
||||
/// <summary>
|
||||
/// Final status of the algorithm
|
||||
/// </summary>
|
||||
public AlgorithmStatus AlgorithmStatus => AlgorithmStatus.Completed;
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate what the expected statistics are from running the algorithm
|
||||
/// </summary>
|
||||
@@ -125,6 +130,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Estimated Strategy Capacity", "$27000000.00"},
|
||||
{"Lowest Capacity Asset", "SPY R735QTJ8XC9X"},
|
||||
{"Portfolio Turnover", "59.86%"},
|
||||
{"Drawdown Recovery", "3"},
|
||||
{"OrderListHash", "f209ed42701b0419858e0100595b40c0"}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -98,10 +98,10 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{
|
||||
private QCAlgorithm _algorithm;
|
||||
private Future _future;
|
||||
public ExponentialMovingAverage EMA;
|
||||
public decimal Price;
|
||||
public bool IsLong;
|
||||
public bool IsShort;
|
||||
public ExponentialMovingAverage EMA { get; set; }
|
||||
public decimal Price { get; set; }
|
||||
public bool IsLong { get; set; }
|
||||
public bool IsShort { get; set; }
|
||||
public Symbol Symbol => _future.Symbol;
|
||||
public Symbol Mapped => _future.Mapped;
|
||||
|
||||
@@ -171,50 +171,56 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate which languages this algorithm is written in.
|
||||
/// </summary>
|
||||
public Language[] Languages { get; } = { Language.CSharp, Language.Python };
|
||||
public List<Language> Languages { get; } = new() { Language.CSharp, Language.Python };
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of all timeslices of algorithm
|
||||
/// </summary>
|
||||
public long DataPoints => 1334;
|
||||
public long DataPoints => 727;
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of the algorithm history
|
||||
/// </summary>
|
||||
public int AlgorithmHistoryDataPoints => 4;
|
||||
public int AlgorithmHistoryDataPoints => 2;
|
||||
|
||||
/// <summary>
|
||||
/// Final status of the algorithm
|
||||
/// </summary>
|
||||
public AlgorithmStatus AlgorithmStatus => AlgorithmStatus.Completed;
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate what the expected statistics are from running the algorithm
|
||||
/// </summary>
|
||||
public Dictionary<string, string> ExpectedStatistics => new Dictionary<string, string>
|
||||
{
|
||||
{"Total Orders", "2"},
|
||||
{"Average Win", "0.53%"},
|
||||
{"Total Orders", "1"},
|
||||
{"Average Win", "0%"},
|
||||
{"Average Loss", "0%"},
|
||||
{"Compounding Annual Return", "3.011%"},
|
||||
{"Compounding Annual Return", "-0.010%"},
|
||||
{"Drawdown", "0.000%"},
|
||||
{"Expectancy", "0"},
|
||||
{"Start Equity", "1000000"},
|
||||
{"End Equity", "1005283.2"},
|
||||
{"Net Profit", "0.528%"},
|
||||
{"Sharpe Ratio", "1.285"},
|
||||
{"End Equity", "999983.2"},
|
||||
{"Net Profit", "-0.002%"},
|
||||
{"Sharpe Ratio", "-225.214"},
|
||||
{"Sortino Ratio", "0"},
|
||||
{"Probabilistic Sharpe Ratio", "83.704%"},
|
||||
{"Probabilistic Sharpe Ratio", "0.135%"},
|
||||
{"Loss Rate", "0%"},
|
||||
{"Win Rate", "100%"},
|
||||
{"Win Rate", "0%"},
|
||||
{"Profit-Loss Ratio", "0"},
|
||||
{"Alpha", "0.015"},
|
||||
{"Beta", "-0.004"},
|
||||
{"Annual Standard Deviation", "0.011"},
|
||||
{"Alpha", "-0.008"},
|
||||
{"Beta", "0"},
|
||||
{"Annual Standard Deviation", "0"},
|
||||
{"Annual Variance", "0"},
|
||||
{"Information Ratio", "-4.774"},
|
||||
{"Tracking Error", "0.084"},
|
||||
{"Treynor Ratio", "-3.121"},
|
||||
{"Total Fees", "$4.30"},
|
||||
{"Estimated Strategy Capacity", "$5900000000.00"},
|
||||
{"Information Ratio", "-5.146"},
|
||||
{"Tracking Error", "0.083"},
|
||||
{"Treynor Ratio", "-542.359"},
|
||||
{"Total Fees", "$2.15"},
|
||||
{"Estimated Strategy Capacity", "$0"},
|
||||
{"Lowest Capacity Asset", "ES VMKLFZIH2MTD"},
|
||||
{"Portfolio Turnover", "0.27%"},
|
||||
{"OrderListHash", "90f952729deb9cb20be75867576e5b87"}
|
||||
{"Portfolio Turnover", "0.13%"},
|
||||
{"Drawdown Recovery", "0"},
|
||||
{"OrderListHash", "a6ccce3a1a7f549f887d83e84bfa878d"}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,11 +39,9 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
|
||||
// S&P 500 EMini futures
|
||||
private const string RootSP500 = Futures.Indices.SP500EMini;
|
||||
public Symbol SP500 = QuantConnect.Symbol.Create(RootSP500, SecurityType.Future, Market.CME);
|
||||
|
||||
// Gold futures
|
||||
private const string RootGold = Futures.Metals.Gold;
|
||||
public Symbol Gold = QuantConnect.Symbol.Create(RootGold, SecurityType.Future, Market.COMEX);
|
||||
|
||||
/// <summary>
|
||||
/// Initialize your algorithm and add desired assets.
|
||||
@@ -81,7 +79,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
Debug($"{Time} - SymbolChanged event: {changedEvent}");
|
||||
if (Time.TimeOfDay != TimeSpan.Zero)
|
||||
{
|
||||
throw new Exception($"{Time} unexpected symbol changed event {changedEvent}!");
|
||||
throw new RegressionTestException($"{Time} unexpected symbol changed event {changedEvent}!");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -117,7 +115,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
var futureMarginModel = buyingPowerModel as FutureMarginModel;
|
||||
if (buyingPowerModel == null)
|
||||
{
|
||||
throw new Exception($"Invalid buying power model. Found: {buyingPowerModel.GetType().Name}. Expected: {nameof(FutureMarginModel)}");
|
||||
throw new RegressionTestException($"Invalid buying power model. Found: {buyingPowerModel.GetType().Name}. Expected: {nameof(FutureMarginModel)}");
|
||||
}
|
||||
var initialOvernight = futureMarginModel.InitialOvernightMarginRequirement;
|
||||
var maintenanceOvernight = futureMarginModel.MaintenanceOvernightMarginRequirement;
|
||||
@@ -133,7 +131,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
&& !addedSecurity.Symbol.IsCanonical()
|
||||
&& !addedSecurity.HasData)
|
||||
{
|
||||
throw new Exception($"Future contracts did not work up as expected: {addedSecurity.Symbol}");
|
||||
throw new RegressionTestException($"Future contracts did not work up as expected: {addedSecurity.Symbol}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -146,17 +144,22 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate which languages this algorithm is written in.
|
||||
/// </summary>
|
||||
public Language[] Languages { get; } = { Language.CSharp, Language.Python };
|
||||
public List<Language> Languages { get; } = new() { Language.CSharp, Language.Python };
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of all timeslices of algorithm
|
||||
/// </summary>
|
||||
public long DataPoints => 75403;
|
||||
public long DataPoints => 40308;
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of the algorithm history
|
||||
/// </summary>
|
||||
public int AlgorithmHistoryDataPoints => 340;
|
||||
public int AlgorithmHistoryDataPoints => 354;
|
||||
|
||||
/// <summary>
|
||||
/// Final status of the algorithm
|
||||
/// </summary>
|
||||
public AlgorithmStatus AlgorithmStatus => AlgorithmStatus.Completed;
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate what the expected statistics are from running the algorithm
|
||||
@@ -166,7 +169,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Total Orders", "2700"},
|
||||
{"Average Win", "0.00%"},
|
||||
{"Average Loss", "0.00%"},
|
||||
{"Compounding Annual Return", "-99.777%"},
|
||||
{"Compounding Annual Return", "-99.597%"},
|
||||
{"Drawdown", "4.400%"},
|
||||
{"Expectancy", "-0.724"},
|
||||
{"Start Equity", "1000000"},
|
||||
@@ -189,6 +192,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Estimated Strategy Capacity", "$14000.00"},
|
||||
{"Lowest Capacity Asset", "GC VOFJUCDY9XNH"},
|
||||
{"Portfolio Turnover", "9912.69%"},
|
||||
{"Drawdown Recovery", "0"},
|
||||
{"OrderListHash", "6e0f767a46a54365287801295cf7bb75"}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
* QUANTCONNECT.COM - Democratizing Finance, Empowering Individuals.
|
||||
* Lean Algorithmic Trading Engine v2.0. Copyright 2014 QuantConnect Corporation.
|
||||
*
|
||||
@@ -33,7 +33,6 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
public class BasicTemplateFuturesConsolidationAlgorithm : QCAlgorithm
|
||||
{
|
||||
private const string RootSP500 = Futures.Indices.SP500EMini;
|
||||
public Symbol SP500 = QuantConnect.Symbol.Create(RootSP500, SecurityType.Future, Market.CME);
|
||||
private HashSet<Symbol> _futureContracts = new HashSet<Symbol>();
|
||||
|
||||
public override void Initialize()
|
||||
@@ -78,4 +77,4 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
Log(quoteBar.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,8 +18,8 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using QuantConnect.Data;
|
||||
using QuantConnect.Data.UniverseSelection;
|
||||
using QuantConnect.Interfaces;
|
||||
using QuantConnect.Orders;
|
||||
using QuantConnect.Securities;
|
||||
using QuantConnect.Securities.Future;
|
||||
|
||||
@@ -83,7 +83,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
// if found, trade it.
|
||||
// Also check if exchange is open for regular or extended hours. Since daily data comes at 8PM, this allows us prevent the
|
||||
// algorithm from trading on friday when there is not after-market.
|
||||
if (contract != null && Securities[contract.Symbol].Exchange.Hours.IsOpen(Time, true))
|
||||
if (contract != null)
|
||||
{
|
||||
MarketOrder(contract.Symbol, 1);
|
||||
}
|
||||
@@ -99,11 +99,21 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{
|
||||
if (Time.TimeOfDay != TimeSpan.Zero)
|
||||
{
|
||||
throw new Exception($"{Time} unexpected symbol changed event {changedEvent}!");
|
||||
throw new RegressionTestException($"{Time} unexpected symbol changed event {changedEvent}!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnSecuritiesChanged(SecurityChanges changes)
|
||||
{
|
||||
if (changes.RemovedSecurities.Count > 0 &&
|
||||
Portfolio.Invested &&
|
||||
Securities.Values.Where(x => x.Invested).All(x => x.Exchange.Hours.IsOpen(Time, true)))
|
||||
{
|
||||
Liquidate();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate if the open source Lean repository has the required data to run this algorithm.
|
||||
/// </summary>
|
||||
@@ -112,50 +122,56 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate which languages this algorithm is written in.
|
||||
/// </summary>
|
||||
public virtual Language[] Languages { get; } = { Language.CSharp, Language.Python };
|
||||
public virtual List<Language> Languages { get; } = new() { Language.CSharp, Language.Python };
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of all timeslices of algorithm
|
||||
/// </summary>
|
||||
public virtual long DataPoints => 14038;
|
||||
public virtual long DataPoints => 5867;
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of the algorithm history
|
||||
/// </summary>
|
||||
public virtual int AlgorithmHistoryDataPoints => 0;
|
||||
|
||||
/// <summary>
|
||||
/// Final status of the algorithm
|
||||
/// </summary>
|
||||
public AlgorithmStatus AlgorithmStatus => AlgorithmStatus.Completed;
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate what the expected statistics are from running the algorithm
|
||||
/// </summary>
|
||||
public virtual Dictionary<string, string> ExpectedStatistics => new Dictionary<string, string>
|
||||
{
|
||||
{"Total Orders", "128"},
|
||||
{"Average Win", "0.26%"},
|
||||
{"Average Loss", "-0.01%"},
|
||||
{"Compounding Annual Return", "-0.071%"},
|
||||
{"Drawdown", "0.400%"},
|
||||
{"Expectancy", "-0.116"},
|
||||
{"Total Orders", "38"},
|
||||
{"Average Win", "0.33%"},
|
||||
{"Average Loss", "-0.03%"},
|
||||
{"Compounding Annual Return", "0.098%"},
|
||||
{"Drawdown", "0.300%"},
|
||||
{"Expectancy", "0.165"},
|
||||
{"Start Equity", "1000000"},
|
||||
{"End Equity", "999287.06"},
|
||||
{"Net Profit", "-0.071%"},
|
||||
{"Sharpe Ratio", "-1.999"},
|
||||
{"Sortino Ratio", "-1.806"},
|
||||
{"Probabilistic Sharpe Ratio", "10.091%"},
|
||||
{"Loss Rate", "97%"},
|
||||
{"Win Rate", "3%"},
|
||||
{"Profit-Loss Ratio", "27.29"},
|
||||
{"Alpha", "-0.008"},
|
||||
{"Beta", "0.001"},
|
||||
{"End Equity", "1000991.96"},
|
||||
{"Net Profit", "0.099%"},
|
||||
{"Sharpe Ratio", "-1.708"},
|
||||
{"Sortino Ratio", "-0.84"},
|
||||
{"Probabilistic Sharpe Ratio", "14.542%"},
|
||||
{"Loss Rate", "89%"},
|
||||
{"Win Rate", "11%"},
|
||||
{"Profit-Loss Ratio", "10.07"},
|
||||
{"Alpha", "-0.007"},
|
||||
{"Beta", "0.002"},
|
||||
{"Annual Standard Deviation", "0.004"},
|
||||
{"Annual Variance", "0"},
|
||||
{"Information Ratio", "-1.367"},
|
||||
{"Information Ratio", "-1.354"},
|
||||
{"Tracking Error", "0.089"},
|
||||
{"Treynor Ratio", "-5.445"},
|
||||
{"Total Fees", "$285.44"},
|
||||
{"Estimated Strategy Capacity", "$1000.00"},
|
||||
{"Treynor Ratio", "-4.054"},
|
||||
{"Total Fees", "$85.54"},
|
||||
{"Estimated Strategy Capacity", "$0"},
|
||||
{"Lowest Capacity Asset", "ES VRJST036ZY0X"},
|
||||
{"Portfolio Turnover", "3.41%"},
|
||||
{"OrderListHash", "394c47e4e0f54c5981d7c8aa99e9bc83"}
|
||||
{"Portfolio Turnover", "1.04%"},
|
||||
{"Drawdown Recovery", "69"},
|
||||
{"OrderListHash", "eafc33ea4dcb219f7aacdbdd0973d5bc"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -131,18 +131,23 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate which languages this algorithm is written in.
|
||||
/// </summary>
|
||||
public virtual Language[] Languages { get; } = { Language.CSharp, Language.Python };
|
||||
public virtual List<Language> Languages { get; } = new() { Language.CSharp, Language.Python };
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of all timeslices of algorithm
|
||||
/// </summary>
|
||||
public virtual long DataPoints => 57754;
|
||||
public virtual long DataPoints => 24883;
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of the algorithm history
|
||||
/// </summary>
|
||||
public virtual int AlgorithmHistoryDataPoints => 0;
|
||||
|
||||
/// <summary>
|
||||
/// Final status of the algorithm
|
||||
/// </summary>
|
||||
public AlgorithmStatus AlgorithmStatus => AlgorithmStatus.Completed;
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate what the expected statistics are from running the algorithm
|
||||
/// </summary>
|
||||
@@ -174,6 +179,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Estimated Strategy Capacity", "$17000000.00"},
|
||||
{"Lowest Capacity Asset", "GC VL5E74HP3EE5"},
|
||||
{"Portfolio Turnover", "43.23%"},
|
||||
{"Drawdown Recovery", "0"},
|
||||
{"OrderListHash", "c0fc1bcdc3008a8d263521bbc9d7cdbd"}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -36,12 +36,12 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate which languages this algorithm is written in.
|
||||
/// </summary>
|
||||
public override Language[] Languages { get; } = { Language.CSharp, Language.Python };
|
||||
public override List<Language> Languages { get; } = new() { Language.CSharp, Language.Python };
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of all timeslices of algorithm
|
||||
/// </summary>
|
||||
public override long DataPoints => 163410;
|
||||
public override long DataPoints => 70262;
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate what the expected statistics are from running the algorithm
|
||||
@@ -74,6 +74,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Estimated Strategy Capacity", "$52000000.00"},
|
||||
{"Lowest Capacity Asset", "GC VL5E74HP3EE5"},
|
||||
{"Portfolio Turnover", "43.77%"},
|
||||
{"Drawdown Recovery", "0"},
|
||||
{"OrderListHash", "dcdaafcefa47465962ace2759ed99c91"}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
var history = History(10, Resolution.Minute);
|
||||
if (history.Count() < 10)
|
||||
{
|
||||
throw new Exception($"Empty history at {Time}");
|
||||
throw new RegressionTestException($"Empty history at {Time}");
|
||||
}
|
||||
_successCount++;
|
||||
}
|
||||
@@ -78,7 +78,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{
|
||||
if (_successCount < ExpectedHistoryCallCount)
|
||||
{
|
||||
throw new Exception($"Scheduled Event did not assert history call as many times as expected: {_successCount}/49");
|
||||
throw new RegressionTestException($"Scheduled Event did not assert history call as many times as expected: {_successCount}/49");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -135,17 +135,22 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate which languages this algorithm is written in.
|
||||
/// </summary>
|
||||
public virtual Language[] Languages { get; } = { Language.CSharp, Language.Python };
|
||||
public virtual List<Language> Languages { get; } = new() { Language.CSharp, Language.Python };
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of all timeslices of algorithm
|
||||
/// </summary>
|
||||
public virtual long DataPoints => 48690;
|
||||
public virtual long DataPoints => 25316;
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of the algorithm history
|
||||
/// </summary>
|
||||
public virtual int AlgorithmHistoryDataPoints => 5305;
|
||||
public virtual int AlgorithmHistoryDataPoints => 6075;
|
||||
|
||||
/// <summary>
|
||||
/// Final status of the algorithm
|
||||
/// </summary>
|
||||
public AlgorithmStatus AlgorithmStatus => AlgorithmStatus.Completed;
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate what the expected statistics are from running the algorithm
|
||||
@@ -178,6 +183,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Estimated Strategy Capacity", "$0"},
|
||||
{"Lowest Capacity Asset", ""},
|
||||
{"Portfolio Turnover", "0%"},
|
||||
{"Drawdown Recovery", "0"},
|
||||
{"OrderListHash", "d41d8cd98f00b204e9800998ecf8427e"}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -42,18 +42,23 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate which languages this algorithm is written in.
|
||||
/// </summary>
|
||||
public override Language[] Languages { get; } = { Language.CSharp, Language.Python };
|
||||
public override List<Language> Languages { get; } = new() { Language.CSharp, Language.Python };
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of all timeslices of algorithm
|
||||
/// </summary>
|
||||
public override long DataPoints => 147771;
|
||||
public override long DataPoints => 76063;
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of the algorithm history
|
||||
/// </summary>
|
||||
public override int AlgorithmHistoryDataPoints => 6112;
|
||||
|
||||
/// <summary>
|
||||
/// Final status of the algorithm
|
||||
/// </summary>
|
||||
public AlgorithmStatus AlgorithmStatus => AlgorithmStatus.Completed;
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate what the expected statistics are from running the algorithm
|
||||
/// </summary>
|
||||
@@ -85,6 +90,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Estimated Strategy Capacity", "$0"},
|
||||
{"Lowest Capacity Asset", ""},
|
||||
{"Portfolio Turnover", "0%"},
|
||||
{"Drawdown Recovery", "0"},
|
||||
{"OrderListHash", "d41d8cd98f00b204e9800998ecf8427e"}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -14,12 +14,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using QuantConnect.Data;
|
||||
using QuantConnect.Interfaces;
|
||||
using QuantConnect.Securities;
|
||||
|
||||
namespace QuantConnect.Algorithm.CSharp
|
||||
{
|
||||
@@ -36,45 +31,46 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate which languages this algorithm is written in.
|
||||
/// </summary>
|
||||
public override Language[] Languages { get; } = { Language.CSharp, Language.Python };
|
||||
public override List<Language> Languages { get; } = new() { Language.CSharp, Language.Python };
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of all timeslices of algorithm
|
||||
/// </summary>
|
||||
public override long DataPoints => 87393;
|
||||
public override long DataPoints => 25339;
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate what the expected statistics are from running the algorithm
|
||||
/// </summary>
|
||||
public override Dictionary<string, string> ExpectedStatistics => new Dictionary<string, string>
|
||||
{
|
||||
{"Total Orders", "638"},
|
||||
{"Average Win", "0.02%"},
|
||||
{"Total Orders", "718"},
|
||||
{"Average Win", "0.03%"},
|
||||
{"Average Loss", "-0.01%"},
|
||||
{"Compounding Annual Return", "-1.610%"},
|
||||
{"Drawdown", "1.600%"},
|
||||
{"Expectancy", "-0.841"},
|
||||
{"Compounding Annual Return", "-1.720%"},
|
||||
{"Drawdown", "1.700%"},
|
||||
{"Expectancy", "-0.770"},
|
||||
{"Start Equity", "1000000"},
|
||||
{"End Equity", "983783.82"},
|
||||
{"Net Profit", "-1.622%"},
|
||||
{"Sharpe Ratio", "-8.787"},
|
||||
{"Sortino Ratio", "-5.428"},
|
||||
{"End Equity", "982676.58"},
|
||||
{"Net Profit", "-1.732%"},
|
||||
{"Sharpe Ratio", "-8.877"},
|
||||
{"Sortino Ratio", "-5.476"},
|
||||
{"Probabilistic Sharpe Ratio", "0.000%"},
|
||||
{"Loss Rate", "96%"},
|
||||
{"Win Rate", "4%"},
|
||||
{"Profit-Loss Ratio", "3.21"},
|
||||
{"Profit-Loss Ratio", "4.90"},
|
||||
{"Alpha", "-0.018"},
|
||||
{"Beta", "-0.003"},
|
||||
{"Beta", "-0.002"},
|
||||
{"Annual Standard Deviation", "0.002"},
|
||||
{"Annual Variance", "0"},
|
||||
{"Information Ratio", "-1.473"},
|
||||
{"Information Ratio", "-1.484"},
|
||||
{"Tracking Error", "0.089"},
|
||||
{"Treynor Ratio", "5.593"},
|
||||
{"Total Fees", "$1456.18"},
|
||||
{"Estimated Strategy Capacity", "$9000.00"},
|
||||
{"Treynor Ratio", "9.171"},
|
||||
{"Total Fees", "$1638.42"},
|
||||
{"Estimated Strategy Capacity", "$8000.00"},
|
||||
{"Lowest Capacity Asset", "ES VP274HSU1AF5"},
|
||||
{"Portfolio Turnover", "17.91%"},
|
||||
{"OrderListHash", "b5214a0fcd0694093aa2a478a983de1a"}
|
||||
{"Portfolio Turnover", "20.14%"},
|
||||
{"Drawdown Recovery", "0"},
|
||||
{"OrderListHash", "c301a0a086f8905b1a555f0257087272"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,11 +39,9 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
|
||||
// S&P 500 EMini futures
|
||||
private const string RootSP500 = Futures.Indices.SP500EMini;
|
||||
public Symbol SP500 = QuantConnect.Symbol.Create(RootSP500, SecurityType.Future, Market.CME);
|
||||
|
||||
// Gold futures
|
||||
private const string RootGold = Futures.Metals.Gold;
|
||||
public Symbol Gold = QuantConnect.Symbol.Create(RootGold, SecurityType.Future, Market.COMEX);
|
||||
|
||||
/// <summary>
|
||||
/// Initialize your algorithm and add desired assets.
|
||||
@@ -81,7 +79,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
Debug($"{Time} - SymbolChanged event: {changedEvent}");
|
||||
if (Time.TimeOfDay != TimeSpan.Zero)
|
||||
{
|
||||
throw new Exception($"{Time} unexpected symbol changed event {changedEvent}!");
|
||||
throw new RegressionTestException($"{Time} unexpected symbol changed event {changedEvent}!");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -117,7 +115,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
var futureMarginModel = buyingPowerModel as FutureMarginModel;
|
||||
if (buyingPowerModel == null)
|
||||
{
|
||||
throw new Exception($"Invalid buying power model. Found: {buyingPowerModel.GetType().Name}. Expected: {nameof(FutureMarginModel)}");
|
||||
throw new RegressionTestException($"Invalid buying power model. Found: {buyingPowerModel.GetType().Name}. Expected: {nameof(FutureMarginModel)}");
|
||||
}
|
||||
var initialOvernight = futureMarginModel.InitialOvernightMarginRequirement;
|
||||
var maintenanceOvernight = futureMarginModel.MaintenanceOvernightMarginRequirement;
|
||||
@@ -133,7 +131,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
&& !addedSecurity.Symbol.IsCanonical()
|
||||
&& !addedSecurity.HasData)
|
||||
{
|
||||
throw new Exception($"Future contracts did not work up as expected: {addedSecurity.Symbol}");
|
||||
throw new RegressionTestException($"Future contracts did not work up as expected: {addedSecurity.Symbol}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -146,17 +144,22 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate which languages this algorithm is written in.
|
||||
/// </summary>
|
||||
public Language[] Languages { get; } = { Language.CSharp, Language.Python };
|
||||
public List<Language> Languages { get; } = new() { Language.CSharp, Language.Python };
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of all timeslices of algorithm
|
||||
/// </summary>
|
||||
public long DataPoints => 224662;
|
||||
public long DataPoints => 117079;
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of the algorithm history
|
||||
/// </summary>
|
||||
public int AlgorithmHistoryDataPoints => 340;
|
||||
public int AlgorithmHistoryDataPoints => 354;
|
||||
|
||||
/// <summary>
|
||||
/// Final status of the algorithm
|
||||
/// </summary>
|
||||
public AlgorithmStatus AlgorithmStatus => AlgorithmStatus.Completed;
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate what the expected statistics are from running the algorithm
|
||||
@@ -189,6 +192,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Estimated Strategy Capacity", "$130000.00"},
|
||||
{"Lowest Capacity Asset", "GC VOFJUCDY9XNH"},
|
||||
{"Portfolio Turnover", "32523.20%"},
|
||||
{"Drawdown Recovery", "0"},
|
||||
{"OrderListHash", "0664a72652a19956ea3c4915269cc4b9"}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -14,14 +14,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using QuantConnect.Data;
|
||||
using QuantConnect.Interfaces;
|
||||
using QuantConnect.Orders;
|
||||
using QuantConnect.Securities;
|
||||
using QuantConnect.Securities.Future;
|
||||
|
||||
namespace QuantConnect.Algorithm.CSharp
|
||||
{
|
||||
@@ -38,45 +31,46 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate which languages this algorithm is written in.
|
||||
/// </summary>
|
||||
public override Language[] Languages { get; } = { Language.CSharp, Language.Python };
|
||||
public override List<Language> Languages { get; } = new() { Language.CSharp, Language.Python };
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of all timeslices of algorithm
|
||||
/// </summary>
|
||||
public override long DataPoints => 16265;
|
||||
public override long DataPoints => 5971;
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate what the expected statistics are from running the algorithm
|
||||
/// </summary>
|
||||
public override Dictionary<string, string> ExpectedStatistics => new Dictionary<string, string>
|
||||
{
|
||||
{"Total Orders", "156"},
|
||||
{"Average Win", "0.31%"},
|
||||
{"Average Loss", "-0.01%"},
|
||||
{"Compounding Annual Return", "-0.024%"},
|
||||
{"Drawdown", "0.400%"},
|
||||
{"Expectancy", "-0.035"},
|
||||
{"Total Orders", "36"},
|
||||
{"Average Win", "0.33%"},
|
||||
{"Average Loss", "-0.03%"},
|
||||
{"Compounding Annual Return", "0.103%"},
|
||||
{"Drawdown", "0.300%"},
|
||||
{"Expectancy", "0.172"},
|
||||
{"Start Equity", "1000000"},
|
||||
{"End Equity", "999754.94"},
|
||||
{"Net Profit", "-0.025%"},
|
||||
{"Sharpe Ratio", "-1.602"},
|
||||
{"Sortino Ratio", "-1.913"},
|
||||
{"Probabilistic Sharpe Ratio", "11.172%"},
|
||||
{"Loss Rate", "97%"},
|
||||
{"Win Rate", "3%"},
|
||||
{"Profit-Loss Ratio", "36.65"},
|
||||
{"End Equity", "1001033.76"},
|
||||
{"Net Profit", "0.103%"},
|
||||
{"Sharpe Ratio", "-1.701"},
|
||||
{"Sortino Ratio", "-0.809"},
|
||||
{"Probabilistic Sharpe Ratio", "14.685%"},
|
||||
{"Loss Rate", "89%"},
|
||||
{"Win Rate", "11%"},
|
||||
{"Profit-Loss Ratio", "9.55"},
|
||||
{"Alpha", "-0.007"},
|
||||
{"Beta", "-0.001"},
|
||||
{"Annual Standard Deviation", "0.005"},
|
||||
{"Beta", "0.002"},
|
||||
{"Annual Standard Deviation", "0.004"},
|
||||
{"Annual Variance", "0"},
|
||||
{"Information Ratio", "-1.359"},
|
||||
{"Information Ratio", "-1.353"},
|
||||
{"Tracking Error", "0.089"},
|
||||
{"Treynor Ratio", "8.008"},
|
||||
{"Total Fees", "$347.56"},
|
||||
{"Estimated Strategy Capacity", "$1000.00"},
|
||||
{"Treynor Ratio", "-4.042"},
|
||||
{"Total Fees", "$81.24"},
|
||||
{"Estimated Strategy Capacity", "$0"},
|
||||
{"Lowest Capacity Asset", "ES VRJST036ZY0X"},
|
||||
{"Portfolio Turnover", "4.16%"},
|
||||
{"OrderListHash", "52580f1e94ab1875301d3bbd157f4580"}
|
||||
{"Portfolio Turnover", "0.99%"},
|
||||
{"Drawdown Recovery", "69"},
|
||||
{"OrderListHash", "67120ad5c9a6116001dda6c8061e5353"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,29 +36,29 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate which languages this algorithm is written in.
|
||||
/// </summary>
|
||||
public override Language[] Languages { get; } = { Language.CSharp, Language.Python };
|
||||
public override List<Language> Languages { get; } = new() { Language.CSharp, Language.Python };
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of all timeslices of algorithm
|
||||
/// </summary>
|
||||
public override long DataPoints => 228938;
|
||||
public override long DataPoints => 67998;
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate what the expected statistics are from running the algorithm
|
||||
/// </summary>
|
||||
public override Dictionary<string, string> ExpectedStatistics => new Dictionary<string, string>
|
||||
{
|
||||
{"Total Orders", "1990"},
|
||||
{"Total Orders", "1992"},
|
||||
{"Average Win", "0.01%"},
|
||||
{"Average Loss", "-0.01%"},
|
||||
{"Compounding Annual Return", "-4.683%"},
|
||||
{"Compounding Annual Return", "-4.687%"},
|
||||
{"Drawdown", "4.700%"},
|
||||
{"Expectancy", "-0.911"},
|
||||
{"Start Equity", "1000000"},
|
||||
{"End Equity", "952831.02"},
|
||||
{"Net Profit", "-4.717%"},
|
||||
{"Sharpe Ratio", "-7.178"},
|
||||
{"Sortino Ratio", "-5.126"},
|
||||
{"End Equity", "952789.22"},
|
||||
{"Net Profit", "-4.721%"},
|
||||
{"Sharpe Ratio", "-7.183"},
|
||||
{"Sortino Ratio", "-5.14"},
|
||||
{"Probabilistic Sharpe Ratio", "0%"},
|
||||
{"Loss Rate", "97%"},
|
||||
{"Win Rate", "3%"},
|
||||
@@ -69,12 +69,13 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Annual Variance", "0"},
|
||||
{"Information Ratio", "-1.702"},
|
||||
{"Tracking Error", "0.09"},
|
||||
{"Treynor Ratio", "5.049"},
|
||||
{"Total Fees", "$4538.98"},
|
||||
{"Treynor Ratio", "5.054"},
|
||||
{"Total Fees", "$4543.28"},
|
||||
{"Estimated Strategy Capacity", "$3000.00"},
|
||||
{"Lowest Capacity Asset", "ES VP274HSU1AF5"},
|
||||
{"Portfolio Turnover", "56.68%"},
|
||||
{"OrderListHash", "60f85901ecc345e597c0153506792285"}
|
||||
{"Portfolio Turnover", "56.73%"},
|
||||
{"Drawdown Recovery", "0"},
|
||||
{"OrderListHash", "6ce7812de5c98744cc35169a86a24325"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,8 +52,8 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// OnData event is the primary entry point for your algorithm. Each new data point will be pumped in here.
|
||||
/// </summary>
|
||||
/// <param name="data">Slice object keyed by symbol containing the stock data</param>
|
||||
public override void OnData(Slice data)
|
||||
/// <param name="slice">Slice object keyed by symbol containing the stock data</param>
|
||||
public override void OnData(Slice slice)
|
||||
{
|
||||
if (!Portfolio.Invested)
|
||||
{
|
||||
@@ -70,7 +70,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate which languages this algorithm is written in.
|
||||
/// </summary>
|
||||
public Language[] Languages { get; } = { Language.CSharp };
|
||||
public List<Language> Languages { get; } = new() { Language.CSharp };
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of all timeslices of algorithm
|
||||
@@ -82,6 +82,11 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// </summary>
|
||||
public int AlgorithmHistoryDataPoints => 0;
|
||||
|
||||
/// <summary>
|
||||
/// Final status of the algorithm
|
||||
/// </summary>
|
||||
public AlgorithmStatus AlgorithmStatus => AlgorithmStatus.Completed;
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate what the expected statistics are from running the algorithm
|
||||
/// </summary>
|
||||
@@ -113,7 +118,8 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Estimated Strategy Capacity", "$110000000.00"},
|
||||
{"Lowest Capacity Asset", "SPY R735QTJ8XC9X"},
|
||||
{"Portfolio Turnover", "19.96%"},
|
||||
{"OrderListHash", "966f8355817adbc8c724d1062691a60b"}
|
||||
{"Drawdown Recovery", "2"},
|
||||
{"OrderListHash", "60747dce5c2aed393b7dccc258d2c9b5"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,8 +30,8 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <meta name="tag" content="indexes" />
|
||||
public class BasicTemplateIndexAlgorithm : QCAlgorithm, IRegressionAlgorithmDefinition
|
||||
{
|
||||
protected Symbol Spx;
|
||||
protected Symbol SpxOption;
|
||||
protected Symbol Spx { get; set; }
|
||||
protected Symbol SpxOption { get; set; }
|
||||
private ExponentialMovingAverage _emaSlow;
|
||||
private ExponentialMovingAverage _emaFast;
|
||||
|
||||
@@ -61,10 +61,10 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
|
||||
AddIndexOptionContract(SpxOption, Resolution);
|
||||
|
||||
_emaSlow = EMA(Spx, 80);
|
||||
_emaFast = EMA(Spx, 200);
|
||||
_emaSlow = EMA(Spx, Resolution > Resolution.Minute ? 6 : 80);
|
||||
_emaFast = EMA(Spx, Resolution > Resolution.Minute ? 2 : 200);
|
||||
|
||||
Settings.DailyStrictEndTimeEnabled = true;
|
||||
Settings.DailyPreciseEndTime = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -93,12 +93,25 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Asserts indicators are ready
|
||||
/// </summary>
|
||||
/// <exception cref="RegressionTestException"></exception>
|
||||
protected void AssertIndicators()
|
||||
{
|
||||
if (!_emaSlow.IsReady || !_emaFast.IsReady)
|
||||
{
|
||||
throw new RegressionTestException("Indicators are not ready!");
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnEndOfAlgorithm()
|
||||
{
|
||||
if (Portfolio[Spx].TotalSaleVolume > 0)
|
||||
{
|
||||
throw new Exception("Index is not tradable.");
|
||||
throw new RegressionTestException("Index is not tradable.");
|
||||
}
|
||||
AssertIndicators();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -109,7 +122,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate which languages this algorithm is written in.
|
||||
/// </summary>
|
||||
public virtual Language[] Languages { get; } = { Language.CSharp, Language.Python };
|
||||
public virtual List<Language> Languages { get; } = new() { Language.CSharp, Language.Python };
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of all timeslices of algorithm
|
||||
@@ -121,6 +134,11 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// </summary>
|
||||
public virtual int AlgorithmHistoryDataPoints => 0;
|
||||
|
||||
/// <summary>
|
||||
/// Final status of the algorithm
|
||||
/// </summary>
|
||||
public AlgorithmStatus AlgorithmStatus => AlgorithmStatus.Completed;
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate what the expected statistics are from running the algorithm
|
||||
/// </summary>
|
||||
@@ -150,9 +168,10 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Treynor Ratio", "-1.771"},
|
||||
{"Total Fees", "$0.00"},
|
||||
{"Estimated Strategy Capacity", "$3000.00"},
|
||||
{"Lowest Capacity Asset", "SPX XL80P3GHDZXQ|SPX 31"},
|
||||
{"Lowest Capacity Asset", "SPX XL80P3GHIA9A|SPX 31"},
|
||||
{"Portfolio Turnover", "23.97%"},
|
||||
{"OrderListHash", "51f1bc2ea080df79748dc66c2520b782"}
|
||||
{"Drawdown Recovery", "9"},
|
||||
{"OrderListHash", "4b560d2a8cfae510c3c8dc92603470fc"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
|
||||
// two complete weeks starting from the 5th. The 18th bar is not included since it is a holiday
|
||||
protected virtual int ExpectedBarCount => 2 * 5;
|
||||
protected int BarCounter = 0;
|
||||
protected int BarCounter { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Purchase a contract when we are not invested, liquidate otherwise
|
||||
@@ -62,6 +62,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{
|
||||
throw new ArgumentException($"Bar Count {BarCounter} is not expected count of {ExpectedBarCount}");
|
||||
}
|
||||
AssertIndicators();
|
||||
|
||||
if (Resolution != Resolution.Daily)
|
||||
{
|
||||
@@ -69,7 +70,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
}
|
||||
|
||||
var openInterest = Securities[SpxOption].Cache.GetAll<OpenInterest>();
|
||||
if (openInterest.Single().EndTime != new DateTime(2021, 1, 15, 23, 0, 0))
|
||||
if (openInterest.Single().EndTime != new DateTime(2021, 1, 15, 15, 15, 0))
|
||||
{
|
||||
throw new ArgumentException($"Unexpected open interest time: {openInterest.Single().EndTime}");
|
||||
}
|
||||
@@ -79,15 +80,15 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
var history = History(symbol, 10).ToList();
|
||||
if (history.Count != 10)
|
||||
{
|
||||
throw new Exception($"Unexpected history count: {history.Count}");
|
||||
throw new RegressionTestException($"Unexpected history count: {history.Count}");
|
||||
}
|
||||
if (history.Any(x => x.Time.TimeOfDay != new TimeSpan(8, 30, 0)))
|
||||
{
|
||||
throw new Exception($"Unexpected history data start time");
|
||||
throw new RegressionTestException($"Unexpected history data start time");
|
||||
}
|
||||
if (history.Any(x => x.EndTime.TimeOfDay != new TimeSpan(15, 15, 0)))
|
||||
{
|
||||
throw new Exception($"Unexpected history data end time");
|
||||
throw new RegressionTestException($"Unexpected history data end time");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -100,18 +101,23 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate which languages this algorithm is written in.
|
||||
/// </summary>
|
||||
public override Language[] Languages { get; } = { Language.CSharp, Language.Python };
|
||||
public override List<Language> Languages { get; } = new() { Language.CSharp, Language.Python };
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of all timeslices of algorithm
|
||||
/// </summary>
|
||||
public override long DataPoints => 121;
|
||||
public override long DataPoints => 122;
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of the algorithm history
|
||||
/// </summary>
|
||||
public override int AlgorithmHistoryDataPoints => 30;
|
||||
|
||||
/// <summary>
|
||||
/// Final status of the algorithm
|
||||
/// </summary>
|
||||
public AlgorithmStatus AlgorithmStatus => AlgorithmStatus.Completed;
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate what the expected statistics are from running the algorithm
|
||||
/// </summary>
|
||||
@@ -120,7 +126,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Total Orders", "11"},
|
||||
{"Average Win", "0%"},
|
||||
{"Average Loss", "0%"},
|
||||
{"Compounding Annual Return", "621.484%"},
|
||||
{"Compounding Annual Return", "653.545%"},
|
||||
{"Drawdown", "0%"},
|
||||
{"Expectancy", "0"},
|
||||
{"Start Equity", "1000000"},
|
||||
@@ -141,9 +147,10 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Treynor Ratio", "-6.937"},
|
||||
{"Total Fees", "$0.00"},
|
||||
{"Estimated Strategy Capacity", "$0"},
|
||||
{"Lowest Capacity Asset", "SPX XL80P3GHDZXQ|SPX 31"},
|
||||
{"Lowest Capacity Asset", "SPX XL80P3GHIA9A|SPX 31"},
|
||||
{"Portfolio Turnover", "2.42%"},
|
||||
{"OrderListHash", "61e8517ac3da6bed414ef23d26736fef"}
|
||||
{"Drawdown Recovery", "0"},
|
||||
{"OrderListHash", "ce421d0aeb7bde3bc92a6b87c09c510e"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate which languages this algorithm is written in.
|
||||
/// </summary>
|
||||
public override Language[] Languages { get; } = { Language.CSharp };
|
||||
public override List<Language> Languages { get; } = new() { Language.CSharp };
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of all timeslices of algorithm
|
||||
@@ -30,6 +30,11 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// </summary>
|
||||
public override int AlgorithmHistoryDataPoints => 0;
|
||||
|
||||
/// <summary>
|
||||
/// Final status of the algorithm
|
||||
/// </summary>
|
||||
public AlgorithmStatus AlgorithmStatus => AlgorithmStatus.Completed;
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate what the expected statistics are from running the algorithm
|
||||
/// </summary>
|
||||
@@ -59,9 +64,10 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Treynor Ratio", "-6.189"},
|
||||
{"Total Fees", "$0.00"},
|
||||
{"Estimated Strategy Capacity", "$300000.00"},
|
||||
{"Lowest Capacity Asset", "SPX XL80P3GHDZXQ|SPX 31"},
|
||||
{"Lowest Capacity Asset", "SPX XL80P3GHIA9A|SPX 31"},
|
||||
{"Portfolio Turnover", "24.63%"},
|
||||
{"OrderListHash", "44325fc1fdebb8e54f64a3f6e8a4bcd7"}
|
||||
{"Drawdown Recovery", "0"},
|
||||
{"OrderListHash", "7bc05310e971f09b0663bc380fdfee80"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
*
|
||||
*/
|
||||
|
||||
using System;
|
||||
using QuantConnect.Data;
|
||||
using System.Collections.Generic;
|
||||
using QuantConnect.Indicators;
|
||||
@@ -48,10 +47,10 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
var spxOptions = AddIndexOption(_spx, Resolution);
|
||||
spxOptions.SetFilter(filterFunc => filterFunc.CallsOnly());
|
||||
|
||||
_emaSlow = EMA(_spx, 80);
|
||||
_emaFast = EMA(_spx, 200);
|
||||
_emaSlow = EMA(_spx, Resolution > Resolution.Minute ? 6 : 80);
|
||||
_emaFast = EMA(_spx, Resolution > Resolution.Minute ? 2 : 200);
|
||||
|
||||
Settings.DailyStrictEndTimeEnabled = true;
|
||||
Settings.DailyPreciseEndTime = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -104,12 +103,13 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{
|
||||
if (Portfolio[_spx].TotalSaleVolume > 0)
|
||||
{
|
||||
throw new Exception("Index is not tradable.");
|
||||
throw new RegressionTestException("Index is not tradable.");
|
||||
}
|
||||
if (Portfolio.TotalSaleVolume == 0)
|
||||
{
|
||||
throw new Exception("Trade volume should be greater than zero by the end of this algorithm");
|
||||
throw new RegressionTestException("Trade volume should be greater than zero by the end of this algorithm");
|
||||
}
|
||||
AssertIndicators();
|
||||
}
|
||||
|
||||
public Symbol InvertOption(Symbol symbol)
|
||||
@@ -123,6 +123,18 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
symbol.ID.Date);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Asserts indicators are ready
|
||||
/// </summary>
|
||||
/// <exception cref="RegressionTestException"></exception>
|
||||
protected void AssertIndicators()
|
||||
{
|
||||
if (!_emaSlow.IsReady || !_emaFast.IsReady)
|
||||
{
|
||||
throw new RegressionTestException("Indicators are not ready!");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate if the open source Lean repository has the required data to run this algorithm.
|
||||
/// </summary>
|
||||
@@ -131,7 +143,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate which languages this algorithm is written in.
|
||||
/// </summary>
|
||||
public virtual Language[] Languages { get; } = { Language.CSharp, Language.Python };
|
||||
public virtual List<Language> Languages { get; } = new() { Language.CSharp, Language.Python };
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of all timeslices of algorithm
|
||||
@@ -143,6 +155,11 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// </summary>
|
||||
public virtual int AlgorithmHistoryDataPoints => 0;
|
||||
|
||||
/// <summary>
|
||||
/// Final status of the algorithm
|
||||
/// </summary>
|
||||
public AlgorithmStatus AlgorithmStatus => AlgorithmStatus.Completed;
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate what the expected statistics are from running the algorithm
|
||||
/// </summary>
|
||||
|
||||
@@ -62,18 +62,23 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate which languages this algorithm is written in.
|
||||
/// </summary>
|
||||
public override Language[] Languages { get; } = { Language.CSharp };
|
||||
public override List<Language> Languages { get; } = new() { Language.CSharp };
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of all timeslices of algorithm
|
||||
/// </summary>
|
||||
public override long DataPoints => 378;
|
||||
public override long DataPoints => 360;
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of the algorithm history
|
||||
/// </summary>
|
||||
public override int AlgorithmHistoryDataPoints => 0;
|
||||
|
||||
/// <summary>
|
||||
/// Final status of the algorithm
|
||||
/// </summary>
|
||||
public AlgorithmStatus AlgorithmStatus => AlgorithmStatus.Completed;
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate what the expected statistics are from running the algorithm
|
||||
/// </summary>
|
||||
@@ -103,9 +108,10 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Treynor Ratio", "-44.954"},
|
||||
{"Total Fees", "$0.00"},
|
||||
{"Estimated Strategy Capacity", "$0"},
|
||||
{"Lowest Capacity Asset", "SPX XL80P59H5E6M|SPX 31"},
|
||||
{"Lowest Capacity Asset", "SPX XL80P59H9OI6|SPX 31"},
|
||||
{"Portfolio Turnover", "0.00%"},
|
||||
{"OrderListHash", "285cec32c0947f0e8cf90ccb672cfa43"}
|
||||
{"Drawdown Recovery", "0"},
|
||||
{"OrderListHash", "34d295b82e29b1dbe8f104d3300d9255"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,18 +33,23 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate which languages this algorithm is written in.
|
||||
/// </summary>
|
||||
public override Language[] Languages { get; } = { Language.CSharp };
|
||||
public override List<Language> Languages { get; } = new() { Language.CSharp };
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of all timeslices of algorithm
|
||||
/// </summary>
|
||||
public override long DataPoints => 2163;
|
||||
public override long DataPoints => 1269;
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of the algorithm history
|
||||
/// </summary>
|
||||
public override int AlgorithmHistoryDataPoints => 0;
|
||||
|
||||
/// <summary>
|
||||
/// Final status of the algorithm
|
||||
/// </summary>
|
||||
public AlgorithmStatus AlgorithmStatus => AlgorithmStatus.Completed;
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate what the expected statistics are from running the algorithm
|
||||
/// </summary>
|
||||
@@ -74,9 +79,10 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Treynor Ratio", "116.921"},
|
||||
{"Total Fees", "$0.00"},
|
||||
{"Estimated Strategy Capacity", "$0"},
|
||||
{"Lowest Capacity Asset", "SPX XL80P59H5E6M|SPX 31"},
|
||||
{"Lowest Capacity Asset", "SPX XL80P59H9OI6|SPX 31"},
|
||||
{"Portfolio Turnover", "0.00%"},
|
||||
{"OrderListHash", "75e6584cb26058b09720c3a828b9fbda"}
|
||||
{"Drawdown Recovery", "0"},
|
||||
{"OrderListHash", "214026660a13ecaecc7074fa97f86ea1"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// OnData event is the primary entry point for your algorithm. Each new data point will be pumped in here.
|
||||
/// </summary>
|
||||
/// <param name="data">Slice object keyed by symbol containing the stock data</param>
|
||||
public override void OnData(Slice data)
|
||||
public override void OnData(Slice slice)
|
||||
{
|
||||
if (!Portfolio.Invested)
|
||||
{
|
||||
@@ -80,7 +80,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate which languages this algorithm is written in.
|
||||
/// </summary>
|
||||
public Language[] Languages { get; } = { Language.CSharp, Language.Python };
|
||||
public List<Language> Languages { get; } = new() { Language.CSharp, Language.Python };
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of all timeslices of algorithm
|
||||
@@ -92,6 +92,11 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// </summary>
|
||||
public int AlgorithmHistoryDataPoints => 0;
|
||||
|
||||
/// <summary>
|
||||
/// Final status of the algorithm
|
||||
/// </summary>
|
||||
public AlgorithmStatus AlgorithmStatus => AlgorithmStatus.Completed;
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate what the expected statistics are from running the algorithm
|
||||
/// </summary>
|
||||
@@ -123,7 +128,8 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Estimated Strategy Capacity", "₹61000000000.00"},
|
||||
{"Lowest Capacity Asset", "YESBANK UL"},
|
||||
{"Portfolio Turnover", "0.00%"},
|
||||
{"OrderListHash", "7a0257f08e3bb9143b825e07ab47fea0"}
|
||||
{"Drawdown Recovery", "0"},
|
||||
{"OrderListHash", "06f782c83dd633dac6f228b91273ba26"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,8 +31,8 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <meta name="tag" content="indexes" />
|
||||
public class BasicTemplateIndiaIndexAlgorithm : QCAlgorithm, IRegressionAlgorithmDefinition
|
||||
{
|
||||
protected Symbol Nifty;
|
||||
protected Symbol NiftyETF;
|
||||
protected Symbol Nifty { get; set; }
|
||||
protected Symbol NiftyETF { get; set; }
|
||||
private ExponentialMovingAverage _emaSlow;
|
||||
private ExponentialMovingAverage _emaFast;
|
||||
|
||||
@@ -92,7 +92,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{
|
||||
if (Portfolio[Nifty].TotalSaleVolume > 0)
|
||||
{
|
||||
throw new Exception("Index is not tradable.");
|
||||
throw new RegressionTestException("Index is not tradable.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,7 +104,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate which languages this algorithm is written in.
|
||||
/// </summary>
|
||||
public virtual Language[] Languages { get; } = { Language.CSharp, Language.Python };
|
||||
public virtual List<Language> Languages { get; } = new() { Language.CSharp, Language.Python };
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of all timeslices of algorithm
|
||||
@@ -116,6 +116,11 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// </summary>
|
||||
public int AlgorithmHistoryDataPoints => 0;
|
||||
|
||||
/// <summary>
|
||||
/// Final status of the algorithm
|
||||
/// </summary>
|
||||
public AlgorithmStatus AlgorithmStatus => AlgorithmStatus.Completed;
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate what the expected statistics are from running the algorithm
|
||||
/// </summary>
|
||||
@@ -147,7 +152,8 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Estimated Strategy Capacity", "₹84000.00"},
|
||||
{"Lowest Capacity Asset", "JUNIORBEES UL"},
|
||||
{"Portfolio Turnover", "0.04%"},
|
||||
{"OrderListHash", "79ab9ec506959c562be8b3cdbb174c39"}
|
||||
{"Drawdown Recovery", "0"},
|
||||
{"OrderListHash", "8790bec8175539e6d92e01608ac57733"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,8 +32,8 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
public class BasicTemplateIntrinioEconomicData : QCAlgorithm
|
||||
{
|
||||
// Set your Intrinio user and password.
|
||||
public string _user = "";
|
||||
public string _password = "";
|
||||
private string _user = string.Empty;
|
||||
private string _password = string.Empty;
|
||||
|
||||
private Symbol _uso; // United States Oil Fund LP
|
||||
private Symbol _bno; // United States Brent Oil Fund LP
|
||||
@@ -81,9 +81,9 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// OnData event is the primary entry point for your algorithm. Each new data point will be pumped in here.
|
||||
/// </summary>
|
||||
/// <param name="data">Slice object keyed by symbol containing the stock data</param>
|
||||
public override void OnData(Slice data)
|
||||
public override void OnData(Slice slice)
|
||||
{
|
||||
var customData = data.Get<IntrinioEconomicData>();
|
||||
var customData = slice.Get<IntrinioEconomicData>();
|
||||
if (customData.Count == 0) return;
|
||||
|
||||
foreach (var economicData in customData.Values)
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <meta name="tag" content="trading and orders" />
|
||||
public class BasicTemplateOptionEquityStrategyAlgorithm : QCAlgorithm, IRegressionAlgorithmDefinition
|
||||
{
|
||||
protected Symbol _optionSymbol;
|
||||
private Symbol _optionSymbol;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
@@ -44,7 +44,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
_optionSymbol = option.Symbol;
|
||||
|
||||
// set our strike/expiry filter for this option chain
|
||||
option.SetFilter(u => u.Strikes(-2, +2)
|
||||
option.SetFilter(u => u.StandardsOnly().Strikes(-2, +2)
|
||||
// Expiration method accepts TimeSpan objects or integer for days.
|
||||
// The following statements yield the same filtering criteria
|
||||
.Expiration(0, 180));
|
||||
@@ -73,7 +73,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
var higherStrike = callContracts[2].Strike;
|
||||
|
||||
var optionStrategy = OptionStrategies.CallButterfly(_optionSymbol, higherStrike, middleStrike, lowerStrike, expiry);
|
||||
|
||||
|
||||
Order(optionStrategy, 10);
|
||||
}
|
||||
}
|
||||
@@ -97,18 +97,23 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate which languages this algorithm is written in.
|
||||
/// </summary>
|
||||
public Language[] Languages { get; } = { Language.CSharp, Language.Python };
|
||||
public List<Language> Languages { get; } = new() { Language.CSharp, Language.Python };
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of all timeslices of algorithm
|
||||
/// </summary>
|
||||
public long DataPoints => 471135;
|
||||
public long DataPoints => 15023;
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of the algorithm history
|
||||
/// </summary>
|
||||
public int AlgorithmHistoryDataPoints => 0;
|
||||
|
||||
/// <summary>
|
||||
/// Final status of the algorithm
|
||||
/// </summary>
|
||||
public AlgorithmStatus AlgorithmStatus => AlgorithmStatus.Completed;
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate what the expected statistics are from running the algorithm
|
||||
/// </summary>
|
||||
@@ -137,10 +142,11 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0"},
|
||||
{"Treynor Ratio", "0"},
|
||||
{"Total Fees", "$26.00"},
|
||||
{"Estimated Strategy Capacity", "$70000.00"},
|
||||
{"Lowest Capacity Asset", "GOOCV W78ZERHAOVVQ|GOOCV VP83T1ZUHROL"},
|
||||
{"Estimated Strategy Capacity", "$69000.00"},
|
||||
{"Lowest Capacity Asset", "GOOCV W78ZERHAT67A|GOOCV VP83T1ZUHROL"},
|
||||
{"Portfolio Turnover", "61.31%"},
|
||||
{"OrderListHash", "35d406df401e5b27244e20f5ec57346e"}
|
||||
{"Drawdown Recovery", "0"},
|
||||
{"OrderListHash", "ccd6cb1b6244d0c6d30b2760938958f1"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,8 +50,9 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
// set our strike/expiry filter for this option chain
|
||||
// SetFilter method accepts TimeSpan objects or integer for days.
|
||||
// The following statements yield the same filtering criteria
|
||||
option.SetFilter(-2, +2, 0, 180);
|
||||
// option.SetFilter(-2, +2, TimeSpan.Zero, TimeSpan.FromDays(180));
|
||||
option.SetFilter(u => u.StandardsOnly()
|
||||
.Strikes(-2, +2)
|
||||
.Expiration(0, 180));
|
||||
|
||||
// Adding this to reproduce GH issue #2314
|
||||
SetWarmup(TimeSpan.FromMinutes(1));
|
||||
@@ -83,7 +84,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
Liquidate();
|
||||
}
|
||||
|
||||
foreach(var kpv in slice.Bars)
|
||||
foreach (var kpv in slice.Bars)
|
||||
{
|
||||
Log($"---> OnData: {Time}, {kpv.Key.Value}, {kpv.Value.Close:0.00}");
|
||||
}
|
||||
@@ -107,18 +108,23 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate which languages this algorithm is written in.
|
||||
/// </summary>
|
||||
public Language[] Languages { get; } = { Language.CSharp };
|
||||
public List<Language> Languages { get; } = new() { Language.CSharp };
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of all timeslices of algorithm
|
||||
/// </summary>
|
||||
public long DataPoints => 471124;
|
||||
public long DataPoints => 15130;
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of the algorithm history
|
||||
/// </summary>
|
||||
public int AlgorithmHistoryDataPoints => 0;
|
||||
|
||||
/// <summary>
|
||||
/// Final status of the algorithm
|
||||
/// </summary>
|
||||
public AlgorithmStatus AlgorithmStatus => AlgorithmStatus.Completed;
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate what the expected statistics are from running the algorithm
|
||||
/// </summary>
|
||||
@@ -147,10 +153,11 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0"},
|
||||
{"Treynor Ratio", "0"},
|
||||
{"Total Fees", "$543.40"},
|
||||
{"Estimated Strategy Capacity", "$3000.00"},
|
||||
{"Lowest Capacity Asset", "GOOCV W78ZFMEBBB2E|GOOCV VP83T1ZUHROL"},
|
||||
{"Estimated Strategy Capacity", "$4000.00"},
|
||||
{"Lowest Capacity Asset", "GOOCV W78ZFMEBFLDY|GOOCV VP83T1ZUHROL"},
|
||||
{"Portfolio Turnover", "338.60%"},
|
||||
{"OrderListHash", "301c15063f6e269023d144ca69a765da"}
|
||||
{"Drawdown Recovery", "0"},
|
||||
{"OrderListHash", "8229716b93428dc885cf856b4cc9fc35"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
public class BasicTemplateOptionsAlgorithm : QCAlgorithm, IRegressionAlgorithmDefinition
|
||||
{
|
||||
private const string UnderlyingTicker = "GOOG";
|
||||
public Symbol OptionSymbol;
|
||||
private Symbol _optionSymbol;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
@@ -45,14 +45,13 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
|
||||
var equity = AddEquity(UnderlyingTicker);
|
||||
var option = AddOption(UnderlyingTicker);
|
||||
OptionSymbol = option.Symbol;
|
||||
_optionSymbol = option.Symbol;
|
||||
|
||||
// set our strike/expiry filter for this option chain
|
||||
option.SetFilter(u => u.Strikes(-2, +2)
|
||||
option.SetFilter(u => u.StandardsOnly().Strikes(-2, +2)
|
||||
// Expiration method accepts TimeSpan objects or integer for days.
|
||||
// The following statements yield the same filtering criteria
|
||||
.Expiration(0, 180));
|
||||
// .Expiration(TimeSpan.Zero, TimeSpan.FromDays(180)));
|
||||
.Expiration(0, 180)); // .Expiration(TimeSpan.Zero, TimeSpan.FromDays(180)));
|
||||
|
||||
// use the underlying equity as the benchmark
|
||||
SetBenchmark(equity.Symbol);
|
||||
@@ -64,10 +63,10 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <param name="slice">The current slice of data keyed by symbol string</param>
|
||||
public override void OnData(Slice slice)
|
||||
{
|
||||
if (!Portfolio.Invested && IsMarketOpen(OptionSymbol))
|
||||
if (!Portfolio.Invested && IsMarketOpen(_optionSymbol))
|
||||
{
|
||||
OptionChain chain;
|
||||
if (slice.OptionChains.TryGetValue(OptionSymbol, out chain))
|
||||
if (slice.OptionChains.TryGetValue(_optionSymbol, out chain))
|
||||
{
|
||||
// we find at the money (ATM) put contract with farthest expiration
|
||||
var atmContract = chain
|
||||
@@ -104,18 +103,23 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate which languages this algorithm is written in.
|
||||
/// </summary>
|
||||
public Language[] Languages { get; } = { Language.CSharp, Language.Python };
|
||||
public List<Language> Languages { get; } = new() { Language.CSharp, Language.Python };
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of all timeslices of algorithm
|
||||
/// </summary>
|
||||
public long DataPoints => 471124;
|
||||
public long DataPoints => 15012;
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of the algorithm history
|
||||
/// </summary>
|
||||
public int AlgorithmHistoryDataPoints => 0;
|
||||
|
||||
/// <summary>
|
||||
/// Final status of the algorithm
|
||||
/// </summary>
|
||||
public AlgorithmStatus AlgorithmStatus => AlgorithmStatus.Completed;
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate what the expected statistics are from running the algorithm
|
||||
/// </summary>
|
||||
@@ -145,9 +149,10 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Treynor Ratio", "0"},
|
||||
{"Total Fees", "$2.00"},
|
||||
{"Estimated Strategy Capacity", "$1300000.00"},
|
||||
{"Lowest Capacity Asset", "GOOCV 30AKMEIPOSS1Y|GOOCV VP83T1ZUHROL"},
|
||||
{"Lowest Capacity Asset", "GOOCV 30AKMEIPOX2DI|GOOCV VP83T1ZUHROL"},
|
||||
{"Portfolio Turnover", "10.71%"},
|
||||
{"OrderListHash", "8a36462ee0349c04d01d464e592dd347"}
|
||||
{"Drawdown Recovery", "0"},
|
||||
{"OrderListHash", "19ba1220073493495880581b38df2da9"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,7 +97,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate which languages this algorithm is written in.
|
||||
/// </summary>
|
||||
public Language[] Languages { get; } = { Language.CSharp, Language.Python };
|
||||
public List<Language> Languages { get; } = new() { Language.CSharp, Language.Python };
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of all timeslices of algorithm
|
||||
@@ -109,6 +109,11 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// </summary>
|
||||
public int AlgorithmHistoryDataPoints => 0;
|
||||
|
||||
/// <summary>
|
||||
/// Final status of the algorithm
|
||||
/// </summary>
|
||||
public AlgorithmStatus AlgorithmStatus => AlgorithmStatus.Completed;
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate what the expected statistics are from running the algorithm
|
||||
/// </summary>
|
||||
@@ -140,6 +145,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Estimated Strategy Capacity", "$0"},
|
||||
{"Lowest Capacity Asset", ""},
|
||||
{"Portfolio Turnover", "0%"},
|
||||
{"Drawdown Recovery", "0"},
|
||||
{"OrderListHash", "d41d8cd98f00b204e9800998ecf8427e"}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -34,21 +34,21 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <meta name="tag" content="filter selection" />
|
||||
public class BasicTemplateOptionsDailyAlgorithm : QCAlgorithm, IRegressionAlgorithmDefinition
|
||||
{
|
||||
private const string UnderlyingTicker = "GOOG";
|
||||
public Symbol OptionSymbol;
|
||||
private const string UnderlyingTicker = "AAPL";
|
||||
private Symbol _optionSymbol;
|
||||
private bool _optionExpired;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
SetStartDate(2015, 12, 23);
|
||||
SetEndDate(2016, 1, 20);
|
||||
SetStartDate(2015, 12, 15);
|
||||
SetEndDate(2016, 2, 1);
|
||||
SetCash(100000);
|
||||
|
||||
var equity = AddEquity(UnderlyingTicker, Resolution.Daily);
|
||||
var option = AddOption(UnderlyingTicker, Resolution.Daily);
|
||||
OptionSymbol = option.Symbol;
|
||||
_optionSymbol = option.Symbol;
|
||||
|
||||
option.SetFilter(x => x.CallsOnly().Strikes(0, 1).Expiration(0, 30));
|
||||
option.SetFilter(x => x.CallsOnly().Expiration(0, 60));
|
||||
|
||||
// use the underlying equity as the benchmark
|
||||
SetBenchmark(equity.Symbol);
|
||||
@@ -63,7 +63,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
if (!Portfolio.Invested)
|
||||
{
|
||||
OptionChain chain;
|
||||
if (slice.OptionChains.TryGetValue(OptionSymbol, out chain))
|
||||
if (slice.OptionChains.TryGetValue(_optionSymbol, out chain))
|
||||
{
|
||||
// Grab us the contract nearest expiry that is not today
|
||||
var contractsByExpiration = chain.Where(x => x.Expiry != Time.Date).OrderBy(x => x.Expiry);
|
||||
@@ -117,18 +117,23 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate which languages this algorithm is written in.
|
||||
/// </summary>
|
||||
public Language[] Languages { get; } = { Language.CSharp, Language.Python };
|
||||
public List<Language> Languages { get; } = new() { Language.CSharp, Language.Python };
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of all timeslices of algorithm
|
||||
/// </summary>
|
||||
public long DataPoints => 36834;
|
||||
public long DataPoints => 308;
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of the algorithm history
|
||||
/// </summary>
|
||||
public int AlgorithmHistoryDataPoints => 0;
|
||||
|
||||
/// <summary>
|
||||
/// Final status of the algorithm
|
||||
/// </summary>
|
||||
public AlgorithmStatus AlgorithmStatus => AlgorithmStatus.Completed;
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate what the expected statistics are from running the algorithm
|
||||
/// </summary>
|
||||
@@ -136,31 +141,32 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{
|
||||
{"Total Orders", "2"},
|
||||
{"Average Win", "0%"},
|
||||
{"Average Loss", "-1.31%"},
|
||||
{"Compounding Annual Return", "-15.304%"},
|
||||
{"Drawdown", "1.300%"},
|
||||
{"Average Loss", "-1.16%"},
|
||||
{"Compounding Annual Return", "-8.351%"},
|
||||
{"Drawdown", "1.200%"},
|
||||
{"Expectancy", "-1"},
|
||||
{"Start Equity", "100000"},
|
||||
{"End Equity", "98689"},
|
||||
{"Net Profit", "-1.311%"},
|
||||
{"Sharpe Ratio", "-3.607"},
|
||||
{"Sortino Ratio", "-1.188"},
|
||||
{"Probabilistic Sharpe Ratio", "0.035%"},
|
||||
{"End Equity", "98844"},
|
||||
{"Net Profit", "-1.156%"},
|
||||
{"Sharpe Ratio", "-4.04"},
|
||||
{"Sortino Ratio", "-2.422"},
|
||||
{"Probabilistic Sharpe Ratio", "0.099%"},
|
||||
{"Loss Rate", "100%"},
|
||||
{"Win Rate", "0%"},
|
||||
{"Profit-Loss Ratio", "0"},
|
||||
{"Alpha", "0"},
|
||||
{"Beta", "0"},
|
||||
{"Annual Standard Deviation", "0.034"},
|
||||
{"Annual Variance", "0.001"},
|
||||
{"Information Ratio", "-3.31"},
|
||||
{"Tracking Error", "0.034"},
|
||||
{"Treynor Ratio", "0"},
|
||||
{"Alpha", "-0.058"},
|
||||
{"Beta", "0.021"},
|
||||
{"Annual Standard Deviation", "0.017"},
|
||||
{"Annual Variance", "0"},
|
||||
{"Information Ratio", "1.49"},
|
||||
{"Tracking Error", "0.289"},
|
||||
{"Treynor Ratio", "-3.212"},
|
||||
{"Total Fees", "$1.00"},
|
||||
{"Estimated Strategy Capacity", "$0"},
|
||||
{"Lowest Capacity Asset", "GOOCV W78ZFMML01JA|GOOCV VP83T1ZUHROL"},
|
||||
{"Portfolio Turnover", "0.05%"},
|
||||
{"OrderListHash", "e188868e048fab6b6a0481b4479e97f9"}
|
||||
{"Estimated Strategy Capacity", "$72000.00"},
|
||||
{"Lowest Capacity Asset", "AAPL W78ZEO29CFS6|AAPL R735QTJ8XC9X"},
|
||||
{"Portfolio Turnover", "0.02%"},
|
||||
{"Drawdown Recovery", "0"},
|
||||
{"OrderListHash", "5639c19a7d56ec312f61029b943903b8"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
*
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using QuantConnect.Data;
|
||||
@@ -36,7 +35,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
public class BasicTemplateOptionsFilterUniverseAlgorithm : QCAlgorithm, IRegressionAlgorithmDefinition
|
||||
{
|
||||
private const string UnderlyingTicker = "GOOG";
|
||||
public Symbol OptionSymbol;
|
||||
private Symbol _optionSymbol;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
@@ -46,7 +45,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
|
||||
var equity = AddEquity(UnderlyingTicker);
|
||||
var option = AddOption(UnderlyingTicker);
|
||||
OptionSymbol = option.Symbol;
|
||||
_optionSymbol = option.Symbol;
|
||||
|
||||
// Set our custom universe filter, Expires today, is a call, and is within 10 dollars of the current price
|
||||
option.SetFilter(universe => from symbol in universe.WeeklysOnly().Expiration(0, 1)
|
||||
@@ -64,7 +63,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
if (!Portfolio.Invested)
|
||||
{
|
||||
OptionChain chain;
|
||||
if (slice.OptionChains.TryGetValue(OptionSymbol, out chain))
|
||||
if (slice.OptionChains.TryGetValue(_optionSymbol, out chain))
|
||||
{
|
||||
// Get the first ITM call expiring today
|
||||
var contract = (
|
||||
@@ -95,18 +94,23 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate which languages this algorithm is written in.
|
||||
/// </summary>
|
||||
public Language[] Languages { get; } = { Language.CSharp, Language.Python };
|
||||
public List<Language> Languages { get; } = new() { Language.CSharp, Language.Python };
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of all timeslices of algorithm
|
||||
/// </summary>
|
||||
public long DataPoints => 1252633;
|
||||
public long DataPoints => 12290;
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of the algorithm history
|
||||
/// </summary>
|
||||
public int AlgorithmHistoryDataPoints => 0;
|
||||
|
||||
/// <summary>
|
||||
/// Final status of the algorithm
|
||||
/// </summary>
|
||||
public AlgorithmStatus AlgorithmStatus => AlgorithmStatus.Completed;
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate what the expected statistics are from running the algorithm
|
||||
/// </summary>
|
||||
@@ -115,7 +119,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Total Orders", "2"},
|
||||
{"Average Win", "0%"},
|
||||
{"Average Loss", "-0.40%"},
|
||||
{"Compounding Annual Return", "-21.622%"},
|
||||
{"Compounding Annual Return", "-20.338%"},
|
||||
{"Drawdown", "0.300%"},
|
||||
{"Expectancy", "-1"},
|
||||
{"Start Equity", "100000"},
|
||||
@@ -138,7 +142,8 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Estimated Strategy Capacity", "$0"},
|
||||
{"Lowest Capacity Asset", "GOOCV VP83T1ZUHROL"},
|
||||
{"Portfolio Turnover", "15.08%"},
|
||||
{"OrderListHash", "db6a1134ad325bce31c2bdd2e87ff5f4"}
|
||||
{"Drawdown Recovery", "0"},
|
||||
{"OrderListHash", "c53bc9318676161ed3b7797c945e2113"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -134,50 +134,56 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate which languages this algorithm is written in.
|
||||
/// </summary>
|
||||
public Language[] Languages { get; } = { Language.CSharp, Language.Python };
|
||||
public List<Language> Languages { get; } = new() { Language.CSharp, Language.Python };
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of all timeslices of algorithm
|
||||
/// </summary>
|
||||
public long DataPoints => 1847643;
|
||||
public long DataPoints => 17487;
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of the algorithm history
|
||||
/// </summary>
|
||||
public int AlgorithmHistoryDataPoints => 0;
|
||||
|
||||
/// <summary>
|
||||
/// Final status of the algorithm
|
||||
/// </summary>
|
||||
public AlgorithmStatus AlgorithmStatus => AlgorithmStatus.Completed;
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate what the expected statistics are from running the algorithm
|
||||
/// </summary>
|
||||
public Dictionary<string, string> ExpectedStatistics => new Dictionary<string, string>
|
||||
{
|
||||
{"Total Orders", "5"},
|
||||
{"Average Win", "0.14%"},
|
||||
{"Average Loss", "-0.28%"},
|
||||
{"Compounding Annual Return", "-47.543%"},
|
||||
{"Average Win", "0.13%"},
|
||||
{"Average Loss", "-0.30%"},
|
||||
{"Compounding Annual Return", "-46.395%"},
|
||||
{"Drawdown", "1.600%"},
|
||||
{"Expectancy", "0.502"},
|
||||
{"Expectancy", "0.429"},
|
||||
{"Start Equity", "100000"},
|
||||
{"End Equity", "99178.50"},
|
||||
{"Net Profit", "-0.821%"},
|
||||
{"Sharpe Ratio", "-4.136"},
|
||||
{"End Equity", "99149.50"},
|
||||
{"Net Profit", "-0.850%"},
|
||||
{"Sharpe Ratio", "-4.298"},
|
||||
{"Sortino Ratio", "0"},
|
||||
{"Probabilistic Sharpe Ratio", "17.155%"},
|
||||
{"Probabilistic Sharpe Ratio", "15.319%"},
|
||||
{"Loss Rate", "0%"},
|
||||
{"Win Rate", "100%"},
|
||||
{"Profit-Loss Ratio", "0.50"},
|
||||
{"Alpha", "-0.855"},
|
||||
{"Beta", "1.047"},
|
||||
{"Annual Standard Deviation", "0.099"},
|
||||
{"Profit-Loss Ratio", "0.43"},
|
||||
{"Alpha", "-0.84"},
|
||||
{"Beta", "0.986"},
|
||||
{"Annual Standard Deviation", "0.098"},
|
||||
{"Annual Variance", "0.01"},
|
||||
{"Information Ratio", "-9.141"},
|
||||
{"Information Ratio", "-9.299"},
|
||||
{"Tracking Error", "0.091"},
|
||||
{"Treynor Ratio", "-0.392"},
|
||||
{"Treynor Ratio", "-0.428"},
|
||||
{"Total Fees", "$4.00"},
|
||||
{"Estimated Strategy Capacity", "$0"},
|
||||
{"Lowest Capacity Asset", "AAPL R735QTJ8XC9X"},
|
||||
{"Portfolio Turnover", "13.49%"},
|
||||
{"OrderListHash", "2722fee93126736e03d66d7ab880b537"}
|
||||
{"Portfolio Turnover", "13.50%"},
|
||||
{"Drawdown Recovery", "2"},
|
||||
{"OrderListHash", "2ab4ffc0944a2888a3be0568c2570a79"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
public class BasicTemplateOptionsHourlyAlgorithm : QCAlgorithm, IRegressionAlgorithmDefinition
|
||||
{
|
||||
private const string UnderlyingTicker = "AAPL";
|
||||
public Symbol OptionSymbol;
|
||||
private Symbol _optionSymbol;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
@@ -45,10 +45,10 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
|
||||
var equity = AddEquity(UnderlyingTicker, Resolution.Hour);
|
||||
var option = AddOption(UnderlyingTicker, Resolution.Hour);
|
||||
OptionSymbol = option.Symbol;
|
||||
_optionSymbol = option.Symbol;
|
||||
|
||||
// set our strike/expiry filter for this option chain
|
||||
option.SetFilter(u => u.Strikes(-2, +2)
|
||||
option.SetFilter(u => u.StandardsOnly().Strikes(-2, +2)
|
||||
// Expiration method accepts TimeSpan objects or integer for days.
|
||||
// The following statements yield the same filtering criteria
|
||||
.Expiration(0, 180));
|
||||
@@ -64,10 +64,10 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <param name="slice">The current slice of data keyed by symbol string</param>
|
||||
public override void OnData(Slice slice)
|
||||
{
|
||||
if (!Portfolio.Invested && IsMarketOpen(OptionSymbol))
|
||||
if (!Portfolio.Invested && IsMarketOpen(_optionSymbol))
|
||||
{
|
||||
OptionChain chain;
|
||||
if (slice.OptionChains.TryGetValue(OptionSymbol, out chain))
|
||||
if (slice.OptionChains.TryGetValue(_optionSymbol, out chain))
|
||||
{
|
||||
// we find at the money (ATM) put contract with farthest expiration
|
||||
var atmContract = chain
|
||||
@@ -104,18 +104,23 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate which languages this algorithm is written in.
|
||||
/// </summary>
|
||||
public Language[] Languages { get; } = { Language.CSharp, Language.Python };
|
||||
public List<Language> Languages { get; } = new() { Language.CSharp, Language.Python };
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of all timeslices of algorithm
|
||||
/// </summary>
|
||||
public long DataPoints => 32351;
|
||||
public long DataPoints => 9504;
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of the algorithm history
|
||||
/// </summary>
|
||||
public int AlgorithmHistoryDataPoints => 0;
|
||||
|
||||
/// <summary>
|
||||
/// Final status of the algorithm
|
||||
/// </summary>
|
||||
public AlgorithmStatus AlgorithmStatus => AlgorithmStatus.Completed;
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate what the expected statistics are from running the algorithm
|
||||
/// </summary>
|
||||
@@ -124,7 +129,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Total Orders", "5"},
|
||||
{"Average Win", "0%"},
|
||||
{"Average Loss", "-0.07%"},
|
||||
{"Compounding Annual Return", "-12.496%"},
|
||||
{"Compounding Annual Return", "-11.517%"},
|
||||
{"Drawdown", "0.200%"},
|
||||
{"Expectancy", "-1"},
|
||||
{"Start Equity", "100000"},
|
||||
@@ -145,9 +150,10 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Treynor Ratio", "1.434"},
|
||||
{"Total Fees", "$4.00"},
|
||||
{"Estimated Strategy Capacity", "$1000.00"},
|
||||
{"Lowest Capacity Asset", "AAPL 2ZTXYMUAHCIAU|AAPL R735QTJ8XC9X"},
|
||||
{"Lowest Capacity Asset", "AAPL 2ZTXYMUAHGSME|AAPL R735QTJ8XC9X"},
|
||||
{"Portfolio Turnover", "2.28%"},
|
||||
{"OrderListHash", "7804b3dcf20d3096a2265a289fa81cd3"}
|
||||
{"Drawdown Recovery", "0"},
|
||||
{"OrderListHash", "70bbc60c969f18e943e8e00cf0f7a0ea"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,14 +43,12 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
SetEndDate(2021, 1, 10);
|
||||
SetCash(1000000);
|
||||
|
||||
var spx = AddIndex("SPX").Symbol;
|
||||
|
||||
// regular option SPX contracts
|
||||
var spxOptions = AddIndexOption(spx);
|
||||
var spxOptions = AddIndexOption("SPX");
|
||||
spxOptions.SetFilter(u => u.Strikes(0, 1).Expiration(0, 30));
|
||||
|
||||
// weekly option SPX contracts
|
||||
var spxw = AddIndexOption(spx, "SPXW");
|
||||
var spxw = AddIndexOption("SPX", "SPXW");
|
||||
spxw.SetFilter(u => u.Strikes(0, 1)
|
||||
// single week ahead since there are many SPXW contracts and we want to preserve performance
|
||||
.Expiration(0, 7)
|
||||
@@ -100,50 +98,56 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate which languages this algorithm is written in.
|
||||
/// </summary>
|
||||
public virtual Language[] Languages { get; } = { Language.CSharp, Language.Python };
|
||||
public virtual List<Language> Languages { get; } = new() { Language.CSharp, Language.Python };
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of all timeslices of algorithm
|
||||
/// </summary>
|
||||
public virtual long DataPoints => 57869;
|
||||
public virtual long DataPoints => 21467;
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of the algorithm history
|
||||
/// </summary>
|
||||
public virtual int AlgorithmHistoryDataPoints => 0;
|
||||
|
||||
/// <summary>
|
||||
/// Final status of the algorithm
|
||||
/// </summary>
|
||||
public AlgorithmStatus AlgorithmStatus => AlgorithmStatus.Completed;
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate what the expected statistics are from running the algorithm
|
||||
/// </summary>
|
||||
public virtual Dictionary<string, string> ExpectedStatistics => new Dictionary<string, string>
|
||||
{
|
||||
{"Total Orders", "5"},
|
||||
{"Average Win", "0%"},
|
||||
{"Average Loss", "-0.69%"},
|
||||
{"Compounding Annual Return", "59.804%"},
|
||||
{"Average Win", "0.63%"},
|
||||
{"Average Loss", "-0.03%"},
|
||||
{"Compounding Annual Return", "54.478%"},
|
||||
{"Drawdown", "0.400%"},
|
||||
{"Expectancy", "-0.5"},
|
||||
{"Expectancy", "23.219"},
|
||||
{"Start Equity", "1000000"},
|
||||
{"End Equity", "1006025"},
|
||||
{"Net Profit", "0.602%"},
|
||||
{"Sharpe Ratio", "3.01"},
|
||||
{"Sharpe Ratio", "2.62"},
|
||||
{"Sortino Ratio", "0"},
|
||||
{"Probabilistic Sharpe Ratio", "62.865%"},
|
||||
{"Loss Rate", "50%"},
|
||||
{"Win Rate", "50%"},
|
||||
{"Profit-Loss Ratio", "0"},
|
||||
{"Alpha", "0.249"},
|
||||
{"Beta", "-0.033"},
|
||||
{"Probabilistic Sharpe Ratio", "63.221%"},
|
||||
{"Loss Rate", "0%"},
|
||||
{"Win Rate", "100%"},
|
||||
{"Profit-Loss Ratio", "23.22"},
|
||||
{"Alpha", "0.067"},
|
||||
{"Beta", "-0.013"},
|
||||
{"Annual Standard Deviation", "0.004"},
|
||||
{"Annual Variance", "0"},
|
||||
{"Information Ratio", "-99.414"},
|
||||
{"Tracking Error", "0.072"},
|
||||
{"Treynor Ratio", "-0.382"},
|
||||
{"Information Ratio", "-50.808"},
|
||||
{"Tracking Error", "0.086"},
|
||||
{"Treynor Ratio", "-0.725"},
|
||||
{"Total Fees", "$0.00"},
|
||||
{"Estimated Strategy Capacity", "$580000.00"},
|
||||
{"Lowest Capacity Asset", "SPXW 31K54PVWHUJHQ|SPX 31"},
|
||||
{"Portfolio Turnover", "0.48%"},
|
||||
{"OrderListHash", "07a085baedb37bb7c8d460558ea77e88"}
|
||||
{"Lowest Capacity Asset", "SPXW 31K54PVWHYTTA|SPX 31"},
|
||||
{"Portfolio Turnover", "0.40%"},
|
||||
{"Drawdown Recovery", "0"},
|
||||
{"OrderListHash", "03148bbb5453fc1056a3285bd31ce158"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
Debug(orderEvent.ToString());
|
||||
if (orderEvent.Symbol.ID.Symbol != "SPXW")
|
||||
{
|
||||
throw new Exception("Unexpected order event symbol!");
|
||||
throw new RegressionTestException("Unexpected order event symbol!");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,29 +104,34 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate which languages this algorithm is written in.
|
||||
/// </summary>
|
||||
public virtual Language[] Languages { get; } = { Language.CSharp };
|
||||
public virtual List<Language> Languages { get; } = new() { Language.CSharp };
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of all timeslices of algorithm
|
||||
/// </summary>
|
||||
public virtual long DataPoints => 40968;
|
||||
public virtual long DataPoints => 16680;
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of the algorithm history
|
||||
/// </summary>
|
||||
public virtual int AlgorithmHistoryDataPoints => 0;
|
||||
|
||||
/// <summary>
|
||||
/// Final status of the algorithm
|
||||
/// </summary>
|
||||
public AlgorithmStatus AlgorithmStatus => AlgorithmStatus.Completed;
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate what the expected statistics are from running the algorithm
|
||||
/// </summary>
|
||||
public virtual Dictionary<string, string> ExpectedStatistics => new Dictionary<string, string>
|
||||
{
|
||||
{"Total Orders", "10"},
|
||||
{"Average Win", "0.47%"},
|
||||
{"Average Win", "0.46%"},
|
||||
{"Average Loss", "-0.01%"},
|
||||
{"Compounding Annual Return", "101.998%"},
|
||||
{"Drawdown", "0.100%"},
|
||||
{"Expectancy", "24.484"},
|
||||
{"Expectancy", "24.137"},
|
||||
{"Start Equity", "1000000"},
|
||||
{"End Equity", "1009050"},
|
||||
{"Net Profit", "0.905%"},
|
||||
@@ -135,7 +140,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Probabilistic Sharpe Ratio", "95.546%"},
|
||||
{"Loss Rate", "50%"},
|
||||
{"Win Rate", "50%"},
|
||||
{"Profit-Loss Ratio", "49.97"},
|
||||
{"Profit-Loss Ratio", "49.27"},
|
||||
{"Alpha", "-2.01"},
|
||||
{"Beta", "0.307"},
|
||||
{"Annual Standard Deviation", "0.021"},
|
||||
@@ -145,9 +150,10 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Treynor Ratio", "0.589"},
|
||||
{"Total Fees", "$0.00"},
|
||||
{"Estimated Strategy Capacity", "$13000000.00"},
|
||||
{"Lowest Capacity Asset", "SPXW XKX6S2GM9PGU|SPX 31"},
|
||||
{"Lowest Capacity Asset", "SPXW XKX6S2GMDZSE|SPX 31"},
|
||||
{"Portfolio Turnover", "0.28%"},
|
||||
{"OrderListHash", "c1a9bc141ae25c9542b93a887e79dafe"}
|
||||
{"Drawdown Recovery", "2"},
|
||||
{"OrderListHash", "9d03f85003416861df07ccb31a18af9a"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{
|
||||
if (!_ticket.Status.IsFill())
|
||||
{
|
||||
throw new Exception("Index is tradable.");
|
||||
throw new RegressionTestException("Index is tradable.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -87,9 +87,10 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Treynor Ratio", "-1.771"},
|
||||
{"Total Fees", "$0.00"},
|
||||
{"Estimated Strategy Capacity", "$3000.00"},
|
||||
{"Lowest Capacity Asset", "SPX XL80P3GHDZXQ|SPX 31"},
|
||||
{"Lowest Capacity Asset", "SPX XL80P3GHIA9A|SPX 31"},
|
||||
{"Portfolio Turnover", "24.03%"},
|
||||
{"OrderListHash", "fcd6fddb0a315e21095c2b35eb633e2b"}
|
||||
{"Drawdown Recovery", "9"},
|
||||
{"OrderListHash", "691cf4990024b856a0a70255c9fd2545"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user