Skip to content

Commit

Permalink
Adds EWPCM Usage Examples in BasicTemplateFrameworkAlgorithm
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexCatarino committed Oct 24, 2019
1 parent f02b399 commit 7258891
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
10 changes: 9 additions & 1 deletion Algorithm.CSharp/BasicTemplateFrameworkAlgorithm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,15 @@ public override void Initialize()
// set algorithm framework models
SetUniverseSelection(new ManualUniverseSelectionModel(QuantConnect.Symbol.Create("SPY", SecurityType.Equity, Market.USA)));
SetAlpha(new ConstantAlphaModel(InsightType.Price, InsightDirection.Up, TimeSpan.FromMinutes(20), 0.025, null));
SetPortfolioConstruction(new EqualWeightingPortfolioConstructionModel());

// We can define who often the EWPCM will rebalance if no new insight is submitted using:
// Resolution Enum:
SetPortfolioConstruction(new EqualWeightingPortfolioConstructionModel(Resolution.Daily));
// TimeSpan
// SetPortfolioConstruction(new EqualWeightingPortfolioConstructionModel(TimeSpan.FromDays(2)));
// A Func<DateTime, DateTime>. In this case, we can use the pre-defined func at Expiry helper class
// SetPortfolioConstruction(new EqualWeightingPortfolioConstructionModel(Expiry.EndOfWeek));

SetExecution(new ImmediateExecutionModel());
SetRiskManagement(new MaximumDrawdownPercentPerSecurity(0.01m));
}
Expand Down
10 changes: 9 additions & 1 deletion Algorithm.Python/BasicTemplateFrameworkAlgorithm.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,15 @@ def Initialize(self):
# set algorithm framework models
self.SetUniverseSelection(ManualUniverseSelectionModel(symbols))
self.SetAlpha(ConstantAlphaModel(InsightType.Price, InsightDirection.Up, timedelta(minutes = 20), 0.025, None))
self.SetPortfolioConstruction(EqualWeightingPortfolioConstructionModel())

# We can define who often the EWPCM will rebalance if no new insight is submitted using:
# Resolution Enum:
self.SetPortfolioConstruction(EqualWeightingPortfolioConstructionModel(Resolution.Daily))
# timedelta
# self.SetPortfolioConstruction(EqualWeightingPortfolioConstructionModel(timedelta(2)))
# A lamdda datetime -> datetime. In this case, we can use the pre-defined func at Expiry helper class
# self.SetPortfolioConstruction(EqualWeightingPortfolioConstructionModel(Expiry.EndOfWeek))

self.SetExecution(ImmediateExecutionModel())
self.SetRiskManagement(MaximumDrawdownPercentPerSecurity(0.01))

Expand Down

0 comments on commit 7258891

Please sign in to comment.