赞
踩
基于QuantConnect的开源Lean引擎,生成本地数据源,并实现运行Python语言的Fama-French五因子策略
public IEnumerable<Symbol> GenerateRandomSymbols() { if (!Settings.Tickers.IsNullOrEmpty()) { foreach (var symbol in Settings.Tickers.SelectMany(GenerateAsset)) { yield return symbol; } } else { for (var i = 0; i < Settings.SymbolCount; i++) { //生成stk000000,stk000001,...stk000999格式的证券符号 var ticker = "stk" + i.ToString().PadLeft(6, '0'); var symbol = Symbol.Create(ticker, Settings.SecurityType, Settings.Market); yield return symbol; //foreach (var symbol in GenerateAsset()) //{ // yield return symbol; //} } } }
--app=rdg
--start=19980101
--end=20240319
--symbol-count=1000
--resolution=Daily
--random-seed=123456
--rename-percentage=0.0
--ipo-percentage=0.0
--splits-percentage=0.0
--dividends-percentage=0.0
--dividend-every-quarter-percentage=0.0
5.目录\ToolBox\CoarseUniverseGenerator\CoarseUniverseGeneratorProgram.cs下语句修改成var hasFundamentalData = true; 目录\Common\Data\UniverseSelection\CoarseFundamentalDataProvider.cs下语句修改成return coarse.HasFundamentalData;项目属性–app=rdg修改为cug然后F5生成基本面Fundamental的股票池Universe数据;
private static CoarseFundamental GenerateFactorFileRow(string ticker, SecurityIdentifierContext sidContext, CorporateFactorProvider factorFile, TradeBar tradeBar)
{
var date = tradeBar.Time;
var factorFileRow = factorFile?.GetScalingFactors(date);
var dollarVolume = Math.Truncate((double)(tradeBar.Close * tradeBar.Volume))
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。