private IPrimitive FormatPeriod(MetaFormulaItem arg) { IPrimitive nowPeriod = FormatNowPeriod(arg); var getDateCall = new FunctionCall(arg.PeriodShiftSource + ":date") .AddParameter(nowPeriod) .AddCondition(_factory.MakeIsNotNull(nowPeriod)); var findDateCall = new FunctionCall("core.findDate") .AddParameter(FormatStreamOrValue(arg)) .AddParameter(getDateCall) .AddParameter("false"); return(findDateCall); }
private List <IPrimitive> AddCreateSourcesCode(IMetaSource source, string parentSourceId) { var lines = new List <IPrimitive>(); var sourceId = source.Id; switch (source) { case IndicatorSource indicatorSource: var createIndicatorCall = new FunctionCall("core.indicators:create") .AddParameter(new QuotedStringPrimitive(indicatorSource.Name.ToUpper())) .AddParameter(GetIndicatorSourceId(indicatorSource.Source)); AddParameters(indicatorSource, createIndicatorCall); lines.Add(new AssigmentStatement(" " + sourceId, createIndicatorCall)); if (_model.Debug) { lines.Add(new FunctionCall(" debug_helper:AddIndicator", true).AddParameter(sourceId)); } break; case MainInstrumentSource maintInstrumentSource: sourceId = "trading_logic.MainSource"; break; case InstrumentSource instrumentSource: if (parentSourceId == null) { parentSourceId = sourceId; } var extSubscribeCall = new FunctionCall("ExtSubscribe") .AddParameter(sourceId + "_id") .AddParameter("nil") .AddParameter(ReplaceStringParameter(instrumentSource.Timeframe)) .AddParameter(instrumentSource.PriceType) .AddParameter(new QuotedStringPrimitive("bar")); lines.Add(new AssigmentStatement($" {sourceId}", extSubscribeCall)); if (_model.Debug) { lines.Add(new FunctionCall(" debug_helper:AddInstrument", true).AddParameter(sourceId)); } break; } return(lines); }