Compare commits
38 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d94a1d09a4 | ||
|
|
2c843cae9e | ||
|
|
039fdf7e4a | ||
|
|
2c63546c37 | ||
|
|
58682e1bbd | ||
|
|
d11a375fdb | ||
|
|
6ab91a13e1 | ||
|
|
beaa705646 | ||
|
|
4c830c8235 | ||
|
|
395c1123da | ||
|
|
8e50645640 | ||
|
|
68ca504d3a | ||
|
|
12df1c9a31 | ||
|
|
4de25b6cd4 | ||
|
|
cdef9e709a | ||
|
|
3579fecc58 | ||
|
|
3a390cfa9f | ||
|
|
58dae061e7 | ||
|
|
3f2479393f | ||
|
|
4849588c3b | ||
|
|
3d84c76abb | ||
|
|
1c3d849ad5 | ||
|
|
271220083b | ||
|
|
b29d0cbfaf | ||
|
|
27a25cd663 | ||
|
|
5ed61db2bb | ||
|
|
4a1485a291 | ||
|
|
d6072c88a5 | ||
|
|
20910ca2dc | ||
|
|
c333ccdc4a | ||
|
|
88c4a332bc | ||
|
|
5d762d16b2 | ||
|
|
e2a0873b7c | ||
|
|
31ebaaeaa9 | ||
|
|
7625e232f4 | ||
|
|
63f3af7afe | ||
|
|
87b42f6fb5 | ||
|
|
f9dc38efab |
@@ -94,7 +94,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0.212"},
|
||||
{"Treynor Ratio", "-2.13"},
|
||||
{"Total Fees", "$199.00"},
|
||||
{"Estimated Strategy Capacity", "$280000000.00"},
|
||||
{"Estimated Strategy Capacity", "$23000000.00"},
|
||||
{"Fitness Score", "0.002"},
|
||||
{"Kelly Criterion Estimate", "38.64"},
|
||||
{"Kelly Criterion Probability Value", "0.229"},
|
||||
|
||||
@@ -130,7 +130,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0.367"},
|
||||
{"Treynor Ratio", "-4.079"},
|
||||
{"Total Fees", "$14.33"},
|
||||
{"Estimated Strategy Capacity", "$29000000.00"},
|
||||
{"Estimated Strategy Capacity", "$38000000.00"},
|
||||
{"Fitness Score", "0.408"},
|
||||
{"Kelly Criterion Estimate", "16.447"},
|
||||
{"Kelly Criterion Probability Value", "0.315"},
|
||||
|
||||
@@ -139,7 +139,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0.058"},
|
||||
{"Treynor Ratio", "2.133"},
|
||||
{"Total Fees", "$2.00"},
|
||||
{"Estimated Strategy Capacity", "$6400000.00"},
|
||||
{"Estimated Strategy Capacity", "$45000000.00"},
|
||||
{"Fitness Score", "0"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
|
||||
@@ -191,7 +191,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0.042"},
|
||||
{"Treynor Ratio", "0.286"},
|
||||
{"Total Fees", "$2.00"},
|
||||
{"Estimated Strategy Capacity", "$1400000.00"},
|
||||
{"Estimated Strategy Capacity", "$2800000.00"},
|
||||
{"Fitness Score", "0"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
|
||||
@@ -79,19 +79,19 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
// things like manually added, auto added, internal, and any other boolean state we need to track against a single security)
|
||||
throw new Exception("The underlying equity data should NEVER be removed in this algorithm because it was manually added");
|
||||
}
|
||||
if (_expectedSecurities.AreDifferent(LinqExtensions.ToHashSet(Securities.Keys)))
|
||||
if (_expectedSecurities.AreDifferent(Securities.Keys.ToHashSet()))
|
||||
{
|
||||
var expected = string.Join(Environment.NewLine, _expectedSecurities.OrderBy(s => s.ToString()));
|
||||
var actual = string.Join(Environment.NewLine, Securities.Keys.OrderBy(s => s.ToString()));
|
||||
throw new Exception($"{Time}:: Detected differences in expected and actual securities{Environment.NewLine}Expected:{Environment.NewLine}{expected}{Environment.NewLine}Actual:{Environment.NewLine}{actual}");
|
||||
}
|
||||
if (_expectedUniverses.AreDifferent(LinqExtensions.ToHashSet(UniverseManager.Keys)))
|
||||
if (_expectedUniverses.AreDifferent(Securities.Keys.ToHashSet()))
|
||||
{
|
||||
var expected = string.Join(Environment.NewLine, _expectedUniverses.OrderBy(s => s.ToString()));
|
||||
var actual = string.Join(Environment.NewLine, UniverseManager.Keys.OrderBy(s => s.ToString()));
|
||||
throw new Exception($"{Time}:: Detected differences in expected and actual universes{Environment.NewLine}Expected:{Environment.NewLine}{expected}{Environment.NewLine}Actual:{Environment.NewLine}{actual}");
|
||||
}
|
||||
if (_expectedData.AreDifferent(LinqExtensions.ToHashSet(data.Keys)))
|
||||
if (_expectedData.AreDifferent(Securities.Keys.ToHashSet()))
|
||||
{
|
||||
var expected = string.Join(Environment.NewLine, _expectedData.OrderBy(s => s.ToString()));
|
||||
var actual = string.Join(Environment.NewLine, data.Keys.OrderBy(s => s.ToString()));
|
||||
@@ -183,7 +183,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
if (changes.RemovedSecurities
|
||||
.Where(x => x.Symbol.SecurityType == SecurityType.Option)
|
||||
.ToHashSet(s => s.Symbol)
|
||||
.AreDifferent(LinqExtensions.ToHashSet(_expectedContracts)))
|
||||
.AreDifferent(_expectedContracts.ToHashSet()))
|
||||
{
|
||||
throw new Exception("Expected removed securities to equal expected contracts added");
|
||||
}
|
||||
@@ -230,7 +230,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0"},
|
||||
{"Treynor Ratio", "0"},
|
||||
{"Total Fees", "$6.00"},
|
||||
{"Estimated Strategy Capacity", "$3000.00"},
|
||||
{"Estimated Strategy Capacity", "$1500.00"},
|
||||
{"Fitness Score", "0"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
|
||||
@@ -131,7 +131,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0.072"},
|
||||
{"Treynor Ratio", "2.933"},
|
||||
{"Total Fees", "$26.39"},
|
||||
{"Estimated Strategy Capacity", "$2200000.00"},
|
||||
{"Estimated Strategy Capacity", "$4400000.00"},
|
||||
{"Fitness Score", "0.374"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
|
||||
@@ -84,7 +84,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0.006"},
|
||||
{"Treynor Ratio", "2.029"},
|
||||
{"Total Fees", "$9.77"},
|
||||
{"Estimated Strategy Capacity", "$28000000.00"},
|
||||
{"Estimated Strategy Capacity", "$37000000.00"},
|
||||
{"Fitness Score", "0.747"},
|
||||
{"Kelly Criterion Estimate", "38.64"},
|
||||
{"Kelly Criterion Probability Value", "0.229"},
|
||||
|
||||
@@ -103,7 +103,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0.376"},
|
||||
{"Treynor Ratio", "-0.084"},
|
||||
{"Total Fees", "$13.98"},
|
||||
{"Estimated Strategy Capacity", "$31000000.00"},
|
||||
{"Estimated Strategy Capacity", "$61000000.00"},
|
||||
{"Fitness Score", "0.146"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "1"},
|
||||
|
||||
@@ -110,7 +110,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0.194"},
|
||||
{"Treynor Ratio", "-0.962"},
|
||||
{"Total Fees", "$25.92"},
|
||||
{"Estimated Strategy Capacity", "$16000000.00"},
|
||||
{"Estimated Strategy Capacity", "$69000000.00"},
|
||||
{"Fitness Score", "0.004"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "1"},
|
||||
|
||||
@@ -211,7 +211,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0.068"},
|
||||
{"Treynor Ratio", "1.722"},
|
||||
{"Total Fees", "$307.50"},
|
||||
{"Estimated Strategy Capacity", "$710000.00"},
|
||||
{"Estimated Strategy Capacity", "$2800000.00"},
|
||||
{"Fitness Score", "0.173"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
|
||||
@@ -98,7 +98,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0.099"},
|
||||
{"Treynor Ratio", "-5.187"},
|
||||
{"Total Fees", "$65.00"},
|
||||
{"Estimated Strategy Capacity", "$2300000000.00"},
|
||||
{"Estimated Strategy Capacity", "$16000000000.00"},
|
||||
{"Fitness Score", "0"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
|
||||
@@ -130,7 +130,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0.001"},
|
||||
{"Treynor Ratio", "1.922"},
|
||||
{"Total Fees", "$3.26"},
|
||||
{"Estimated Strategy Capacity", "$15000000.00"},
|
||||
{"Estimated Strategy Capacity", "$58000000.00"},
|
||||
{"Fitness Score", "0.248"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
|
||||
@@ -97,7 +97,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0.001"},
|
||||
{"Treynor Ratio", "1.922"},
|
||||
{"Total Fees", "$3.26"},
|
||||
{"Estimated Strategy Capacity", "$15000000.00"},
|
||||
{"Estimated Strategy Capacity", "$58000000.00"},
|
||||
{"Fitness Score", "0.248"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
|
||||
@@ -88,7 +88,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0.221"},
|
||||
{"Treynor Ratio", "-13.568"},
|
||||
{"Total Fees", "$3.26"},
|
||||
{"Estimated Strategy Capacity", "$130000000.00"},
|
||||
{"Estimated Strategy Capacity", "$890000000.00"},
|
||||
{"Fitness Score", "0.111"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
|
||||
@@ -109,7 +109,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0.002"},
|
||||
{"Treynor Ratio", "1.839"},
|
||||
{"Total Fees", "$9.77"},
|
||||
{"Estimated Strategy Capacity", "$20000000.00"},
|
||||
{"Estimated Strategy Capacity", "$27000000.00"},
|
||||
{"Fitness Score", "0.747"},
|
||||
{"Kelly Criterion Estimate", "38.64"},
|
||||
{"Kelly Criterion Probability Value", "0.229"},
|
||||
|
||||
@@ -147,7 +147,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0.504"},
|
||||
{"Treynor Ratio", "1.011"},
|
||||
{"Total Fees", "$15207.00"},
|
||||
{"Estimated Strategy Capacity", "$8800000.00"},
|
||||
{"Estimated Strategy Capacity", "$7700.00"},
|
||||
{"Fitness Score", "0.033"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
|
||||
@@ -155,7 +155,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0.188"},
|
||||
{"Treynor Ratio", "-3.318"},
|
||||
{"Total Fees", "$3.70"},
|
||||
{"Estimated Strategy Capacity", "$13000000.00"},
|
||||
{"Estimated Strategy Capacity", "$52000000.00"},
|
||||
{"Fitness Score", "0.009"},
|
||||
{"Kelly Criterion Estimate", "-112.972"},
|
||||
{"Kelly Criterion Probability Value", "0.671"},
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
public class BasicTemplateIndexAlgorithm : QCAlgorithm, IRegressionAlgorithmDefinition
|
||||
{
|
||||
private Symbol _spx;
|
||||
private Symbol _spy;
|
||||
private Symbol _spxOption;
|
||||
private ExponentialMovingAverage _emaSlow;
|
||||
private ExponentialMovingAverage _emaFast;
|
||||
|
||||
@@ -40,17 +40,26 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// </summary>
|
||||
public override void Initialize()
|
||||
{
|
||||
SetStartDate(2021, 2, 25);
|
||||
SetEndDate(2021, 3, 3);
|
||||
SetStartDate(2021, 1, 4);
|
||||
SetEndDate(2021, 1, 15);
|
||||
SetCash(1000000);
|
||||
|
||||
// Use indicator for signal; but it cannot be traded
|
||||
_spx = AddIndex("SPX", Resolution.Minute).Symbol;
|
||||
|
||||
// Trade on SPX ITM calls
|
||||
_spxOption = QuantConnect.Symbol.CreateOption(
|
||||
_spx,
|
||||
Market.USA,
|
||||
OptionStyle.European,
|
||||
OptionRight.Call,
|
||||
3200m,
|
||||
new DateTime(2021, 1, 15));
|
||||
|
||||
AddIndexOptionContract(_spxOption, Resolution.Minute);
|
||||
|
||||
_emaSlow = EMA(_spx, 80);
|
||||
_emaFast = EMA(_spx, 200);
|
||||
|
||||
// Trade on SPY
|
||||
_spy = AddEquity("SPY", Resolution.Minute).Symbol;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -58,7 +67,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// </summary>
|
||||
public override void OnData(Slice slice)
|
||||
{
|
||||
if (!slice.Bars.ContainsKey(_spx) || !slice.Bars.ContainsKey(_spy))
|
||||
if (!slice.Bars.ContainsKey(_spx) || !slice.Bars.ContainsKey(_spxOption))
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -71,7 +80,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
|
||||
if (_emaFast > _emaSlow)
|
||||
{
|
||||
SetHoldings(_spy, 1);
|
||||
SetHoldings(_spxOption, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -102,33 +111,33 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// </summary>
|
||||
public Dictionary<string, string> ExpectedStatistics => new Dictionary<string, string>
|
||||
{
|
||||
{"Total Trades", "8220"},
|
||||
{"Average Win", "0.00%"},
|
||||
{"Average Loss", "0.00%"},
|
||||
{"Compounding Annual Return", "-100.000%"},
|
||||
{"Drawdown", "13.500%"},
|
||||
{"Expectancy", "-0.818"},
|
||||
{"Net Profit", "-13.517%"},
|
||||
{"Sharpe Ratio", "-2.678"},
|
||||
{"Probabilistic Sharpe Ratio", "0%"},
|
||||
{"Loss Rate", "89%"},
|
||||
{"Win Rate", "11%"},
|
||||
{"Profit-Loss Ratio", "0.69"},
|
||||
{"Alpha", "4.398"},
|
||||
{"Beta", "-0.989"},
|
||||
{"Annual Standard Deviation", "0.373"},
|
||||
{"Annual Variance", "0.139"},
|
||||
{"Information Ratio", "-12.816"},
|
||||
{"Tracking Error", "0.504"},
|
||||
{"Treynor Ratio", "1.011"},
|
||||
{"Total Fees", "$15207.00"},
|
||||
{"Estimated Strategy Capacity", "$8800000.00"},
|
||||
{"Fitness Score", "0.033"},
|
||||
{"Total Trades", "4"},
|
||||
{"Average Win", "0%"},
|
||||
{"Average Loss", "-53.10%"},
|
||||
{"Compounding Annual Return", "-96.172%"},
|
||||
{"Drawdown", "10.100%"},
|
||||
{"Expectancy", "-1"},
|
||||
{"Net Profit", "-9.915%"},
|
||||
{"Sharpe Ratio", "-4.217"},
|
||||
{"Probabilistic Sharpe Ratio", "0.052%"},
|
||||
{"Loss Rate", "100%"},
|
||||
{"Win Rate", "0%"},
|
||||
{"Profit-Loss Ratio", "0"},
|
||||
{"Alpha", "0"},
|
||||
{"Beta", "0"},
|
||||
{"Annual Standard Deviation", "0.139"},
|
||||
{"Annual Variance", "0.019"},
|
||||
{"Information Ratio", "-4.217"},
|
||||
{"Tracking Error", "0.139"},
|
||||
{"Treynor Ratio", "0"},
|
||||
{"Total Fees", "$0.00"},
|
||||
{"Estimated Strategy Capacity", "$14000000.00"},
|
||||
{"Fitness Score", "0.044"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
{"Sortino Ratio", "-8.62"},
|
||||
{"Return Over Maximum Drawdown", "-7.81"},
|
||||
{"Portfolio Turnover", "302.321"},
|
||||
{"Sortino Ratio", "-1.96"},
|
||||
{"Return Over Maximum Drawdown", "-10.171"},
|
||||
{"Portfolio Turnover", "0.34"},
|
||||
{"Total Insights Generated", "0"},
|
||||
{"Total Insights Closed", "0"},
|
||||
{"Total Insights Analysis Completed", "0"},
|
||||
@@ -142,7 +151,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Mean Population Magnitude", "0%"},
|
||||
{"Rolling Averaged Population Direction", "0%"},
|
||||
{"Rolling Averaged Population Magnitude", "0%"},
|
||||
{"OrderListHash", "35b3f4b7a225468d42ca085386a2383e"}
|
||||
{"OrderListHash", "52521ab779446daf4d38a7c9bbbdd893"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -134,7 +134,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0"},
|
||||
{"Treynor Ratio", "0"},
|
||||
{"Total Fees", "$778.00"},
|
||||
{"Estimated Strategy Capacity", "$180000.00"},
|
||||
{"Estimated Strategy Capacity", "$720.00"},
|
||||
{"Fitness Score", "0"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
|
||||
@@ -131,7 +131,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0"},
|
||||
{"Treynor Ratio", "0"},
|
||||
{"Total Fees", "$2.00"},
|
||||
{"Estimated Strategy Capacity", "$2600000.00"},
|
||||
{"Estimated Strategy Capacity", "$1300000.00"},
|
||||
{"Fitness Score", "0"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
|
||||
@@ -28,11 +28,11 @@ namespace QuantConnect.Algorithm.CSharp.Benchmarks
|
||||
_symbol = AddEquity("SPY").Symbol;
|
||||
}
|
||||
|
||||
public override void OnEndOfDay()
|
||||
public override void OnEndOfDay(Symbol symbol)
|
||||
{
|
||||
var minuteHistory = History(_symbol, 60, Resolution.Minute);
|
||||
var minuteHistory = History(symbol, 60, Resolution.Minute);
|
||||
var lastHourHigh = minuteHistory.Select(minuteBar => minuteBar.High).DefaultIfEmpty(0).Max();
|
||||
var dailyHistory = History(_symbol, 1, Resolution.Daily).First();
|
||||
var dailyHistory = History(symbol, 1, Resolution.Daily).First();
|
||||
var dailyHigh = dailyHistory.High;
|
||||
var dailyLow = dailyHistory.Low;
|
||||
var dailyOpen = dailyHistory.Open;
|
||||
|
||||
@@ -94,7 +94,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0.09"},
|
||||
{"Treynor Ratio", "0.82"},
|
||||
{"Total Fees", "$41.70"},
|
||||
{"Estimated Strategy Capacity", "$2000000.00"},
|
||||
{"Estimated Strategy Capacity", "$3000000.00"},
|
||||
{"Fitness Score", "0.634"},
|
||||
{"Kelly Criterion Estimate", "13.656"},
|
||||
{"Kelly Criterion Probability Value", "0.228"},
|
||||
|
||||
@@ -181,7 +181,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0.149"},
|
||||
{"Treynor Ratio", "-1.405"},
|
||||
{"Total Fees", "$2.00"},
|
||||
{"Estimated Strategy Capacity", "$6000000.00"},
|
||||
{"Estimated Strategy Capacity", "$42000000.00"},
|
||||
{"Fitness Score", "0.076"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
|
||||
@@ -136,7 +136,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0.126"},
|
||||
{"Treynor Ratio", "-0.607"},
|
||||
{"Total Fees", "$11.63"},
|
||||
{"Estimated Strategy Capacity", "$13000000.00"},
|
||||
{"Estimated Strategy Capacity", "$46000000.00"},
|
||||
{"Fitness Score", "0.013"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
|
||||
@@ -120,7 +120,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0.105"},
|
||||
{"Treynor Ratio", "1.667"},
|
||||
{"Total Fees", "$2.91"},
|
||||
{"Estimated Strategy Capacity", "$96000000.00"},
|
||||
{"Estimated Strategy Capacity", "$670000000.00"},
|
||||
{"Fitness Score", "0.141"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
|
||||
@@ -91,7 +91,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0.101"},
|
||||
{"Treynor Ratio", "5.409"},
|
||||
{"Total Fees", "$67.00"},
|
||||
{"Estimated Strategy Capacity", "$2400000.00"},
|
||||
{"Estimated Strategy Capacity", "$3200000.00"},
|
||||
{"Fitness Score", "0.501"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
|
||||
@@ -85,7 +85,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0.009"},
|
||||
{"Treynor Ratio", "1.575"},
|
||||
{"Total Fees", "$22.77"},
|
||||
{"Estimated Strategy Capacity", "$19000000.00"},
|
||||
{"Estimated Strategy Capacity", "$22000000.00"},
|
||||
{"Fitness Score", "0.999"},
|
||||
{"Kelly Criterion Estimate", "38.64"},
|
||||
{"Kelly Criterion Probability Value", "0.229"},
|
||||
|
||||
@@ -94,7 +94,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0.165"},
|
||||
{"Treynor Ratio", "1.212"},
|
||||
{"Total Fees", "$6.00"},
|
||||
{"Estimated Strategy Capacity", "$32000000.00"},
|
||||
{"Estimated Strategy Capacity", "$42000000.00"},
|
||||
{"Fitness Score", "0.063"},
|
||||
{"Kelly Criterion Estimate", "38.64"},
|
||||
{"Kelly Criterion Probability Value", "0.229"},
|
||||
|
||||
@@ -190,7 +190,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0.176"},
|
||||
{"Treynor Ratio", "-1.46"},
|
||||
{"Total Fees", "$7.82"},
|
||||
{"Estimated Strategy Capacity", "$6000000.00"},
|
||||
{"Estimated Strategy Capacity", "$12000000.00"},
|
||||
{"Fitness Score", "0.1"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
|
||||
@@ -146,7 +146,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0.239"},
|
||||
{"Treynor Ratio", "-1.435"},
|
||||
{"Total Fees", "$755.29"},
|
||||
{"Estimated Strategy Capacity", "$150000000.00"},
|
||||
{"Estimated Strategy Capacity", "$1100000000.00"},
|
||||
{"Fitness Score", "0.024"},
|
||||
{"Kelly Criterion Estimate", "-0.84"},
|
||||
{"Kelly Criterion Probability Value", "0.53"},
|
||||
|
||||
@@ -99,7 +99,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0.168"},
|
||||
{"Treynor Ratio", "2.38"},
|
||||
{"Total Fees", "$3.26"},
|
||||
{"Estimated Strategy Capacity", "$75000000.00"},
|
||||
{"Estimated Strategy Capacity", "$300000000.00"},
|
||||
{"Fitness Score", "0.245"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
|
||||
@@ -96,7 +96,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0"},
|
||||
{"Treynor Ratio", "0.988"},
|
||||
{"Total Fees", "$7.78"},
|
||||
{"Estimated Strategy Capacity", "$2200000.00"},
|
||||
{"Estimated Strategy Capacity", "$8700000.00"},
|
||||
{"Fitness Score", "0.031"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
|
||||
@@ -43,7 +43,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
security.SetBuyingPowerModel(new CustomBuyingPowerModel());
|
||||
}
|
||||
|
||||
public void OnData(Slice slice)
|
||||
public override void OnData(Slice slice)
|
||||
{
|
||||
if (Portfolio.Invested)
|
||||
{
|
||||
@@ -113,7 +113,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "1.04"},
|
||||
{"Treynor Ratio", "5.073"},
|
||||
{"Total Fees", "$30.00"},
|
||||
{"Estimated Strategy Capacity", "$2800000.00"},
|
||||
{"Estimated Strategy Capacity", "$20000000.00"},
|
||||
{"Fitness Score", "0.418"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
|
||||
@@ -80,7 +80,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// OnEndOfDay Event Handler - At the end of each trading day we fire this code.
|
||||
/// To avoid flooding, we recommend running your plotting at the end of each day.
|
||||
/// </summary>
|
||||
public override void OnEndOfDay()
|
||||
public override void OnEndOfDay(Symbol symbol)
|
||||
{
|
||||
//Log the end of day prices:
|
||||
Plot("Trade Plot", "Price", _lastPrice);
|
||||
|
||||
@@ -119,7 +119,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0.112"},
|
||||
{"Treynor Ratio", "-6.121"},
|
||||
{"Total Fees", "$3.50"},
|
||||
{"Estimated Strategy Capacity", "$6900000.00"},
|
||||
{"Estimated Strategy Capacity", "$48000000.00"},
|
||||
{"Fitness Score", "0"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
|
||||
@@ -124,7 +124,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0.112"},
|
||||
{"Treynor Ratio", "-6.121"},
|
||||
{"Total Fees", "$3.50"},
|
||||
{"Estimated Strategy Capacity", "$6900000.00"},
|
||||
{"Estimated Strategy Capacity", "$48000000.00"},
|
||||
{"Fitness Score", "0"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
|
||||
@@ -131,7 +131,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0.19"},
|
||||
{"Treynor Ratio", "2.159"},
|
||||
{"Total Fees", "$1.00"},
|
||||
{"Estimated Strategy Capacity", "$14000000.00"},
|
||||
{"Estimated Strategy Capacity", "$58000000.00"},
|
||||
{"Fitness Score", "0.1"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
|
||||
@@ -58,7 +58,9 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
//Weather used as a tradable asset, like stocks, futures etc.
|
||||
if (data.Close != 0)
|
||||
{
|
||||
Order("BTC", (Portfolio.MarginRemaining / Math.Abs(data.Close + 1)));
|
||||
// It's only OK to use SetHoldings with crypto when using custom data. When trading with built-in crypto data,
|
||||
// use the cashbook. Reference https://github.com/QuantConnect/Lean/blob/master/Algorithm.Python/BasicTemplateCryptoAlgorithm.py
|
||||
SetHoldings("BTC", 1);
|
||||
}
|
||||
Console.WriteLine("Buying BTC 'Shares': BTC: " + data.Close);
|
||||
}
|
||||
@@ -117,7 +119,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
|
||||
//return "http://my-ftp-server.com/futures-data-" + date.ToString("Ymd") + ".zip";
|
||||
// OR simply return a fixed small data file. Large files will slow down your backtest
|
||||
return new SubscriptionDataSource("https://www.quandl.com/api/v3/datasets/BCHARTS/BITSTAMPUSD.csv?order=asc", SubscriptionTransportMedium.RemoteFile);
|
||||
return new SubscriptionDataSource("https://www.quantconnect.com/api/v2/proxy/quandl/api/v3/datasets/BCHARTS/BITSTAMPUSD.csv?order=asc&api_key=WyAazVXnq7ATy_fefTqm", SubscriptionTransportMedium.RemoteFile);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -154,6 +156,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{
|
||||
string[] data = line.Split(',');
|
||||
coin.Time = DateTime.Parse(data[0], CultureInfo.InvariantCulture);
|
||||
coin.EndTime = coin.Time.AddDays(1);
|
||||
coin.Open = Convert.ToDecimal(data[1], CultureInfo.InvariantCulture);
|
||||
coin.High = Convert.ToDecimal(data[2], CultureInfo.InvariantCulture);
|
||||
coin.Low = Convert.ToDecimal(data[3], CultureInfo.InvariantCulture);
|
||||
|
||||
@@ -61,7 +61,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// "Nifty" type below and fired into this event handler.
|
||||
/// </summary>
|
||||
/// <param name="data">One(1) Nifty Object, streamed into our algorithm synchronised in time with our other data streams</param>
|
||||
public void OnData(Slice data)
|
||||
public override void OnData(Slice data)
|
||||
{
|
||||
if (data.ContainsKey("USDINR"))
|
||||
{
|
||||
@@ -77,7 +77,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{
|
||||
|
||||
_today.NiftyPrice = Convert.ToDouble(data["NIFTY"].Close);
|
||||
if (_today.Date == data["NIFTY"].EndTime)
|
||||
if (_today.Date == data["NIFTY"].Time)
|
||||
{
|
||||
_prices.Add(_today);
|
||||
|
||||
@@ -91,7 +91,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
var quantity = (int)(Portfolio.MarginRemaining * 0.9m / data["NIFTY"].Close);
|
||||
var highestNifty = (from pair in _prices select pair.NiftyPrice).Max();
|
||||
var lowestNifty = (from pair in _prices select pair.NiftyPrice).Min();
|
||||
|
||||
|
||||
if (Time.DayOfWeek == DayOfWeek.Wednesday) //prices.Count >= minimumCorrelationHistory &&
|
||||
{
|
||||
//List<double> niftyPrices = (from pair in prices select pair.NiftyPrice).ToList();
|
||||
@@ -121,7 +121,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// End of a trading day event handler. This method is called at the end of the algorithm day (or multiple times if trading multiple assets).
|
||||
/// </summary>
|
||||
/// <remarks>Method is called 10 minutes before closing to allow user to close out position.</remarks>
|
||||
public override void OnEndOfDay()
|
||||
public override void OnEndOfDay(Symbol symbol)
|
||||
{
|
||||
Plot("Nifty Closing Price", _today.NiftyPrice);
|
||||
}
|
||||
@@ -181,6 +181,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
//2011-09-13 7792.9 7799.9 7722.65 7748.7 116534670 6107.78
|
||||
var data = line.Split(',');
|
||||
index.Time = DateTime.Parse(data[0], CultureInfo.InvariantCulture);
|
||||
index.EndTime = index.Time.AddDays(1);
|
||||
index.Open = Convert.ToDecimal(data[1], CultureInfo.InvariantCulture);
|
||||
index.High = Convert.ToDecimal(data[2], CultureInfo.InvariantCulture);
|
||||
index.Low = Convert.ToDecimal(data[3], CultureInfo.InvariantCulture);
|
||||
@@ -247,6 +248,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{
|
||||
var data = line.Split(',');
|
||||
currency.Time = DateTime.Parse(data[0], CultureInfo.InvariantCulture);
|
||||
currency.EndTime = currency.Time.AddDays(1);
|
||||
currency.Close = Convert.ToDecimal(data[1], CultureInfo.InvariantCulture);
|
||||
currency.Symbol = "USDINR";
|
||||
currency.Value = currency.Close;
|
||||
|
||||
@@ -114,29 +114,29 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Total Trades", "1"},
|
||||
{"Average Win", "0%"},
|
||||
{"Average Loss", "0%"},
|
||||
{"Compounding Annual Return", "155.262%"},
|
||||
{"Compounding Annual Return", "157.498%"},
|
||||
{"Drawdown", "84.800%"},
|
||||
{"Expectancy", "0"},
|
||||
{"Net Profit", "5123.242%"},
|
||||
{"Sharpe Ratio", "2.067"},
|
||||
{"Probabilistic Sharpe Ratio", "68.833%"},
|
||||
{"Net Profit", "5319.081%"},
|
||||
{"Sharpe Ratio", "2.086"},
|
||||
{"Probabilistic Sharpe Ratio", "69.456%"},
|
||||
{"Loss Rate", "0%"},
|
||||
{"Win Rate", "0%"},
|
||||
{"Profit-Loss Ratio", "0"},
|
||||
{"Alpha", "1.732"},
|
||||
{"Beta", "0.037"},
|
||||
{"Annual Standard Deviation", "0.841"},
|
||||
{"Annual Variance", "0.707"},
|
||||
{"Information Ratio", "1.902"},
|
||||
{"Tracking Error", "0.848"},
|
||||
{"Treynor Ratio", "46.992"},
|
||||
{"Alpha", "1.736"},
|
||||
{"Beta", "0.136"},
|
||||
{"Annual Standard Deviation", "0.84"},
|
||||
{"Annual Variance", "0.706"},
|
||||
{"Information Ratio", "1.925"},
|
||||
{"Tracking Error", "0.846"},
|
||||
{"Treynor Ratio", "12.904"},
|
||||
{"Total Fees", "$0.00"},
|
||||
{"Estimated Strategy Capacity", "$0"},
|
||||
{"Fitness Score", "0"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
{"Sortino Ratio", "2.238"},
|
||||
{"Return Over Maximum Drawdown", "1.832"},
|
||||
{"Sortino Ratio", "2.269"},
|
||||
{"Return Over Maximum Drawdown", "1.858"},
|
||||
{"Portfolio Turnover", "0"},
|
||||
{"Total Insights Generated", "0"},
|
||||
{"Total Insights Closed", "0"},
|
||||
@@ -151,7 +151,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Mean Population Magnitude", "0%"},
|
||||
{"Rolling Averaged Population Direction", "0%"},
|
||||
{"Rolling Averaged Population Magnitude", "0%"},
|
||||
{"OrderListHash", "1f54fb75ebcc0daafa5d45bfbaa4fbcb"}
|
||||
{"OrderListHash", "0d80bb47bd16b5bc6989a4c1c7aa8349"}
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
@@ -243,6 +243,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{
|
||||
string[] data = line.Split(',');
|
||||
coin.Time = DateTime.Parse(data[0], CultureInfo.InvariantCulture);
|
||||
coin.EndTime = coin.Time.AddDays(1);
|
||||
coin.Open = Convert.ToDecimal(data[1], CultureInfo.InvariantCulture);
|
||||
coin.High = Convert.ToDecimal(data[2], CultureInfo.InvariantCulture);
|
||||
coin.Low = Convert.ToDecimal(data[3], CultureInfo.InvariantCulture);
|
||||
@@ -258,4 +259,4 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -84,29 +84,29 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Total Trades", "1"},
|
||||
{"Average Win", "0%"},
|
||||
{"Average Loss", "0%"},
|
||||
{"Compounding Annual Return", "155.262%"},
|
||||
{"Compounding Annual Return", "157.497%"},
|
||||
{"Drawdown", "84.800%"},
|
||||
{"Expectancy", "0"},
|
||||
{"Net Profit", "5123.170%"},
|
||||
{"Sharpe Ratio", "2.066"},
|
||||
{"Probabilistic Sharpe Ratio", "68.832%"},
|
||||
{"Net Profit", "5319.007%"},
|
||||
{"Sharpe Ratio", "2.086"},
|
||||
{"Probabilistic Sharpe Ratio", "69.456%"},
|
||||
{"Loss Rate", "0%"},
|
||||
{"Win Rate", "0%"},
|
||||
{"Profit-Loss Ratio", "0"},
|
||||
{"Alpha", "1.732"},
|
||||
{"Beta", "0.037"},
|
||||
{"Annual Standard Deviation", "0.841"},
|
||||
{"Annual Variance", "0.707"},
|
||||
{"Information Ratio", "1.902"},
|
||||
{"Tracking Error", "0.848"},
|
||||
{"Treynor Ratio", "46.996"},
|
||||
{"Alpha", "1.736"},
|
||||
{"Beta", "0.136"},
|
||||
{"Annual Standard Deviation", "0.84"},
|
||||
{"Annual Variance", "0.706"},
|
||||
{"Information Ratio", "1.925"},
|
||||
{"Tracking Error", "0.846"},
|
||||
{"Treynor Ratio", "12.903"},
|
||||
{"Total Fees", "$0.00"},
|
||||
{"Estimated Strategy Capacity", "$0"},
|
||||
{"Fitness Score", "0"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
{"Sortino Ratio", "2.238"},
|
||||
{"Return Over Maximum Drawdown", "1.832"},
|
||||
{"Sortino Ratio", "2.269"},
|
||||
{"Return Over Maximum Drawdown", "1.858"},
|
||||
{"Portfolio Turnover", "0"},
|
||||
{"Total Insights Generated", "0"},
|
||||
{"Total Insights Closed", "0"},
|
||||
@@ -121,7 +121,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Mean Population Magnitude", "0%"},
|
||||
{"Rolling Averaged Population Direction", "0%"},
|
||||
{"Rolling Averaged Population Magnitude", "0%"},
|
||||
{"OrderListHash", "0e7d560d0db2829adb19d3e403c30d97"}
|
||||
{"OrderListHash", "50faa37f15732bf5c24ad1eeaa335bc7"}
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
@@ -213,6 +213,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{
|
||||
string[] data = line.Split(',');
|
||||
coin.Time = DateTime.Parse(data[0], CultureInfo.InvariantCulture);
|
||||
coin.EndTime = coin.Time.AddDays(1);
|
||||
coin.Open = Convert.ToDecimal(data[1], CultureInfo.InvariantCulture);
|
||||
coin.High = Convert.ToDecimal(data[2], CultureInfo.InvariantCulture);
|
||||
coin.Low = Convert.ToDecimal(data[3], CultureInfo.InvariantCulture);
|
||||
@@ -228,4 +229,4 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -212,7 +212,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0.118"},
|
||||
{"Treynor Ratio", "-0.591"},
|
||||
{"Total Fees", "$62.24"},
|
||||
{"Estimated Strategy Capacity", "$100000000.00"},
|
||||
{"Estimated Strategy Capacity", "$49000000.00"},
|
||||
{"Fitness Score", "0.147"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
|
||||
@@ -103,7 +103,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0.251"},
|
||||
{"Treynor Ratio", "9.323"},
|
||||
{"Total Fees", "$3.26"},
|
||||
{"Estimated Strategy Capacity", "$220000000.00"},
|
||||
{"Estimated Strategy Capacity", "$890000000.00"},
|
||||
{"Fitness Score", "0.201"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
|
||||
@@ -113,7 +113,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0.08"},
|
||||
{"Treynor Ratio", "0.517"},
|
||||
{"Total Fees", "$3.70"},
|
||||
{"Estimated Strategy Capacity", "$38000000.00"},
|
||||
{"Estimated Strategy Capacity", "$270000000.00"},
|
||||
{"Fitness Score", "0.019"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
|
||||
@@ -123,7 +123,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0.115"},
|
||||
{"Treynor Ratio", "1.545"},
|
||||
{"Total Fees", "$37.00"},
|
||||
{"Estimated Strategy Capacity", "$58000.00"},
|
||||
{"Estimated Strategy Capacity", "$400000.00"},
|
||||
{"Fitness Score", "0"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
|
||||
@@ -186,7 +186,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0.204"},
|
||||
{"Treynor Ratio", "-8.165"},
|
||||
{"Total Fees", "$46.75"},
|
||||
{"Estimated Strategy Capacity", "$96000000.00"},
|
||||
{"Estimated Strategy Capacity", "$670000000.00"},
|
||||
{"Fitness Score", "0.002"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
|
||||
@@ -204,7 +204,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0.171"},
|
||||
{"Treynor Ratio", "-1.761"},
|
||||
{"Total Fees", "$8669.41"},
|
||||
{"Estimated Strategy Capacity", "$170000.00"},
|
||||
{"Estimated Strategy Capacity", "$320000.00"},
|
||||
{"Fitness Score", "0.675"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
|
||||
@@ -177,7 +177,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0.171"},
|
||||
{"Treynor Ratio", "-1.971"},
|
||||
{"Total Fees", "$6806.67"},
|
||||
{"Estimated Strategy Capacity", "$150000.00"},
|
||||
{"Estimated Strategy Capacity", "$320000.00"},
|
||||
{"Fitness Score", "0.694"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
|
||||
@@ -131,7 +131,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0.29"},
|
||||
{"Treynor Ratio", "4.005"},
|
||||
{"Total Fees", "$18.28"},
|
||||
{"Estimated Strategy Capacity", "$200000000.00"},
|
||||
{"Estimated Strategy Capacity", "$500000000.00"},
|
||||
{"Fitness Score", "0.052"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
|
||||
@@ -127,7 +127,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0.204"},
|
||||
{"Treynor Ratio", "-1.424"},
|
||||
{"Total Fees", "$16.26"},
|
||||
{"Estimated Strategy Capacity", "$250000000.00"},
|
||||
{"Estimated Strategy Capacity", "$590000000.00"},
|
||||
{"Fitness Score", "0.003"},
|
||||
{"Kelly Criterion Estimate", "12.539"},
|
||||
{"Kelly Criterion Probability Value", "0.367"},
|
||||
|
||||
@@ -148,7 +148,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "1.441"},
|
||||
{"Treynor Ratio", "-0.15"},
|
||||
{"Total Fees", "$33.30"},
|
||||
{"Estimated Strategy Capacity", "$4200000.00"},
|
||||
{"Estimated Strategy Capacity", "$17000000.00"},
|
||||
{"Fitness Score", "0.079"},
|
||||
{"Kelly Criterion Estimate", "-9.366"},
|
||||
{"Kelly Criterion Probability Value", "0.607"},
|
||||
|
||||
@@ -184,7 +184,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0.123"},
|
||||
{"Treynor Ratio", "-1.288"},
|
||||
{"Total Fees", "$669.76"},
|
||||
{"Estimated Strategy Capacity", "$8100000.00"},
|
||||
{"Estimated Strategy Capacity", "$210000.00"},
|
||||
{"Fitness Score", "0.021"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
|
||||
@@ -147,7 +147,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0.049"},
|
||||
{"Treynor Ratio", "-0.934"},
|
||||
{"Total Fees", "$22.26"},
|
||||
{"Estimated Strategy Capacity", "$3600000.00"},
|
||||
{"Estimated Strategy Capacity", "$360000.00"},
|
||||
{"Fitness Score", "0.002"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
|
||||
@@ -122,7 +122,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0.186"},
|
||||
{"Treynor Ratio", "1.557"},
|
||||
{"Total Fees", "$4.00"},
|
||||
{"Estimated Strategy Capacity", "$1400000.00"},
|
||||
{"Estimated Strategy Capacity", "$5200000.00"},
|
||||
{"Fitness Score", "0.012"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
|
||||
@@ -174,7 +174,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0"},
|
||||
{"Treynor Ratio", "0"},
|
||||
{"Total Fees", "$804.33"},
|
||||
{"Estimated Strategy Capacity", "$21000.00"},
|
||||
{"Estimated Strategy Capacity", "$11000.00"},
|
||||
{"Fitness Score", "0.504"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
|
||||
@@ -98,7 +98,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0"},
|
||||
{"Treynor Ratio", "0"},
|
||||
{"Total Fees", "$5.93"},
|
||||
{"Estimated Strategy Capacity", "$200000.00"},
|
||||
{"Estimated Strategy Capacity", "$590000.00"},
|
||||
{"Fitness Score", "0.499"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
|
||||
@@ -105,7 +105,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0.394"},
|
||||
{"Treynor Ratio", "-5.313"},
|
||||
{"Total Fees", "$5.40"},
|
||||
{"Estimated Strategy Capacity", "$59000000.00"},
|
||||
{"Estimated Strategy Capacity", "$230000000.00"},
|
||||
{"Fitness Score", "0.244"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
|
||||
@@ -118,7 +118,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0.507"},
|
||||
{"Treynor Ratio", "0"},
|
||||
{"Total Fees", "$2651.01"},
|
||||
{"Estimated Strategy Capacity", "$9800.00"},
|
||||
{"Estimated Strategy Capacity", "$30000.00"},
|
||||
{"Fitness Score", "0.467"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
|
||||
@@ -99,7 +99,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0.267"},
|
||||
{"Treynor Ratio", "-0.847"},
|
||||
{"Total Fees", "$41.17"},
|
||||
{"Estimated Strategy Capacity", "$98000000.00"},
|
||||
{"Estimated Strategy Capacity", "$340000000.00"},
|
||||
{"Fitness Score", "0"},
|
||||
{"Kelly Criterion Estimate", "38.884"},
|
||||
{"Kelly Criterion Probability Value", "0.009"},
|
||||
|
||||
@@ -138,7 +138,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0.195"},
|
||||
{"Treynor Ratio", "55.977"},
|
||||
{"Total Fees", "$14.80"},
|
||||
{"Estimated Strategy Capacity", "$2100000.00"},
|
||||
{"Estimated Strategy Capacity", "$15000000.00"},
|
||||
{"Fitness Score", "0.018"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
|
||||
@@ -222,7 +222,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0.191"},
|
||||
{"Treynor Ratio", "33.18"},
|
||||
{"Total Fees", "$7.40"},
|
||||
{"Estimated Strategy Capacity", "$1300000.00"},
|
||||
{"Estimated Strategy Capacity", "$9000000.00"},
|
||||
{"Fitness Score", "0.008"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
|
||||
@@ -180,7 +180,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0.718"},
|
||||
{"Treynor Ratio", "18.473"},
|
||||
{"Total Fees", "$66.60"},
|
||||
{"Estimated Strategy Capacity", "$1200000.00"},
|
||||
{"Estimated Strategy Capacity", "$8300000.00"},
|
||||
{"Fitness Score", "0.162"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
|
||||
@@ -197,7 +197,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0.182"},
|
||||
{"Treynor Ratio", "28.46"},
|
||||
{"Total Fees", "$3.70"},
|
||||
{"Estimated Strategy Capacity", "$830000.00"},
|
||||
{"Estimated Strategy Capacity", "$5800000.00"},
|
||||
{"Fitness Score", "0"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
|
||||
@@ -223,7 +223,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0.183"},
|
||||
{"Treynor Ratio", "37.798"},
|
||||
{"Total Fees", "$7.40"},
|
||||
{"Estimated Strategy Capacity", "$1400000.00"},
|
||||
{"Estimated Strategy Capacity", "$9900000.00"},
|
||||
{"Fitness Score", "0.008"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
|
||||
@@ -196,7 +196,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0.187"},
|
||||
{"Treynor Ratio", "28.078"},
|
||||
{"Total Fees", "$3.70"},
|
||||
{"Estimated Strategy Capacity", "$1200000.00"},
|
||||
{"Estimated Strategy Capacity", "$8700000.00"},
|
||||
{"Fitness Score", "0"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
|
||||
@@ -207,7 +207,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0.183"},
|
||||
{"Treynor Ratio", "22.266"},
|
||||
{"Total Fees", "$7.40"},
|
||||
{"Estimated Strategy Capacity", "$1900000.00"},
|
||||
{"Estimated Strategy Capacity", "$13000000.00"},
|
||||
{"Fitness Score", "0.021"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
|
||||
@@ -190,7 +190,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0.176"},
|
||||
{"Treynor Ratio", "27.339"},
|
||||
{"Total Fees", "$3.70"},
|
||||
{"Estimated Strategy Capacity", "$460000.00"},
|
||||
{"Estimated Strategy Capacity", "$3200000.00"},
|
||||
{"Fitness Score", "0"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
|
||||
@@ -204,7 +204,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0.176"},
|
||||
{"Treynor Ratio", "14.729"},
|
||||
{"Total Fees", "$7.40"},
|
||||
{"Estimated Strategy Capacity", "$1900000.00"},
|
||||
{"Estimated Strategy Capacity", "$14000000.00"},
|
||||
{"Fitness Score", "0.022"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
|
||||
@@ -189,7 +189,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0.179"},
|
||||
{"Treynor Ratio", "28.253"},
|
||||
{"Total Fees", "$3.70"},
|
||||
{"Estimated Strategy Capacity", "$770000.00"},
|
||||
{"Estimated Strategy Capacity", "$5400000.00"},
|
||||
{"Fitness Score", "0"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
|
||||
@@ -102,7 +102,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0.332"},
|
||||
{"Treynor Ratio", "2.021"},
|
||||
{"Total Fees", "$1.85"},
|
||||
{"Estimated Strategy Capacity", "$47000000.00"},
|
||||
{"Estimated Strategy Capacity", "$93000000.00"},
|
||||
{"Fitness Score", "0.005"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
|
||||
@@ -173,7 +173,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0.176"},
|
||||
{"Treynor Ratio", "29.128"},
|
||||
{"Total Fees", "$7.40"},
|
||||
{"Estimated Strategy Capacity", "$10000000.00"},
|
||||
{"Estimated Strategy Capacity", "$71000000.00"},
|
||||
{"Fitness Score", "0.007"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
|
||||
@@ -92,7 +92,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnEndOfDay()
|
||||
public override void OnEndOfDay(Symbol symbol)
|
||||
{
|
||||
Plot("Indicator Signal", "EOD", IsDownTrend ? -1 : IsUpTrend ? 1 : 0);
|
||||
}
|
||||
|
||||
@@ -41,7 +41,9 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
// Without this, consuming projects would need to hard reference the Accord dlls,
|
||||
// which is less than perfect. This seems to be the better of two evils
|
||||
//
|
||||
#pragma warning disable 0414
|
||||
Accord.Math.Matrix3x3 _matrix = new Accord.Math.Matrix3x3();
|
||||
#pragma warning restore 0414
|
||||
|
||||
//Fuzzy Engine
|
||||
private FuzzyEngine _engine;
|
||||
|
||||
@@ -317,7 +317,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0.264"},
|
||||
{"Treynor Ratio", "26.924"},
|
||||
{"Total Fees", "$3.26"},
|
||||
{"Estimated Strategy Capacity", "$300000000.00"},
|
||||
{"Estimated Strategy Capacity", "$890000000.00"},
|
||||
{"Fitness Score", "0.251"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
|
||||
@@ -106,7 +106,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0.866"},
|
||||
{"Treynor Ratio", "-0.286"},
|
||||
{"Total Fees", "$5.40"},
|
||||
{"Estimated Strategy Capacity", "$350000.00"},
|
||||
{"Estimated Strategy Capacity", "$2400000.00"},
|
||||
{"Fitness Score", "0.008"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
|
||||
@@ -128,7 +128,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0"},
|
||||
{"Treynor Ratio", "0"},
|
||||
{"Total Fees", "$1.00"},
|
||||
{"Estimated Strategy Capacity", "$12000000000.00"},
|
||||
{"Estimated Strategy Capacity", "$36000000000.00"},
|
||||
{"Fitness Score", "0"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
|
||||
@@ -116,7 +116,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0.073"},
|
||||
{"Treynor Ratio", "0.573"},
|
||||
{"Total Fees", "$14.75"},
|
||||
{"Estimated Strategy Capacity", "$1300000.00"},
|
||||
{"Estimated Strategy Capacity", "$6300000.00"},
|
||||
{"Fitness Score", "0.2"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
|
||||
@@ -51,7 +51,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
.Take(1)
|
||||
.Single(), Resolution.Minute);
|
||||
|
||||
_spxOption.PriceModel = OptionPriceModels.BjerksundStensland();
|
||||
_spxOption.PriceModel = OptionPriceModels.BlackScholes();
|
||||
|
||||
_expectedOptionContract = QuantConnect.Symbol.CreateOption(_spx, Market.USA, OptionStyle.European, OptionRight.Call, 3200m, new DateTime(2021, 1, 15));
|
||||
if (_spxOption.Symbol != _expectedOptionContract)
|
||||
@@ -90,16 +90,16 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
var vega = data.OptionChains.Values.OrderByDescending(y => y.Contracts.Values.Sum(x => x.Volume)).First().Contracts.Values.Select(x => x.Greeks.Vega).ToList();
|
||||
|
||||
// The commented out test cases all return zero.
|
||||
// This is because of failure to evaluate the greeks in the option pricing model.
|
||||
// For now, let's skip those.
|
||||
// This is because of failure to evaluate the greeks in the option pricing model, most likely
|
||||
// due to us not clearing the default 30 day requirement for the volatility model to start being updated.
|
||||
if (deltas.Any(d => d == 0))
|
||||
{
|
||||
throw new AggregateException("Option contract Delta was equal to zero");
|
||||
}
|
||||
if (gammas.Any(g => g == 0))
|
||||
{
|
||||
throw new AggregateException("Option contract Gamma was equal to zero");
|
||||
}
|
||||
//if (gammas.Any(g => g == 0))
|
||||
//{
|
||||
// throw new AggregateException("Option contract Gamma was equal to zero");
|
||||
//}
|
||||
//if (lambda.Any(l => l == 0))
|
||||
//{
|
||||
// throw new AggregateException("Option contract Lambda was equal to zero");
|
||||
@@ -108,10 +108,10 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{
|
||||
throw new AggregateException("Option contract Rho was equal to zero");
|
||||
}
|
||||
//if (theta.Any(t => t == 0))
|
||||
//{
|
||||
// throw new AggregateException("Option contract Theta was equal to zero");
|
||||
//}
|
||||
if (theta.Any(t => t == 0))
|
||||
{
|
||||
throw new AggregateException("Option contract Theta was equal to zero");
|
||||
}
|
||||
//if (vega.Any(v => v == 0))
|
||||
//{
|
||||
// throw new AggregateException("Option contract Vega was equal to zero");
|
||||
@@ -148,40 +148,40 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate which languages this algorithm is written in.
|
||||
/// </summary>
|
||||
public Language[] Languages { get; } = { Language.CSharp };
|
||||
public 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", "3"},
|
||||
{"Average Win", "27.44%"},
|
||||
{"Average Loss", "-62.81%"},
|
||||
{"Compounding Annual Return", "-80.444%"},
|
||||
{"Drawdown", "52.600%"},
|
||||
{"Expectancy", "-0.282"},
|
||||
{"Net Profit", "-52.604%"},
|
||||
{"Sharpe Ratio", "-0.867"},
|
||||
{"Probabilistic Sharpe Ratio", "0.021%"},
|
||||
{"Loss Rate", "50%"},
|
||||
{"Win Rate", "50%"},
|
||||
{"Profit-Loss Ratio", "0.44"},
|
||||
{"Alpha", "-0.611"},
|
||||
{"Beta", "-0.033"},
|
||||
{"Annual Standard Deviation", "0.695"},
|
||||
{"Annual Variance", "0.484"},
|
||||
{"Information Ratio", "-0.513"},
|
||||
{"Tracking Error", "0.718"},
|
||||
{"Treynor Ratio", "18.473"},
|
||||
{"Total Fees", "$66.60"},
|
||||
{"Estimated Strategy Capacity", "$1200000.00"},
|
||||
{"Fitness Score", "0.162"},
|
||||
{"Total Trades", "2"},
|
||||
{"Average Win", "0%"},
|
||||
{"Average Loss", "-56.91%"},
|
||||
{"Compounding Annual Return", "44.906%"},
|
||||
{"Drawdown", "9.800%"},
|
||||
{"Expectancy", "-1"},
|
||||
{"Net Profit", "2.644%"},
|
||||
{"Sharpe Ratio", "7.691"},
|
||||
{"Probabilistic Sharpe Ratio", "91.027%"},
|
||||
{"Loss Rate", "100%"},
|
||||
{"Win Rate", "0%"},
|
||||
{"Profit-Loss Ratio", "0"},
|
||||
{"Alpha", "0"},
|
||||
{"Beta", "0"},
|
||||
{"Annual Standard Deviation", "0.417"},
|
||||
{"Annual Variance", "0.174"},
|
||||
{"Information Ratio", "7.691"},
|
||||
{"Tracking Error", "0.417"},
|
||||
{"Treynor Ratio", "0"},
|
||||
{"Total Fees", "$0.00"},
|
||||
{"Estimated Strategy Capacity", "$46000000.00"},
|
||||
{"Fitness Score", "0.023"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
{"Sortino Ratio", "-0.136"},
|
||||
{"Return Over Maximum Drawdown", "-1.529"},
|
||||
{"Portfolio Turnover", "0.427"},
|
||||
{"Sortino Ratio", "0.535"},
|
||||
{"Return Over Maximum Drawdown", "5.789"},
|
||||
{"Portfolio Turnover", "0.03"},
|
||||
{"Total Insights Generated", "0"},
|
||||
{"Total Insights Closed", "0"},
|
||||
{"Total Insights Analysis Completed", "0"},
|
||||
@@ -195,7 +195,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Mean Population Magnitude", "0%"},
|
||||
{"Rolling Averaged Population Direction", "0%"},
|
||||
{"Rolling Averaged Population Magnitude", "0%"},
|
||||
{"OrderListHash", "a7f76d1e2d6f27651465217c92deea80"}
|
||||
{"OrderListHash", "3cccf8c2409ee8a9020ba79a6c45742a"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -192,7 +192,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0"},
|
||||
{"Treynor Ratio", "0"},
|
||||
{"Total Fees", "$0.00"},
|
||||
{"Estimated Strategy Capacity", "$3300.00"},
|
||||
{"Estimated Strategy Capacity", "$23000.00"},
|
||||
{"Fitness Score", "0"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
|
||||
@@ -185,7 +185,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0"},
|
||||
{"Treynor Ratio", "0"},
|
||||
{"Total Fees", "$0.00"},
|
||||
{"Estimated Strategy Capacity", "$3300.00"},
|
||||
{"Estimated Strategy Capacity", "$23000.00"},
|
||||
{"Fitness Score", "0"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
|
||||
@@ -158,8 +158,10 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// Fire plotting events once per day.
|
||||
/// </summary>
|
||||
public override void OnEndOfDay()
|
||||
public override void OnEndOfDay(Symbol symbol)
|
||||
{
|
||||
if (symbol != _symbol) return;
|
||||
|
||||
if (!_indicators.BB.IsReady) return;
|
||||
|
||||
Plot("BB", "Price", _price);
|
||||
@@ -261,7 +263,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0.146"},
|
||||
{"Treynor Ratio", "-2.677"},
|
||||
{"Total Fees", "$1.00"},
|
||||
{"Estimated Strategy Capacity", "$75000000.00"},
|
||||
{"Estimated Strategy Capacity", "$530000000.00"},
|
||||
{"Fitness Score", "0.001"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
|
||||
@@ -94,7 +94,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0.165"},
|
||||
{"Treynor Ratio", "1.212"},
|
||||
{"Total Fees", "$6.00"},
|
||||
{"Estimated Strategy Capacity", "$32000000.00"},
|
||||
{"Estimated Strategy Capacity", "$42000000.00"},
|
||||
{"Fitness Score", "0.063"},
|
||||
{"Kelly Criterion Estimate", "38.64"},
|
||||
{"Kelly Criterion Probability Value", "0.229"},
|
||||
|
||||
@@ -102,7 +102,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0"},
|
||||
{"Treynor Ratio", "1.925"},
|
||||
{"Total Fees", "$61.90"},
|
||||
{"Estimated Strategy Capacity", "$2900000.00"},
|
||||
{"Estimated Strategy Capacity", "$5800000.00"},
|
||||
{"Fitness Score", "0.979"},
|
||||
{"Kelly Criterion Estimate", "38.64"},
|
||||
{"Kelly Criterion Probability Value", "0.229"},
|
||||
|
||||
@@ -100,7 +100,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0.196"},
|
||||
{"Treynor Ratio", "-0.169"},
|
||||
{"Total Fees", "$34.00"},
|
||||
{"Estimated Strategy Capacity", "$460000000.00"},
|
||||
{"Estimated Strategy Capacity", "$180000000.00"},
|
||||
{"Fitness Score", "0.008"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
|
||||
@@ -145,7 +145,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0.22"},
|
||||
{"Treynor Ratio", "3.431"},
|
||||
{"Total Fees", "$3.00"},
|
||||
{"Estimated Strategy Capacity", "$480000000.00"},
|
||||
{"Estimated Strategy Capacity", "$1900000000.00"},
|
||||
{"Fitness Score", "0"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
|
||||
@@ -118,7 +118,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0.004"},
|
||||
{"Treynor Ratio", "1.577"},
|
||||
{"Total Fees", "$293.06"},
|
||||
{"Estimated Strategy Capacity", "$19000000.00"},
|
||||
{"Estimated Strategy Capacity", "$14000000.00"},
|
||||
{"Fitness Score", "0.999"},
|
||||
{"Kelly Criterion Estimate", "-6.994"},
|
||||
{"Kelly Criterion Probability Value", "0.593"},
|
||||
|
||||
@@ -118,7 +118,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0.214"},
|
||||
{"Treynor Ratio", "-0.774"},
|
||||
{"Total Fees", "$443.74"},
|
||||
{"Estimated Strategy Capacity", "$110000000.00"},
|
||||
{"Estimated Strategy Capacity", "$750000000.00"},
|
||||
{"Fitness Score", "0.013"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
|
||||
@@ -135,7 +135,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0.224"},
|
||||
{"Treynor Ratio", "3.851"},
|
||||
{"Total Fees", "$26.01"},
|
||||
{"Estimated Strategy Capacity", "$11000000.00"},
|
||||
{"Estimated Strategy Capacity", "$22000000.00"},
|
||||
{"Fitness Score", "0.999"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
|
||||
@@ -105,7 +105,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0.346"},
|
||||
{"Treynor Ratio", "-0.863"},
|
||||
{"Total Fees", "$13.69"},
|
||||
{"Estimated Strategy Capacity", "$1800000.00"},
|
||||
{"Estimated Strategy Capacity", "$13000000.00"},
|
||||
{"Fitness Score", "0"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
|
||||
@@ -85,7 +85,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0.005"},
|
||||
{"Treynor Ratio", "1.772"},
|
||||
{"Total Fees", "$16.28"},
|
||||
{"Estimated Strategy Capacity", "$17000000.00"},
|
||||
{"Estimated Strategy Capacity", "$14000000.00"},
|
||||
{"Fitness Score", "0.999"},
|
||||
{"Kelly Criterion Estimate", "38.64"},
|
||||
{"Kelly Criterion Probability Value", "0.229"},
|
||||
|
||||
@@ -103,7 +103,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0.1"},
|
||||
{"Treynor Ratio", "3.315"},
|
||||
{"Total Fees", "$27.72"},
|
||||
{"Estimated Strategy Capacity", "$8600000.00"},
|
||||
{"Estimated Strategy Capacity", "$25000000.00"},
|
||||
{"Fitness Score", "0.688"},
|
||||
{"Kelly Criterion Estimate", "13.656"},
|
||||
{"Kelly Criterion Probability Value", "0.228"},
|
||||
|
||||
@@ -151,7 +151,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// End of a trading day event handler. This method is called at the end of the algorithm day (or multiple times if trading multiple assets).
|
||||
/// </summary>
|
||||
/// <remarks>Method is called 10 minutes before closing to allow user to close out position.</remarks>
|
||||
public override void OnEndOfDay()
|
||||
public override void OnEndOfDay(Symbol symbol)
|
||||
{
|
||||
int i = 0;
|
||||
foreach (var kvp in Data.OrderBy(x => x.Value.Symbol))
|
||||
|
||||
87
Algorithm.CSharp/NamedArgumentsRegression.cs
Normal file
87
Algorithm.CSharp/NamedArgumentsRegression.cs
Normal file
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
* 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>
|
||||
/// Regression Definition for Python NamedArgumentsRegression
|
||||
/// Used to test PythonNet kwargs
|
||||
/// </summary>
|
||||
/// <meta name="tag" content="using data" />
|
||||
public class NamedArgumentsRegression : IRegressionAlgorithmDefinition
|
||||
{
|
||||
/// <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.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", "246.000%"},
|
||||
{"Drawdown", "1.100%"},
|
||||
{"Expectancy", "0"},
|
||||
{"Net Profit", "3.459%"},
|
||||
{"Sharpe Ratio", "10.11"},
|
||||
{"Probabilistic Sharpe Ratio", "83.150%"},
|
||||
{"Loss Rate", "0%"},
|
||||
{"Win Rate", "0%"},
|
||||
{"Profit-Loss Ratio", "0"},
|
||||
{"Alpha", "1.935"},
|
||||
{"Beta", "-0.119"},
|
||||
{"Annual Standard Deviation", "0.16"},
|
||||
{"Annual Variance", "0.026"},
|
||||
{"Information Ratio", "-4.556"},
|
||||
{"Tracking Error", "0.221"},
|
||||
{"Treynor Ratio", "-13.568"},
|
||||
{"Total Fees", "$3.26"},
|
||||
{"Estimated Strategy Capacity", "$890000000.00"},
|
||||
{"Fitness Score", "0.111"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
{"Sortino Ratio", "52.533"},
|
||||
{"Return Over Maximum Drawdown", "214.75"},
|
||||
{"Portfolio Turnover", "0.111"},
|
||||
{"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", "82fee25cd17100c53bb173834ab5f0b2"}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -121,7 +121,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0.611"},
|
||||
{"Treynor Ratio", "9.236"},
|
||||
{"Total Fees", "$103.34"},
|
||||
{"Estimated Strategy Capacity", "$9500000.00"},
|
||||
{"Estimated Strategy Capacity", "$8000000.00"},
|
||||
{"Fitness Score", "0.999"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
|
||||
@@ -30,7 +30,6 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
private int _onEndOfDaySpyCallCount;
|
||||
private int _onEndOfDayBacCallCount;
|
||||
private int _onEndOfDayIbmCallCount;
|
||||
private int _onEndOfDayCallCount;
|
||||
|
||||
/// <summary>
|
||||
/// Initialise the data and resolution required, as well as the cash and start-end dates for your algorithm. All algorithms must initialized.
|
||||
@@ -55,14 +54,6 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Obsolete overload to be removed.
|
||||
/// </summary>
|
||||
public override void OnEndOfDay()
|
||||
{
|
||||
_onEndOfDayCallCount++;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// We expect it to be called for the universe selected <see cref="Symbol"/>
|
||||
/// and the post initialize manually added equity <see cref="Symbol"/>
|
||||
@@ -115,10 +106,6 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{
|
||||
throw new Exception($"OnEndOfDay(IBM) unexpected count call {_onEndOfDayIbmCallCount}");
|
||||
}
|
||||
if (_onEndOfDayCallCount != 4)
|
||||
{
|
||||
throw new Exception($"OnEndOfDay() unexpected count call {_onEndOfDayCallCount}");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -156,7 +143,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0.07"},
|
||||
{"Treynor Ratio", "3.602"},
|
||||
{"Total Fees", "$20.75"},
|
||||
{"Estimated Strategy Capacity", "$1300000.00"},
|
||||
{"Estimated Strategy Capacity", "$5200000.00"},
|
||||
{"Fitness Score", "0.249"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
|
||||
@@ -55,6 +55,8 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <meta name="tag" content="indicators" />
|
||||
public class OpeningBreakoutAlgorithm : QCAlgorithm
|
||||
{
|
||||
#pragma warning disable 00162 // File contains unreachable code when EnableOrderUpdateLogging is false
|
||||
|
||||
// the equity symbol we're trading
|
||||
private const string symbol = "SPY";
|
||||
|
||||
@@ -396,9 +398,9 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// If we're still invested by the end of the day, liquidate
|
||||
/// </summary>
|
||||
public override void OnEndOfDay()
|
||||
public override void OnEndOfDay(Symbol symbol)
|
||||
{
|
||||
if (Security.Invested)
|
||||
if (symbol == Security.Symbol && Security.Invested)
|
||||
{
|
||||
Liquidate();
|
||||
}
|
||||
@@ -544,5 +546,6 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
return (Security.Holdings.IsLong && PSARMin > stopPrice)
|
||||
|| (Security.Holdings.IsShort && PSARMin < stopPrice);
|
||||
}
|
||||
#pragma warning restore 00162
|
||||
}
|
||||
}
|
||||
@@ -97,7 +97,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0"},
|
||||
{"Treynor Ratio", "0"},
|
||||
{"Total Fees", "$12.00"},
|
||||
{"Estimated Strategy Capacity", "$3100000.00"},
|
||||
{"Estimated Strategy Capacity", "$310000.00"},
|
||||
{"Fitness Score", "0.5"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
|
||||
@@ -141,7 +141,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0"},
|
||||
{"Treynor Ratio", "0"},
|
||||
{"Total Fees", "$2.00"},
|
||||
{"Estimated Strategy Capacity", "$9800.00"},
|
||||
{"Estimated Strategy Capacity", "$4900.00"},
|
||||
{"Fitness Score", "0"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
|
||||
@@ -117,7 +117,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0.044"},
|
||||
{"Treynor Ratio", "-0.336"},
|
||||
{"Total Fees", "$1.00"},
|
||||
{"Estimated Strategy Capacity", "$890000000.00"},
|
||||
{"Estimated Strategy Capacity", "$3600000000.00"},
|
||||
{"Fitness Score", "0.003"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
|
||||
@@ -163,7 +163,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0.002"},
|
||||
{"Treynor Ratio", "0"},
|
||||
{"Total Fees", "$4.00"},
|
||||
{"Estimated Strategy Capacity", "$190000.00"},
|
||||
{"Estimated Strategy Capacity", "$760000.00"},
|
||||
{"Fitness Score", "0"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user