Compare commits
132 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3ff7882dbf | ||
|
|
dace6d7ee1 | ||
|
|
71d9eed07e | ||
|
|
c4a4550a66 | ||
|
|
67081a8a05 | ||
|
|
a567053404 | ||
|
|
56b8ccc4b4 | ||
|
|
5f65677ede | ||
|
|
def916aed1 | ||
|
|
46ce138fa1 | ||
|
|
b8768ae274 | ||
|
|
db04b5e110 | ||
|
|
cff3640f15 | ||
|
|
b5574a7986 | ||
|
|
c638f82337 | ||
|
|
3a591c3a72 | ||
|
|
fdfb1b54c0 | ||
|
|
7cfdd1243f | ||
|
|
3fc042af33 | ||
|
|
1d6fed8843 | ||
|
|
2109394060 | ||
|
|
d2d99b1f10 | ||
|
|
659735946a | ||
|
|
29294cb1f4 | ||
|
|
4546bbe9b1 | ||
|
|
af958f0ce4 | ||
|
|
6c42a266be | ||
|
|
8b7da686ea | ||
|
|
d3280c5e60 | ||
|
|
fe1f22543f | ||
|
|
57ddbbbf05 | ||
|
|
9579c4263b | ||
|
|
f082a40f34 | ||
|
|
d739873daa | ||
|
|
0f7dfe8ec8 | ||
|
|
58968bf05f | ||
|
|
627f280100 | ||
|
|
9ca57c2de9 | ||
|
|
35c2951abb | ||
|
|
2c237b7f84 | ||
|
|
4e6e0c85c6 | ||
|
|
a2ac956d53 | ||
|
|
5fecb77c8a | ||
|
|
3e8f15a62f | ||
|
|
0931ae868a | ||
|
|
e13df5c901 | ||
|
|
7be1b7db1a | ||
|
|
024d416ddd | ||
|
|
eb2dbe2af7 | ||
|
|
8358c394e1 | ||
|
|
d7c7adbd0d | ||
|
|
1ab1f90e27 | ||
|
|
bf2ef35ada | ||
|
|
2001f9a181 | ||
|
|
8026785116 | ||
|
|
5083433f68 | ||
|
|
5d4f428906 | ||
|
|
da60daa60d | ||
|
|
7d88b5040b | ||
|
|
d76106b444 | ||
|
|
de09ec0933 | ||
|
|
c3874bc618 | ||
|
|
0e1e497fbf | ||
|
|
8eb023e854 | ||
|
|
b251cffc2f | ||
|
|
1d904e716c | ||
|
|
df57428bd7 | ||
|
|
9d734c4d8f | ||
|
|
765ce87df1 | ||
|
|
8a5766fa39 | ||
|
|
933e5ce6ca | ||
|
|
dc433493b7 | ||
|
|
9acf68ad19 | ||
|
|
5ebf451fb3 | ||
|
|
a4d49c05ca | ||
|
|
aaba566954 | ||
|
|
bf28a1d313 | ||
|
|
85a4d3364b | ||
|
|
eccca2c029 | ||
|
|
b0314e1c7c | ||
|
|
3410832ccf | ||
|
|
d573a0f6c7 | ||
|
|
7a3d8667c5 | ||
|
|
c3543f844a | ||
|
|
1fdb36ee89 | ||
|
|
cd9e451ead | ||
|
|
b4f6b51ad1 | ||
|
|
a5e395d298 | ||
|
|
a40329c70c | ||
|
|
6546647e08 | ||
|
|
46829f0f01 | ||
|
|
e722e72aaa | ||
|
|
e92230a7fe | ||
|
|
7881aeb3a5 | ||
|
|
32fdb51ab5 | ||
|
|
190fe012f1 | ||
|
|
893ca2b41d | ||
|
|
c30bd32fb0 | ||
|
|
e720147e50 | ||
|
|
b77f0122b2 | ||
|
|
646adb9131 | ||
|
|
e2ae173d99 | ||
|
|
1cfc044034 | ||
|
|
9b7af08b3e | ||
|
|
1a02fbaae5 | ||
|
|
ed835faf35 | ||
|
|
5ea70e2a89 | ||
|
|
2603694263 | ||
|
|
4a3a7a44f5 | ||
|
|
76c930a035 | ||
|
|
12f70aab46 | ||
|
|
650ce2e2b5 | ||
|
|
ef4fea7592 | ||
|
|
3cf9cc7d41 | ||
|
|
a9b634b096 | ||
|
|
1793add749 | ||
|
|
41636c94c3 | ||
|
|
2624b8c6f5 | ||
|
|
d8a86f182f | ||
|
|
0da9d626dc | ||
|
|
9888081cc0 | ||
|
|
611326b140 | ||
|
|
907a9f086c | ||
|
|
0c4e577885 | ||
|
|
e823dfdfb7 | ||
|
|
4469d18eb6 | ||
|
|
808ba17bff | ||
|
|
00f68b951f | ||
|
|
c07b643273 | ||
|
|
95f199eae5 | ||
|
|
2cb239a330 | ||
|
|
cb326788b3 |
@@ -117,18 +117,18 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Drawdown", "1.700%"},
|
||||
{"Expectancy", "1.781"},
|
||||
{"Net Profit", "1.442%"},
|
||||
{"Sharpe Ratio", "4.017"},
|
||||
{"Probabilistic Sharpe Ratio", "59.636%"},
|
||||
{"Sharpe Ratio", "4.86"},
|
||||
{"Probabilistic Sharpe Ratio", "59.497%"},
|
||||
{"Loss Rate", "33%"},
|
||||
{"Win Rate", "67%"},
|
||||
{"Profit-Loss Ratio", "3.17"},
|
||||
{"Alpha", "1.53"},
|
||||
{"Beta", "-0.292"},
|
||||
{"Annual Standard Deviation", "0.279"},
|
||||
{"Annual Variance", "0.078"},
|
||||
{"Information Ratio", "-0.743"},
|
||||
{"Tracking Error", "0.372"},
|
||||
{"Treynor Ratio", "-3.845"},
|
||||
{"Alpha", "4.181"},
|
||||
{"Beta", "-1.322"},
|
||||
{"Annual Standard Deviation", "0.321"},
|
||||
{"Annual Variance", "0.103"},
|
||||
{"Information Ratio", "-0.795"},
|
||||
{"Tracking Error", "0.532"},
|
||||
{"Treynor Ratio", "-1.18"},
|
||||
{"Total Fees", "$14.78"},
|
||||
{"Estimated Strategy Capacity", "$47000000.00"},
|
||||
{"Lowest Capacity Asset", "IBM R735QTJ8XC9X"},
|
||||
|
||||
@@ -0,0 +1,134 @@
|
||||
/*
|
||||
* 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.Linq;
|
||||
using QuantConnect.Data;
|
||||
using QuantConnect.Interfaces;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace QuantConnect.Algorithm.CSharp
|
||||
{
|
||||
/// <summary>
|
||||
/// Regression algorithm reproducing GH issue #5748 where in some cases an option underlying symbol was not being
|
||||
/// removed from all universes it was hold
|
||||
/// </summary>
|
||||
public class AddAndRemoveOptionContractRegressionAlgorithm : QCAlgorithm, IRegressionAlgorithmDefinition
|
||||
{
|
||||
private Symbol _contract;
|
||||
private bool _hasRemoved;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
SetStartDate(2014, 06, 06);
|
||||
SetEndDate(2014, 06, 09);
|
||||
|
||||
UniverseSettings.DataNormalizationMode = DataNormalizationMode.Raw;
|
||||
UniverseSettings.MinimumTimeInUniverse = TimeSpan.Zero;
|
||||
|
||||
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);
|
||||
AddOptionContract(_contract);
|
||||
}
|
||||
|
||||
public override void OnData(Slice slice)
|
||||
{
|
||||
if (slice.HasData)
|
||||
{
|
||||
if (!_hasRemoved)
|
||||
{
|
||||
RemoveOptionContract(_contract);
|
||||
RemoveSecurity(_contract.Underlying);
|
||||
_hasRemoved = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("Expect a single call to OnData where we removed the option and underlying");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnEndOfAlgorithm()
|
||||
{
|
||||
if (!_hasRemoved)
|
||||
{
|
||||
throw new Exception("Expect a single call to OnData where we removed the option and underlying");
|
||||
}
|
||||
}
|
||||
|
||||
/// <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 Language[] Languages { get; } = { Language.CSharp };
|
||||
|
||||
/// <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 Trades", "0"},
|
||||
{"Average Win", "0%"},
|
||||
{"Average Loss", "0%"},
|
||||
{"Compounding Annual Return", "0%"},
|
||||
{"Drawdown", "0%"},
|
||||
{"Expectancy", "0"},
|
||||
{"Net Profit", "0%"},
|
||||
{"Sharpe 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", "-9.486"},
|
||||
{"Tracking Error", "0.008"},
|
||||
{"Treynor Ratio", "0"},
|
||||
{"Total Fees", "$0.00"},
|
||||
{"Estimated Strategy Capacity", "$0"},
|
||||
{"Lowest Capacity Asset", ""},
|
||||
{"Fitness Score", "0"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
{"Sortino Ratio", "79228162514264337593543950335"},
|
||||
{"Return Over Maximum Drawdown", "79228162514264337593543950335"},
|
||||
{"Portfolio Turnover", "0"},
|
||||
{"Total Insights Generated", "0"},
|
||||
{"Total Insights Closed", "0"},
|
||||
{"Total Insights Analysis Completed", "0"},
|
||||
{"Long Insight Count", "0"},
|
||||
{"Short Insight Count", "0"},
|
||||
{"Long/Short Ratio", "100%"},
|
||||
{"Estimated Monthly Alpha Value", "$0"},
|
||||
{"Total Accumulated Estimated Alpha Value", "$0"},
|
||||
{"Mean Population Estimated Insight Value", "$0"},
|
||||
{"Mean Population Direction", "0%"},
|
||||
{"Mean Population Magnitude", "0%"},
|
||||
{"Rolling Averaged Population Direction", "0%"},
|
||||
{"Rolling Averaged Population Magnitude", "0%"},
|
||||
{"OrderListHash", "d41d8cd98f00b204e9800998ecf8427e"}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -40,7 +40,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
SetStartDate(2020, 1, 5);
|
||||
SetStartDate(2020, 1, 4);
|
||||
SetEndDate(2020, 1, 6);
|
||||
|
||||
_es20h20 = AddFutureContract(
|
||||
@@ -51,7 +51,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
QuantConnect.Symbol.CreateFuture(Futures.Indices.SP500EMini, Market.CME, new DateTime(2020, 6, 19)),
|
||||
Resolution.Minute).Symbol;
|
||||
|
||||
var optionChains = OptionChainProvider.GetOptionContractList(_es20h20, Time)
|
||||
var optionChains = OptionChainProvider.GetOptionContractList(_es20h20, Time.AddDays(1))
|
||||
.Concat(OptionChainProvider.GetOptionContractList(_es19m20, Time));
|
||||
|
||||
foreach (var optionContract in optionChains)
|
||||
@@ -168,31 +168,31 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Total Trades", "2"},
|
||||
{"Average Win", "0%"},
|
||||
{"Average Loss", "0%"},
|
||||
{"Compounding Annual Return", "217.585%"},
|
||||
{"Compounding Annual Return", "116.059%"},
|
||||
{"Drawdown", "0.600%"},
|
||||
{"Expectancy", "0"},
|
||||
{"Net Profit", "0.635%"},
|
||||
{"Sharpe Ratio", "0"},
|
||||
{"Sharpe Ratio", "17.16"},
|
||||
{"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"},
|
||||
{"Alpha", "2.25"},
|
||||
{"Beta", "-1.665"},
|
||||
{"Annual Standard Deviation", "0.071"},
|
||||
{"Annual Variance", "0.005"},
|
||||
{"Information Ratio", "5.319"},
|
||||
{"Tracking Error", "0.114"},
|
||||
{"Treynor Ratio", "-0.735"},
|
||||
{"Total Fees", "$7.40"},
|
||||
{"Estimated Strategy Capacity", "$28000000.00"},
|
||||
{"Estimated Strategy Capacity", "$24000000.00"},
|
||||
{"Lowest Capacity Asset", "ES XFH59UK0MYO1"},
|
||||
{"Fitness Score", "1"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
{"Sortino Ratio", "79228162514264337593543950335"},
|
||||
{"Return Over Maximum Drawdown", "79228162514264337593543950335"},
|
||||
{"Portfolio Turnover", "3.199"},
|
||||
{"Portfolio Turnover", "2.133"},
|
||||
{"Total Insights Generated", "0"},
|
||||
{"Total Insights Closed", "0"},
|
||||
{"Total Insights Analysis Completed", "0"},
|
||||
|
||||
@@ -42,7 +42,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
SetStartDate(2020, 1, 5);
|
||||
SetStartDate(2020, 1, 4);
|
||||
SetEndDate(2020, 1, 6);
|
||||
|
||||
_es = AddFuture(Futures.Indices.SP500EMini, Resolution.Minute, Market.CME);
|
||||
@@ -227,31 +227,31 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Total Trades", "2"},
|
||||
{"Average Win", "0%"},
|
||||
{"Average Loss", "0%"},
|
||||
{"Compounding Annual Return", "-15.625%"},
|
||||
{"Compounding Annual Return", "-10.708%"},
|
||||
{"Drawdown", "0.200%"},
|
||||
{"Expectancy", "0"},
|
||||
{"Net Profit", "-0.093%"},
|
||||
{"Sharpe Ratio", "-11.181"},
|
||||
{"Sharpe Ratio", "-10.594"},
|
||||
{"Probabilistic Sharpe Ratio", "0%"},
|
||||
{"Loss Rate", "0%"},
|
||||
{"Win Rate", "0%"},
|
||||
{"Profit-Loss Ratio", "0"},
|
||||
{"Alpha", "0.002"},
|
||||
{"Beta", "-0.016"},
|
||||
{"Annual Standard Deviation", "0.001"},
|
||||
{"Alpha", "-0.261"},
|
||||
{"Beta", "0.244"},
|
||||
{"Annual Standard Deviation", "0.01"},
|
||||
{"Annual Variance", "0"},
|
||||
{"Information Ratio", "-14.343"},
|
||||
{"Tracking Error", "0.044"},
|
||||
{"Treynor Ratio", "0.479"},
|
||||
{"Information Ratio", "-22.456"},
|
||||
{"Tracking Error", "0.032"},
|
||||
{"Treynor Ratio", "-0.454"},
|
||||
{"Total Fees", "$3.70"},
|
||||
{"Estimated Strategy Capacity", "$41000.00"},
|
||||
{"Lowest Capacity Asset", "ES 31C3JQTOYO9T0|ES XCZJLC9NOB29"},
|
||||
{"Fitness Score", "0.41"},
|
||||
{"Fitness Score", "0.273"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
{"Sortino Ratio", "79228162514264337593543950335"},
|
||||
{"Return Over Maximum Drawdown", "-185.654"},
|
||||
{"Portfolio Turnover", "0.821"},
|
||||
{"Return Over Maximum Drawdown", "-123.159"},
|
||||
{"Portfolio Turnover", "0.547"},
|
||||
{"Total Insights Generated", "0"},
|
||||
{"Total Insights Closed", "0"},
|
||||
{"Total Insights Analysis Completed", "0"},
|
||||
|
||||
@@ -126,18 +126,18 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Drawdown", "0.300%"},
|
||||
{"Expectancy", "-0.042"},
|
||||
{"Net Profit", "-0.332%"},
|
||||
{"Sharpe Ratio", "-3.7"},
|
||||
{"Probabilistic Sharpe Ratio", "0.563%"},
|
||||
{"Sharpe Ratio", "-3.149"},
|
||||
{"Probabilistic Sharpe Ratio", "0.427%"},
|
||||
{"Loss Rate", "50%"},
|
||||
{"Win Rate", "50%"},
|
||||
{"Profit-Loss Ratio", "0.92"},
|
||||
{"Alpha", "-0.021"},
|
||||
{"Beta", "-0.011"},
|
||||
{"Annual Standard Deviation", "0.006"},
|
||||
{"Alpha", "-0.015"},
|
||||
{"Beta", "-0.012"},
|
||||
{"Annual Standard Deviation", "0.005"},
|
||||
{"Annual Variance", "0"},
|
||||
{"Information Ratio", "-3.385"},
|
||||
{"Tracking Error", "0.058"},
|
||||
{"Treynor Ratio", "2.117"},
|
||||
{"Information Ratio", "-2.823"},
|
||||
{"Tracking Error", "0.049"},
|
||||
{"Treynor Ratio", "1.372"},
|
||||
{"Total Fees", "$2.00"},
|
||||
{"Estimated Strategy Capacity", "$45000000.00"},
|
||||
{"Lowest Capacity Asset", "AOL R735QTJ8XC9X"},
|
||||
@@ -160,7 +160,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Mean Population Magnitude", "0%"},
|
||||
{"Rolling Averaged Population Direction", "0%"},
|
||||
{"Rolling Averaged Population Magnitude", "0%"},
|
||||
{"OrderListHash", "486118a60d78f74811fe8d927c2c6b43"}
|
||||
{"OrderListHash", "b006bb7864c0b2f1a6552fb2aa7f03b8"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -90,18 +90,18 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Drawdown", "3.300%"},
|
||||
{"Expectancy", "-1"},
|
||||
{"Net Profit", "-0.168%"},
|
||||
{"Sharpe Ratio", "-0.126"},
|
||||
{"Probabilistic Sharpe Ratio", "45.081%"},
|
||||
{"Sharpe Ratio", "62.513"},
|
||||
{"Probabilistic Sharpe Ratio", "0%"},
|
||||
{"Loss Rate", "100%"},
|
||||
{"Win Rate", "0%"},
|
||||
{"Profit-Loss Ratio", "0"},
|
||||
{"Alpha", "-2.896"},
|
||||
{"Beta", "0.551"},
|
||||
{"Annual Standard Deviation", "0.385"},
|
||||
{"Annual Variance", "0.148"},
|
||||
{"Information Ratio", "-13.66"},
|
||||
{"Tracking Error", "0.382"},
|
||||
{"Treynor Ratio", "-0.088"},
|
||||
{"Alpha", "1.118"},
|
||||
{"Beta", "1.19"},
|
||||
{"Annual Standard Deviation", "0.213"},
|
||||
{"Annual Variance", "0.046"},
|
||||
{"Information Ratio", "70.862"},
|
||||
{"Tracking Error", "0.043"},
|
||||
{"Treynor Ratio", "11.209"},
|
||||
{"Total Fees", "$23.21"},
|
||||
{"Estimated Strategy Capacity", "$340000000.00"},
|
||||
{"Lowest Capacity Asset", "FB V6OIPNZEM8V9"},
|
||||
|
||||
@@ -37,6 +37,10 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
// Set requested data resolution
|
||||
UniverseSettings.Resolution = Resolution.Daily;
|
||||
|
||||
// Order margin value has to have a minimum of 0.5% of Portfolio value, allows filtering out small trades and reduce fees.
|
||||
// Commented so regression algorithm is more sensitive
|
||||
//Settings.MinimumOrderMarginPortfolioPercentage = 0.005m;
|
||||
|
||||
SetStartDate(2014, 03, 24);
|
||||
SetEndDate(2014, 04, 07);
|
||||
SetCash(100000);
|
||||
@@ -90,33 +94,33 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// </summary>
|
||||
public Dictionary<string, string> ExpectedStatistics => new Dictionary<string, string>
|
||||
{
|
||||
{"Total Trades", "25"},
|
||||
{"Average Win", "0.00%"},
|
||||
{"Total Trades", "27"},
|
||||
{"Average Win", "0.01%"},
|
||||
{"Average Loss", "-0.01%"},
|
||||
{"Compounding Annual Return", "-75.314%"},
|
||||
{"Compounding Annual Return", "-75.320%"},
|
||||
{"Drawdown", "5.800%"},
|
||||
{"Expectancy", "-0.633"},
|
||||
{"Net Profit", "-5.587%"},
|
||||
{"Sharpe Ratio", "-3.271"},
|
||||
{"Probabilistic Sharpe Ratio", "5.832%"},
|
||||
{"Loss Rate", "75%"},
|
||||
{"Win Rate", "25%"},
|
||||
{"Profit-Loss Ratio", "0.47"},
|
||||
{"Alpha", "-0.594"},
|
||||
{"Beta", "0.707"},
|
||||
{"Annual Standard Deviation", "0.203"},
|
||||
{"Annual Variance", "0.041"},
|
||||
{"Information Ratio", "-2.928"},
|
||||
{"Tracking Error", "0.193"},
|
||||
{"Treynor Ratio", "-0.942"},
|
||||
{"Total Fees", "$35.25"},
|
||||
{"Expectancy", "-0.731"},
|
||||
{"Net Profit", "-5.588%"},
|
||||
{"Sharpe Ratio", "-3.252"},
|
||||
{"Probabilistic Sharpe Ratio", "5.526%"},
|
||||
{"Loss Rate", "86%"},
|
||||
{"Win Rate", "14%"},
|
||||
{"Profit-Loss Ratio", "0.89"},
|
||||
{"Alpha", "-0.499"},
|
||||
{"Beta", "1.483"},
|
||||
{"Annual Standard Deviation", "0.196"},
|
||||
{"Annual Variance", "0.039"},
|
||||
{"Information Ratio", "-3.844"},
|
||||
{"Tracking Error", "0.142"},
|
||||
{"Treynor Ratio", "-0.43"},
|
||||
{"Total Fees", "$37.25"},
|
||||
{"Estimated Strategy Capacity", "$520000000.00"},
|
||||
{"Lowest Capacity Asset", "AAPL R735QTJ8XC9X"},
|
||||
{"Fitness Score", "0.004"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "1"},
|
||||
{"Sortino Ratio", "-4.468"},
|
||||
{"Return Over Maximum Drawdown", "-13.058"},
|
||||
{"Sortino Ratio", "-4.469"},
|
||||
{"Return Over Maximum Drawdown", "-13.057"},
|
||||
{"Portfolio Turnover", "0.084"},
|
||||
{"Total Insights Generated", "33"},
|
||||
{"Total Insights Closed", "30"},
|
||||
@@ -131,7 +135,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Mean Population Magnitude", "0%"},
|
||||
{"Rolling Averaged Population Direction", "0%"},
|
||||
{"Rolling Averaged Population Magnitude", "0%"},
|
||||
{"OrderListHash", "c5553cbcef8480c184203c444794ccf1"}
|
||||
{"OrderListHash", "f837879b96f5e565b60fd040299d2123"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -198,18 +198,18 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Drawdown", "0%"},
|
||||
{"Expectancy", "0"},
|
||||
{"Net Profit", "0.192%"},
|
||||
{"Sharpe Ratio", "31.331"},
|
||||
{"Probabilistic Sharpe Ratio", "88.448%"},
|
||||
{"Sharpe Ratio", "231.673"},
|
||||
{"Probabilistic Sharpe Ratio", "0%"},
|
||||
{"Loss Rate", "0%"},
|
||||
{"Win Rate", "0%"},
|
||||
{"Profit-Loss Ratio", "0"},
|
||||
{"Alpha", "0.138"},
|
||||
{"Beta", "0.04"},
|
||||
{"Annual Standard Deviation", "0.004"},
|
||||
{"Alpha", "0.163"},
|
||||
{"Beta", "-0.007"},
|
||||
{"Annual Standard Deviation", "0.001"},
|
||||
{"Annual Variance", "0"},
|
||||
{"Information Ratio", "4.767"},
|
||||
{"Tracking Error", "0.077"},
|
||||
{"Treynor Ratio", "3.223"},
|
||||
{"Information Ratio", "4.804"},
|
||||
{"Tracking Error", "0.098"},
|
||||
{"Treynor Ratio", "-22.526"},
|
||||
{"Total Fees", "$307.50"},
|
||||
{"Estimated Strategy Capacity", "$2600000.00"},
|
||||
{"Lowest Capacity Asset", "GOOCV VP83T1ZUHROL"},
|
||||
|
||||
188
Algorithm.CSharp/AlphaStreamsBasicTemplateAlgorithm.cs
Normal file
188
Algorithm.CSharp/AlphaStreamsBasicTemplateAlgorithm.cs
Normal file
@@ -0,0 +1,188 @@
|
||||
/*
|
||||
* 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.Linq;
|
||||
using QuantConnect.Data;
|
||||
using QuantConnect.Orders;
|
||||
using QuantConnect.Interfaces;
|
||||
using QuantConnect.Brokerages;
|
||||
using QuantConnect.Securities;
|
||||
using System.Collections.Generic;
|
||||
using QuantConnect.Data.UniverseSelection;
|
||||
using QuantConnect.Data.Custom.AlphaStreams;
|
||||
using QuantConnect.Algorithm.Framework.Execution;
|
||||
using QuantConnect.Algorithm.Framework.Portfolio;
|
||||
|
||||
namespace QuantConnect.Algorithm.CSharp
|
||||
{
|
||||
/// <summary>
|
||||
/// Example algorithm consuming an alpha streams portfolio state and trading based on it
|
||||
/// </summary>
|
||||
public class AlphaStreamsBasicTemplateAlgorithm : QCAlgorithm, IRegressionAlgorithmDefinition
|
||||
{
|
||||
private Dictionary<Symbol, HashSet<Symbol>> _symbolsPerAlpha = new Dictionary<Symbol, HashSet<Symbol>>();
|
||||
|
||||
/// <summary>
|
||||
/// Initialise the data and resolution required, as well as the cash and start-end dates for your algorithm. All algorithms must initialized.
|
||||
/// </summary>
|
||||
public override void Initialize()
|
||||
{
|
||||
SetStartDate(2018, 04, 04);
|
||||
SetEndDate(2018, 04, 06);
|
||||
|
||||
SetExecution(new ImmediateExecutionModel());
|
||||
Settings.MinimumOrderMarginPortfolioPercentage = 0.01m;
|
||||
SetPortfolioConstruction(new EqualWeightingAlphaStreamsPortfolioConstructionModel());
|
||||
|
||||
SetSecurityInitializer(new BrokerageModelSecurityInitializer(BrokerageModel,
|
||||
new FuncSecuritySeeder(GetLastKnownPrices)));
|
||||
|
||||
foreach (var alphaId in new [] { "623b06b231eb1cc1aa3643a46", "9fc8ef73792331b11dbd5429a" })
|
||||
{
|
||||
AddData<AlphaStreamsPortfolioState>(alphaId);
|
||||
}
|
||||
}
|
||||
|
||||
/// <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)
|
||||
{
|
||||
foreach (var portfolioState in data.Get<AlphaStreamsPortfolioState>().Values)
|
||||
{
|
||||
ProcessPortfolioState(portfolioState);
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnOrderEvent(OrderEvent orderEvent)
|
||||
{
|
||||
Log($"OnOrderEvent: {orderEvent}");
|
||||
}
|
||||
|
||||
public override void OnSecuritiesChanged(SecurityChanges changes)
|
||||
{
|
||||
changes.FilterCustomSecurities = false;
|
||||
foreach (var addedSecurity in changes.AddedSecurities)
|
||||
{
|
||||
if (addedSecurity.Symbol.IsCustomDataType<AlphaStreamsPortfolioState>())
|
||||
{
|
||||
if (!_symbolsPerAlpha.ContainsKey(addedSecurity.Symbol))
|
||||
{
|
||||
_symbolsPerAlpha[addedSecurity.Symbol] = new HashSet<Symbol>();
|
||||
}
|
||||
// warmup alpha state, adding target securities
|
||||
ProcessPortfolioState(addedSecurity.Cache.GetData<AlphaStreamsPortfolioState>());
|
||||
}
|
||||
}
|
||||
|
||||
Log($"OnSecuritiesChanged: {changes}");
|
||||
}
|
||||
|
||||
private bool UsedBySomeAlpha(Symbol asset)
|
||||
{
|
||||
return _symbolsPerAlpha.Any(pair => pair.Value.Contains(asset));
|
||||
}
|
||||
|
||||
private void ProcessPortfolioState(AlphaStreamsPortfolioState portfolioState)
|
||||
{
|
||||
if (portfolioState == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var alphaId = portfolioState.Symbol;
|
||||
if (!_symbolsPerAlpha.TryGetValue(alphaId, out var currentSymbols))
|
||||
{
|
||||
_symbolsPerAlpha[alphaId] = currentSymbols = new HashSet<Symbol>();
|
||||
}
|
||||
|
||||
var newSymbols = new HashSet<Symbol>(currentSymbols.Count);
|
||||
foreach (var symbol in portfolioState.PositionGroups?.SelectMany(positionGroup => positionGroup.Positions).Select(state => state.Symbol) ?? Enumerable.Empty<Symbol>())
|
||||
{
|
||||
// only add it if it's not used by any alpha (already added check)
|
||||
if (newSymbols.Add(symbol) && !UsedBySomeAlpha(symbol))
|
||||
{
|
||||
AddSecurity(symbol, resolution: UniverseSettings.Resolution, extendedMarketHours: UniverseSettings.ExtendedMarketHours);
|
||||
}
|
||||
}
|
||||
_symbolsPerAlpha[alphaId] = newSymbols;
|
||||
|
||||
foreach (var symbol in currentSymbols.Where(symbol => !UsedBySomeAlpha(symbol)))
|
||||
{
|
||||
RemoveSecurity(symbol);
|
||||
}
|
||||
}
|
||||
|
||||
/// <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 Language[] Languages { get; } = { Language.CSharp };
|
||||
|
||||
/// <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 Trades", "2"},
|
||||
{"Average Win", "0%"},
|
||||
{"Average Loss", "-0.12%"},
|
||||
{"Compounding Annual Return", "-14.722%"},
|
||||
{"Drawdown", "0.200%"},
|
||||
{"Expectancy", "-1"},
|
||||
{"Net Profit", "-0.116%"},
|
||||
{"Sharpe Ratio", "0"},
|
||||
{"Probabilistic Sharpe Ratio", "0%"},
|
||||
{"Loss Rate", "100%"},
|
||||
{"Win Rate", "0%"},
|
||||
{"Profit-Loss Ratio", "0"},
|
||||
{"Alpha", "0"},
|
||||
{"Beta", "0"},
|
||||
{"Annual Standard Deviation", "0"},
|
||||
{"Annual Variance", "0"},
|
||||
{"Information Ratio", "2.474"},
|
||||
{"Tracking Error", "0.339"},
|
||||
{"Treynor Ratio", "0"},
|
||||
{"Total Fees", "$0.00"},
|
||||
{"Estimated Strategy Capacity", "$83000.00"},
|
||||
{"Lowest Capacity Asset", "BTCUSD XJ"},
|
||||
{"Fitness Score", "0.017"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
{"Sortino Ratio", "79228162514264337593543950335"},
|
||||
{"Return Over Maximum Drawdown", "-138.588"},
|
||||
{"Portfolio Turnover", "0.034"},
|
||||
{"Total Insights Generated", "0"},
|
||||
{"Total Insights Closed", "0"},
|
||||
{"Total Insights Analysis Completed", "0"},
|
||||
{"Long Insight Count", "0"},
|
||||
{"Short Insight Count", "0"},
|
||||
{"Long/Short Ratio", "100%"},
|
||||
{"Estimated Monthly Alpha Value", "$0"},
|
||||
{"Total Accumulated Estimated Alpha Value", "$0"},
|
||||
{"Mean Population Estimated Insight Value", "$0"},
|
||||
{"Mean Population Direction", "0%"},
|
||||
{"Mean Population Magnitude", "0%"},
|
||||
{"Rolling Averaged Population Direction", "0%"},
|
||||
{"Rolling Averaged Population Magnitude", "0%"},
|
||||
{"OrderListHash", "2b94bc50a74caebe06c075cdab1bc6da"}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
namespace QuantConnect.Algorithm.CSharp
|
||||
{
|
||||
/// <summary>
|
||||
/// Example algorithm with existing holdings consuming an alpha streams portfolio state and trading based on it
|
||||
/// </summary>
|
||||
public class AlphaStreamsDifferentAccountCurrencyBasicTemplateAlgorithm : AlphaStreamsWithHoldingsBasicTemplateAlgorithm
|
||||
{
|
||||
/// <summary>
|
||||
/// Initialise the data and resolution required, as well as the cash and start-end dates for your algorithm. All algorithms must initialized.
|
||||
/// </summary>
|
||||
public override void Initialize()
|
||||
{
|
||||
SetAccountCurrency("EUR");
|
||||
base.Initialize();
|
||||
}
|
||||
|
||||
/// <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 Language[] Languages { get; } = { Language.CSharp };
|
||||
|
||||
/// <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 Trades", "2"},
|
||||
{"Average Win", "0.01%"},
|
||||
{"Average Loss", "0.00%"},
|
||||
{"Compounding Annual Return", "-78.502%"},
|
||||
{"Drawdown", "3.100%"},
|
||||
{"Expectancy", "7.797"},
|
||||
{"Net Profit", "-1.134%"},
|
||||
{"Sharpe Ratio", "-2.456"},
|
||||
{"Probabilistic Sharpe Ratio", "0%"},
|
||||
{"Loss Rate", "50%"},
|
||||
{"Win Rate", "50%"},
|
||||
{"Profit-Loss Ratio", "16.59"},
|
||||
{"Alpha", "0.006"},
|
||||
{"Beta", "1.011"},
|
||||
{"Annual Standard Deviation", "0.343"},
|
||||
{"Annual Variance", "0.117"},
|
||||
{"Information Ratio", "-0.859"},
|
||||
{"Tracking Error", "0.004"},
|
||||
{"Treynor Ratio", "-0.832"},
|
||||
{"Total Fees", "$2.89"},
|
||||
{"Estimated Strategy Capacity", "$8900000000.00"},
|
||||
{"Lowest Capacity Asset", "AAPL R735QTJ8XC9X"},
|
||||
{"Fitness Score", "0.506"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
{"Sortino Ratio", "79228162514264337593543950335"},
|
||||
{"Return Over Maximum Drawdown", "79228162514264337593543950335"},
|
||||
{"Portfolio Turnover", "0.506"},
|
||||
{"Total Insights Generated", "0"},
|
||||
{"Total Insights Closed", "0"},
|
||||
{"Total Insights Analysis Completed", "0"},
|
||||
{"Long Insight Count", "0"},
|
||||
{"Short Insight Count", "0"},
|
||||
{"Long/Short Ratio", "100%"},
|
||||
{"Estimated Monthly Alpha Value", "€0"},
|
||||
{"Total Accumulated Estimated Alpha Value", "€0"},
|
||||
{"Mean Population Estimated Insight Value", "€0"},
|
||||
{"Mean Population Direction", "0%"},
|
||||
{"Mean Population Magnitude", "0%"},
|
||||
{"Rolling Averaged Population Direction", "0%"},
|
||||
{"Rolling Averaged Population Magnitude", "0%"},
|
||||
{"OrderListHash", "a9dd0a0ab6070455479d1b9caaa4e69c"}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,117 @@
|
||||
/*
|
||||
* 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.UniverseSelection;
|
||||
using QuantConnect.Data.Custom.AlphaStreams;
|
||||
using QuantConnect.Algorithm.Framework.Execution;
|
||||
using QuantConnect.Algorithm.Framework.Portfolio;
|
||||
using QuantConnect.Algorithm.Framework.Selection;
|
||||
|
||||
namespace QuantConnect.Algorithm.CSharp
|
||||
{
|
||||
/// <summary>
|
||||
/// Example algorithm consuming an alpha streams portfolio state and trading based on it
|
||||
/// </summary>
|
||||
public class AlphaStreamsUniverseSelectionTemplateAlgorithm : AlphaStreamsBasicTemplateAlgorithm
|
||||
{
|
||||
/// <summary>
|
||||
/// Initialise the data and resolution required, as well as the cash and start-end dates for your algorithm. All algorithms must initialized.
|
||||
/// </summary>
|
||||
public override void Initialize()
|
||||
{
|
||||
SetStartDate(2018, 04, 04);
|
||||
SetEndDate(2018, 04, 06);
|
||||
|
||||
SetExecution(new ImmediateExecutionModel());
|
||||
Settings.MinimumOrderMarginPortfolioPercentage = 0.01m;
|
||||
SetPortfolioConstruction(new EqualWeightingAlphaStreamsPortfolioConstructionModel());
|
||||
|
||||
SetUniverseSelection(new ScheduledUniverseSelectionModel(
|
||||
DateRules.EveryDay(),
|
||||
TimeRules.Midnight,
|
||||
SelectAlphas,
|
||||
new UniverseSettings(UniverseSettings)
|
||||
{
|
||||
SubscriptionDataTypes = new List<Tuple<Type, TickType>>
|
||||
{new(typeof(AlphaStreamsPortfolioState), TickType.Trade)},
|
||||
FillForward = false,
|
||||
}
|
||||
));
|
||||
}
|
||||
|
||||
private IEnumerable<Symbol> SelectAlphas(DateTime dateTime)
|
||||
{
|
||||
Log($"SelectAlphas() {Time}");
|
||||
foreach (var alphaId in new[] {"623b06b231eb1cc1aa3643a46", "9fc8ef73792331b11dbd5429a"})
|
||||
{
|
||||
var alphaSymbol = new Symbol(SecurityIdentifier.GenerateBase(typeof(AlphaStreamsPortfolioState), alphaId, Market.USA),
|
||||
alphaId);
|
||||
|
||||
yield return alphaSymbol;
|
||||
}
|
||||
}
|
||||
|
||||
/// <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 Trades", "2"},
|
||||
{"Average Win", "0%"},
|
||||
{"Average Loss", "-0.12%"},
|
||||
{"Compounding Annual Return", "-13.200%"},
|
||||
{"Drawdown", "0.200%"},
|
||||
{"Expectancy", "-1"},
|
||||
{"Net Profit", "-0.116%"},
|
||||
{"Sharpe Ratio", "0"},
|
||||
{"Probabilistic Sharpe Ratio", "0%"},
|
||||
{"Loss Rate", "100%"},
|
||||
{"Win Rate", "0%"},
|
||||
{"Profit-Loss Ratio", "0"},
|
||||
{"Alpha", "0"},
|
||||
{"Beta", "0"},
|
||||
{"Annual Standard Deviation", "0"},
|
||||
{"Annual Variance", "0"},
|
||||
{"Information Ratio", "2.474"},
|
||||
{"Tracking Error", "0.339"},
|
||||
{"Treynor Ratio", "0"},
|
||||
{"Total Fees", "$0.00"},
|
||||
{"Estimated Strategy Capacity", "$83000.00"},
|
||||
{"Lowest Capacity Asset", "BTCUSD XJ"},
|
||||
{"Fitness Score", "0.011"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
{"Sortino Ratio", "79228162514264337593543950335"},
|
||||
{"Return Over Maximum Drawdown", "-113.513"},
|
||||
{"Portfolio Turnover", "0.023"},
|
||||
{"Total Insights Generated", "0"},
|
||||
{"Total Insights Closed", "0"},
|
||||
{"Total Insights Analysis Completed", "0"},
|
||||
{"Long Insight Count", "0"},
|
||||
{"Short Insight Count", "0"},
|
||||
{"Long/Short Ratio", "100%"},
|
||||
{"Estimated Monthly Alpha Value", "$0"},
|
||||
{"Total Accumulated Estimated Alpha Value", "$0"},
|
||||
{"Mean Population Estimated Insight Value", "$0"},
|
||||
{"Mean Population Direction", "0%"},
|
||||
{"Mean Population Magnitude", "0%"},
|
||||
{"Rolling Averaged Population Direction", "0%"},
|
||||
{"Rolling Averaged Population Magnitude", "0%"},
|
||||
{"OrderListHash", "2b94bc50a74caebe06c075cdab1bc6da"}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,144 @@
|
||||
/*
|
||||
* 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.Orders;
|
||||
using System.Collections.Generic;
|
||||
using QuantConnect.Data.Custom.AlphaStreams;
|
||||
using QuantConnect.Algorithm.Framework.Execution;
|
||||
using QuantConnect.Algorithm.Framework.Portfolio;
|
||||
|
||||
namespace QuantConnect.Algorithm.CSharp
|
||||
{
|
||||
/// <summary>
|
||||
/// Example algorithm with existing holdings consuming an alpha streams portfolio state and trading based on it
|
||||
/// </summary>
|
||||
public class AlphaStreamsWithHoldingsBasicTemplateAlgorithm : AlphaStreamsBasicTemplateAlgorithm
|
||||
{
|
||||
private decimal _expectedSpyQuantity;
|
||||
/// <summary>
|
||||
/// Initialise the data and resolution required, as well as the cash and start-end dates for your algorithm. All algorithms must initialized.
|
||||
/// </summary>
|
||||
public override void Initialize()
|
||||
{
|
||||
SetStartDate(2018, 04, 04);
|
||||
SetEndDate(2018, 04, 06);
|
||||
SetCash(100000);
|
||||
|
||||
SetExecution(new ImmediateExecutionModel());
|
||||
UniverseSettings.Resolution = Resolution.Hour;
|
||||
Settings.MinimumOrderMarginPortfolioPercentage = 0.001m;
|
||||
SetPortfolioConstruction(new EqualWeightingAlphaStreamsPortfolioConstructionModel());
|
||||
|
||||
// AAPL should be liquidated since it's not hold by the alpha
|
||||
// This is handled by the PCM
|
||||
var aapl = AddEquity("AAPL", Resolution.Hour);
|
||||
aapl.Holdings.SetHoldings(40, 10);
|
||||
|
||||
// SPY will be bought following the alpha streams portfolio
|
||||
// This is handled by the PCM + Execution Model
|
||||
var spy = AddEquity("SPY", Resolution.Hour);
|
||||
spy.Holdings.SetHoldings(246, -10);
|
||||
|
||||
AddData<AlphaStreamsPortfolioState>("94d820a93fff127fa46c15231d");
|
||||
}
|
||||
|
||||
public override void OnOrderEvent(OrderEvent orderEvent)
|
||||
{
|
||||
if (_expectedSpyQuantity == 0 && orderEvent.Symbol == "SPY" && orderEvent.Status == OrderStatus.Filled)
|
||||
{
|
||||
var security = Securities["SPY"];
|
||||
var priceInAccountCurrency = Portfolio.CashBook.ConvertToAccountCurrency(security.AskPrice, security.QuoteCurrency.Symbol);
|
||||
_expectedSpyQuantity = (Portfolio.TotalPortfolioValue - Settings.FreePortfolioValue) / priceInAccountCurrency;
|
||||
_expectedSpyQuantity = _expectedSpyQuantity.DiscretelyRoundBy(1, MidpointRounding.ToZero);
|
||||
}
|
||||
|
||||
base.OnOrderEvent(orderEvent);
|
||||
}
|
||||
|
||||
public override void OnEndOfAlgorithm()
|
||||
{
|
||||
if (Securities["AAPL"].HoldStock)
|
||||
{
|
||||
throw new Exception("We should no longer hold AAPL since the alpha does not");
|
||||
}
|
||||
|
||||
// we allow some padding for small price differences
|
||||
if (Math.Abs(Securities["SPY"].Holdings.Quantity - _expectedSpyQuantity) > _expectedSpyQuantity * 0.03m)
|
||||
{
|
||||
throw new Exception($"Unexpected SPY holdings. Expected {_expectedSpyQuantity} was {Securities["SPY"].Holdings.Quantity}");
|
||||
}
|
||||
}
|
||||
|
||||
/// <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 Language[] Languages { get; } = { Language.CSharp };
|
||||
|
||||
/// <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 Trades", "2"},
|
||||
{"Average Win", "0.01%"},
|
||||
{"Average Loss", "0.00%"},
|
||||
{"Compounding Annual Return", "-87.617%"},
|
||||
{"Drawdown", "3.100%"},
|
||||
{"Expectancy", "8.518"},
|
||||
{"Net Profit", "-1.515%"},
|
||||
{"Sharpe Ratio", "-2.45"},
|
||||
{"Probabilistic Sharpe Ratio", "0%"},
|
||||
{"Loss Rate", "50%"},
|
||||
{"Win Rate", "50%"},
|
||||
{"Profit-Loss Ratio", "18.04"},
|
||||
{"Alpha", "0.008"},
|
||||
{"Beta", "1.015"},
|
||||
{"Annual Standard Deviation", "0.344"},
|
||||
{"Annual Variance", "0.118"},
|
||||
{"Information Ratio", "-0.856"},
|
||||
{"Tracking Error", "0.005"},
|
||||
{"Treynor Ratio", "-0.83"},
|
||||
{"Total Fees", "$3.09"},
|
||||
{"Estimated Strategy Capacity", "$8900000000.00"},
|
||||
{"Lowest Capacity Asset", "AAPL R735QTJ8XC9X"},
|
||||
{"Fitness Score", "0.511"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
{"Sortino Ratio", "79228162514264337593543950335"},
|
||||
{"Return Over Maximum Drawdown", "6113.173"},
|
||||
{"Portfolio Turnover", "0.511"},
|
||||
{"Total Insights Generated", "0"},
|
||||
{"Total Insights Closed", "0"},
|
||||
{"Total Insights Analysis Completed", "0"},
|
||||
{"Long Insight Count", "0"},
|
||||
{"Short Insight Count", "0"},
|
||||
{"Long/Short Ratio", "100%"},
|
||||
{"Estimated Monthly Alpha Value", "$0"},
|
||||
{"Total Accumulated Estimated Alpha Value", "$0"},
|
||||
{"Mean Population Estimated Insight Value", "$0"},
|
||||
{"Mean Population Direction", "0%"},
|
||||
{"Mean Population Magnitude", "0%"},
|
||||
{"Rolling Averaged Population Direction", "0%"},
|
||||
{"Rolling Averaged Population Magnitude", "0%"},
|
||||
{"OrderListHash", "788eb2c74715a78476ba0db3b2654eb6"}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1,117 +0,0 @@
|
||||
/*
|
||||
* 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;
|
||||
using QuantConnect.Data.Custom.Benzinga;
|
||||
using QuantConnect.Data.UniverseSelection;
|
||||
|
||||
namespace QuantConnect.Algorithm.CSharp.AltData
|
||||
{
|
||||
/// <summary>
|
||||
/// Benzinga is a provider of news data. Their news is made in-house
|
||||
/// and covers stock related news such as corporate events.
|
||||
/// </summary>
|
||||
public class BenzingaNewsAlgorithm : QCAlgorithm
|
||||
{
|
||||
// Predefine a dictionary of words with scores to scan for in the description
|
||||
// of the Benzinga news article
|
||||
private readonly Dictionary<string, double> _words = new Dictionary<string, double>()
|
||||
{
|
||||
{"bad", -0.5}, {"good", 0.5},
|
||||
{"negative", -0.5}, {"great", 0.5},
|
||||
{"growth", 0.5}, {"fail", -0.5},
|
||||
{"failed", -0.5}, {"success", 0.5},
|
||||
{"nailed", 0.5}, {"beat", 0.5},
|
||||
{"missed", -0.5}
|
||||
};
|
||||
|
||||
// Trade only every 5 days
|
||||
private DateTime _lastTrade = DateTime.MinValue;
|
||||
|
||||
/// <summary>
|
||||
/// Initialise the data and resolution required, as well as the cash and start-end dates for your algorithm. All algorithms must initialized.
|
||||
/// </summary>
|
||||
public override void Initialize()
|
||||
{
|
||||
SetStartDate(2018, 6, 5);
|
||||
SetEndDate(2018, 8, 4);
|
||||
SetCash(100000);
|
||||
|
||||
var aapl = AddEquity("AAPL", Resolution.Hour).Symbol;
|
||||
var ibm = AddEquity("IBM", Resolution.Hour).Symbol;
|
||||
|
||||
AddData<BenzingaNews>(aapl);
|
||||
AddData<BenzingaNews>(ibm);
|
||||
}
|
||||
|
||||
public override void OnData(Slice data)
|
||||
{
|
||||
if ((Time - _lastTrade) < TimeSpan.FromDays(5))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Get rid of our holdings after 5 days, and start fresh
|
||||
Liquidate();
|
||||
|
||||
// Get all Benzinga data and loop over it
|
||||
foreach (var article in data.Get<BenzingaNews>().Values)
|
||||
{
|
||||
// Select the same Symbol we're getting a data point for
|
||||
// from the articles list so that we can get the sentiment of the article.
|
||||
// We use the underlying Symbol because the Symbols included in the `Symbols` property
|
||||
// are equity Symbols.
|
||||
var selectedSymbol = article.Symbols.SingleOrDefault(s => s == article.Symbol.Underlying);
|
||||
if (selectedSymbol == null)
|
||||
{
|
||||
throw new Exception($"Could not find current Symbol {article.Symbol.Underlying} even though it should exist");
|
||||
}
|
||||
|
||||
// The intersection of the article contents and the pre-defined words are the words that are included in both collections
|
||||
var intersection = article.Contents.ToLowerInvariant().Split(' ').Intersect(_words.Keys);
|
||||
// Get the words, then get the aggregate sentiment
|
||||
var sentimentSum = intersection.Select(x => _words[x]).Sum();
|
||||
|
||||
if (sentimentSum >= 0.5)
|
||||
{
|
||||
Log($"Longing {article.Symbol.Underlying} with sentiment score of {sentimentSum}");
|
||||
SetHoldings(article.Symbol.Underlying, sentimentSum / 5);
|
||||
|
||||
_lastTrade = Time;
|
||||
}
|
||||
if (sentimentSum <= -0.5)
|
||||
{
|
||||
Log($"Shorting {article.Symbol.Underlying} with sentiment score of {sentimentSum}");
|
||||
SetHoldings(article.Symbol.Underlying, sentimentSum / 5);
|
||||
|
||||
_lastTrade = Time;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnSecuritiesChanged(SecurityChanges changes)
|
||||
{
|
||||
foreach (var r in changes.RemovedSecurities)
|
||||
{
|
||||
// If removed from the universe, liquidate and remove the custom data from the algorithm
|
||||
Liquidate(r.Symbol);
|
||||
RemoveSecurity(QuantConnect.Symbol.CreateBase(typeof(BenzingaNews), r.Symbol, Market.USA));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,66 +0,0 @@
|
||||
/*
|
||||
* 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 QuantConnect.Data;
|
||||
using QuantConnect.Data.Custom.CBOE;
|
||||
using QuantConnect.Data.Custom.Fred;
|
||||
using QuantConnect.Data.Custom.USEnergy;
|
||||
|
||||
namespace QuantConnect.Algorithm.CSharp.AltData
|
||||
{
|
||||
public class CachedAlternativeDataAlgorithm : QCAlgorithm
|
||||
{
|
||||
private Symbol _cboeVix;
|
||||
private Symbol _usEnergy;
|
||||
private Symbol _fredPeakToTrough;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
SetStartDate(2003, 1, 1);
|
||||
SetEndDate(2019, 10, 11);
|
||||
SetCash(100000);
|
||||
|
||||
// QuantConnect caches a small subset of alternative data for easy consumption for the community.
|
||||
// You can use this in your algorithm as demonstrated below:
|
||||
|
||||
_cboeVix = AddData<CBOE>("VIX", Resolution.Daily).Symbol;
|
||||
// United States EIA data: https://eia.gov/
|
||||
_usEnergy = AddData<USEnergy>(USEnergy.Petroleum.UnitedStates.WeeklyGrossInputsIntoRefineries, Resolution.Daily).Symbol;
|
||||
// FRED data
|
||||
_fredPeakToTrough = AddData<Fred>(Fred.OECDRecessionIndicators.UnitedStatesFromPeakThroughTheTrough, Resolution.Daily).Symbol;
|
||||
}
|
||||
|
||||
public override void OnData(Slice data)
|
||||
{
|
||||
if (data.ContainsKey(_cboeVix))
|
||||
{
|
||||
var vix = data.Get<CBOE>(_cboeVix);
|
||||
Log($"VIX: {vix}");
|
||||
}
|
||||
|
||||
if (data.ContainsKey(_usEnergy))
|
||||
{
|
||||
var inputIntoRefineries = data.Get<USEnergy>(_usEnergy);
|
||||
Log($"U.S. Input Into Refineries: {Time}, {inputIntoRefineries.Value}");
|
||||
}
|
||||
|
||||
if (data.ContainsKey(_fredPeakToTrough))
|
||||
{
|
||||
var peakToTrough = data.Get<Fred>(_fredPeakToTrough);
|
||||
Log($"OECD based Recession Indicator for the United States from the Peak through the Trough: {peakToTrough}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,62 +0,0 @@
|
||||
/*
|
||||
* 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.Linq;
|
||||
using QuantConnect.Data;
|
||||
using QuantConnect.Data.Custom.Quiver;
|
||||
|
||||
namespace QuantConnect.Algorithm.CSharp.AltData
|
||||
{
|
||||
/// <summary>
|
||||
/// Quiver Quantitative is a provider of alternative data.
|
||||
/// This algorithm shows how to consume the <see cref="QuiverWallStreetBets"/>
|
||||
/// </summary>
|
||||
public class QuiverWallStreetBetsDataAlgorithm : QCAlgorithm
|
||||
{
|
||||
/// <summary>
|
||||
/// Initialise the data and resolution required, as well as the cash and start-end dates for your algorithm. All algorithms must initialized.
|
||||
/// </summary>
|
||||
public override void Initialize()
|
||||
{
|
||||
SetStartDate(2019, 1, 1);
|
||||
SetEndDate(2020, 6, 1);
|
||||
SetCash(100000);
|
||||
|
||||
var aapl = AddEquity("AAPL", Resolution.Daily).Symbol;
|
||||
var quiverWSBSymbol = AddData<QuiverWallStreetBets>(aapl).Symbol;
|
||||
var history = History<QuiverWallStreetBets>(quiverWSBSymbol, 60, Resolution.Daily);
|
||||
|
||||
Debug($"We got {history.Count()} items from our history request");
|
||||
}
|
||||
|
||||
public override void OnData(Slice data)
|
||||
{
|
||||
var points = data.Get<QuiverWallStreetBets>();
|
||||
foreach (var point in points.Values)
|
||||
{
|
||||
// Go long in the stock if it was mentioned more than 5 times in the WallStreetBets daily discussion
|
||||
if (point.Mentions > 5)
|
||||
{
|
||||
SetHoldings(point.Symbol.Underlying, 1);
|
||||
}
|
||||
// Go short in the stock if it was mentioned less than 5 times in the WallStreetBets daily discussion
|
||||
if (point.Mentions < 5)
|
||||
{
|
||||
SetHoldings(point.Symbol.Underlying, -1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,99 +0,0 @@
|
||||
/*
|
||||
* 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.Algorithm.Framework.Selection;
|
||||
using QuantConnect.Data;
|
||||
using QuantConnect.Data.Custom.SEC;
|
||||
using QuantConnect.Data.UniverseSelection;
|
||||
|
||||
namespace QuantConnect.Algorithm.CSharp
|
||||
{
|
||||
public class SECReport8KAlgorithm : QCAlgorithm
|
||||
{
|
||||
/// <summary>
|
||||
/// Initialise the data and resolution required, as well as the cash and start-end dates for your algorithm. All algorithms must initialized.
|
||||
/// </summary>
|
||||
public override void Initialize()
|
||||
{
|
||||
SetStartDate(2019, 1, 1);
|
||||
SetEndDate(2019, 8, 21);
|
||||
SetCash(100000);
|
||||
|
||||
UniverseSettings.Resolution = Resolution.Minute;
|
||||
AddUniverseSelection(new CoarseFundamentalUniverseSelectionModel(CoarseSelector));
|
||||
|
||||
// Request underlying equity data.
|
||||
var ibm = AddEquity("IBM", Resolution.Minute).Symbol;
|
||||
// Add SEC report 10-Q data for the underlying IBM asset
|
||||
var earningsFiling = AddData<SECReport10Q>(ibm, Resolution.Daily).Symbol;
|
||||
// Request 120 days of history with the SECReport10Q IBM custom data Symbol.
|
||||
var history = History<SECReport10Q>(earningsFiling, 120, Resolution.Daily);
|
||||
|
||||
// Count the number of items we get from our history request
|
||||
Debug($"We got {history.Count()} items from our history request");
|
||||
}
|
||||
|
||||
public IEnumerable<Symbol> CoarseSelector(IEnumerable<CoarseFundamental> coarse)
|
||||
{
|
||||
// Add SEC data from the filtered coarse selection
|
||||
var symbols = coarse.Where(x => x.HasFundamentalData && x.DollarVolume > 50000000)
|
||||
.Select(x => x.Symbol)
|
||||
.Take(10);
|
||||
|
||||
foreach (var symbol in symbols)
|
||||
{
|
||||
AddData<SECReport8K>(symbol);
|
||||
}
|
||||
|
||||
return symbols;
|
||||
}
|
||||
|
||||
public override void OnData(Slice data)
|
||||
{
|
||||
// Store the symbols we want to long in a list
|
||||
// so that we can have an equal-weighted portfolio
|
||||
var longEquitySymbols = new List<Symbol>();
|
||||
|
||||
// Get all SEC data and loop over it
|
||||
foreach (var report in data.Get<SECReport8K>().Values)
|
||||
{
|
||||
// Get the length of all contents contained within the report
|
||||
var reportTextLength = report.Report.Documents.Select(x => x.Text.Length).Sum();
|
||||
|
||||
if (reportTextLength > 20000)
|
||||
{
|
||||
longEquitySymbols.Add(report.Symbol.Underlying);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var equitySymbol in longEquitySymbols)
|
||||
{
|
||||
SetHoldings(equitySymbol, 1m / longEquitySymbols.Count);
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnSecuritiesChanged(SecurityChanges changes)
|
||||
{
|
||||
foreach (var r in changes.RemovedSecurities)
|
||||
{
|
||||
// If removed from the universe, liquidate and remove the custom data from the algorithm
|
||||
Liquidate(r.Symbol);
|
||||
RemoveSecurity(QuantConnect.Symbol.CreateBase(typeof(SECReport8K), r.Symbol, Market.USA));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,90 +0,0 @@
|
||||
/*
|
||||
* 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.Algorithm.Framework.Selection;
|
||||
using QuantConnect.Data;
|
||||
using QuantConnect.Data.Custom.SmartInsider;
|
||||
using QuantConnect.Data.UniverseSelection;
|
||||
|
||||
namespace QuantConnect.Algorithm.CSharp
|
||||
{
|
||||
public class SmartInsiderTransactionAlgorithm : QCAlgorithm
|
||||
{
|
||||
public override void Initialize()
|
||||
{
|
||||
SetStartDate(2019, 3, 1);
|
||||
SetEndDate(2019, 7, 4);
|
||||
SetCash(1000000);
|
||||
|
||||
AddUniverseSelection(new CoarseFundamentalUniverseSelectionModel(CoarseUniverse));
|
||||
|
||||
// Request underlying equity data.
|
||||
var ibm = AddEquity("IBM", Resolution.Minute).Symbol;
|
||||
// Add Smart Insider stock buyback transaction data for the underlying IBM asset
|
||||
var si = AddData<SmartInsiderTransaction>(ibm).Symbol;
|
||||
// Request 60 days of history with the SmartInsiderTransaction IBM Custom Data Symbol.
|
||||
var history = History<SmartInsiderTransaction>(si, 60, Resolution.Daily);
|
||||
|
||||
// Count the number of items we get from our history request
|
||||
Debug($"We got {history.Count()} items from our history request");
|
||||
}
|
||||
|
||||
public IEnumerable<Symbol> CoarseUniverse(IEnumerable<CoarseFundamental> coarse)
|
||||
{
|
||||
var symbols = coarse.Where(x => x.HasFundamentalData && x.DollarVolume > 50000000)
|
||||
.Select(x => x.Symbol)
|
||||
.Take(10);
|
||||
|
||||
foreach (var symbol in symbols)
|
||||
{
|
||||
AddData<SmartInsiderTransaction>(symbol);
|
||||
}
|
||||
|
||||
return symbols;
|
||||
}
|
||||
|
||||
public override void OnData(Slice data)
|
||||
{
|
||||
// Get all SmartInsider data available
|
||||
var transactions = data.Get<SmartInsiderTransaction>();
|
||||
|
||||
foreach (var transaction in transactions.Values)
|
||||
{
|
||||
if (transaction.VolumePercentage == null || transaction.EventType == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// Using the Smart Insider transaction information, buy when company does a stock buyback
|
||||
if (transaction.EventType == SmartInsiderEventType.Transaction && transaction.VolumePercentage > 5)
|
||||
{
|
||||
SetHoldings(transaction.Symbol.Underlying, (decimal)transaction.VolumePercentage / 100);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnSecuritiesChanged(SecurityChanges changes)
|
||||
{
|
||||
foreach (var r in changes.RemovedSecurities)
|
||||
{
|
||||
// If removed from the universe, liquidate and remove the custom data from the algorithm
|
||||
Liquidate(r.Symbol);
|
||||
RemoveSecurity(QuantConnect.Symbol.CreateBase(typeof(SmartInsiderTransaction), r.Symbol, Market.USA));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,85 +0,0 @@
|
||||
/*
|
||||
* 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.Data;
|
||||
using QuantConnect.Data.Custom.Tiingo;
|
||||
|
||||
namespace QuantConnect.Algorithm.CSharp
|
||||
{
|
||||
/// <summary>
|
||||
/// Look for positive and negative words in the news article description
|
||||
/// and trade based on the sum of the sentiment
|
||||
/// </summary>
|
||||
public class TiingoNewsAlgorithm : QCAlgorithm
|
||||
{
|
||||
private Symbol _tiingoSymbol;
|
||||
|
||||
// Predefine a dictionary of words with scores to scan for in the description
|
||||
// of the Tiingo news article
|
||||
private readonly Dictionary<string, double> _words = new Dictionary<string, double>()
|
||||
{
|
||||
{"bad", -0.5}, {"good", 0.5},
|
||||
{ "negative", -0.5}, {"great", 0.5},
|
||||
{"growth", 0.5}, {"fail", -0.5},
|
||||
{"failed", -0.5}, {"success", 0.5},
|
||||
{"nailed", 0.5}, {"beat", 0.5},
|
||||
{"missed", -0.5}
|
||||
};
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
SetStartDate(2019, 6, 10);
|
||||
SetEndDate(2019, 10, 3);
|
||||
SetCash(100000);
|
||||
|
||||
var aapl = AddEquity("AAPL", Resolution.Hour).Symbol;
|
||||
_tiingoSymbol = AddData<TiingoNews>(aapl).Symbol;
|
||||
|
||||
// Request underlying equity data
|
||||
var ibm = AddEquity("IBM", Resolution.Minute).Symbol;
|
||||
// Add news data for the underlying IBM asset
|
||||
var news = AddData<TiingoNews>(ibm).Symbol;
|
||||
// Request 60 days of history with the TiingoNews IBM Custom Data Symbol.
|
||||
var history = History<TiingoNews>(news, 60, Resolution.Daily);
|
||||
|
||||
// Count the number of items we get from our history request
|
||||
Debug($"We got {history.Count()} items from our history request");
|
||||
}
|
||||
|
||||
public override void OnData(Slice data)
|
||||
{
|
||||
//Confirm that the data is in the collection
|
||||
if (!data.ContainsKey(_tiingoSymbol)) return;
|
||||
|
||||
// Gets the first piece of data from the Slice
|
||||
var article = data.Get<TiingoNews>(_tiingoSymbol);
|
||||
|
||||
// Article descriptions come in all caps. Lower and split by word
|
||||
var descriptionWords = article.Description.ToLowerInvariant().Split(' ');
|
||||
|
||||
// Take the intersection of predefined words and the words in the
|
||||
// description to get a list of matching words
|
||||
var intersection = _words.Keys.Intersect(descriptionWords);
|
||||
|
||||
// Get the sum of the article's sentiment, and go long or short
|
||||
// depending if it's a positive or negative description
|
||||
var sentiment = intersection.Select(x => _words[x]).Sum();
|
||||
|
||||
SetHoldings(article.Symbol.Underlying, sentiment);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,80 +0,0 @@
|
||||
/*
|
||||
* 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.Linq;
|
||||
using QuantConnect.Data;
|
||||
using QuantConnect.Data.Custom.TradingEconomics;
|
||||
|
||||
namespace QuantConnect.Algorithm.CSharp
|
||||
{
|
||||
/// <summary>
|
||||
/// Trades on interest rate announcements from data provided by Trading Economics
|
||||
/// </summary>
|
||||
public class TradingEconomicsAlgorithm : QCAlgorithm
|
||||
{
|
||||
private Symbol _interestRate;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
SetStartDate(2013, 11, 1);
|
||||
SetEndDate(2019, 10, 3);
|
||||
SetCash(100000);
|
||||
|
||||
AddEquity("AGG", Resolution.Hour);
|
||||
AddEquity("SPY", Resolution.Hour);
|
||||
|
||||
_interestRate = AddData<TradingEconomicsCalendar>(TradingEconomics.Calendar.UnitedStates.InterestRate).Symbol;
|
||||
|
||||
// Request 365 days of interest rate history with the TradingEconomicsCalendar custom data Symbol.
|
||||
// We should expect no historical data because 2013-11-01 is before the absolute first point of data
|
||||
var history = History<TradingEconomicsCalendar>(_interestRate, 365, Resolution.Daily);
|
||||
|
||||
// Count the number of items we get from our history request (should be zero)
|
||||
Debug($"We got {history.Count()} items from our history request");
|
||||
}
|
||||
|
||||
public override void OnData(Slice data)
|
||||
{
|
||||
// Make sure we have an interest rate calendar event
|
||||
if (!data.ContainsKey(_interestRate))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var announcement = data.Get<TradingEconomicsCalendar>(_interestRate);
|
||||
|
||||
// Confirm it's a FED Rate Decision
|
||||
if (announcement.Event != TradingEconomics.Event.UnitedStates.FedInterestRateDecision)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// In the event of a rate increase, rebalance 50% to Bonds.
|
||||
var interestRateDecreased = announcement.Actual <= announcement.Previous;
|
||||
|
||||
if (interestRateDecreased)
|
||||
{
|
||||
SetHoldings("SPY", 1);
|
||||
SetHoldings("AGG", 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetHoldings("SPY", 0.5);
|
||||
SetHoldings("AGG", 0.5);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,87 +0,0 @@
|
||||
/*
|
||||
* 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.Linq;
|
||||
using QuantConnect.Data;
|
||||
using QuantConnect.Data.Custom.USTreasury;
|
||||
|
||||
namespace QuantConnect.Algorithm.CSharp
|
||||
{
|
||||
public class USTreasuryYieldCurveRateAlgorithm : QCAlgorithm
|
||||
{
|
||||
private Symbol _yieldCurve;
|
||||
private Symbol _spy;
|
||||
private DateTime _lastInversion = DateTime.MinValue;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
SetStartDate(2000, 3, 1);
|
||||
SetEndDate(2019, 9, 15);
|
||||
SetCash(100000);
|
||||
|
||||
_spy = AddEquity("SPY", Resolution.Hour).Symbol;
|
||||
_yieldCurve = AddData<USTreasuryYieldCurveRate>("USTYCR", Resolution.Daily).Symbol;
|
||||
|
||||
// Request 60 days of history with the USTreasuryYieldCurveRate custom data Symbol.
|
||||
var history = History<USTreasuryYieldCurveRate>(_yieldCurve, 60, Resolution.Daily);
|
||||
|
||||
// Count the number of items we get from our history request
|
||||
Debug($"We got {history.Count()} items from our history request");
|
||||
}
|
||||
|
||||
public override void OnData(Slice data)
|
||||
{
|
||||
if (!data.ContainsKey(_yieldCurve))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Preserve null values by getting the data with `slice.Get<T>`
|
||||
// Accessing the data using `data[_yieldCurve]` results in null
|
||||
// values becoming `default(decimal)` which is equal to 0
|
||||
var rates = data.Get<USTreasuryYieldCurveRate>().Values.First();
|
||||
|
||||
// Check for null before using the values
|
||||
if (!rates.TenYear.HasValue || !rates.TwoYear.HasValue)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Only advance if a year has gone by
|
||||
if (Time - _lastInversion < TimeSpan.FromDays(365))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// if there is a yield curve inversion after not having one for a year, short SPY for two years
|
||||
if (!Portfolio.Invested && rates.TwoYear > rates.TenYear)
|
||||
{
|
||||
Debug($"{Time} - Yield curve inversion! Shorting the market for two years");
|
||||
SetHoldings(_spy, -0.5);
|
||||
|
||||
_lastInversion = Time;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// If two years have passed, liquidate our position in SPY
|
||||
if (Time - _lastInversion >= TimeSpan.FromDays(365 * 2))
|
||||
{
|
||||
Liquidate(_spy);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -85,18 +85,18 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Drawdown", "0.100%"},
|
||||
{"Expectancy", "3.321"},
|
||||
{"Net Profit", "0.089%"},
|
||||
{"Sharpe Ratio", "0.868"},
|
||||
{"Probabilistic Sharpe Ratio", "44.482%"},
|
||||
{"Sharpe Ratio", "0.798"},
|
||||
{"Probabilistic Sharpe Ratio", "40.893%"},
|
||||
{"Loss Rate", "24%"},
|
||||
{"Win Rate", "76%"},
|
||||
{"Profit-Loss Ratio", "4.67"},
|
||||
{"Alpha", "0.001"},
|
||||
{"Beta", "-0"},
|
||||
{"Alpha", "-0.001"},
|
||||
{"Beta", "0.008"},
|
||||
{"Annual Standard Deviation", "0.001"},
|
||||
{"Annual Variance", "0"},
|
||||
{"Information Ratio", "-2.148"},
|
||||
{"Tracking Error", "0.101"},
|
||||
{"Treynor Ratio", "-4.168"},
|
||||
{"Information Ratio", "-1.961"},
|
||||
{"Tracking Error", "0.092"},
|
||||
{"Treynor Ratio", "0.08"},
|
||||
{"Total Fees", "$52.00"},
|
||||
{"Estimated Strategy Capacity", "$32000000000.00"},
|
||||
{"Lowest Capacity Asset", "SPY R735QTJ8XC9X"},
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{
|
||||
UniverseSettings.DataNormalizationMode = DataNormalizationMode.Raw;
|
||||
EnableAutomaticIndicatorWarmUp = true;
|
||||
SetStartDate(2013, 10, 08);
|
||||
SetStartDate(2013, 10, 07);
|
||||
SetEndDate(2013, 10, 09);
|
||||
|
||||
var SP500 = QuantConnect.Symbol.Create(Futures.Indices.SP500EMini, SecurityType.Future, Market.CME);
|
||||
@@ -151,31 +151,31 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Total Trades", "1"},
|
||||
{"Average Win", "0%"},
|
||||
{"Average Loss", "0%"},
|
||||
{"Compounding Annual Return", "-99.999%"},
|
||||
{"Drawdown", "16.100%"},
|
||||
{"Compounding Annual Return", "-100.000%"},
|
||||
{"Drawdown", "19.800%"},
|
||||
{"Expectancy", "0"},
|
||||
{"Net Profit", "-6.366%"},
|
||||
{"Sharpe Ratio", "1.194"},
|
||||
{"Net Profit", "-10.353%"},
|
||||
{"Sharpe Ratio", "-1.379"},
|
||||
{"Probabilistic Sharpe Ratio", "0%"},
|
||||
{"Loss Rate", "0%"},
|
||||
{"Win Rate", "0%"},
|
||||
{"Profit-Loss Ratio", "0"},
|
||||
{"Alpha", "5.56"},
|
||||
{"Beta", "-71.105"},
|
||||
{"Annual Standard Deviation", "0.434"},
|
||||
{"Annual Variance", "0.188"},
|
||||
{"Information Ratio", "1.016"},
|
||||
{"Tracking Error", "0.44"},
|
||||
{"Treynor Ratio", "-0.007"},
|
||||
{"Alpha", "3.004"},
|
||||
{"Beta", "5.322"},
|
||||
{"Annual Standard Deviation", "0.725"},
|
||||
{"Annual Variance", "0.525"},
|
||||
{"Information Ratio", "-0.42"},
|
||||
{"Tracking Error", "0.589"},
|
||||
{"Treynor Ratio", "-0.188"},
|
||||
{"Total Fees", "$20.35"},
|
||||
{"Estimated Strategy Capacity", "$19000000.00"},
|
||||
{"Estimated Strategy Capacity", "$13000000.00"},
|
||||
{"Lowest Capacity Asset", "ES VMKLFZIH2MTD"},
|
||||
{"Fitness Score", "0.138"},
|
||||
{"Fitness Score", "0.125"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
{"Sortino Ratio", "-1.727"},
|
||||
{"Return Over Maximum Drawdown", "-12.061"},
|
||||
{"Portfolio Turnover", "4.916"},
|
||||
{"Sortino Ratio", "-2.162"},
|
||||
{"Return Over Maximum Drawdown", "-8.144"},
|
||||
{"Portfolio Turnover", "3.184"},
|
||||
{"Total Insights Generated", "0"},
|
||||
{"Total Insights Closed", "0"},
|
||||
{"Total Insights Analysis Completed", "0"},
|
||||
@@ -189,7 +189,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Mean Population Magnitude", "0%"},
|
||||
{"Rolling Averaged Population Direction", "0%"},
|
||||
{"Rolling Averaged Population Magnitude", "0%"},
|
||||
{"OrderListHash", "7c841ca58a4385f42236838e5bf0c382"}
|
||||
{"OrderListHash", "7ff48adafe9676f341e64ac9388d3c2c"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -305,18 +305,18 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Drawdown", "0.400%"},
|
||||
{"Expectancy", "-1"},
|
||||
{"Net Profit", "-0.329%"},
|
||||
{"Sharpe Ratio", "-11.083"},
|
||||
{"Probabilistic Sharpe Ratio", "0%"},
|
||||
{"Sharpe Ratio", "-7.887"},
|
||||
{"Probabilistic Sharpe Ratio", "1.216%"},
|
||||
{"Loss Rate", "100%"},
|
||||
{"Win Rate", "0%"},
|
||||
{"Profit-Loss Ratio", "0"},
|
||||
{"Alpha", "-0.003"},
|
||||
{"Alpha", "-0.001"},
|
||||
{"Beta", "0.097"},
|
||||
{"Annual Standard Deviation", "0.002"},
|
||||
{"Annual Variance", "0"},
|
||||
{"Information Ratio", "9.742"},
|
||||
{"Tracking Error", "0.021"},
|
||||
{"Treynor Ratio", "-0.26"},
|
||||
{"Information Ratio", "7.39"},
|
||||
{"Tracking Error", "0.015"},
|
||||
{"Treynor Ratio", "-0.131"},
|
||||
{"Total Fees", "$2.00"},
|
||||
{"Estimated Strategy Capacity", "$0"},
|
||||
{"Lowest Capacity Asset", "GOOCV VP83T1ZUHROL"},
|
||||
|
||||
130
Algorithm.CSharp/BasicTemplateAtreyuAlgorithm.cs
Normal file
130
Algorithm.CSharp/BasicTemplateAtreyuAlgorithm.cs
Normal file
@@ -0,0 +1,130 @@
|
||||
/*
|
||||
* 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 QuantConnect.Data;
|
||||
using QuantConnect.Orders;
|
||||
using QuantConnect.Interfaces;
|
||||
using QuantConnect.Brokerages;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace QuantConnect.Algorithm.CSharp
|
||||
{
|
||||
/// <summary>
|
||||
/// Basic template algorithm for the Atreyu brokerage
|
||||
/// </summary>
|
||||
/// <meta name="tag" content="using data" />
|
||||
/// <meta name="tag" content="using quantconnect" />
|
||||
/// <meta name="tag" content="trading and orders" />
|
||||
public class BasicTemplateAtreyuAlgorithm : QCAlgorithm, IRegressionAlgorithmDefinition
|
||||
{
|
||||
/// <summary>
|
||||
/// Initialise the data and resolution required, as well as the cash and start-end dates for your algorithm. All algorithms must initialized.
|
||||
/// </summary>
|
||||
public override void Initialize()
|
||||
{
|
||||
SetStartDate(2013, 10, 07);
|
||||
SetEndDate(2013, 10, 11);
|
||||
SetCash(100000);
|
||||
|
||||
SetBrokerageModel(BrokerageName.Atreyu);
|
||||
AddEquity("SPY", Resolution.Minute);
|
||||
|
||||
DefaultOrderProperties = new AtreyuOrderProperties
|
||||
{
|
||||
// Can specify the default exchange to execute an order on.
|
||||
// If not specified will default to the primary exchange
|
||||
Exchange = Exchange.NASDAQ,
|
||||
// Currently only support order for the day
|
||||
TimeInForce = TimeInForce.Day
|
||||
};
|
||||
}
|
||||
|
||||
/// <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)
|
||||
{
|
||||
if (!Portfolio.Invested)
|
||||
{
|
||||
// will set 25% of our buying power with a market order that will be routed to exchange set in the default order properties (NASDAQ)
|
||||
SetHoldings("SPY", 0.25m);
|
||||
// will increase our SPY holdings to 50% of our buying power with a market order that will be routed to ARCA
|
||||
SetHoldings("SPY", 0.50m, orderProperties: new AtreyuOrderProperties { Exchange = Exchange.ARCA });
|
||||
|
||||
Debug("Purchased SPY!");
|
||||
}
|
||||
}
|
||||
|
||||
/// <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 Language[] Languages { get; } = { Language.CSharp, Language.Python };
|
||||
|
||||
/// <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 Trades", "2"},
|
||||
{"Average Win", "0%"},
|
||||
{"Average Loss", "0%"},
|
||||
{"Compounding Annual Return", "93.443%"},
|
||||
{"Drawdown", "1.100%"},
|
||||
{"Expectancy", "0"},
|
||||
{"Net Profit", "0.847%"},
|
||||
{"Sharpe Ratio", "6.515"},
|
||||
{"Probabilistic Sharpe Ratio", "67.535%"},
|
||||
{"Loss Rate", "0%"},
|
||||
{"Win Rate", "0%"},
|
||||
{"Profit-Loss Ratio", "0"},
|
||||
{"Alpha", "0"},
|
||||
{"Beta", "0"},
|
||||
{"Annual Standard Deviation", "0.11"},
|
||||
{"Annual Variance", "0.012"},
|
||||
{"Information Ratio", "6.515"},
|
||||
{"Tracking Error", "0.11"},
|
||||
{"Treynor Ratio", "0"},
|
||||
{"Total Fees", "$0.52"},
|
||||
{"Estimated Strategy Capacity", "$8600000.00"},
|
||||
{"Lowest Capacity Asset", "SPY R735QTJ8XC9X"},
|
||||
{"Fitness Score", "0.124"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
{"Sortino Ratio", "79228162514264337593543950335"},
|
||||
{"Return Over Maximum Drawdown", "78.376"},
|
||||
{"Portfolio Turnover", "0.124"},
|
||||
{"Total Insights Generated", "0"},
|
||||
{"Total Insights Closed", "0"},
|
||||
{"Total Insights Analysis Completed", "0"},
|
||||
{"Long Insight Count", "0"},
|
||||
{"Short Insight Count", "0"},
|
||||
{"Long/Short Ratio", "100%"},
|
||||
{"Estimated Monthly Alpha Value", "$0"},
|
||||
{"Total Accumulated Estimated Alpha Value", "$0"},
|
||||
{"Mean Population Estimated Insight Value", "$0"},
|
||||
{"Mean Population Direction", "0%"},
|
||||
{"Mean Population Magnitude", "0%"},
|
||||
{"Rolling Averaged Population Direction", "0%"},
|
||||
{"Rolling Averaged Population Magnitude", "0%"},
|
||||
{"OrderListHash", "867df80d1338dc526316a01e68435498"}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
/*
|
||||
* 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.Algorithm.Framework.Alphas;
|
||||
using QuantConnect.Algorithm.Framework.Execution;
|
||||
using QuantConnect.Algorithm.Framework.Portfolio;
|
||||
using QuantConnect.Data.UniverseSelection;
|
||||
|
||||
namespace QuantConnect.Algorithm.CSharp
|
||||
{
|
||||
/// <summary>
|
||||
/// Basic template algorithm which showcases <see cref="ConstituentsUniverse"/> simple use case
|
||||
/// </summary>
|
||||
public class BasicTemplateConstituentUniverseAlgorithm : QCAlgorithm
|
||||
{
|
||||
/// <summary>
|
||||
/// Initialise the data and resolution required, as well as the cash and start-end dates for your algorithm. All algorithms must initialized.
|
||||
/// </summary>
|
||||
public override void Initialize()
|
||||
{
|
||||
SetStartDate(2013, 10, 07);
|
||||
SetEndDate(2013, 10, 11);
|
||||
|
||||
// by default will use algorithms UniverseSettings
|
||||
AddUniverse(Universe.Constituent.Steel());
|
||||
|
||||
// we specify the UniverseSettings it should use
|
||||
AddUniverse(Universe.Constituent.AggressiveGrowth(
|
||||
new UniverseSettings(Resolution.Hour,
|
||||
2,
|
||||
false,
|
||||
false,
|
||||
UniverseSettings.MinimumTimeInUniverse)));
|
||||
|
||||
SetAlpha(new ConstantAlphaModel(InsightType.Price, InsightDirection.Up, TimeSpan.FromDays(1)));
|
||||
SetExecution(new ImmediateExecutionModel());
|
||||
SetPortfolioConstruction(new EqualWeightingPortfolioConstructionModel());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -75,18 +75,18 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Drawdown", "1.200%"},
|
||||
{"Expectancy", "0"},
|
||||
{"Net Profit", "3.464%"},
|
||||
{"Sharpe Ratio", "9.933"},
|
||||
{"Probabilistic Sharpe Ratio", "82.470%"},
|
||||
{"Sharpe Ratio", "19.148"},
|
||||
{"Probabilistic Sharpe Ratio", "97.754%"},
|
||||
{"Loss Rate", "0%"},
|
||||
{"Win Rate", "0%"},
|
||||
{"Profit-Loss Ratio", "0"},
|
||||
{"Alpha", "1.957"},
|
||||
{"Beta", "-0.125"},
|
||||
{"Annual Standard Deviation", "0.164"},
|
||||
{"Annual Variance", "0.027"},
|
||||
{"Information Ratio", "-4.577"},
|
||||
{"Tracking Error", "0.225"},
|
||||
{"Treynor Ratio", "-13.006"},
|
||||
{"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.651"},
|
||||
{"Total Fees", "$3.45"},
|
||||
{"Estimated Strategy Capacity", "$970000000.00"},
|
||||
{"Lowest Capacity Asset", "SPY R735QTJ8XC9X"},
|
||||
|
||||
@@ -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 Language[] Languages { get; } = { Language.CSharp, Language.Python };
|
||||
public virtual Language[] Languages { get; } = { Language.CSharp, Language.Python };
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate what the expected statistics are from running the algorithm
|
||||
|
||||
@@ -134,18 +134,18 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Drawdown", "13.500%"},
|
||||
{"Expectancy", "-0.818"},
|
||||
{"Net Profit", "-13.517%"},
|
||||
{"Sharpe Ratio", "-2.678"},
|
||||
{"Sharpe Ratio", "-98.781"},
|
||||
{"Probabilistic Sharpe Ratio", "0%"},
|
||||
{"Loss Rate", "89%"},
|
||||
{"Win Rate", "11%"},
|
||||
{"Profit-Loss Ratio", "0.69"},
|
||||
{"Alpha", "4.469"},
|
||||
{"Beta", "-0.961"},
|
||||
{"Annual Standard Deviation", "0.373"},
|
||||
{"Annual Variance", "0.139"},
|
||||
{"Information Ratio", "-13.191"},
|
||||
{"Tracking Error", "0.507"},
|
||||
{"Treynor Ratio", "1.04"},
|
||||
{"Alpha", "-1.676"},
|
||||
{"Beta", "0.042"},
|
||||
{"Annual Standard Deviation", "0.01"},
|
||||
{"Annual Variance", "0"},
|
||||
{"Information Ratio", "-73.981"},
|
||||
{"Tracking Error", "0.233"},
|
||||
{"Treynor Ratio", "-23.975"},
|
||||
{"Total Fees", "$15207.00"},
|
||||
{"Estimated Strategy Capacity", "$8000.00"},
|
||||
{"Lowest Capacity Asset", "GC VOFJUCDY9XNH"},
|
||||
|
||||
@@ -142,18 +142,18 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Drawdown", "5.000%"},
|
||||
{"Expectancy", "0"},
|
||||
{"Net Profit", "-3.312%"},
|
||||
{"Sharpe Ratio", "-7.795"},
|
||||
{"Probabilistic Sharpe Ratio", "0.164%"},
|
||||
{"Sharpe Ratio", "-6.305"},
|
||||
{"Probabilistic Sharpe Ratio", "9.342%"},
|
||||
{"Loss Rate", "0%"},
|
||||
{"Win Rate", "0%"},
|
||||
{"Profit-Loss Ratio", "0"},
|
||||
{"Alpha", "-1.362"},
|
||||
{"Beta", "0.257"},
|
||||
{"Annual Standard Deviation", "0.109"},
|
||||
{"Annual Variance", "0.012"},
|
||||
{"Information Ratio", "-14.947"},
|
||||
{"Tracking Error", "0.19"},
|
||||
{"Treynor Ratio", "-3.309"},
|
||||
{"Alpha", "-1.465"},
|
||||
{"Beta", "0.312"},
|
||||
{"Annual Standard Deviation", "0.134"},
|
||||
{"Annual Variance", "0.018"},
|
||||
{"Information Ratio", "-14.77"},
|
||||
{"Tracking Error", "0.192"},
|
||||
{"Treynor Ratio", "-2.718"},
|
||||
{"Total Fees", "$3.70"},
|
||||
{"Estimated Strategy Capacity", "$52000000.00"},
|
||||
{"Lowest Capacity Asset", "GC VL5E74HP3EE5"},
|
||||
|
||||
124
Algorithm.CSharp/BasicTemplateHourlyAlgorithm.cs
Normal file
124
Algorithm.CSharp/BasicTemplateHourlyAlgorithm.cs
Normal file
@@ -0,0 +1,124 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
namespace QuantConnect.Algorithm.CSharp
|
||||
{
|
||||
/// <summary>
|
||||
/// Basic template algorithm simply initializes the date range and cash. This is a skeleton
|
||||
/// framework you can use for designing an algorithm.
|
||||
/// </summary>
|
||||
/// <meta name="tag" content="using data" />
|
||||
/// <meta name="tag" content="using quantconnect" />
|
||||
/// <meta name="tag" content="trading and orders" />
|
||||
public class BasicTemplateHourlyAlgorithm : QCAlgorithm, IRegressionAlgorithmDefinition
|
||||
{
|
||||
private Symbol _spy = QuantConnect.Symbol.Create("SPY", SecurityType.Equity, Market.USA);
|
||||
|
||||
/// <summary>
|
||||
/// Initialise the data and resolution required, as well as the cash and start-end dates for your algorithm. All algorithms must initialized.
|
||||
/// </summary>
|
||||
public override void Initialize()
|
||||
{
|
||||
SetStartDate(2013, 10, 07); //Set Start Date
|
||||
SetEndDate(2013, 10, 11); //Set End Date
|
||||
SetCash(100000); //Set Strategy Cash
|
||||
|
||||
// Find more symbols here: http://quantconnect.com/data
|
||||
// Forex, CFD, Equities Resolutions: Tick, Second, Minute, Hour, Daily.
|
||||
// Futures Resolution: Tick, Second, Minute
|
||||
// Options Resolution: Minute Only.
|
||||
AddEquity("SPY", Resolution.Hour);
|
||||
|
||||
// There are other assets with similar methods. See "Selecting Options" etc for more details.
|
||||
// AddFuture, AddForex, AddCfd, AddOption
|
||||
}
|
||||
|
||||
/// <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)
|
||||
{
|
||||
if (!Portfolio.Invested)
|
||||
{
|
||||
SetHoldings(_spy, 1);
|
||||
Debug("Purchased Stock");
|
||||
}
|
||||
}
|
||||
|
||||
/// <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 Language[] Languages { get; } = { Language.CSharp };
|
||||
|
||||
/// <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 Trades", "1"},
|
||||
{"Average Win", "0%"},
|
||||
{"Average Loss", "0%"},
|
||||
{"Compounding Annual Return", "227.693%"},
|
||||
{"Drawdown", "2.000%"},
|
||||
{"Expectancy", "0"},
|
||||
{"Net Profit", "1.529%"},
|
||||
{"Sharpe Ratio", "8.889"},
|
||||
{"Probabilistic Sharpe Ratio", "67.609%"},
|
||||
{"Loss Rate", "0%"},
|
||||
{"Win Rate", "0%"},
|
||||
{"Profit-Loss Ratio", "0"},
|
||||
{"Alpha", "-0.005"},
|
||||
{"Beta", "0.996"},
|
||||
{"Annual Standard Deviation", "0.222"},
|
||||
{"Annual Variance", "0.049"},
|
||||
{"Information Ratio", "-14.564"},
|
||||
{"Tracking Error", "0.001"},
|
||||
{"Treynor Ratio", "1.978"},
|
||||
{"Total Fees", "$3.44"},
|
||||
{"Estimated Strategy Capacity", "$110000000.00"},
|
||||
{"Lowest Capacity Asset", "SPY R735QTJ8XC9X"},
|
||||
{"Fitness Score", "0.247"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
{"Sortino Ratio", "12.105"},
|
||||
{"Return Over Maximum Drawdown", "112.047"},
|
||||
{"Portfolio Turnover", "0.249"},
|
||||
{"Total Insights Generated", "0"},
|
||||
{"Total Insights Closed", "0"},
|
||||
{"Total Insights Analysis Completed", "0"},
|
||||
{"Long Insight Count", "0"},
|
||||
{"Short Insight Count", "0"},
|
||||
{"Long/Short Ratio", "100%"},
|
||||
{"Estimated Monthly Alpha Value", "$0"},
|
||||
{"Total Accumulated Estimated Alpha Value", "$0"},
|
||||
{"Mean Population Estimated Insight Value", "$0"},
|
||||
{"Mean Population Direction", "0%"},
|
||||
{"Mean Population Magnitude", "0%"},
|
||||
{"Rolling Averaged Population Direction", "0%"},
|
||||
{"Rolling Averaged Population Magnitude", "0%"},
|
||||
{"OrderListHash", "f409be3a7c63d9c1394c2e6c005a15ee"}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -118,18 +118,18 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Drawdown", "10.100%"},
|
||||
{"Expectancy", "-1"},
|
||||
{"Net Profit", "-9.915%"},
|
||||
{"Sharpe Ratio", "-4.217"},
|
||||
{"Probabilistic Sharpe Ratio", "0.052%"},
|
||||
{"Sharpe Ratio", "-4.068"},
|
||||
{"Probabilistic Sharpe Ratio", "0.055%"},
|
||||
{"Loss Rate", "100%"},
|
||||
{"Win Rate", "0%"},
|
||||
{"Profit-Loss Ratio", "0"},
|
||||
{"Alpha", "-0.908"},
|
||||
{"Beta", "0.468"},
|
||||
{"Annual Standard Deviation", "0.139"},
|
||||
{"Annual Variance", "0.019"},
|
||||
{"Information Ratio", "-9.003"},
|
||||
{"Tracking Error", "0.142"},
|
||||
{"Treynor Ratio", "-1.251"},
|
||||
{"Alpha", "-0.745"},
|
||||
{"Beta", "0.432"},
|
||||
{"Annual Standard Deviation", "0.126"},
|
||||
{"Annual Variance", "0.016"},
|
||||
{"Information Ratio", "-7.972"},
|
||||
{"Tracking Error", "0.132"},
|
||||
{"Treynor Ratio", "-1.189"},
|
||||
{"Total Fees", "$0.00"},
|
||||
{"Estimated Strategy Capacity", "$14000000.00"},
|
||||
{"Lowest Capacity Asset", "SPX XL80P3GHDZXQ|SPX 31"},
|
||||
|
||||
@@ -13,16 +13,9 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using QuantConnect.Algorithm.Framework.Alphas;
|
||||
using QuantConnect.Algorithm.Framework.Execution;
|
||||
using QuantConnect.Algorithm.Framework.Portfolio;
|
||||
using QuantConnect.Algorithm.Framework.Risk;
|
||||
using QuantConnect.Algorithm.Framework.Selection;
|
||||
using QuantConnect.Orders;
|
||||
using QuantConnect.Interfaces;
|
||||
using QuantConnect.Data;
|
||||
using QuantConnect.Orders;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace QuantConnect.Algorithm.CSharp
|
||||
{
|
||||
@@ -47,15 +40,14 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
// Find more symbols here: http://quantconnect.com/data
|
||||
// Equities Resolutions: Tick, Second, Minute, Hour, Daily.
|
||||
AddEquity("UNIONBANK", Resolution.Second, Market.India);
|
||||
|
||||
|
||||
//Set Order Prperties as per the requirements for order placement
|
||||
DefaultOrderProperties = new ZerodhaOrderProperties(exchange: "nse");
|
||||
DefaultOrderProperties = new IndiaOrderProperties(exchange: Exchange.NSE);
|
||||
//override default productType value set in config.json if needed - order specific productType value
|
||||
//DefaultOrderProperties = new ZerodhaOrderProperties(exchange: "nse",ZerodhaOrderProperties.KiteProductType.CNC);
|
||||
//DefaultOrderProperties = new IndiaOrderProperties(exchange: Exchange.NSE, IndiaOrderProperties.IndiaProductType.CNC);
|
||||
|
||||
// General Debug statement for acknowledgement
|
||||
Debug("Intialization Done");
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -70,7 +62,6 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public override void OnOrderEvent(OrderEvent orderEvent)
|
||||
{
|
||||
if (orderEvent.Status.IsFill())
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
private readonly Identity _brent = new Identity("Brent");
|
||||
private readonly Identity _wti = new Identity("WTI");
|
||||
|
||||
private CompositeIndicator<IndicatorDataPoint> _spread;
|
||||
private CompositeIndicator _spread;
|
||||
|
||||
private ExponentialMovingAverage _emaWti;
|
||||
|
||||
|
||||
@@ -1,63 +0,0 @@
|
||||
/*
|
||||
* 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.Data.Custom.SEC;
|
||||
using QuantConnect.Securities;
|
||||
|
||||
namespace QuantConnect.Algorithm.CSharp.Benchmarks
|
||||
{
|
||||
public class SECReportBenchmarkAlgorithm : QCAlgorithm
|
||||
{
|
||||
private List<Security> _securities;
|
||||
/// <summary>
|
||||
/// Initialise the data and resolution required, as well as the cash and start-end dates for your algorithm. All algorithms must initialized.
|
||||
/// </summary>
|
||||
public override void Initialize()
|
||||
{
|
||||
SetStartDate(2018, 1, 1);
|
||||
SetEndDate(2019, 1, 1);
|
||||
|
||||
var tickers = new List<string> {"AAPL", "AMZN", "MSFT", "IBM", "FB", "QQQ",
|
||||
"IWM", "BAC", "BNO", "AIG", "UW", "WM" };
|
||||
_securities = new List<Security>();
|
||||
|
||||
foreach (var ticker in tickers)
|
||||
{
|
||||
var equity = AddEquity(ticker);
|
||||
_securities.Add(equity);
|
||||
|
||||
AddData<SECReport8K>(equity.Symbol, Resolution.Daily);
|
||||
AddData<SECReport10K>(equity.Symbol, Resolution.Daily);
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnData(Slice data)
|
||||
{
|
||||
foreach (var security in _securities)
|
||||
{
|
||||
SECReport8K report8K = security.Data.Get<SECReport8K>();
|
||||
SECReport10K report10K = security.Data.Get<SECReport10K>();
|
||||
|
||||
if (!security.HoldStock && report8K != null && report10K != null)
|
||||
{
|
||||
SetHoldings(security.Symbol, 1d / _securities.Count);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,81 +0,0 @@
|
||||
/*
|
||||
* 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.Custom.SmartInsider;
|
||||
using QuantConnect.Securities;
|
||||
|
||||
namespace QuantConnect.Algorithm.CSharp.Benchmarks
|
||||
{
|
||||
public class SmartInsiderEventBenchmarkAlgorithm : QCAlgorithm
|
||||
{
|
||||
private List<Security> _securities;
|
||||
private List<Symbol> _customSymbols;
|
||||
private int _historySymbolCount;
|
||||
|
||||
/// <summary>
|
||||
/// Initialise the data and resolution required, as well as the cash and start-end dates for your algorithm. All algorithms must initialized.
|
||||
/// </summary>
|
||||
public override void Initialize()
|
||||
{
|
||||
SetStartDate(2010, 1, 1);
|
||||
SetEndDate(2019, 1, 1);
|
||||
|
||||
var tickers = new List<string> {"AAPL", "AMZN", "MSFT", "IBM", "FB", "QQQ",
|
||||
"IWM", "BAC", "BNO", "AIG", "UW", "WM" };
|
||||
_securities = new List<Security>();
|
||||
_customSymbols = new List<Symbol>();
|
||||
|
||||
foreach (var ticker in tickers)
|
||||
{
|
||||
var equity = AddEquity(ticker, Resolution.Hour);
|
||||
_securities.Add(equity);
|
||||
|
||||
_customSymbols.Add(
|
||||
AddData<SmartInsiderIntention>(equity.Symbol, Resolution.Daily).Symbol);
|
||||
_customSymbols.Add(
|
||||
AddData<SmartInsiderTransaction>(equity.Symbol, Resolution.Daily).Symbol);
|
||||
}
|
||||
|
||||
Schedule.On(DateRules.EveryDay(), TimeRules.At(16, 0), () =>
|
||||
{
|
||||
foreach (var slice in History(_customSymbols, TimeSpan.FromDays(5)))
|
||||
{
|
||||
_historySymbolCount += slice.Count;
|
||||
}
|
||||
|
||||
foreach (var security in _securities)
|
||||
{
|
||||
SmartInsiderIntention intention = security.Data.Get<SmartInsiderIntention>();
|
||||
SmartInsiderTransaction transaction = security.Data.Get<SmartInsiderTransaction>();
|
||||
|
||||
if (!security.HoldStock && intention != null && transaction != null)
|
||||
{
|
||||
SetHoldings(security.Symbol, 1d / _securities.Count);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public override void OnData(Slice data)
|
||||
{
|
||||
var intentions = data.Get<SmartInsiderIntention>();
|
||||
var transactions = data.Get<SmartInsiderTransaction>();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -37,6 +37,10 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
// Set requested data resolution
|
||||
UniverseSettings.Resolution = Resolution.Minute;
|
||||
|
||||
// Order margin value has to have a minimum of 0.5% of Portfolio value, allows filtering out small trades and reduce fees.
|
||||
// Commented so regression algorithm is more sensitive
|
||||
//Settings.MinimumOrderMarginPortfolioPercentage = 0.005m;
|
||||
|
||||
SetStartDate(2013, 10, 07); //Set Start Date
|
||||
SetEndDate(2013, 10, 11); //Set End Date
|
||||
SetCash(100000); //Set Strategy Cash
|
||||
@@ -74,33 +78,33 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// </summary>
|
||||
public Dictionary<string, string> ExpectedStatistics => new Dictionary<string, string>
|
||||
{
|
||||
{"Total Trades", "17"},
|
||||
{"Total Trades", "20"},
|
||||
{"Average Win", "0%"},
|
||||
{"Average Loss", "-0.17%"},
|
||||
{"Compounding Annual Return", "62.842%"},
|
||||
{"Average Loss", "-0.13%"},
|
||||
{"Compounding Annual Return", "62.435%"},
|
||||
{"Drawdown", "1.100%"},
|
||||
{"Expectancy", "-1"},
|
||||
{"Net Profit", "0.670%"},
|
||||
{"Sharpe Ratio", "3.525"},
|
||||
{"Probabilistic Sharpe Ratio", "59.239%"},
|
||||
{"Net Profit", "0.667%"},
|
||||
{"Sharpe Ratio", "3.993"},
|
||||
{"Probabilistic Sharpe Ratio", "58.777%"},
|
||||
{"Loss Rate", "100%"},
|
||||
{"Win Rate", "0%"},
|
||||
{"Profit-Loss Ratio", "0"},
|
||||
{"Alpha", "-0.382"},
|
||||
{"Beta", "0.565"},
|
||||
{"Annual Standard Deviation", "0.116"},
|
||||
{"Annual Variance", "0.013"},
|
||||
{"Information Ratio", "-10.772"},
|
||||
{"Tracking Error", "0.092"},
|
||||
{"Treynor Ratio", "0.722"},
|
||||
{"Total Fees", "$43.20"},
|
||||
{"Estimated Strategy Capacity", "$3200000.00"},
|
||||
{"Alpha", "-0.598"},
|
||||
{"Beta", "0.569"},
|
||||
{"Annual Standard Deviation", "0.133"},
|
||||
{"Annual Variance", "0.018"},
|
||||
{"Information Ratio", "-13.973"},
|
||||
{"Tracking Error", "0.104"},
|
||||
{"Treynor Ratio", "0.932"},
|
||||
{"Total Fees", "$46.20"},
|
||||
{"Estimated Strategy Capacity", "$2300000.00"},
|
||||
{"Lowest Capacity Asset", "AIG R735QTJ8XC9X"},
|
||||
{"Fitness Score", "0.644"},
|
||||
{"Fitness Score", "0.645"},
|
||||
{"Kelly Criterion Estimate", "13.787"},
|
||||
{"Kelly Criterion Probability Value", "0.231"},
|
||||
{"Sortino Ratio", "79228162514264337593543950335"},
|
||||
{"Return Over Maximum Drawdown", "66.069"},
|
||||
{"Return Over Maximum Drawdown", "65.642"},
|
||||
{"Portfolio Turnover", "0.645"},
|
||||
{"Total Insights Generated", "13"},
|
||||
{"Total Insights Closed", "10"},
|
||||
@@ -115,7 +119,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Mean Population Magnitude", "70%"},
|
||||
{"Rolling Averaged Population Direction", "94.5154%"},
|
||||
{"Rolling Averaged Population Magnitude", "94.5154%"},
|
||||
{"OrderListHash", "3d0949901dfba45209ed339866d4f4f1"}
|
||||
{"OrderListHash", "0945ff7a39bb8f8a07b3dcc817c070aa"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{
|
||||
SetAccountCurrency("EUR");
|
||||
|
||||
SetStartDate(2019, 2, 20);
|
||||
SetStartDate(2019, 2, 19);
|
||||
SetEndDate(2019, 2, 21);
|
||||
SetCash("EUR", 100000);
|
||||
|
||||
@@ -75,34 +75,34 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// </summary>
|
||||
public Dictionary<string, string> ExpectedStatistics => new Dictionary<string, string>
|
||||
{
|
||||
{"Total Trades", "251"},
|
||||
{"Total Trades", "279"},
|
||||
{"Average Win", "0.01%"},
|
||||
{"Average Loss", "-0.01%"},
|
||||
{"Compounding Annual Return", "-37.465%"},
|
||||
{"Compounding Annual Return", "-33.650%"},
|
||||
{"Drawdown", "0.300%"},
|
||||
{"Expectancy", "-0.285"},
|
||||
{"Net Profit", "-0.257%"},
|
||||
{"Sharpe Ratio", "-40.568"},
|
||||
{"Expectancy", "-0.345"},
|
||||
{"Net Profit", "-0.337%"},
|
||||
{"Sharpe Ratio", "-19.772"},
|
||||
{"Probabilistic Sharpe Ratio", "0%"},
|
||||
{"Loss Rate", "66%"},
|
||||
{"Win Rate", "34%"},
|
||||
{"Profit-Loss Ratio", "1.08"},
|
||||
{"Loss Rate", "68%"},
|
||||
{"Win Rate", "32%"},
|
||||
{"Profit-Loss Ratio", "1.07"},
|
||||
{"Alpha", "0"},
|
||||
{"Beta", "0"},
|
||||
{"Annual Standard Deviation", "0.006"},
|
||||
{"Annual Standard Deviation", "0.014"},
|
||||
{"Annual Variance", "0"},
|
||||
{"Information Ratio", "-40.568"},
|
||||
{"Tracking Error", "0.006"},
|
||||
{"Information Ratio", "-19.772"},
|
||||
{"Tracking Error", "0.014"},
|
||||
{"Treynor Ratio", "0"},
|
||||
{"Total Fees", "$0.00"},
|
||||
{"Estimated Strategy Capacity", "$660000.00"},
|
||||
{"Estimated Strategy Capacity", "$670000.00"},
|
||||
{"Lowest Capacity Asset", "DE30EUR 8I"},
|
||||
{"Fitness Score", "0.002"},
|
||||
{"Fitness Score", "0"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
{"Sortino Ratio", "-23.868"},
|
||||
{"Return Over Maximum Drawdown", "-170.818"},
|
||||
{"Portfolio Turnover", "12.673"},
|
||||
{"Sortino Ratio", "-101.587"},
|
||||
{"Return Over Maximum Drawdown", "-110.633"},
|
||||
{"Portfolio Turnover", "9.513"},
|
||||
{"Total Insights Generated", "0"},
|
||||
{"Total Insights Closed", "0"},
|
||||
{"Total Insights Analysis Completed", "0"},
|
||||
@@ -116,7 +116,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Mean Population Magnitude", "0%"},
|
||||
{"Rolling Averaged Population Direction", "0%"},
|
||||
{"Rolling Averaged Population Magnitude", "0%"},
|
||||
{"OrderListHash", "6745cf313aa3ef780d052ca3ba933c6c"}
|
||||
{"OrderListHash", "64c098abe3c1e7206424b0c3825b0069"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <meta name="tag" content="indicators" />
|
||||
/// <meta name="tag" content="using data" />
|
||||
/// <meta name="tag" content="consolidating data" />
|
||||
public class RenkoConsolidatorAlgorithm : QCAlgorithm, IRegressionAlgorithmDefinition
|
||||
public class ClassicRenkoConsolidatorAlgorithm : QCAlgorithm, IRegressionAlgorithmDefinition
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes the algorithm state.
|
||||
@@ -43,7 +43,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
// property of the data it receives.
|
||||
|
||||
// break SPY into $2.5 renko bricks and send that data to our 'OnRenkoBar' method
|
||||
var renkoClose = new RenkoConsolidator(2.5m);
|
||||
var renkoClose = new ClassicRenkoConsolidator(2.5m);
|
||||
renkoClose.DataConsolidated += (sender, consolidated) =>
|
||||
{
|
||||
// call our event handler for renko data
|
||||
@@ -58,7 +58,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
// this allows us to perform the renko logic on values other than Close, even computed values!
|
||||
|
||||
// break SPY into (2*o + h + l + 3*c)/7
|
||||
var renko7bar = new RenkoConsolidator<TradeBar>(2.5m, x => (2 * x.Open + x.High + x.Low + 3 * x.Close) / 7m, x => x.Volume);
|
||||
var renko7bar = new ClassicRenkoConsolidator<TradeBar>(2.5m, x => (2 * x.Open + x.High + x.Low + 3 * x.Close) / 7m, x => x.Volume);
|
||||
renko7bar.DataConsolidated += (sender, consolidated) =>
|
||||
{
|
||||
HandleRenko7Bar(consolidated);
|
||||
@@ -123,18 +123,18 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Drawdown", "6.800%"},
|
||||
{"Expectancy", "0.281"},
|
||||
{"Net Profit", "7.841%"},
|
||||
{"Sharpe Ratio", "0.878"},
|
||||
{"Probabilistic Sharpe Ratio", "43.343%"},
|
||||
{"Sharpe Ratio", "0.799"},
|
||||
{"Probabilistic Sharpe Ratio", "39.344%"},
|
||||
{"Loss Rate", "43%"},
|
||||
{"Win Rate", "57%"},
|
||||
{"Profit-Loss Ratio", "1.24"},
|
||||
{"Alpha", "0.065"},
|
||||
{"Beta", "0.013"},
|
||||
{"Annual Standard Deviation", "0.077"},
|
||||
{"Annual Variance", "0.006"},
|
||||
{"Information Ratio", "-0.513"},
|
||||
{"Tracking Error", "0.139"},
|
||||
{"Treynor Ratio", "5.253"},
|
||||
{"Alpha", "0.009"},
|
||||
{"Beta", "0.411"},
|
||||
{"Annual Standard Deviation", "0.07"},
|
||||
{"Annual Variance", "0.005"},
|
||||
{"Information Ratio", "-0.703"},
|
||||
{"Tracking Error", "0.083"},
|
||||
{"Treynor Ratio", "0.136"},
|
||||
{"Total Fees", "$129.35"},
|
||||
{"Estimated Strategy Capacity", "$1000000000.00"},
|
||||
{"Lowest Capacity Asset", "SPY R735QTJ8XC9X"},
|
||||
@@ -168,18 +168,18 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Drawdown", "1.400%"},
|
||||
{"Expectancy", "0"},
|
||||
{"Net Profit", "1.163%"},
|
||||
{"Sharpe Ratio", "2.876"},
|
||||
{"Probabilistic Sharpe Ratio", "64.984%"},
|
||||
{"Sharpe Ratio", "2.754"},
|
||||
{"Probabilistic Sharpe Ratio", "64.748%"},
|
||||
{"Loss Rate", "0%"},
|
||||
{"Win Rate", "100%"},
|
||||
{"Profit-Loss Ratio", "0"},
|
||||
{"Alpha", "0.237"},
|
||||
{"Beta", "-0.188"},
|
||||
{"Annual Standard Deviation", "0.089"},
|
||||
{"Annual Variance", "0.008"},
|
||||
{"Information Ratio", "2.409"},
|
||||
{"Tracking Error", "0.148"},
|
||||
{"Treynor Ratio", "-1.358"},
|
||||
{"Alpha", "0.277"},
|
||||
{"Beta", "0.436"},
|
||||
{"Annual Standard Deviation", "0.086"},
|
||||
{"Annual Variance", "0.007"},
|
||||
{"Information Ratio", "3.572"},
|
||||
{"Tracking Error", "0.092"},
|
||||
{"Treynor Ratio", "0.54"},
|
||||
{"Total Fees", "$2.00"},
|
||||
{"Estimated Strategy Capacity", "$49000000.00"},
|
||||
{"Lowest Capacity Asset", "IBM R735QTJ8XC9X"},
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
_aapl = QuantConnect.Symbol.Create("AAPL", SecurityType.Equity, Market.USA);
|
||||
UniverseSettings.Resolution = Resolution.Minute;
|
||||
|
||||
SetStartDate(2014, 06, 05);
|
||||
SetStartDate(2014, 06, 04);
|
||||
SetEndDate(2014, 06, 06);
|
||||
|
||||
var selectionUniverse = AddUniverse(enumerable => new[] { Time.Date <= new DateTime(2014, 6, 5) ? _twx : _aapl },
|
||||
@@ -144,34 +144,12 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// </summary>
|
||||
public Dictionary<string, string> ExpectedStatistics => new Dictionary<string, string>
|
||||
{
|
||||
{"Total Trades", "13"},
|
||||
{"Average Win", "0.65%"},
|
||||
{"Average Loss", "-0.05%"},
|
||||
{"Compounding Annual Return", "79228162514264337593543950335%"},
|
||||
{"Drawdown", "0.500%"},
|
||||
{"Expectancy", "1.393"},
|
||||
{"Net Profit", "149.699%"},
|
||||
{"Sharpe Ratio", "4.743312616499238E+27"},
|
||||
{"Probabilistic Sharpe Ratio", "0%"},
|
||||
{"Loss Rate", "83%"},
|
||||
{"Win Rate", "17%"},
|
||||
{"Profit-Loss Ratio", "13.36"},
|
||||
{"Alpha", "7.922816251426434E+28"},
|
||||
{"Beta", "304.581"},
|
||||
{"Annual Standard Deviation", "16.703"},
|
||||
{"Annual Variance", "278.995"},
|
||||
{"Information Ratio", "4.75893717482582E+27"},
|
||||
{"Tracking Error", "16.648"},
|
||||
{"Treynor Ratio", "2.6012216611301735E+26"},
|
||||
{"Total Fees", "$13.20"},
|
||||
{"Estimated Strategy Capacity", "$3000000.00"},
|
||||
{"Lowest Capacity Asset", "AOL VRKS95ENLBYE|AOL R735QTJ8XC9X"},
|
||||
{"Fitness Score", "0.18"},
|
||||
{"Fitness Score", "0.12"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
{"Sortino Ratio", "79228162514264337593543950335"},
|
||||
{"Return Over Maximum Drawdown", "79228162514264337593543950335"},
|
||||
{"Portfolio Turnover", "0.18"},
|
||||
{"Portfolio Turnover", "0.12"},
|
||||
{"Total Insights Generated", "0"},
|
||||
{"Total Insights Closed", "0"},
|
||||
{"Total Insights Analysis Completed", "0"},
|
||||
|
||||
@@ -123,18 +123,18 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Drawdown", "1.700%"},
|
||||
{"Expectancy", "0.850"},
|
||||
{"Net Profit", "0.637%"},
|
||||
{"Sharpe Ratio", "1.131"},
|
||||
{"Probabilistic Sharpe Ratio", "50.538%"},
|
||||
{"Sharpe Ratio", "1.088"},
|
||||
{"Probabilistic Sharpe Ratio", "50.223%"},
|
||||
{"Loss Rate", "40%"},
|
||||
{"Win Rate", "60%"},
|
||||
{"Profit-Loss Ratio", "2.08"},
|
||||
{"Alpha", "0.186"},
|
||||
{"Beta", "0.465"},
|
||||
{"Annual Standard Deviation", "0.123"},
|
||||
{"Annual Variance", "0.015"},
|
||||
{"Information Ratio", "1.908"},
|
||||
{"Tracking Error", "0.126"},
|
||||
{"Treynor Ratio", "0.299"},
|
||||
{"Alpha", "0.198"},
|
||||
{"Beta", "0.741"},
|
||||
{"Annual Standard Deviation", "0.118"},
|
||||
{"Annual Variance", "0.014"},
|
||||
{"Information Ratio", "2.294"},
|
||||
{"Tracking Error", "0.097"},
|
||||
{"Treynor Ratio", "0.173"},
|
||||
{"Total Fees", "$27.94"},
|
||||
{"Estimated Strategy Capacity", "$200000000.00"},
|
||||
{"Lowest Capacity Asset", "AAPL R735QTJ8XC9X"},
|
||||
|
||||
@@ -107,18 +107,18 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Drawdown", "1.000%"},
|
||||
{"Expectancy", "0"},
|
||||
{"Net Profit", "1.003%"},
|
||||
{"Sharpe Ratio", "5.024"},
|
||||
{"Probabilistic Sharpe Ratio", "68.421%"},
|
||||
{"Sharpe Ratio", "5.36"},
|
||||
{"Probabilistic Sharpe Ratio", "69.521%"},
|
||||
{"Loss Rate", "0%"},
|
||||
{"Win Rate", "0%"},
|
||||
{"Profit-Loss Ratio", "0"},
|
||||
{"Alpha", "0.312"},
|
||||
{"Beta", "0.27"},
|
||||
{"Alpha", "0"},
|
||||
{"Beta", "1.003"},
|
||||
{"Annual Standard Deviation", "0.087"},
|
||||
{"Annual Variance", "0.008"},
|
||||
{"Information Ratio", "-0.242"},
|
||||
{"Tracking Error", "0.105"},
|
||||
{"Treynor Ratio", "1.616"},
|
||||
{"Annual Variance", "0.007"},
|
||||
{"Information Ratio", "6.477"},
|
||||
{"Tracking Error", "0"},
|
||||
{"Treynor Ratio", "0.462"},
|
||||
{"Total Fees", "$3.08"},
|
||||
{"Estimated Strategy Capacity", "$720000000.00"},
|
||||
{"Lowest Capacity Asset", "SPY R735QTJ8XC9X"},
|
||||
|
||||
@@ -1,119 +0,0 @@
|
||||
/*
|
||||
* 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.Interfaces;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using QuantConnect.Data;
|
||||
using QuantConnect.Data.Custom.Tiingo;
|
||||
using QuantConnect.Data.UniverseSelection;
|
||||
using QuantConnect.Securities;
|
||||
|
||||
namespace QuantConnect.Algorithm.CSharp
|
||||
{
|
||||
/// <summary>
|
||||
/// Example algorithm of a custom universe selection using coarse data and adding TiingoNews
|
||||
/// If conditions are met will add the underlying and trade it
|
||||
/// </summary>
|
||||
public class CoarseTiingoNewsUniverseSelectionAlgorithm : QCAlgorithm
|
||||
{
|
||||
private const int NumberOfSymbols = 3;
|
||||
private List<Symbol> _symbols;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
SetStartDate(2014, 03, 24);
|
||||
SetEndDate(2014, 04, 07);
|
||||
|
||||
UniverseSettings.FillForward = false;
|
||||
|
||||
AddUniverse(new CustomDataCoarseFundamentalUniverse(UniverseSettings, CoarseSelectionFunction));
|
||||
|
||||
_symbols = new List<Symbol>();
|
||||
}
|
||||
|
||||
// sort the data by daily dollar volume and take the top 'NumberOfSymbols'
|
||||
public IEnumerable<Symbol> CoarseSelectionFunction(IEnumerable<CoarseFundamental> coarse)
|
||||
{
|
||||
// sort descending by daily dollar volume
|
||||
var sortedByDollarVolume = coarse.OrderByDescending(x => x.DollarVolume);
|
||||
|
||||
// take the top entries from our sorted collection
|
||||
var top = sortedByDollarVolume.Take(NumberOfSymbols);
|
||||
|
||||
// we need to return only the symbol objects
|
||||
return top.Select(x => QuantConnect.Symbol.CreateBase(typeof(TiingoNews), x.Symbol, x.Symbol.ID.Market));
|
||||
}
|
||||
|
||||
public override void OnData(Slice data)
|
||||
{
|
||||
var articles = data.Get<TiingoNews>();
|
||||
|
||||
foreach (var kvp in articles)
|
||||
{
|
||||
var news = kvp.Value;
|
||||
if (news.Title.IndexOf("Stocks Drop", 0, StringComparison.CurrentCultureIgnoreCase) != -1)
|
||||
{
|
||||
if (!Securities.ContainsKey(kvp.Key.Underlying))
|
||||
{
|
||||
// add underlying we want to trade
|
||||
AddSecurity(kvp.Key.Underlying);
|
||||
_symbols.Add(kvp.Key.Underlying);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var symbol in _symbols)
|
||||
{
|
||||
if (Securities[symbol].HasData)
|
||||
{
|
||||
SetHoldings(symbol, 1m / _symbols.Count);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnSecuritiesChanged(SecurityChanges changes)
|
||||
{
|
||||
changes.FilterCustomSecurities = false;
|
||||
Log($"{Time} {changes}");
|
||||
}
|
||||
|
||||
private class CustomDataCoarseFundamentalUniverse : CoarseFundamentalUniverse
|
||||
{
|
||||
public CustomDataCoarseFundamentalUniverse(UniverseSettings universeSettings, Func<IEnumerable<CoarseFundamental>, IEnumerable<Symbol>> selector)
|
||||
: base(universeSettings, selector)
|
||||
{ }
|
||||
|
||||
public override IEnumerable<SubscriptionRequest> GetSubscriptionRequests(Security security, DateTime currentTimeUtc, DateTime maximumEndTimeUtc,
|
||||
ISubscriptionDataConfigService subscriptionService)
|
||||
{
|
||||
var config = subscriptionService.Add(
|
||||
typeof(TiingoNews),
|
||||
security.Symbol,
|
||||
UniverseSettings.Resolution,
|
||||
UniverseSettings.FillForward,
|
||||
UniverseSettings.ExtendedMarketHours,
|
||||
dataNormalizationMode: UniverseSettings.DataNormalizationMode);
|
||||
return new[]{new SubscriptionRequest(isUniverseSubscription: false,
|
||||
universe: this,
|
||||
security: security,
|
||||
configuration: config,
|
||||
startTimeUtc: currentTimeUtc,
|
||||
endTimeUtc: maximumEndTimeUtc)};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -37,6 +37,10 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
// Set requested data resolution
|
||||
UniverseSettings.Resolution = Resolution.Minute;
|
||||
|
||||
// Order margin value has to have a minimum of 0.5% of Portfolio value, allows filtering out small trades and reduce fees.
|
||||
// Commented so regression algorithm is more sensitive
|
||||
//Settings.MinimumOrderMarginPortfolioPercentage = 0.005m;
|
||||
|
||||
SetStartDate(2013, 10, 07); //Set Start Date
|
||||
SetEndDate(2013, 10, 11); //Set End Date
|
||||
SetCash(100000); //Set Strategy Cash
|
||||
@@ -74,34 +78,34 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// </summary>
|
||||
public Dictionary<string, string> ExpectedStatistics => new Dictionary<string, string>
|
||||
{
|
||||
{"Total Trades", "5"},
|
||||
{"Average Win", "0.00%"},
|
||||
{"Total Trades", "17"},
|
||||
{"Average Win", "0%"},
|
||||
{"Average Loss", "0.00%"},
|
||||
{"Compounding Annual Return", "38.796%"},
|
||||
{"Compounding Annual Return", "37.229%"},
|
||||
{"Drawdown", "0.600%"},
|
||||
{"Expectancy", "-0.247"},
|
||||
{"Net Profit", "0.420%"},
|
||||
{"Sharpe Ratio", "5.57"},
|
||||
{"Probabilistic Sharpe Ratio", "67.303%"},
|
||||
{"Loss Rate", "50%"},
|
||||
{"Win Rate", "50%"},
|
||||
{"Profit-Loss Ratio", "0.51"},
|
||||
{"Alpha", "-0.185"},
|
||||
{"Beta", "0.249"},
|
||||
{"Expectancy", "-1"},
|
||||
{"Net Profit", "0.405%"},
|
||||
{"Sharpe Ratio", "5.424"},
|
||||
{"Probabilistic Sharpe Ratio", "66.818%"},
|
||||
{"Loss Rate", "100%"},
|
||||
{"Win Rate", "0%"},
|
||||
{"Profit-Loss Ratio", "0"},
|
||||
{"Alpha", "-0.191"},
|
||||
{"Beta", "0.247"},
|
||||
{"Annual Standard Deviation", "0.055"},
|
||||
{"Annual Variance", "0.003"},
|
||||
{"Information Ratio", "-10.015"},
|
||||
{"Tracking Error", "0.167"},
|
||||
{"Treynor Ratio", "1.24"},
|
||||
{"Total Fees", "$5.00"},
|
||||
{"Estimated Strategy Capacity", "$42000000.00"},
|
||||
{"Information Ratio", "-10.052"},
|
||||
{"Tracking Error", "0.168"},
|
||||
{"Treynor Ratio", "1.207"},
|
||||
{"Total Fees", "$17.00"},
|
||||
{"Estimated Strategy Capacity", "$45000000.00"},
|
||||
{"Lowest Capacity Asset", "SPY R735QTJ8XC9X"},
|
||||
{"Fitness Score", "0.063"},
|
||||
{"Fitness Score", "0.067"},
|
||||
{"Kelly Criterion Estimate", "38.796"},
|
||||
{"Kelly Criterion Probability Value", "0.228"},
|
||||
{"Sortino Ratio", "79228162514264337593543950335"},
|
||||
{"Return Over Maximum Drawdown", "71.109"},
|
||||
{"Portfolio Turnover", "0.063"},
|
||||
{"Return Over Maximum Drawdown", "65.855"},
|
||||
{"Portfolio Turnover", "0.067"},
|
||||
{"Total Insights Generated", "100"},
|
||||
{"Total Insights Closed", "99"},
|
||||
{"Total Insights Analysis Completed", "99"},
|
||||
@@ -115,7 +119,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Mean Population Magnitude", "53.5354%"},
|
||||
{"Rolling Averaged Population Direction", "58.2788%"},
|
||||
{"Rolling Averaged Population Magnitude", "58.2788%"},
|
||||
{"OrderListHash", "6ab0483f63f36295e21400be1271ad40"}
|
||||
{"OrderListHash", "8a8c913e5ad4ea956a345c84430649c2"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -147,22 +147,22 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Total Trades", "1"},
|
||||
{"Average Win", "0%"},
|
||||
{"Average Loss", "0%"},
|
||||
{"Compounding Annual Return", "-99.999%"},
|
||||
{"Drawdown", "16.100%"},
|
||||
{"Compounding Annual Return", "0%"},
|
||||
{"Drawdown", "0%"},
|
||||
{"Expectancy", "0"},
|
||||
{"Net Profit", "-6.366%"},
|
||||
{"Sharpe Ratio", "1.194"},
|
||||
{"Net Profit", "0%"},
|
||||
{"Sharpe Ratio", "0"},
|
||||
{"Probabilistic Sharpe Ratio", "0%"},
|
||||
{"Loss Rate", "0%"},
|
||||
{"Win Rate", "0%"},
|
||||
{"Profit-Loss Ratio", "0"},
|
||||
{"Alpha", "5.56"},
|
||||
{"Beta", "-71.105"},
|
||||
{"Annual Standard Deviation", "0.434"},
|
||||
{"Annual Variance", "0.188"},
|
||||
{"Information Ratio", "1.016"},
|
||||
{"Tracking Error", "0.44"},
|
||||
{"Treynor Ratio", "-0.007"},
|
||||
{"Alpha", "0"},
|
||||
{"Beta", "0"},
|
||||
{"Annual Standard Deviation", "0"},
|
||||
{"Annual Variance", "0"},
|
||||
{"Information Ratio", "0"},
|
||||
{"Tracking Error", "0"},
|
||||
{"Treynor Ratio", "0"},
|
||||
{"Total Fees", "$20.35"},
|
||||
{"Estimated Strategy Capacity", "$19000000.00"},
|
||||
{"Lowest Capacity Asset", "ES VMKLFZIH2MTD"},
|
||||
|
||||
@@ -35,7 +35,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
SetCash(100000); // Set Strategy Cash
|
||||
|
||||
// Add QC500 Universe
|
||||
AddUniverse(Universe.Index.QC500);
|
||||
AddUniverse(Universe.QC500);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -177,18 +177,18 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Drawdown", "0.900%"},
|
||||
{"Expectancy", "-1"},
|
||||
{"Net Profit", "-0.540%"},
|
||||
{"Sharpe Ratio", "-3.168"},
|
||||
{"Probabilistic Sharpe Ratio", "23.963%"},
|
||||
{"Sharpe Ratio", "-3.349"},
|
||||
{"Probabilistic Sharpe Ratio", "25.715%"},
|
||||
{"Loss Rate", "100%"},
|
||||
{"Win Rate", "0%"},
|
||||
{"Profit-Loss Ratio", "0"},
|
||||
{"Alpha", "-0.456"},
|
||||
{"Beta", "0.157"},
|
||||
{"Annual Standard Deviation", "0.075"},
|
||||
{"Annual Variance", "0.006"},
|
||||
{"Information Ratio", "-9.176"},
|
||||
{"Tracking Error", "0.178"},
|
||||
{"Treynor Ratio", "-1.514"},
|
||||
{"Alpha", "-0.724"},
|
||||
{"Beta", "0.22"},
|
||||
{"Annual Standard Deviation", "0.086"},
|
||||
{"Annual Variance", "0.007"},
|
||||
{"Information Ratio", "-12.125"},
|
||||
{"Tracking Error", "0.187"},
|
||||
{"Treynor Ratio", "-1.304"},
|
||||
{"Total Fees", "$32.32"},
|
||||
{"Estimated Strategy Capacity", "$95000000.00"},
|
||||
{"Lowest Capacity Asset", "AAPL R735QTJ8XC9X"},
|
||||
|
||||
@@ -133,18 +133,18 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Drawdown", "53.000%"},
|
||||
{"Expectancy", "-0.053"},
|
||||
{"Net Profit", "-29.486%"},
|
||||
{"Sharpe Ratio", "-0.078"},
|
||||
{"Probabilistic Sharpe Ratio", "0.004%"},
|
||||
{"Sharpe Ratio", "-0.072"},
|
||||
{"Probabilistic Sharpe Ratio", "0.001%"},
|
||||
{"Loss Rate", "56%"},
|
||||
{"Win Rate", "44%"},
|
||||
{"Profit-Loss Ratio", "1.15"},
|
||||
{"Alpha", "-0.013"},
|
||||
{"Beta", "0.007"},
|
||||
{"Annual Standard Deviation", "0.163"},
|
||||
{"Annual Variance", "0.027"},
|
||||
{"Information Ratio", "-0.393"},
|
||||
{"Tracking Error", "0.238"},
|
||||
{"Treynor Ratio", "-1.72"},
|
||||
{"Alpha", "-0.004"},
|
||||
{"Beta", "-0.095"},
|
||||
{"Annual Standard Deviation", "0.149"},
|
||||
{"Annual Variance", "0.022"},
|
||||
{"Information Ratio", "-0.34"},
|
||||
{"Tracking Error", "0.23"},
|
||||
{"Treynor Ratio", "0.113"},
|
||||
{"Total Fees", "$796.82"},
|
||||
{"Estimated Strategy Capacity", "$1200000000.00"},
|
||||
{"Lowest Capacity Asset", "SPY R735QTJ8XC9X"},
|
||||
|
||||
@@ -117,7 +117,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Mean Population Magnitude", "0%"},
|
||||
{"Rolling Averaged Population Direction", "0%"},
|
||||
{"Rolling Averaged Population Magnitude", "0%"},
|
||||
{"OrderListHash", "9ce7252112d0ad7be0704297f7d48a88"}
|
||||
{"OrderListHash", "b7b8e83e4456e143c2c4c11fa31a1cf2"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,18 +104,18 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Drawdown", "21.600%"},
|
||||
{"Expectancy", "0"},
|
||||
{"Net Profit", "38.619%"},
|
||||
{"Sharpe Ratio", "33.779"},
|
||||
{"Probabilistic Sharpe Ratio", "77.029%"},
|
||||
{"Sharpe Ratio", "14.33"},
|
||||
{"Probabilistic Sharpe Ratio", "75.756%"},
|
||||
{"Loss Rate", "0%"},
|
||||
{"Win Rate", "0%"},
|
||||
{"Profit-Loss Ratio", "0"},
|
||||
{"Alpha", "32.812"},
|
||||
{"Beta", "8.756"},
|
||||
{"Annual Standard Deviation", "1.11"},
|
||||
{"Annual Variance", "1.231"},
|
||||
{"Information Ratio", "37.501"},
|
||||
{"Tracking Error", "0.985"},
|
||||
{"Treynor Ratio", "4.281"},
|
||||
{"Alpha", "10.389"},
|
||||
{"Beta", "8.754"},
|
||||
{"Annual Standard Deviation", "0.95"},
|
||||
{"Annual Variance", "0.903"},
|
||||
{"Information Ratio", "15.703"},
|
||||
{"Tracking Error", "0.844"},
|
||||
{"Treynor Ratio", "1.555"},
|
||||
{"Total Fees", "$30.00"},
|
||||
{"Estimated Strategy Capacity", "$22000000.00"},
|
||||
{"Lowest Capacity Asset", "SPY R735QTJ8XC9X"},
|
||||
@@ -138,7 +138,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Mean Population Magnitude", "0%"},
|
||||
{"Rolling Averaged Population Direction", "0%"},
|
||||
{"Rolling Averaged Population Magnitude", "0%"},
|
||||
{"OrderListHash", "3df007afa8125770e8f1a49263af90a2"}
|
||||
{"OrderListHash", "eba70a03119f2e8fe526d1092fbc36d0"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -123,13 +123,13 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Loss Rate", "0%"},
|
||||
{"Win Rate", "0%"},
|
||||
{"Profit-Loss Ratio", "0"},
|
||||
{"Alpha", "1.736"},
|
||||
{"Beta", "0.142"},
|
||||
{"Alpha", "1.747"},
|
||||
{"Beta", "0.047"},
|
||||
{"Annual Standard Deviation", "0.84"},
|
||||
{"Annual Variance", "0.706"},
|
||||
{"Information Ratio", "1.925"},
|
||||
{"Tracking Error", "0.846"},
|
||||
{"Treynor Ratio", "12.334"},
|
||||
{"Information Ratio", "1.922"},
|
||||
{"Tracking Error", "0.848"},
|
||||
{"Treynor Ratio", "37.47"},
|
||||
{"Total Fees", "$0.00"},
|
||||
{"Estimated Strategy Capacity", "$0"},
|
||||
{"Lowest Capacity Asset", "BTC.Bitcoin 2S"},
|
||||
|
||||
@@ -93,13 +93,13 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Loss Rate", "0%"},
|
||||
{"Win Rate", "0%"},
|
||||
{"Profit-Loss Ratio", "0"},
|
||||
{"Alpha", "1.736"},
|
||||
{"Beta", "0.142"},
|
||||
{"Alpha", "1.747"},
|
||||
{"Beta", "0.047"},
|
||||
{"Annual Standard Deviation", "0.84"},
|
||||
{"Annual Variance", "0.706"},
|
||||
{"Information Ratio", "1.925"},
|
||||
{"Tracking Error", "0.846"},
|
||||
{"Treynor Ratio", "12.333"},
|
||||
{"Information Ratio", "1.922"},
|
||||
{"Tracking Error", "0.848"},
|
||||
{"Treynor Ratio", "37.473"},
|
||||
{"Total Fees", "$0.00"},
|
||||
{"Estimated Strategy Capacity", "$0"},
|
||||
{"Lowest Capacity Asset", "BTC.Bitcoin 2S"},
|
||||
|
||||
@@ -128,18 +128,18 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Drawdown", "11.000%"},
|
||||
{"Expectancy", "0"},
|
||||
{"Net Profit", "-10.343%"},
|
||||
{"Sharpe Ratio", "-1.554"},
|
||||
{"Probabilistic Sharpe Ratio", "0.001%"},
|
||||
{"Sharpe Ratio", "-1.696"},
|
||||
{"Probabilistic Sharpe Ratio", "0.009%"},
|
||||
{"Loss Rate", "0%"},
|
||||
{"Win Rate", "0%"},
|
||||
{"Profit-Loss Ratio", "0"},
|
||||
{"Alpha", "-0.91"},
|
||||
{"Beta", "-5.602"},
|
||||
{"Annual Standard Deviation", "0.643"},
|
||||
{"Annual Variance", "0.413"},
|
||||
{"Information Ratio", "-1.378"},
|
||||
{"Tracking Error", "0.736"},
|
||||
{"Treynor Ratio", "0.178"},
|
||||
{"Alpha", "-0.924"},
|
||||
{"Beta", "-5.612"},
|
||||
{"Annual Standard Deviation", "0.587"},
|
||||
{"Annual Variance", "0.345"},
|
||||
{"Information Ratio", "-1.517"},
|
||||
{"Tracking Error", "0.664"},
|
||||
{"Treynor Ratio", "0.177"},
|
||||
{"Total Fees", "$0.00"},
|
||||
{"Estimated Strategy Capacity", "$0"},
|
||||
{"Lowest Capacity Asset", "NWSA.CustomDataUsingMapping T3MO1488O0H0"},
|
||||
|
||||
@@ -199,18 +199,18 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Drawdown", "2.400%"},
|
||||
{"Expectancy", "-0.187"},
|
||||
{"Net Profit", "-0.629%"},
|
||||
{"Sharpe Ratio", "-1.475"},
|
||||
{"Probabilistic Sharpe Ratio", "23.597%"},
|
||||
{"Sharpe Ratio", "-1.281"},
|
||||
{"Probabilistic Sharpe Ratio", "21.874%"},
|
||||
{"Loss Rate", "70%"},
|
||||
{"Win Rate", "30%"},
|
||||
{"Profit-Loss Ratio", "1.73"},
|
||||
{"Alpha", "-0.136"},
|
||||
{"Beta", "0.126"},
|
||||
{"Annual Standard Deviation", "0.047"},
|
||||
{"Alpha", "-0.096"},
|
||||
{"Beta", "0.122"},
|
||||
{"Annual Standard Deviation", "0.04"},
|
||||
{"Annual Variance", "0.002"},
|
||||
{"Information Ratio", "-5.094"},
|
||||
{"Tracking Error", "0.118"},
|
||||
{"Treynor Ratio", "-0.547"},
|
||||
{"Information Ratio", "-4.126"},
|
||||
{"Tracking Error", "0.102"},
|
||||
{"Treynor Ratio", "-0.417"},
|
||||
{"Total Fees", "$62.25"},
|
||||
{"Estimated Strategy Capacity", "$52000000.00"},
|
||||
{"Lowest Capacity Asset", "SPY R735QTJ8XC9X"},
|
||||
|
||||
@@ -90,18 +90,18 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Drawdown", "1.200%"},
|
||||
{"Expectancy", "0"},
|
||||
{"Net Profit", "1.694%"},
|
||||
{"Sharpe Ratio", "6.988"},
|
||||
{"Probabilistic Sharpe Ratio", "68.188%"},
|
||||
{"Sharpe Ratio", "8.671"},
|
||||
{"Probabilistic Sharpe Ratio", "67.159%"},
|
||||
{"Loss Rate", "0%"},
|
||||
{"Win Rate", "0%"},
|
||||
{"Profit-Loss Ratio", "0"},
|
||||
{"Alpha", "1.172"},
|
||||
{"Beta", "0.14"},
|
||||
{"Annual Standard Deviation", "0.196"},
|
||||
{"Annual Variance", "0.038"},
|
||||
{"Information Ratio", "-0.118"},
|
||||
{"Tracking Error", "0.256"},
|
||||
{"Treynor Ratio", "9.783"},
|
||||
{"Alpha", "-0.053"},
|
||||
{"Beta", "1.003"},
|
||||
{"Annual Standard Deviation", "0.223"},
|
||||
{"Annual Variance", "0.05"},
|
||||
{"Information Ratio", "-35.82"},
|
||||
{"Tracking Error", "0.001"},
|
||||
{"Treynor Ratio", "1.93"},
|
||||
{"Total Fees", "$3.45"},
|
||||
{"Estimated Strategy Capacity", "$970000000.00"},
|
||||
{"Lowest Capacity Asset", "SPY R735QTJ8XC9X"},
|
||||
|
||||
@@ -189,8 +189,8 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Beta", "0"},
|
||||
{"Annual Standard Deviation", "0"},
|
||||
{"Annual Variance", "0"},
|
||||
{"Information Ratio", "-2.564"},
|
||||
{"Tracking Error", "0.214"},
|
||||
{"Information Ratio", "-2.094"},
|
||||
{"Tracking Error", "0.175"},
|
||||
{"Treynor Ratio", "0"},
|
||||
{"Total Fees", "$0.00"},
|
||||
{"Estimated Strategy Capacity", "$0"},
|
||||
|
||||
@@ -114,8 +114,8 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Beta", "0"},
|
||||
{"Annual Standard Deviation", "0"},
|
||||
{"Annual Variance", "0"},
|
||||
{"Information Ratio", "-0.098"},
|
||||
{"Tracking Error", "0.179"},
|
||||
{"Information Ratio", "-0.101"},
|
||||
{"Tracking Error", "0.185"},
|
||||
{"Treynor Ratio", "0"},
|
||||
{"Total Fees", "$0.00"},
|
||||
{"Estimated Strategy Capacity", "$0"},
|
||||
|
||||
@@ -114,8 +114,8 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Beta", "0"},
|
||||
{"Annual Standard Deviation", "0"},
|
||||
{"Annual Variance", "0"},
|
||||
{"Information Ratio", "-0.111"},
|
||||
{"Tracking Error", "0.207"},
|
||||
{"Information Ratio", "-0.104"},
|
||||
{"Tracking Error", "0.192"},
|
||||
{"Treynor Ratio", "0"},
|
||||
{"Total Fees", "$0.00"},
|
||||
{"Estimated Strategy Capacity", "$0"},
|
||||
|
||||
@@ -100,18 +100,18 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Drawdown", "1.300%"},
|
||||
{"Expectancy", "0"},
|
||||
{"Net Profit", "1.634%"},
|
||||
{"Sharpe Ratio", "2.495"},
|
||||
{"Probabilistic Sharpe Ratio", "92.298%"},
|
||||
{"Sharpe Ratio", "2.351"},
|
||||
{"Probabilistic Sharpe Ratio", "94.365%"},
|
||||
{"Loss Rate", "0%"},
|
||||
{"Win Rate", "100%"},
|
||||
{"Profit-Loss Ratio", "0"},
|
||||
{"Alpha", "0.006"},
|
||||
{"Beta", "0.157"},
|
||||
{"Annual Standard Deviation", "0.033"},
|
||||
{"Beta", "0.158"},
|
||||
{"Annual Standard Deviation", "0.03"},
|
||||
{"Annual Variance", "0.001"},
|
||||
{"Information Ratio", "-4.901"},
|
||||
{"Tracking Error", "0.081"},
|
||||
{"Treynor Ratio", "0.519"},
|
||||
{"Information Ratio", "-4.444"},
|
||||
{"Tracking Error", "0.075"},
|
||||
{"Treynor Ratio", "0.439"},
|
||||
{"Total Fees", "$3.70"},
|
||||
{"Estimated Strategy Capacity", "$170000000.00"},
|
||||
{"Lowest Capacity Asset", "ES VMKLFZIH2MTD"},
|
||||
|
||||
@@ -132,18 +132,18 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Drawdown", "45.600%"},
|
||||
{"Expectancy", "-1"},
|
||||
{"Net Profit", "-26.400%"},
|
||||
{"Sharpe Ratio", "-0.557"},
|
||||
{"Probabilistic Sharpe Ratio", "20.162%"},
|
||||
{"Sharpe Ratio", "-0.602"},
|
||||
{"Probabilistic Sharpe Ratio", "19.127%"},
|
||||
{"Loss Rate", "100%"},
|
||||
{"Win Rate", "0%"},
|
||||
{"Profit-Loss Ratio", "0"},
|
||||
{"Alpha", "-0.564"},
|
||||
{"Beta", "-0.663"},
|
||||
{"Annual Standard Deviation", "1.752"},
|
||||
{"Annual Variance", "3.069"},
|
||||
{"Information Ratio", "-0.906"},
|
||||
{"Tracking Error", "1.763"},
|
||||
{"Treynor Ratio", "1.472"},
|
||||
{"Alpha", "-0.592"},
|
||||
{"Beta", "-0.737"},
|
||||
{"Annual Standard Deviation", "1.582"},
|
||||
{"Annual Variance", "2.502"},
|
||||
{"Information Ratio", "-0.905"},
|
||||
{"Tracking Error", "1.592"},
|
||||
{"Treynor Ratio", "1.292"},
|
||||
{"Total Fees", "$0.00"},
|
||||
{"Estimated Strategy Capacity", "$1000000.00"},
|
||||
{"Lowest Capacity Asset", "SPX 31KC0UJFONTBI|SPX 31"},
|
||||
|
||||
@@ -147,18 +147,18 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Drawdown", "4.300%"},
|
||||
{"Expectancy", "-1"},
|
||||
{"Net Profit", "-4.312%"},
|
||||
{"Sharpe Ratio", "-5.958"},
|
||||
{"Probabilistic Sharpe Ratio", "0.000%"},
|
||||
{"Sharpe Ratio", "-5.637"},
|
||||
{"Probabilistic Sharpe Ratio", "0.005%"},
|
||||
{"Loss Rate", "100%"},
|
||||
{"Win Rate", "0%"},
|
||||
{"Profit-Loss Ratio", "0"},
|
||||
{"Alpha", "-0.685"},
|
||||
{"Beta", "-0.445"},
|
||||
{"Annual Standard Deviation", "0.119"},
|
||||
{"Annual Variance", "0.014"},
|
||||
{"Information Ratio", "-4.887"},
|
||||
{"Tracking Error", "0.155"},
|
||||
{"Treynor Ratio", "1.589"},
|
||||
{"Alpha", "-0.5"},
|
||||
{"Beta", "-0.346"},
|
||||
{"Annual Standard Deviation", "0.092"},
|
||||
{"Annual Variance", "0.008"},
|
||||
{"Information Ratio", "-4.312"},
|
||||
{"Tracking Error", "0.131"},
|
||||
{"Treynor Ratio", "1.493"},
|
||||
{"Total Fees", "$55.05"},
|
||||
{"Estimated Strategy Capacity", "$43000.00"},
|
||||
{"Lowest Capacity Asset", "AAA SEVKGI6HF885"},
|
||||
@@ -181,7 +181,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Mean Population Magnitude", "0%"},
|
||||
{"Rolling Averaged Population Direction", "0%"},
|
||||
{"Rolling Averaged Population Magnitude", "0%"},
|
||||
{"OrderListHash", "61f4d3c109fc4b6b9eb14d2e4eec4843"}
|
||||
{"OrderListHash", "e357cfa77fd5e5b974c68d550fa66490"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,7 +110,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Drawdown", "0.100%"},
|
||||
{"Expectancy", "-0.679"},
|
||||
{"Net Profit", "-0.112%"},
|
||||
{"Sharpe Ratio", "-1.052"},
|
||||
{"Sharpe Ratio", "-0.966"},
|
||||
{"Probabilistic Sharpe Ratio", "0.000%"},
|
||||
{"Loss Rate", "80%"},
|
||||
{"Win Rate", "20%"},
|
||||
@@ -119,9 +119,9 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Beta", "-0.001"},
|
||||
{"Annual Standard Deviation", "0.001"},
|
||||
{"Annual Variance", "0"},
|
||||
{"Information Ratio", "-1.182"},
|
||||
{"Tracking Error", "0.117"},
|
||||
{"Treynor Ratio", "1.617"},
|
||||
{"Information Ratio", "-1.075"},
|
||||
{"Tracking Error", "0.107"},
|
||||
{"Treynor Ratio", "1.354"},
|
||||
{"Total Fees", "$37.00"},
|
||||
{"Estimated Strategy Capacity", "$860000000.00"},
|
||||
{"Lowest Capacity Asset", "DC V5E8P9SH0U0X"},
|
||||
|
||||
@@ -173,18 +173,18 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Drawdown", "12.400%"},
|
||||
{"Expectancy", "0"},
|
||||
{"Net Profit", "153.224%"},
|
||||
{"Sharpe Ratio", "1.233"},
|
||||
{"Probabilistic Sharpe Ratio", "65.906%"},
|
||||
{"Sharpe Ratio", "1.116"},
|
||||
{"Probabilistic Sharpe Ratio", "56.426%"},
|
||||
{"Loss Rate", "0%"},
|
||||
{"Win Rate", "100%"},
|
||||
{"Profit-Loss Ratio", "0"},
|
||||
{"Alpha", "0.146"},
|
||||
{"Beta", "-0.016"},
|
||||
{"Annual Standard Deviation", "0.117"},
|
||||
{"Annual Variance", "0.014"},
|
||||
{"Information Ratio", "-0.052"},
|
||||
{"Tracking Error", "0.204"},
|
||||
{"Treynor Ratio", "-8.847"},
|
||||
{"Alpha", "0.054"},
|
||||
{"Beta", "0.507"},
|
||||
{"Annual Standard Deviation", "0.107"},
|
||||
{"Annual Variance", "0.011"},
|
||||
{"Information Ratio", "-0.082"},
|
||||
{"Tracking Error", "0.105"},
|
||||
{"Treynor Ratio", "0.235"},
|
||||
{"Total Fees", "$49.43"},
|
||||
{"Estimated Strategy Capacity", "$740000000.00"},
|
||||
{"Lowest Capacity Asset", "SPY R735QTJ8XC9X"},
|
||||
|
||||
@@ -45,6 +45,10 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{
|
||||
UniverseSettings.Resolution = Resolution.Daily;
|
||||
|
||||
// Order margin value has to have a minimum of 0.5% of Portfolio value, allows filtering out small trades and reduce fees.
|
||||
// Commented so regression algorithm is more sensitive
|
||||
//Settings.MinimumOrderMarginPortfolioPercentage = 0.005m;
|
||||
|
||||
SetStartDate(2017, 07, 04);
|
||||
SetEndDate(2018, 07, 04);
|
||||
|
||||
@@ -187,31 +191,31 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Total Trades", "6441"},
|
||||
{"Average Win", "0.07%"},
|
||||
{"Average Loss", "-0.07%"},
|
||||
{"Compounding Annual Return", "14.513%"},
|
||||
{"Drawdown", "10.600%"},
|
||||
{"Expectancy", "0.066"},
|
||||
{"Net Profit", "14.513%"},
|
||||
{"Sharpe Ratio", "1.047"},
|
||||
{"Probabilistic Sharpe Ratio", "49.415%"},
|
||||
{"Compounding Annual Return", "14.802%"},
|
||||
{"Drawdown", "10.400%"},
|
||||
{"Expectancy", "0.068"},
|
||||
{"Net Profit", "14.802%"},
|
||||
{"Sharpe Ratio", "0.978"},
|
||||
{"Probabilistic Sharpe Ratio", "46.740%"},
|
||||
{"Loss Rate", "46%"},
|
||||
{"Win Rate", "54%"},
|
||||
{"Profit-Loss Ratio", "0.97"},
|
||||
{"Alpha", "0.135"},
|
||||
{"Beta", "-0.069"},
|
||||
{"Annual Standard Deviation", "0.121"},
|
||||
{"Annual Variance", "0.015"},
|
||||
{"Information Ratio", "0.033"},
|
||||
{"Tracking Error", "0.17"},
|
||||
{"Treynor Ratio", "-1.832"},
|
||||
{"Total Fees", "$7494.82"},
|
||||
{"Alpha", "0.008"},
|
||||
{"Beta", "0.98"},
|
||||
{"Annual Standard Deviation", "0.109"},
|
||||
{"Annual Variance", "0.012"},
|
||||
{"Information Ratio", "0.158"},
|
||||
{"Tracking Error", "0.041"},
|
||||
{"Treynor Ratio", "0.109"},
|
||||
{"Total Fees", "$7495.19"},
|
||||
{"Estimated Strategy Capacity", "$320000.00"},
|
||||
{"Lowest Capacity Asset", "BNO UN3IMQ2JU1YD"},
|
||||
{"Fitness Score", "0.689"},
|
||||
{"Fitness Score", "0.695"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
{"Sortino Ratio", "1.226"},
|
||||
{"Return Over Maximum Drawdown", "1.367"},
|
||||
{"Portfolio Turnover", "1.627"},
|
||||
{"Sortino Ratio", "1.269"},
|
||||
{"Return Over Maximum Drawdown", "1.424"},
|
||||
{"Portfolio Turnover", "1.613"},
|
||||
{"Total Insights Generated", "0"},
|
||||
{"Total Insights Closed", "0"},
|
||||
{"Total Insights Analysis Completed", "0"},
|
||||
@@ -225,7 +229,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Mean Population Magnitude", "0%"},
|
||||
{"Rolling Averaged Population Direction", "0%"},
|
||||
{"Rolling Averaged Population Magnitude", "0%"},
|
||||
{"OrderListHash", "6cf9ae04274be760ff10b47c718e9797"}
|
||||
{"OrderListHash", "df66ec72bb4332b14bbe31ec9bea7ffc"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,6 +49,10 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
// this sets the resolution for data subscriptions added by our universe
|
||||
UniverseSettings.Resolution = Resolution.Daily;
|
||||
|
||||
// Order margin value has to have a minimum of 0.5% of Portfolio value, allows filtering out small trades and reduce fees.
|
||||
// Commented so regression algorithm is more sensitive
|
||||
//Settings.MinimumOrderMarginPortfolioPercentage = 0.005m;
|
||||
|
||||
// set our start and end for backtest mode
|
||||
SetStartDate(2017, 07, 04);
|
||||
SetEndDate(2018, 07, 04);
|
||||
@@ -160,31 +164,31 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Total Trades", "5059"},
|
||||
{"Average Win", "0.08%"},
|
||||
{"Average Loss", "-0.08%"},
|
||||
{"Compounding Annual Return", "16.166%"},
|
||||
{"Drawdown", "10.500%"},
|
||||
{"Expectancy", "0.080"},
|
||||
{"Net Profit", "16.166%"},
|
||||
{"Sharpe Ratio", "1.157"},
|
||||
{"Probabilistic Sharpe Ratio", "53.509%"},
|
||||
{"Compounding Annual Return", "16.153%"},
|
||||
{"Drawdown", "10.300%"},
|
||||
{"Expectancy", "0.081"},
|
||||
{"Net Profit", "16.153%"},
|
||||
{"Sharpe Ratio", "1.062"},
|
||||
{"Probabilistic Sharpe Ratio", "50.224%"},
|
||||
{"Loss Rate", "45%"},
|
||||
{"Win Rate", "55%"},
|
||||
{"Profit-Loss Ratio", "0.96"},
|
||||
{"Alpha", "0.148"},
|
||||
{"Beta", "-0.068"},
|
||||
{"Annual Standard Deviation", "0.121"},
|
||||
{"Annual Variance", "0.015"},
|
||||
{"Information Ratio", "0.112"},
|
||||
{"Tracking Error", "0.17"},
|
||||
{"Treynor Ratio", "-2.041"},
|
||||
{"Total Fees", "$5872.38"},
|
||||
{"Profit-Loss Ratio", "0.97"},
|
||||
{"Alpha", "0.018"},
|
||||
{"Beta", "0.979"},
|
||||
{"Annual Standard Deviation", "0.109"},
|
||||
{"Annual Variance", "0.012"},
|
||||
{"Information Ratio", "0.38"},
|
||||
{"Tracking Error", "0.041"},
|
||||
{"Treynor Ratio", "0.118"},
|
||||
{"Total Fees", "$5869.25"},
|
||||
{"Estimated Strategy Capacity", "$320000.00"},
|
||||
{"Lowest Capacity Asset", "BNO UN3IMQ2JU1YD"},
|
||||
{"Fitness Score", "0.709"},
|
||||
{"Fitness Score", "0.711"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
{"Sortino Ratio", "1.374"},
|
||||
{"Return Over Maximum Drawdown", "1.543"},
|
||||
{"Portfolio Turnover", "1.291"},
|
||||
{"Sortino Ratio", "1.389"},
|
||||
{"Return Over Maximum Drawdown", "1.564"},
|
||||
{"Portfolio Turnover", "1.271"},
|
||||
{"Total Insights Generated", "0"},
|
||||
{"Total Insights Closed", "0"},
|
||||
{"Total Insights Analysis Completed", "0"},
|
||||
@@ -198,7 +202,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Mean Population Magnitude", "0%"},
|
||||
{"Rolling Averaged Population Direction", "0%"},
|
||||
{"Rolling Averaged Population Magnitude", "0%"},
|
||||
{"OrderListHash", "de8d678cd9f488183e4f5bbd584f47e6"}
|
||||
{"OrderListHash", "5f08ae4997156d48171559e452dda9d3"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,8 +106,8 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Beta", "0"},
|
||||
{"Annual Standard Deviation", "0"},
|
||||
{"Annual Variance", "0"},
|
||||
{"Information Ratio", "-7.163"},
|
||||
{"Tracking Error", "0.195"},
|
||||
{"Information Ratio", "-8.91"},
|
||||
{"Tracking Error", "0.223"},
|
||||
{"Treynor Ratio", "0"},
|
||||
{"Total Fees", "$0.00"},
|
||||
{"Estimated Strategy Capacity", "$0"},
|
||||
|
||||
@@ -1,71 +0,0 @@
|
||||
/*
|
||||
* 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.Data.Custom.SEC;
|
||||
using QuantConnect.Securities;
|
||||
|
||||
namespace QuantConnect.Algorithm.CSharp
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides an example algorithm showcasing the <see cref="Security.Data"/> features
|
||||
/// </summary>
|
||||
public class DynamicSecurityDataAlgorithm : QCAlgorithm
|
||||
{
|
||||
private Security GOOGL;
|
||||
private const string Ticker = "GOOGL";
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
SetStartDate(2015, 10, 22);
|
||||
SetEndDate(2015, 10, 30);
|
||||
|
||||
GOOGL = AddEquity(Ticker, Resolution.Daily);
|
||||
|
||||
AddData<SECReport8K>(Ticker, Resolution.Daily);
|
||||
AddData<SECReport10K>(Ticker, Resolution.Daily);
|
||||
AddData<SECReport10Q>(Ticker, Resolution.Daily);
|
||||
}
|
||||
|
||||
public override void OnData(Slice slice)
|
||||
{
|
||||
// The Security object's Data property provides convenient access
|
||||
// to the various types of data related to that security. You can
|
||||
// access not only the security's price data, but also any custom
|
||||
// data that is mapped to the security, such as our SEC reports.
|
||||
|
||||
// 1. Get the most recent data point of a particular type:
|
||||
// 1.a Using the C# generic method, Get<T>:
|
||||
SECReport8K googlSec8kReport = GOOGL.Data.Get<SECReport8K>();
|
||||
SECReport10K googlSec10kReport = GOOGL.Data.Get<SECReport10K>();
|
||||
Log($"{Time:o}: 8K: {googlSec8kReport}");
|
||||
Log($"{Time:o}: 10K: {googlSec10kReport}");
|
||||
|
||||
// 2. Get the list of data points of a particular type for the most recent time step:
|
||||
// 2.a Using the C# generic method, GetAll<T>:
|
||||
List<SECReport8K> googlSec8kReports = GOOGL.Data.GetAll<SECReport8K>();
|
||||
List<SECReport10K> googlSec10kReports = GOOGL.Data.GetAll<SECReport10K>();
|
||||
Log($"{Time:o}: List: 8K: {googlSec8kReports.Count}");
|
||||
Log($"{Time:o}: List: 10K: {googlSec10kReports.Count}");
|
||||
|
||||
if (!Portfolio.Invested)
|
||||
{
|
||||
Buy(GOOGL.Symbol, 10);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
147
Algorithm.CSharp/DynamicSecurityDataRegressionAlgorithm.cs
Normal file
147
Algorithm.CSharp/DynamicSecurityDataRegressionAlgorithm.cs
Normal file
@@ -0,0 +1,147 @@
|
||||
/*
|
||||
* 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.IO;
|
||||
using QuantConnect.Data;
|
||||
using QuantConnect.Data.Custom.IconicTypes;
|
||||
using QuantConnect.Data.Market;
|
||||
using QuantConnect.Interfaces;
|
||||
using QuantConnect.Securities;
|
||||
|
||||
namespace QuantConnect.Algorithm.CSharp
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides an example algorithm showcasing the <see cref="Security.Data"/> features
|
||||
/// </summary>
|
||||
public class DynamicSecurityDataRegressionAlgorithm : QCAlgorithm, IRegressionAlgorithmDefinition
|
||||
{
|
||||
private Security Equity;
|
||||
private const string Ticker = "GOOGL";
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
SetStartDate(2015, 10, 22);
|
||||
SetEndDate(2015, 10, 30);
|
||||
|
||||
Equity = AddEquity(Ticker, Resolution.Daily);
|
||||
var customLinkedEquity = AddData<LinkedData>(Ticker, Resolution.Daily).Symbol;
|
||||
|
||||
// Adding linked data manually to cache for example purposes, since
|
||||
// LinkedData is a type used for testing and doesn't point to any real data.
|
||||
Equity.Cache.AddDataList(new List<LinkedData>
|
||||
{
|
||||
new LinkedData
|
||||
{
|
||||
Count = 100,
|
||||
|
||||
Symbol = customLinkedEquity,
|
||||
EndTime = StartDate,
|
||||
},
|
||||
new LinkedData
|
||||
{
|
||||
Count = 50,
|
||||
|
||||
Symbol = customLinkedEquity,
|
||||
EndTime = StartDate
|
||||
}
|
||||
}, typeof(LinkedData), false);
|
||||
}
|
||||
|
||||
public override void OnData(Slice slice)
|
||||
{
|
||||
// The Security object's Data property provides convenient access
|
||||
// to the various types of data related to that security. You can
|
||||
// access not only the security's price data, but also any custom
|
||||
// data that is mapped to the security, such as our SEC reports.
|
||||
|
||||
// 1. Get the most recent data point of a particular type:
|
||||
// 1.a Using the C# generic method, Get<T>:
|
||||
LinkedData customLinkedData = Equity.Data.Get<LinkedData>();
|
||||
Log($"{Time:o}: LinkedData: {customLinkedData}");
|
||||
|
||||
// 2. Get the list of data points of a particular type for the most recent time step:
|
||||
// 2.a Using the C# generic method, GetAll<T>:
|
||||
List<LinkedData> customLinkedDataList = Equity.Data.GetAll<LinkedData>();
|
||||
Log($"{Time:o}: List: LinkedData: {customLinkedDataList.Count}");
|
||||
|
||||
if (!Portfolio.Invested)
|
||||
{
|
||||
Buy(Equity.Symbol, 10);
|
||||
}
|
||||
}
|
||||
|
||||
/// <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 Language[] Languages { get; } = { Language.CSharp, Language.Python };
|
||||
|
||||
/// <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 Trades", "1"},
|
||||
{"Average Win", "0%"},
|
||||
{"Average Loss", "0%"},
|
||||
{"Compounding Annual Return", "28.411%"},
|
||||
{"Drawdown", "0.100%"},
|
||||
{"Expectancy", "0"},
|
||||
{"Net Profit", "0.618%"},
|
||||
{"Sharpe Ratio", "8.815"},
|
||||
{"Probabilistic Sharpe Ratio", "99.065%"},
|
||||
{"Loss Rate", "0%"},
|
||||
{"Win Rate", "0%"},
|
||||
{"Profit-Loss Ratio", "0"},
|
||||
{"Alpha", "0.12"},
|
||||
{"Beta", "0.143"},
|
||||
{"Annual Standard Deviation", "0.022"},
|
||||
{"Annual Variance", "0"},
|
||||
{"Information Ratio", "-3.746"},
|
||||
{"Tracking Error", "0.084"},
|
||||
{"Treynor Ratio", "1.349"},
|
||||
{"Total Fees", "$1.00"},
|
||||
{"Estimated Strategy Capacity", "$1000000000.00"},
|
||||
{"Lowest Capacity Asset", "GOOG T1AZ164W5VTX"},
|
||||
{"Fitness Score", "0.008"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
{"Sortino Ratio", "79228162514264337593543950335"},
|
||||
{"Return Over Maximum Drawdown", "383.48"},
|
||||
{"Portfolio Turnover", "0.008"},
|
||||
{"Total Insights Generated", "0"},
|
||||
{"Total Insights Closed", "0"},
|
||||
{"Total Insights Analysis Completed", "0"},
|
||||
{"Long Insight Count", "0"},
|
||||
{"Short Insight Count", "0"},
|
||||
{"Long/Short Ratio", "100%"},
|
||||
{"Estimated Monthly Alpha Value", "$0"},
|
||||
{"Total Accumulated Estimated Alpha Value", "$0"},
|
||||
{"Mean Population Estimated Insight Value", "$0"},
|
||||
{"Mean Population Direction", "0%"},
|
||||
{"Mean Population Magnitude", "0%"},
|
||||
{"Rolling Averaged Population Direction", "0%"},
|
||||
{"Rolling Averaged Population Magnitude", "0%"},
|
||||
{"OrderListHash", "668caaf6ff8f35e16f05228541e99720"}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -51,6 +51,10 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
// set algorithm framework models except ALPHA
|
||||
SetUniverseSelection(new ManualUniverseSelectionModel(_symbol));
|
||||
SetPortfolioConstruction(new EqualWeightingPortfolioConstructionModel());
|
||||
|
||||
// Order margin value has to have a minimum of 0.5% of Portfolio value, allows filtering out small trades and reduce fees.
|
||||
// Commented so regression algorithm is more sensitive
|
||||
//Settings.MinimumOrderMarginPortfolioPercentage = 0.005m;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -111,33 +115,33 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// </summary>
|
||||
public Dictionary<string, string> ExpectedStatistics => new Dictionary<string, string>
|
||||
{
|
||||
{"Total Trades", "5"},
|
||||
{"Total Trades", "6"},
|
||||
{"Average Win", "0%"},
|
||||
{"Average Loss", "-0.02%"},
|
||||
{"Compounding Annual Return", "-72.241%"},
|
||||
{"Compounding Annual Return", "-72.233%"},
|
||||
{"Drawdown", "2.900%"},
|
||||
{"Expectancy", "-1"},
|
||||
{"Net Profit", "-1.740%"},
|
||||
{"Sharpe Ratio", "-2.982"},
|
||||
{"Probabilistic Sharpe Ratio", "22.311%"},
|
||||
{"Sharpe Ratio", "-2.985"},
|
||||
{"Probabilistic Sharpe Ratio", "24.619%"},
|
||||
{"Loss Rate", "100%"},
|
||||
{"Win Rate", "0%"},
|
||||
{"Profit-Loss Ratio", "0"},
|
||||
{"Alpha", "-0.387"},
|
||||
{"Beta", "-0.138"},
|
||||
{"Annual Standard Deviation", "0.195"},
|
||||
{"Annual Variance", "0.038"},
|
||||
{"Information Ratio", "-6.726"},
|
||||
{"Tracking Error", "0.294"},
|
||||
{"Treynor Ratio", "4.2"},
|
||||
{"Total Fees", "$19.23"},
|
||||
{"Estimated Strategy Capacity", "$540000000.00"},
|
||||
{"Alpha", "1.316"},
|
||||
{"Beta", "-0.998"},
|
||||
{"Annual Standard Deviation", "0.222"},
|
||||
{"Annual Variance", "0.049"},
|
||||
{"Information Ratio", "-5.951"},
|
||||
{"Tracking Error", "0.445"},
|
||||
{"Treynor Ratio", "0.664"},
|
||||
{"Total Fees", "$20.23"},
|
||||
{"Estimated Strategy Capacity", "$520000000.00"},
|
||||
{"Lowest Capacity Asset", "SPY R735QTJ8XC9X"},
|
||||
{"Fitness Score", "0.054"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
{"Sortino Ratio", "-4.058"},
|
||||
{"Return Over Maximum Drawdown", "-25.227"},
|
||||
{"Sortino Ratio", "-4.059"},
|
||||
{"Return Over Maximum Drawdown", "-25.228"},
|
||||
{"Portfolio Turnover", "1"},
|
||||
{"Total Insights Generated", "1"},
|
||||
{"Total Insights Closed", "0"},
|
||||
@@ -152,7 +156,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Mean Population Magnitude", "0%"},
|
||||
{"Rolling Averaged Population Direction", "0%"},
|
||||
{"Rolling Averaged Population Magnitude", "0%"},
|
||||
{"OrderListHash", "c548ae1a6ae4d75e832ed401881ddb21"}
|
||||
{"OrderListHash", "4c45e3bf74e05e81b872d293cb65391a"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -114,18 +114,18 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Drawdown", "1.200%"},
|
||||
{"Expectancy", "-0.021"},
|
||||
{"Net Profit", "-0.873%"},
|
||||
{"Sharpe Ratio", "-2.308"},
|
||||
{"Probabilistic Sharpe Ratio", "31.792%"},
|
||||
{"Sharpe Ratio", "-2.39"},
|
||||
{"Probabilistic Sharpe Ratio", "33.387%"},
|
||||
{"Loss Rate", "50%"},
|
||||
{"Win Rate", "50%"},
|
||||
{"Profit-Loss Ratio", "0.96"},
|
||||
{"Alpha", "-0.675"},
|
||||
{"Beta", "0.232"},
|
||||
{"Annual Standard Deviation", "0.152"},
|
||||
{"Annual Variance", "0.023"},
|
||||
{"Information Ratio", "-8.38"},
|
||||
{"Tracking Error", "0.209"},
|
||||
{"Treynor Ratio", "-1.514"},
|
||||
{"Alpha", "-1.646"},
|
||||
{"Beta", "0.62"},
|
||||
{"Annual Standard Deviation", "0.175"},
|
||||
{"Annual Variance", "0.031"},
|
||||
{"Information Ratio", "-17.555"},
|
||||
{"Tracking Error", "0.137"},
|
||||
{"Treynor Ratio", "-0.674"},
|
||||
{"Total Fees", "$17.19"},
|
||||
{"Estimated Strategy Capacity", "$640000000.00"},
|
||||
{"Lowest Capacity Asset", "SPY R735QTJ8XC9X"},
|
||||
|
||||
@@ -41,6 +41,10 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
SetAlpha(new ConstantFutureContractAlphaModel(InsightType.Price, InsightDirection.Up, TimeSpan.FromDays(1)));
|
||||
SetPortfolioConstruction(new EqualWeightingPortfolioConstructionModel());
|
||||
SetExecution(new ImmediateExecutionModel());
|
||||
|
||||
// Order margin value has to have a minimum of 0.5% of Portfolio value, allows filtering out small trades and reduce fees.
|
||||
// Commented so regression algorithm is more sensitive
|
||||
//Settings.MinimumOrderMarginPortfolioPercentage = 0.005m;
|
||||
}
|
||||
|
||||
// future symbol universe selection function
|
||||
@@ -128,34 +132,34 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// </summary>
|
||||
public Dictionary<string, string> ExpectedStatistics => new Dictionary<string, string>
|
||||
{
|
||||
{"Total Trades", "5"},
|
||||
{"Total Trades", "7"},
|
||||
{"Average Win", "0%"},
|
||||
{"Average Loss", "-1.82%"},
|
||||
{"Compounding Annual Return", "-99.936%"},
|
||||
{"Average Loss", "-1.40%"},
|
||||
{"Compounding Annual Return", "-99.829%"},
|
||||
{"Drawdown", "29.500%"},
|
||||
{"Expectancy", "-1"},
|
||||
{"Net Profit", "-9.054%"},
|
||||
{"Sharpe Ratio", "-0.666"},
|
||||
{"Probabilistic Sharpe Ratio", "30.662%"},
|
||||
{"Net Profit", "-7.888%"},
|
||||
{"Sharpe Ratio", "-0.593"},
|
||||
{"Probabilistic Sharpe Ratio", "34.346%"},
|
||||
{"Loss Rate", "100%"},
|
||||
{"Win Rate", "0%"},
|
||||
{"Profit-Loss Ratio", "0"},
|
||||
{"Alpha", "-12.77"},
|
||||
{"Beta", "5.937"},
|
||||
{"Annual Standard Deviation", "1.497"},
|
||||
{"Annual Variance", "2.242"},
|
||||
{"Information Ratio", "-2.283"},
|
||||
{"Tracking Error", "1.305"},
|
||||
{"Treynor Ratio", "-0.168"},
|
||||
{"Total Fees", "$37.00"},
|
||||
{"Estimated Strategy Capacity", "$16000000.00"},
|
||||
{"Alpha", "-15.391"},
|
||||
{"Beta", "7.259"},
|
||||
{"Annual Standard Deviation", "1.679"},
|
||||
{"Annual Variance", "2.818"},
|
||||
{"Information Ratio", "-2.032"},
|
||||
{"Tracking Error", "1.466"},
|
||||
{"Treynor Ratio", "-0.137"},
|
||||
{"Total Fees", "$40.70"},
|
||||
{"Estimated Strategy Capacity", "$4000000.00"},
|
||||
{"Lowest Capacity Asset", "GC VL5E74HP3EE5"},
|
||||
{"Fitness Score", "0.072"},
|
||||
{"Kelly Criterion Estimate", "-9.366"},
|
||||
{"Kelly Criterion Probability Value", "0.607"},
|
||||
{"Sortino Ratio", "-5.173"},
|
||||
{"Sortino Ratio", "-5.172"},
|
||||
{"Return Over Maximum Drawdown", "-5.25"},
|
||||
{"Portfolio Turnover", "4.629"},
|
||||
{"Portfolio Turnover", "4.987"},
|
||||
{"Total Insights Generated", "10"},
|
||||
{"Total Insights Closed", "8"},
|
||||
{"Total Insights Analysis Completed", "8"},
|
||||
@@ -169,7 +173,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Mean Population Magnitude", "0%"},
|
||||
{"Rolling Averaged Population Direction", "25.058%"},
|
||||
{"Rolling Averaged Population Magnitude", "0%"},
|
||||
{"OrderListHash", "0f9f87f5c080b5ec0e48dac003a7e875"}
|
||||
{"OrderListHash", "874fc945335aa8d93f2e3734641f9890"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -171,18 +171,18 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Drawdown", "3.300%"},
|
||||
{"Expectancy", "-0.225"},
|
||||
{"Net Profit", "-2.705%"},
|
||||
{"Sharpe Ratio", "-4.958"},
|
||||
{"Probabilistic Sharpe Ratio", "1.087%"},
|
||||
{"Sharpe Ratio", "-5.022"},
|
||||
{"Probabilistic Sharpe Ratio", "1.586%"},
|
||||
{"Loss Rate", "65%"},
|
||||
{"Win Rate", "35%"},
|
||||
{"Profit-Loss Ratio", "1.20"},
|
||||
{"Alpha", "-1.401"},
|
||||
{"Beta", "0.525"},
|
||||
{"Annual Standard Deviation", "0.135"},
|
||||
{"Annual Variance", "0.018"},
|
||||
{"Information Ratio", "-16.23"},
|
||||
{"Tracking Error", "0.127"},
|
||||
{"Treynor Ratio", "-1.27"},
|
||||
{"Alpha", "-1.879"},
|
||||
{"Beta", "0.571"},
|
||||
{"Annual Standard Deviation", "0.149"},
|
||||
{"Annual Variance", "0.022"},
|
||||
{"Information Ratio", "-22.181"},
|
||||
{"Tracking Error", "0.123"},
|
||||
{"Treynor Ratio", "-1.31"},
|
||||
{"Total Fees", "$670.68"},
|
||||
{"Estimated Strategy Capacity", "$190000.00"},
|
||||
{"Lowest Capacity Asset", "IBM R735QTJ8XC9X"},
|
||||
|
||||
@@ -1,72 +0,0 @@
|
||||
/*
|
||||
* 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 QuantConnect.Data;
|
||||
using QuantConnect.Data.Custom.Estimize;
|
||||
|
||||
namespace QuantConnect.Algorithm.CSharp
|
||||
{
|
||||
/// <summary>
|
||||
/// This example algorithm shows how to import and use Estimize data types.
|
||||
/// </summary>
|
||||
/// <meta name="tag" content="using data" />
|
||||
/// <meta name="tag" content="custom data" />
|
||||
/// <meta name="tag" content="estimize" />
|
||||
public class EstimizeDataAlgorithm : QCAlgorithm
|
||||
{
|
||||
/// <summary>
|
||||
/// Initialise the data and resolution required, as well as the cash and start-end dates for your algorithm. All algorithms must initialized.
|
||||
/// </summary>
|
||||
public override void Initialize()
|
||||
{
|
||||
SetStartDate(2017, 1, 1);
|
||||
SetEndDate(2017, 12, 31);
|
||||
|
||||
// be sure to add the underlying data source for our estimize data as it requires the mappings
|
||||
AddEquity("AAPL");
|
||||
|
||||
AddData<EstimizeRelease>("AAPL");
|
||||
AddData<EstimizeEstimate>("AAPL");
|
||||
AddData<EstimizeConsensus>("AAPL");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// OnData event is the primary entry point for your algorithm. Each new data point will be pumped in here.
|
||||
/// </summary>
|
||||
/// <param name="data">EstimizeRelease object containing the stock release data</param>
|
||||
public void OnData(EstimizeRelease data)
|
||||
{
|
||||
Log($"{Time} - {data}");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// OnData event is the primary entry point for your algorithm. Each new data point will be pumped in here.
|
||||
/// </summary>
|
||||
/// <param name="data">EstimizeEstimate object containing the stock release data</param>
|
||||
public void OnData(EstimizeEstimate data)
|
||||
{
|
||||
Log($"{Time} - {data}");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// OnData event is the primary entry point for your algorithm. Each new data point will be pumped in here.
|
||||
/// </summary>
|
||||
/// <param name="data">EstimizeConsensus object containing the stock release data</param>
|
||||
public void OnData(EstimizeConsensus data)
|
||||
{
|
||||
Log($"{Time} - {data}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -127,33 +127,33 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// </summary>
|
||||
public Dictionary<string, string> ExpectedStatistics => new Dictionary<string, string>
|
||||
{
|
||||
{"Total Trades", "18"},
|
||||
{"Total Trades", "19"},
|
||||
{"Average Win", "0%"},
|
||||
{"Average Loss", "0.00%"},
|
||||
{"Compounding Annual Return", "-74.117%"},
|
||||
{"Compounding Annual Return", "-73.997%"},
|
||||
{"Drawdown", "2.500%"},
|
||||
{"Expectancy", "-1"},
|
||||
{"Net Profit", "-1.044%"},
|
||||
{"Sharpe Ratio", "-8.269"},
|
||||
{"Net Profit", "-1.040%"},
|
||||
{"Sharpe Ratio", "-9.302"},
|
||||
{"Probabilistic Sharpe Ratio", "0%"},
|
||||
{"Loss Rate", "100%"},
|
||||
{"Win Rate", "0%"},
|
||||
{"Profit-Loss Ratio", "0"},
|
||||
{"Alpha", "-0.187"},
|
||||
{"Beta", "0.584"},
|
||||
{"Annual Standard Deviation", "0.065"},
|
||||
{"Annual Variance", "0.004"},
|
||||
{"Information Ratio", "1.354"},
|
||||
{"Tracking Error", "0.048"},
|
||||
{"Treynor Ratio", "-0.926"},
|
||||
{"Total Fees", "$20.45"},
|
||||
{"Estimated Strategy Capacity", "$350000.00"},
|
||||
{"Alpha", "-0.283"},
|
||||
{"Beta", "0.55"},
|
||||
{"Annual Standard Deviation", "0.075"},
|
||||
{"Annual Variance", "0.006"},
|
||||
{"Information Ratio", "0.914"},
|
||||
{"Tracking Error", "0.061"},
|
||||
{"Treynor Ratio", "-1.267"},
|
||||
{"Total Fees", "$21.45"},
|
||||
{"Estimated Strategy Capacity", "$830000.00"},
|
||||
{"Lowest Capacity Asset", "SPY R735QTJ8XC9X"},
|
||||
{"Fitness Score", "0.002"},
|
||||
{"Fitness Score", "0.003"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
{"Sortino Ratio", "-11.829"},
|
||||
{"Return Over Maximum Drawdown", "-71.014"},
|
||||
{"Sortino Ratio", "-11.746"},
|
||||
{"Return Over Maximum Drawdown", "-71.142"},
|
||||
{"Portfolio Turnover", "0.341"},
|
||||
{"Total Insights Generated", "0"},
|
||||
{"Total Insights Closed", "0"},
|
||||
@@ -168,7 +168,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Mean Population Magnitude", "0%"},
|
||||
{"Rolling Averaged Population Direction", "0%"},
|
||||
{"Rolling Averaged Population Magnitude", "0%"},
|
||||
{"OrderListHash", "fbefbed1d94294a14bc563a71b336056"}
|
||||
{"OrderListHash", "6ee62edf1ac883882b0fcef8cb3e9bae"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -109,18 +109,18 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Drawdown", "0.100%"},
|
||||
{"Expectancy", "0"},
|
||||
{"Net Profit", "0.100%"},
|
||||
{"Sharpe Ratio", "7.449"},
|
||||
{"Probabilistic Sharpe Ratio", "85.066%"},
|
||||
{"Sharpe Ratio", "8.342"},
|
||||
{"Probabilistic Sharpe Ratio", "83.750%"},
|
||||
{"Loss Rate", "0%"},
|
||||
{"Win Rate", "0%"},
|
||||
{"Profit-Loss Ratio", "0"},
|
||||
{"Alpha", "0.006"},
|
||||
{"Alpha", "0"},
|
||||
{"Beta", "0.033"},
|
||||
{"Annual Standard Deviation", "0.007"},
|
||||
{"Annual Standard Deviation", "0.008"},
|
||||
{"Annual Variance", "0"},
|
||||
{"Information Ratio", "-7.131"},
|
||||
{"Tracking Error", "0.189"},
|
||||
{"Treynor Ratio", "1.576"},
|
||||
{"Information Ratio", "-8.908"},
|
||||
{"Tracking Error", "0.215"},
|
||||
{"Treynor Ratio", "1.992"},
|
||||
{"Total Fees", "$4.00"},
|
||||
{"Estimated Strategy Capacity", "$6000000.00"},
|
||||
{"Lowest Capacity Asset", "SPY R735QTJ8XC9X"},
|
||||
|
||||
@@ -81,21 +81,21 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Total Trades", "1"},
|
||||
{"Average Win", "0%"},
|
||||
{"Average Loss", "0%"},
|
||||
{"Compounding Annual Return", "0%"},
|
||||
{"Drawdown", "0%"},
|
||||
{"Compounding Annual Return", "16.086%"},
|
||||
{"Drawdown", "0.100%"},
|
||||
{"Expectancy", "0"},
|
||||
{"Net Profit", "0%"},
|
||||
{"Sharpe Ratio", "0"},
|
||||
{"Net Profit", "0.148%"},
|
||||
{"Sharpe Ratio", "9.758"},
|
||||
{"Probabilistic Sharpe Ratio", "0%"},
|
||||
{"Loss Rate", "0%"},
|
||||
{"Win Rate", "0%"},
|
||||
{"Profit-Loss Ratio", "0"},
|
||||
{"Alpha", "0"},
|
||||
{"Beta", "0"},
|
||||
{"Annual Standard Deviation", "0"},
|
||||
{"Annual Standard Deviation", "0.014"},
|
||||
{"Annual Variance", "0"},
|
||||
{"Information Ratio", "0"},
|
||||
{"Tracking Error", "0"},
|
||||
{"Information Ratio", "9.758"},
|
||||
{"Tracking Error", "0.014"},
|
||||
{"Treynor Ratio", "0"},
|
||||
{"Total Fees", "$5.93"},
|
||||
{"Estimated Strategy Capacity", "$150000.00"},
|
||||
|
||||
@@ -92,18 +92,18 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Drawdown", "0.300%"},
|
||||
{"Expectancy", "0"},
|
||||
{"Net Profit", "1.947%"},
|
||||
{"Sharpe Ratio", "14.546"},
|
||||
{"Probabilistic Sharpe Ratio", "90.065%"},
|
||||
{"Sharpe Ratio", "21.391"},
|
||||
{"Probabilistic Sharpe Ratio", "0%"},
|
||||
{"Loss Rate", "0%"},
|
||||
{"Win Rate", "0%"},
|
||||
{"Profit-Loss Ratio", "0"},
|
||||
{"Alpha", "2.13"},
|
||||
{"Beta", "-0.467"},
|
||||
{"Annual Standard Deviation", "0.165"},
|
||||
{"Annual Variance", "0.027"},
|
||||
{"Information Ratio", "7.676"},
|
||||
{"Tracking Error", "0.389"},
|
||||
{"Treynor Ratio", "-5.146"},
|
||||
{"Alpha", "4.505"},
|
||||
{"Beta", "0.567"},
|
||||
{"Annual Standard Deviation", "0.192"},
|
||||
{"Annual Variance", "0.037"},
|
||||
{"Information Ratio", "30.843"},
|
||||
{"Tracking Error", "0.156"},
|
||||
{"Treynor Ratio", "7.25"},
|
||||
{"Total Fees", "$22.30"},
|
||||
{"Estimated Strategy Capacity", "$250000000.00"},
|
||||
{"Lowest Capacity Asset", "AAPL R735QTJ8XC9X"},
|
||||
|
||||
@@ -149,8 +149,8 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Beta", "0"},
|
||||
{"Annual Standard Deviation", "0"},
|
||||
{"Annual Variance", "0"},
|
||||
{"Information Ratio", "5.865"},
|
||||
{"Tracking Error", "0.106"},
|
||||
{"Information Ratio", "5.91"},
|
||||
{"Tracking Error", "0.13"},
|
||||
{"Treynor Ratio", "0"},
|
||||
{"Total Fees", "$0.00"},
|
||||
{"Estimated Strategy Capacity", "$0"},
|
||||
|
||||
@@ -153,8 +153,8 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Beta", "0"},
|
||||
{"Annual Standard Deviation", "0"},
|
||||
{"Annual Variance", "0"},
|
||||
{"Information Ratio", "5.865"},
|
||||
{"Tracking Error", "0.106"},
|
||||
{"Information Ratio", "5.91"},
|
||||
{"Tracking Error", "0.13"},
|
||||
{"Treynor Ratio", "0"},
|
||||
{"Total Fees", "$0.00"},
|
||||
{"Estimated Strategy Capacity", "$0"},
|
||||
|
||||
@@ -101,21 +101,21 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Total Trades", "6"},
|
||||
{"Average Win", "6.02%"},
|
||||
{"Average Loss", "-2.40%"},
|
||||
{"Compounding Annual Return", "915.480%"},
|
||||
{"Compounding Annual Return", "1497.266%"},
|
||||
{"Drawdown", "5.500%"},
|
||||
{"Expectancy", "1.338"},
|
||||
{"Net Profit", "11.400%"},
|
||||
{"Sharpe Ratio", "9.507"},
|
||||
{"Probabilistic Sharpe Ratio", "76.768%"},
|
||||
{"Net Profit", "13.775%"},
|
||||
{"Sharpe Ratio", "3.309"},
|
||||
{"Probabilistic Sharpe Ratio", "61.758%"},
|
||||
{"Loss Rate", "33%"},
|
||||
{"Win Rate", "67%"},
|
||||
{"Profit-Loss Ratio", "2.51"},
|
||||
{"Alpha", "0"},
|
||||
{"Beta", "0"},
|
||||
{"Annual Standard Deviation", "0.507"},
|
||||
{"Annual Variance", "0.257"},
|
||||
{"Information Ratio", "9.507"},
|
||||
{"Tracking Error", "0.507"},
|
||||
{"Annual Standard Deviation", "0.379"},
|
||||
{"Annual Variance", "0.144"},
|
||||
{"Information Ratio", "3.309"},
|
||||
{"Tracking Error", "0.379"},
|
||||
{"Treynor Ratio", "0"},
|
||||
{"Total Fees", "$2651.01"},
|
||||
{"Estimated Strategy Capacity", "$30000.00"},
|
||||
@@ -139,7 +139,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Mean Population Magnitude", "0%"},
|
||||
{"Rolling Averaged Population Direction", "0%"},
|
||||
{"Rolling Averaged Population Magnitude", "0%"},
|
||||
{"OrderListHash", "2b3ac55337ce5619fc0388ccdac72c54"}
|
||||
{"OrderListHash", "604291218c630343a896bfa2f3104932"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,18 +86,18 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Drawdown", "55.000%"},
|
||||
{"Expectancy", "-1"},
|
||||
{"Net Profit", "125.420%"},
|
||||
{"Sharpe Ratio", "0.469"},
|
||||
{"Probabilistic Sharpe Ratio", "2.603%"},
|
||||
{"Sharpe Ratio", "0.427"},
|
||||
{"Probabilistic Sharpe Ratio", "1.166%"},
|
||||
{"Loss Rate", "100%"},
|
||||
{"Win Rate", "0%"},
|
||||
{"Profit-Loss Ratio", "0"},
|
||||
{"Alpha", "0.092"},
|
||||
{"Beta", "-0.091"},
|
||||
{"Annual Standard Deviation", "0.179"},
|
||||
{"Annual Variance", "0.032"},
|
||||
{"Information Ratio", "-0.001"},
|
||||
{"Tracking Error", "0.265"},
|
||||
{"Treynor Ratio", "-0.927"},
|
||||
{"Alpha", "-0"},
|
||||
{"Beta", "0.997"},
|
||||
{"Annual Standard Deviation", "0.164"},
|
||||
{"Annual Variance", "0.027"},
|
||||
{"Information Ratio", "-0.213"},
|
||||
{"Tracking Error", "0.001"},
|
||||
{"Treynor Ratio", "0.07"},
|
||||
{"Total Fees", "$43.46"},
|
||||
{"Estimated Strategy Capacity", "$430000000.00"},
|
||||
{"Lowest Capacity Asset", "SPY R735QTJ8XC9X"},
|
||||
|
||||
@@ -125,18 +125,18 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Drawdown", "5.700%"},
|
||||
{"Expectancy", "-0.148"},
|
||||
{"Net Profit", "-2.802%"},
|
||||
{"Sharpe Ratio", "-0.49"},
|
||||
{"Probabilistic Sharpe Ratio", "10.317%"},
|
||||
{"Sharpe Ratio", "-0.456"},
|
||||
{"Probabilistic Sharpe Ratio", "9.156%"},
|
||||
{"Loss Rate", "50%"},
|
||||
{"Win Rate", "50%"},
|
||||
{"Profit-Loss Ratio", "0.70"},
|
||||
{"Alpha", "-0.042"},
|
||||
{"Alpha", "-0.036"},
|
||||
{"Beta", "-0.012"},
|
||||
{"Annual Standard Deviation", "0.087"},
|
||||
{"Annual Variance", "0.007"},
|
||||
{"Information Ratio", "-0.162"},
|
||||
{"Tracking Error", "0.418"},
|
||||
{"Treynor Ratio", "3.493"},
|
||||
{"Annual Standard Deviation", "0.08"},
|
||||
{"Annual Variance", "0.006"},
|
||||
{"Information Ratio", "-0.15"},
|
||||
{"Tracking Error", "0.387"},
|
||||
{"Treynor Ratio", "3.008"},
|
||||
{"Total Fees", "$14.80"},
|
||||
{"Estimated Strategy Capacity", "$180000000.00"},
|
||||
{"Lowest Capacity Asset", "ES XFH59UK0MYO1"},
|
||||
|
||||
@@ -209,18 +209,18 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Drawdown", "6.300%"},
|
||||
{"Expectancy", "-0.417"},
|
||||
{"Net Profit", "-6.282%"},
|
||||
{"Sharpe Ratio", "-1.316"},
|
||||
{"Probabilistic Sharpe Ratio", "0.004%"},
|
||||
{"Sharpe Ratio", "-1.225"},
|
||||
{"Probabilistic Sharpe Ratio", "0.002%"},
|
||||
{"Loss Rate", "50%"},
|
||||
{"Win Rate", "50%"},
|
||||
{"Profit-Loss Ratio", "0.17"},
|
||||
{"Alpha", "-0.1"},
|
||||
{"Alpha", "-0.086"},
|
||||
{"Beta", "0.004"},
|
||||
{"Annual Standard Deviation", "0.076"},
|
||||
{"Annual Variance", "0.006"},
|
||||
{"Information Ratio", "-0.305"},
|
||||
{"Tracking Error", "0.411"},
|
||||
{"Treynor Ratio", "-27.616"},
|
||||
{"Annual Standard Deviation", "0.07"},
|
||||
{"Annual Variance", "0.005"},
|
||||
{"Information Ratio", "-0.284"},
|
||||
{"Tracking Error", "0.379"},
|
||||
{"Treynor Ratio", "-23.801"},
|
||||
{"Total Fees", "$7.40"},
|
||||
{"Estimated Strategy Capacity", "$180000000.00"},
|
||||
{"Lowest Capacity Asset", "ES XFH59UK0MYO1"},
|
||||
|
||||
@@ -174,18 +174,18 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Drawdown", "29.200%"},
|
||||
{"Expectancy", "-0.375"},
|
||||
{"Net Profit", "-29.224%"},
|
||||
{"Sharpe Ratio", "-1.025"},
|
||||
{"Probabilistic Sharpe Ratio", "0.019%"},
|
||||
{"Sharpe Ratio", "-0.977"},
|
||||
{"Probabilistic Sharpe Ratio", "0.012%"},
|
||||
{"Loss Rate", "50%"},
|
||||
{"Win Rate", "50%"},
|
||||
{"Profit-Loss Ratio", "0.25"},
|
||||
{"Alpha", "-0.387"},
|
||||
{"Alpha", "-0.341"},
|
||||
{"Beta", "0.017"},
|
||||
{"Annual Standard Deviation", "0.377"},
|
||||
{"Annual Variance", "0.142"},
|
||||
{"Information Ratio", "-0.751"},
|
||||
{"Tracking Error", "0.548"},
|
||||
{"Treynor Ratio", "-22.299"},
|
||||
{"Annual Standard Deviation", "0.348"},
|
||||
{"Annual Variance", "0.121"},
|
||||
{"Information Ratio", "-0.715"},
|
||||
{"Tracking Error", "0.506"},
|
||||
{"Treynor Ratio", "-19.652"},
|
||||
{"Total Fees", "$37.00"},
|
||||
{"Estimated Strategy Capacity", "$33000000.00"},
|
||||
{"Lowest Capacity Asset", "ES XFH59UK0MYO1"},
|
||||
|
||||
@@ -184,18 +184,18 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Drawdown", "4.000%"},
|
||||
{"Expectancy", "-1"},
|
||||
{"Net Profit", "-4.029%"},
|
||||
{"Sharpe Ratio", "-1.266"},
|
||||
{"Probabilistic Sharpe Ratio", "0.015%"},
|
||||
{"Sharpe Ratio", "-1.175"},
|
||||
{"Probabilistic Sharpe Ratio", "0.009%"},
|
||||
{"Loss Rate", "100%"},
|
||||
{"Win Rate", "0%"},
|
||||
{"Profit-Loss Ratio", "0"},
|
||||
{"Alpha", "-0.065"},
|
||||
{"Alpha", "-0.056"},
|
||||
{"Beta", "0.002"},
|
||||
{"Annual Standard Deviation", "0.051"},
|
||||
{"Annual Variance", "0.003"},
|
||||
{"Information Ratio", "-0.222"},
|
||||
{"Tracking Error", "0.408"},
|
||||
{"Treynor Ratio", "-27.32"},
|
||||
{"Annual Standard Deviation", "0.047"},
|
||||
{"Annual Variance", "0.002"},
|
||||
{"Information Ratio", "-0.206"},
|
||||
{"Tracking Error", "0.376"},
|
||||
{"Treynor Ratio", "-23.48"},
|
||||
{"Total Fees", "$3.70"},
|
||||
{"Estimated Strategy Capacity", "$200000000.00"},
|
||||
{"Lowest Capacity Asset", "ES XFH59UPHGV9G|ES XFH59UK0MYO1"},
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
SetStartDate(2020, 1, 5);
|
||||
SetStartDate(2020, 1, 4);
|
||||
SetEndDate(2020, 1, 6);
|
||||
|
||||
var goldFutures = AddFuture("GC", Resolution.Minute, Market.COMEX);
|
||||
@@ -105,31 +105,31 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Total Trades", "4"},
|
||||
{"Average Win", "0%"},
|
||||
{"Average Loss", "0%"},
|
||||
{"Compounding Annual Return", "-8.289%"},
|
||||
{"Compounding Annual Return", "-5.605%"},
|
||||
{"Drawdown", "3.500%"},
|
||||
{"Expectancy", "0"},
|
||||
{"Net Profit", "-0.047%"},
|
||||
{"Sharpe Ratio", "0"},
|
||||
{"Sharpe Ratio", "-10.898"},
|
||||
{"Probabilistic Sharpe Ratio", "0%"},
|
||||
{"Loss Rate", "0%"},
|
||||
{"Win Rate", "0%"},
|
||||
{"Profit-Loss Ratio", "0"},
|
||||
{"Alpha", "0"},
|
||||
{"Beta", "0"},
|
||||
{"Annual Standard Deviation", "0"},
|
||||
{"Alpha", "-0.135"},
|
||||
{"Beta", "0.124"},
|
||||
{"Annual Standard Deviation", "0.005"},
|
||||
{"Annual Variance", "0"},
|
||||
{"Information Ratio", "-14.395"},
|
||||
{"Tracking Error", "0.043"},
|
||||
{"Treynor Ratio", "0"},
|
||||
{"Information Ratio", "-17.984"},
|
||||
{"Tracking Error", "0.038"},
|
||||
{"Treynor Ratio", "-0.467"},
|
||||
{"Total Fees", "$7.40"},
|
||||
{"Estimated Strategy Capacity", "$31000000.00"},
|
||||
{"Estimated Strategy Capacity", "$25000000.00"},
|
||||
{"Lowest Capacity Asset", "OG 31BFX0QKBVPGG|GC XE1Y0ZJ8NQ8T"},
|
||||
{"Fitness Score", "0.019"},
|
||||
{"Fitness Score", "0.012"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
{"Sortino Ratio", "79228162514264337593543950335"},
|
||||
{"Return Over Maximum Drawdown", "-194.237"},
|
||||
{"Portfolio Turnover", "0.038"},
|
||||
{"Return Over Maximum Drawdown", "-126.806"},
|
||||
{"Portfolio Turnover", "0.025"},
|
||||
{"Total Insights Generated", "0"},
|
||||
{"Total Insights Closed", "0"},
|
||||
{"Total Insights Analysis Completed", "0"},
|
||||
|
||||
@@ -210,18 +210,18 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Drawdown", "4.500%"},
|
||||
{"Expectancy", "-0.249"},
|
||||
{"Net Profit", "-4.457%"},
|
||||
{"Sharpe Ratio", "-1.381"},
|
||||
{"Probabilistic Sharpe Ratio", "0.002%"},
|
||||
{"Sharpe Ratio", "-1.282"},
|
||||
{"Probabilistic Sharpe Ratio", "0.001%"},
|
||||
{"Loss Rate", "50%"},
|
||||
{"Win Rate", "50%"},
|
||||
{"Profit-Loss Ratio", "0.50"},
|
||||
{"Alpha", "-0.072"},
|
||||
{"Alpha", "-0.062"},
|
||||
{"Beta", "0.003"},
|
||||
{"Annual Standard Deviation", "0.052"},
|
||||
{"Annual Variance", "0.003"},
|
||||
{"Information Ratio", "-0.239"},
|
||||
{"Tracking Error", "0.408"},
|
||||
{"Treynor Ratio", "-28.523"},
|
||||
{"Annual Standard Deviation", "0.048"},
|
||||
{"Annual Variance", "0.002"},
|
||||
{"Information Ratio", "-0.222"},
|
||||
{"Tracking Error", "0.376"},
|
||||
{"Treynor Ratio", "-24.53"},
|
||||
{"Total Fees", "$7.40"},
|
||||
{"Estimated Strategy Capacity", "$220000000.00"},
|
||||
{"Lowest Capacity Asset", "ES XFH59UK0MYO1"},
|
||||
|
||||
@@ -183,18 +183,18 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Drawdown", "5.100%"},
|
||||
{"Expectancy", "-1"},
|
||||
{"Net Profit", "-5.116%"},
|
||||
{"Sharpe Ratio", "-1.253"},
|
||||
{"Probabilistic Sharpe Ratio", "0.015%"},
|
||||
{"Sharpe Ratio", "-1.164"},
|
||||
{"Probabilistic Sharpe Ratio", "0.009%"},
|
||||
{"Loss Rate", "100%"},
|
||||
{"Win Rate", "0%"},
|
||||
{"Profit-Loss Ratio", "0"},
|
||||
{"Alpha", "-0.082"},
|
||||
{"Alpha", "-0.07"},
|
||||
{"Beta", "0.003"},
|
||||
{"Annual Standard Deviation", "0.065"},
|
||||
{"Annual Standard Deviation", "0.06"},
|
||||
{"Annual Variance", "0.004"},
|
||||
{"Information Ratio", "-0.262"},
|
||||
{"Tracking Error", "0.409"},
|
||||
{"Treynor Ratio", "-27.056"},
|
||||
{"Information Ratio", "-0.243"},
|
||||
{"Tracking Error", "0.378"},
|
||||
{"Treynor Ratio", "-23.284"},
|
||||
{"Total Fees", "$3.70"},
|
||||
{"Estimated Strategy Capacity", "$360000000.00"},
|
||||
{"Lowest Capacity Asset", "ES 31EL5FBZBMXES|ES XFH59UK0MYO1"},
|
||||
|
||||
@@ -194,18 +194,18 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Drawdown", "0.500%"},
|
||||
{"Expectancy", "0.393"},
|
||||
{"Net Profit", "3.855%"},
|
||||
{"Sharpe Ratio", "1.182"},
|
||||
{"Probabilistic Sharpe Ratio", "57.797%"},
|
||||
{"Sharpe Ratio", "1.087"},
|
||||
{"Probabilistic Sharpe Ratio", "53.360%"},
|
||||
{"Loss Rate", "50%"},
|
||||
{"Win Rate", "50%"},
|
||||
{"Profit-Loss Ratio", "1.79"},
|
||||
{"Alpha", "0.067"},
|
||||
{"Alpha", "0.057"},
|
||||
{"Beta", "-0.002"},
|
||||
{"Annual Standard Deviation", "0.057"},
|
||||
{"Annual Standard Deviation", "0.052"},
|
||||
{"Annual Variance", "0.003"},
|
||||
{"Information Ratio", "0.101"},
|
||||
{"Tracking Error", "0.41"},
|
||||
{"Treynor Ratio", "-27.331"},
|
||||
{"Information Ratio", "0.093"},
|
||||
{"Tracking Error", "0.379"},
|
||||
{"Treynor Ratio", "-23.26"},
|
||||
{"Total Fees", "$7.40"},
|
||||
{"Estimated Strategy Capacity", "$200000000.00"},
|
||||
{"Lowest Capacity Asset", "ES XFH59UK0MYO1"},
|
||||
|
||||
@@ -177,18 +177,18 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Drawdown", "0.000%"},
|
||||
{"Expectancy", "0"},
|
||||
{"Net Profit", "1.809%"},
|
||||
{"Sharpe Ratio", "1.283"},
|
||||
{"Probabilistic Sharpe Ratio", "65.521%"},
|
||||
{"Sharpe Ratio", "1.183"},
|
||||
{"Probabilistic Sharpe Ratio", "60.809%"},
|
||||
{"Loss Rate", "0%"},
|
||||
{"Win Rate", "100%"},
|
||||
{"Profit-Loss Ratio", "0"},
|
||||
{"Alpha", "0.031"},
|
||||
{"Alpha", "0.026"},
|
||||
{"Beta", "-0.001"},
|
||||
{"Annual Standard Deviation", "0.024"},
|
||||
{"Annual Variance", "0.001"},
|
||||
{"Information Ratio", "0.013"},
|
||||
{"Tracking Error", "0.406"},
|
||||
{"Treynor Ratio", "-28.184"},
|
||||
{"Annual Standard Deviation", "0.022"},
|
||||
{"Annual Variance", "0"},
|
||||
{"Information Ratio", "0.012"},
|
||||
{"Tracking Error", "0.375"},
|
||||
{"Treynor Ratio", "-24.051"},
|
||||
{"Total Fees", "$3.70"},
|
||||
{"Estimated Strategy Capacity", "$78000000.00"},
|
||||
{"Lowest Capacity Asset", "ES XFH59UPNF7B8|ES XFH59UK0MYO1"},
|
||||
|
||||
@@ -191,18 +191,18 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Drawdown", "0.500%"},
|
||||
{"Expectancy", "0.133"},
|
||||
{"Net Profit", "1.318%"},
|
||||
{"Sharpe Ratio", "0.927"},
|
||||
{"Probabilistic Sharpe Ratio", "46.325%"},
|
||||
{"Sharpe Ratio", "0.855"},
|
||||
{"Probabilistic Sharpe Ratio", "42.696%"},
|
||||
{"Loss Rate", "50%"},
|
||||
{"Win Rate", "50%"},
|
||||
{"Profit-Loss Ratio", "1.27"},
|
||||
{"Alpha", "0.022"},
|
||||
{"Alpha", "0.019"},
|
||||
{"Beta", "-0.001"},
|
||||
{"Annual Standard Deviation", "0.024"},
|
||||
{"Annual Variance", "0.001"},
|
||||
{"Information Ratio", "-0.008"},
|
||||
{"Tracking Error", "0.406"},
|
||||
{"Treynor Ratio", "-24.058"},
|
||||
{"Annual Standard Deviation", "0.022"},
|
||||
{"Annual Variance", "0"},
|
||||
{"Information Ratio", "-0.007"},
|
||||
{"Tracking Error", "0.375"},
|
||||
{"Treynor Ratio", "-20.534"},
|
||||
{"Total Fees", "$7.40"},
|
||||
{"Estimated Strategy Capacity", "$130000000.00"},
|
||||
{"Lowest Capacity Asset", "ES XFH59UK0MYO1"},
|
||||
|
||||
@@ -176,18 +176,18 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Drawdown", "0.000%"},
|
||||
{"Expectancy", "0"},
|
||||
{"Net Profit", "3.284%"},
|
||||
{"Sharpe Ratio", "1.309"},
|
||||
{"Probabilistic Sharpe Ratio", "66.205%"},
|
||||
{"Sharpe Ratio", "1.205"},
|
||||
{"Probabilistic Sharpe Ratio", "61.483%"},
|
||||
{"Loss Rate", "0%"},
|
||||
{"Win Rate", "100%"},
|
||||
{"Profit-Loss Ratio", "0"},
|
||||
{"Alpha", "0.056"},
|
||||
{"Alpha", "0.048"},
|
||||
{"Beta", "-0.002"},
|
||||
{"Annual Standard Deviation", "0.043"},
|
||||
{"Annual Standard Deviation", "0.04"},
|
||||
{"Annual Variance", "0.002"},
|
||||
{"Information Ratio", "0.076"},
|
||||
{"Tracking Error", "0.408"},
|
||||
{"Treynor Ratio", "-28.646"},
|
||||
{"Information Ratio", "0.07"},
|
||||
{"Tracking Error", "0.377"},
|
||||
{"Treynor Ratio", "-24.401"},
|
||||
{"Total Fees", "$3.70"},
|
||||
{"Estimated Strategy Capacity", "$80000000.00"},
|
||||
{"Lowest Capacity Asset", "ES 31EL5FAJQ6SBO|ES XFH59UK0MYO1"},
|
||||
|
||||
@@ -89,18 +89,18 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Drawdown", "5.400%"},
|
||||
{"Expectancy", "0"},
|
||||
{"Net Profit", "-3.474%"},
|
||||
{"Sharpe Ratio", "-4.693"},
|
||||
{"Sharpe Ratio", "-68.954"},
|
||||
{"Probabilistic Sharpe Ratio", "0%"},
|
||||
{"Loss Rate", "0%"},
|
||||
{"Win Rate", "0%"},
|
||||
{"Profit-Loss Ratio", "0"},
|
||||
{"Alpha", "1.575"},
|
||||
{"Beta", "-0.437"},
|
||||
{"Annual Standard Deviation", "0.194"},
|
||||
{"Annual Variance", "0.038"},
|
||||
{"Information Ratio", "-19.629"},
|
||||
{"Tracking Error", "0.336"},
|
||||
{"Treynor Ratio", "2.082"},
|
||||
{"Alpha", "-1.896"},
|
||||
{"Beta", "0.058"},
|
||||
{"Annual Standard Deviation", "0.014"},
|
||||
{"Annual Variance", "0"},
|
||||
{"Information Ratio", "-75.062"},
|
||||
{"Tracking Error", "0.229"},
|
||||
{"Treynor Ratio", "-16.736"},
|
||||
{"Total Fees", "$1.85"},
|
||||
{"Estimated Strategy Capacity", "$93000000.00"},
|
||||
{"Lowest Capacity Asset", "GC VOFJUCDY9XNH"},
|
||||
|
||||
@@ -187,18 +187,18 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Drawdown", "2.300%"},
|
||||
{"Expectancy", "-0.053"},
|
||||
{"Net Profit", "-2.345%"},
|
||||
{"Sharpe Ratio", "-0.969"},
|
||||
{"Probabilistic Sharpe Ratio", "0.004%"},
|
||||
{"Sharpe Ratio", "-0.867"},
|
||||
{"Probabilistic Sharpe Ratio", "0.001%"},
|
||||
{"Loss Rate", "50%"},
|
||||
{"Win Rate", "50%"},
|
||||
{"Profit-Loss Ratio", "0.89"},
|
||||
{"Alpha", "-0.018"},
|
||||
{"Alpha", "-0.014"},
|
||||
{"Beta", "0.001"},
|
||||
{"Annual Standard Deviation", "0.018"},
|
||||
{"Annual Standard Deviation", "0.016"},
|
||||
{"Annual Variance", "0"},
|
||||
{"Information Ratio", "-0.696"},
|
||||
{"Tracking Error", "0.33"},
|
||||
{"Treynor Ratio", "-16.321"},
|
||||
{"Information Ratio", "-0.603"},
|
||||
{"Tracking Error", "0.291"},
|
||||
{"Treynor Ratio", "-13.292"},
|
||||
{"Total Fees", "$7.40"},
|
||||
{"Estimated Strategy Capacity", "$45000000.00"},
|
||||
{"Lowest Capacity Asset", "ES XFH59UK0MYO1"},
|
||||
|
||||
@@ -99,8 +99,8 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Beta", "0"},
|
||||
{"Annual Standard Deviation", "0"},
|
||||
{"Annual Variance", "0"},
|
||||
{"Information Ratio", "-3.432"},
|
||||
{"Tracking Error", "0.098"},
|
||||
{"Information Ratio", "-3.102"},
|
||||
{"Tracking Error", "0.091"},
|
||||
{"Treynor Ratio", "0"},
|
||||
{"Total Fees", "$0.00"},
|
||||
{"Estimated Strategy Capacity", "$0"},
|
||||
|
||||
@@ -304,18 +304,18 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Drawdown", "1.200%"},
|
||||
{"Expectancy", "0"},
|
||||
{"Net Profit", "1.694%"},
|
||||
{"Sharpe Ratio", "8.671"},
|
||||
{"Probabilistic Sharpe Ratio", "67.159%"},
|
||||
{"Sharpe Ratio", "57.51"},
|
||||
{"Probabilistic Sharpe Ratio", "0%"},
|
||||
{"Loss Rate", "0%"},
|
||||
{"Win Rate", "0%"},
|
||||
{"Profit-Loss Ratio", "0"},
|
||||
{"Alpha", "1.614"},
|
||||
{"Beta", "0.062"},
|
||||
{"Annual Standard Deviation", "0.223"},
|
||||
{"Annual Variance", "0.05"},
|
||||
{"Information Ratio", "-11.911"},
|
||||
{"Tracking Error", "0.271"},
|
||||
{"Treynor Ratio", "31.034"},
|
||||
{"Alpha", "-0.041"},
|
||||
{"Beta", "0.998"},
|
||||
{"Annual Standard Deviation", "0.177"},
|
||||
{"Annual Variance", "0.031"},
|
||||
{"Information Ratio", "-150.576"},
|
||||
{"Tracking Error", "0"},
|
||||
{"Treynor Ratio", "10.228"},
|
||||
{"Total Fees", "$3.45"},
|
||||
{"Estimated Strategy Capacity", "$970000000.00"},
|
||||
{"Lowest Capacity Asset", "SPY R735QTJ8XC9X"},
|
||||
|
||||
@@ -89,8 +89,8 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Beta", "0"},
|
||||
{"Annual Standard Deviation", "0"},
|
||||
{"Annual Variance", "0"},
|
||||
{"Information Ratio", "-7.163"},
|
||||
{"Tracking Error", "0.195"},
|
||||
{"Information Ratio", "-8.91"},
|
||||
{"Tracking Error", "0.223"},
|
||||
{"Treynor Ratio", "0"},
|
||||
{"Total Fees", "$0.00"},
|
||||
{"Estimated Strategy Capacity", "$0"},
|
||||
|
||||
@@ -14,15 +14,15 @@
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using QuantConnect.Data;
|
||||
using QuantConnect.Data.Market;
|
||||
using QuantConnect.Interfaces;
|
||||
using QuantConnect.Data.Market;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace QuantConnect.Algorithm.CSharp
|
||||
{
|
||||
/// <summary>
|
||||
/// Regression algorithm reproducing GH issue #5232
|
||||
/// Regression algorithm reproducing GH issue #5232, where we expect SPWR to be mapped to SPWRA
|
||||
/// </summary>
|
||||
public class HourResolutionMappingEventRegressionAlgorithm : QCAlgorithm, IRegressionAlgorithmDefinition
|
||||
{
|
||||
@@ -93,18 +93,18 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Drawdown", "31.700%"},
|
||||
{"Expectancy", "0"},
|
||||
{"Net Profit", "-16.363%"},
|
||||
{"Sharpe Ratio", "-0.506"},
|
||||
{"Probabilistic Sharpe Ratio", "27.578%"},
|
||||
{"Sharpe Ratio", "-0.474"},
|
||||
{"Probabilistic Sharpe Ratio", "25.138%"},
|
||||
{"Loss Rate", "0%"},
|
||||
{"Win Rate", "0%"},
|
||||
{"Profit-Loss Ratio", "0"},
|
||||
{"Alpha", "0.45"},
|
||||
{"Beta", "2.007"},
|
||||
{"Annual Standard Deviation", "1.118"},
|
||||
{"Annual Variance", "1.25"},
|
||||
{"Information Ratio", "-0.069"},
|
||||
{"Tracking Error", "0.869"},
|
||||
{"Treynor Ratio", "-0.282"},
|
||||
{"Alpha", "0.335"},
|
||||
{"Beta", "2.004"},
|
||||
{"Annual Standard Deviation", "0.924"},
|
||||
{"Annual Variance", "0.854"},
|
||||
{"Information Ratio", "-0.073"},
|
||||
{"Tracking Error", "0.718"},
|
||||
{"Treynor Ratio", "-0.218"},
|
||||
{"Total Fees", "$5.40"},
|
||||
{"Estimated Strategy Capacity", "$2400000.00"},
|
||||
{"Lowest Capacity Asset", "SPWR TDQZFPKOZ5UT"},
|
||||
@@ -127,7 +127,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Mean Population Magnitude", "0%"},
|
||||
{"Rolling Averaged Population Direction", "0%"},
|
||||
{"Rolling Averaged Population Magnitude", "0%"},
|
||||
{"OrderListHash", "8d5c6263fbdfa4b2338fc725e27b93e9"}
|
||||
{"OrderListHash", "4bf8a2d15c6c6ac98e55d7c6ea10f54e"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -105,7 +105,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Mean Population Magnitude", "0%"},
|
||||
{"Rolling Averaged Population Direction", "0%"},
|
||||
{"Rolling Averaged Population Magnitude", "0%"},
|
||||
{"OrderListHash", "4014a968be616942fad8aff7c37104bc"}
|
||||
{"OrderListHash", "d22c476870c3d52698c94a055b90ed6e"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -111,11 +111,11 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Total Trades", "1"},
|
||||
{"Average Win", "0%"},
|
||||
{"Average Loss", "0%"},
|
||||
{"Compounding Annual Return", "0%"},
|
||||
{"Drawdown", "0%"},
|
||||
{"Compounding Annual Return", "-0.068%"},
|
||||
{"Drawdown", "0.000%"},
|
||||
{"Expectancy", "0"},
|
||||
{"Net Profit", "0%"},
|
||||
{"Sharpe Ratio", "0"},
|
||||
{"Net Profit", "-0.001%"},
|
||||
{"Sharpe Ratio", "-9.163"},
|
||||
{"Probabilistic Sharpe Ratio", "0%"},
|
||||
{"Loss Rate", "0%"},
|
||||
{"Win Rate", "0%"},
|
||||
@@ -124,7 +124,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Beta", "0"},
|
||||
{"Annual Standard Deviation", "0"},
|
||||
{"Annual Variance", "0"},
|
||||
{"Information Ratio", "0"},
|
||||
{"Information Ratio", "-9.163"},
|
||||
{"Tracking Error", "0"},
|
||||
{"Treynor Ratio", "0"},
|
||||
{"Total Fees", "$1.00"},
|
||||
@@ -149,7 +149,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Mean Population Magnitude", "0%"},
|
||||
{"Rolling Averaged Population Direction", "0%"},
|
||||
{"Rolling Averaged Population Magnitude", "0%"},
|
||||
{"OrderListHash", "fb41809f0365b2c06d0ff9d8e40a4775"}
|
||||
{"OrderListHash", "f6ee7a06dc920d5fdabc4bccb84c90df"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user