/// <summary> /// Creates empty parameters. /// </summary> public IndicatorParam() { slotNumb = 0; isDefined = false; slotType = SlotTypes.NotDefined; indicatorName = String.Empty; typeOfIndicator = TypeOfIndicator.Indicator; timeExecution = ExecutionTime.DuringTheBar; aListParam = new ListParam[5]; aNumParam = new NumericParam[6]; aCheckParam = new CheckParam[2]; for (int i = 0; i < 5; i++) aListParam[i] = new ListParam(); for (int i = 0; i < 6; i++) aNumParam[i] = new NumericParam(); for (int i = 0; i < 2; i++) aCheckParam[i] = new CheckParam(); }
public static string ToString(ExecutionTime time) { string strRepresentation; switch (time) { case ExecutionTime.OneMinute: strRepresentation = "1m"; break; case ExecutionTime.FiveMinutes: strRepresentation = "5m"; break; case ExecutionTime.Unlimited: strRepresentation = "ne"; break; default: throw new ArgumentException("No such argument"); } return(strRepresentation); }
public static void Dispatch(Func <IEnumerator> work, ExecutionTime execTime = ExecutionTime.LateUpdate) { Instance.DispatchInternal(work, execTime); }
public void ActivateVisualization(GameObject caster, ExecutionTime time) { }
public Campaign GetEntity(int agencyid, CampaignTypeCharge campaignTypeCharge, Core.Models.SettingModel setting, string code, string username) { //var accountChargeAmount = 0; //if (Type == CampaignType.CustomService || Type == CampaignType.JoinEvent) //{ // accountChargeAmount = AccountChargeAmount ?? 0; //} //else //{ // accountChargeAmount = campaignTypeCharge.AccountChargeAmount; //} //var accountChargeExtraPercent = 0; //if (Type == CampaignType.ShareContent || Type == CampaignType.ShareContentWithCaption) //{ // if (EnabledExtraType) // { // accountChargeExtraPercent = campaignTypeCharge.AccountChargeExtraPercent; // } //} var start = ""; var end = ""; if (!string.IsNullOrEmpty(ExecutionTime)) { var arrDate = ExecutionTime.Split('-'); if (arrDate.Length == 2) { start = arrDate[0].Trim(); end = arrDate[1].Trim(); } } var image = string.Empty; if (Type == CampaignType.ChangeAvatar) { image = Image; } else if (Type == CampaignType.ShareContentWithCaption) { image = AddonImages.ToListString(); } return(new Campaign() { DateCreated = DateTime.Now, AgencyId = agencyid, Data = Data, DateModified = DateTime.Now, Deleted = false, Description = Description, Image = image, Published = true, //Status = CampaignStatus.Created, // cap nhat status da duyet luon de facebook check, Status = CampaignStatus.Confirmed, Title = Title, UserCreated = username, UserModified = username, ExtraOptionChargePercent = setting.CampaignExtraOptionChargePercent, ServiceChargePercent = setting.CampaignServiceChargePercent, ServiceVATPercent = setting.CampaignVATChargePercent, ServiceChargeAmount = 0, AccountChargeExtraPercent = 0, AccountChargeAmount = 0, EnabledAccountChargeExtra = false, AccountChargeTime = 0, Requirement = Type == CampaignType.CustomService ? Requirement : string.Empty, Type = Type, Code = code, Quantity = Quantity, DateStart = start.ToViDateTime(), DateEnd = end.ToViDateTime(), AccountFeedbackBefore = FeedbackBefore.ToViDateTime(), CustomKolNames = CustomKolNames.ToListString(), Method = Method, SampleContent = SampleContent.ToListString(), Hashtag = HashTag.ToListString(), SampleContentText = SampleContentText }); }
/// <summary> /// Reset the timer. /// </summary> public void Reset() { LoadTime.Reset(); ExecutionTime.Reset(); }
public void GetNextExecutionDate() { //var today = DateTime.Today; var days2Add = new List <int>(); var now = DateTime.Now; var year = now.Year; var day = now.Day; var month = now.Month; var hour = now.Hour; var minute = now.Minute; if (ExecutionMonth != null) { month = Convert.ToInt32(ExecutionMonth); if (month < DateTime.Now.Month) { year = year + 1; } } if ((RunEvery_Minute ?? 0) > 0) { var date = DateTime.Now.AddMinutes(Convert.ToInt32(RunEvery_Minute ?? 0)); hour = date.Hour; minute = date.Minute; } else { if (!string.IsNullOrEmpty(ExecutionTime)) { var time = ExecutionTime.Split(':'); hour = Convert.ToInt32(time[0]); minute = Convert.ToInt32(time[1]); } } if (ExecutionDate != null) { day = Convert.ToInt32(ExecutionDate); var tempDate = new DateTime(year, month, day, hour, minute, 0); if (tempDate < DateTime.Now) { month = month + 1; } } else { var tempDate = new DateTime(year, month, day, hour, minute, 0); if (Monday) { AddDayByWeekDays(DayOfWeek.Monday, days2Add, tempDate); } //days2Add.Add(((int)DayOfWeek.Monday - (int)tempDate.DayOfWeek + 7) % 7); if (Tuesday) { AddDayByWeekDays(DayOfWeek.Tuesday, days2Add, tempDate); } //days2Add.Add(((int)DayOfWeek.Tuesday - (int)tempDate.DayOfWeek + 7) % 7); if (Wednesday) { AddDayByWeekDays(DayOfWeek.Wednesday, days2Add, tempDate); } //days2Add.Add(((int)DayOfWeek.Wednesday - (int)tempDate.DayOfWeek + 7) % 7); if (Thursday) { AddDayByWeekDays(DayOfWeek.Thursday, days2Add, tempDate); } //days2Add.Add(((int)DayOfWeek.Thursday - (int)tempDate.DayOfWeek + 7) % 7); if (Friday) { AddDayByWeekDays(DayOfWeek.Friday, days2Add, tempDate); } //days2Add.Add(((int)DayOfWeek.Friday - (int)tempDate.DayOfWeek + 7) % 7); if (Saturday) { AddDayByWeekDays(DayOfWeek.Saturday, days2Add, tempDate); } //days2Add.Add(((int)DayOfWeek.Saturday - (int)tempDate.DayOfWeek + 7) % 7); if (Sunday) { AddDayByWeekDays(DayOfWeek.Sunday, days2Add, tempDate); } //days2Add.Add(((int)DayOfWeek.Sunday - (int)tempDate.DayOfWeek + 7) % 7); if (days2Add.Count == 0) { throw new Exception("გაგზავნის თარიღის დადგენა ვერ მოხერხდა."); } day = DateTime.Now.AddDays(days2Add.Min(x => x)).Day; if (day < DateTime.Now.Day) { month = month + 1; } } var datetime = new DateTime(year, month, day, hour, minute, 0); if (datetime > DateTime.Now) { NextExecutionDate = datetime; } else { NextExecutionDate = datetime.AddDays(1); } }
public int CompareTo(ScheduledDelegate other) => ExecutionTime == other.ExecutionTime ? -1 : ExecutionTime.CompareTo(other.ExecutionTime);
/// <summary> /// Initializes the global variables. /// </summary> void InitTrade() { micron = Data.InstrProperties.Point / 2d; // Sets the maximum lots maximumLots = 100; foreach (IndicatorSlot slot in Data.Strategy.Slot) if (slot.IndicatorName == "Lot Limiter") maximumLots = (int)slot.IndParam.NumParam[0].Value; maximumLots = Math.Min(maximumLots, Data.Strategy.MaxOpenLots); openTimeExec = Data.Strategy.Slot[Data.Strategy.OpenSlot].IndParam.ExecutionTime; openStrPriceType = StrategyPriceType.Unknown; if (openTimeExec == ExecutionTime.AtBarOpening) openStrPriceType = StrategyPriceType.Open; else if (openTimeExec == ExecutionTime.AtBarClosing) openStrPriceType = StrategyPriceType.Close; else openStrPriceType = StrategyPriceType.Indicator; closeTimeExec = Data.Strategy.Slot[Data.Strategy.CloseSlot].IndParam.ExecutionTime; closeStrPriceType = StrategyPriceType.Unknown; if (closeTimeExec == ExecutionTime.AtBarOpening) closeStrPriceType = StrategyPriceType.Open; else if (closeTimeExec == ExecutionTime.AtBarClosing) closeStrPriceType = StrategyPriceType.Close; else if (closeTimeExec == ExecutionTime.CloseAndReverse) closeStrPriceType = StrategyPriceType.CloseAndReverse; else closeStrPriceType = StrategyPriceType.Indicator; if (Configs.UseLogicalGroups) { Data.Strategy.Slot[Data.Strategy.OpenSlot].LogicalGroup = "All"; // Allows calculation of open slot for each group. Data.Strategy.Slot[Data.Strategy.CloseSlot].LogicalGroup = "All"; // Allows calculation of close slot for each group. groupsAllowLong = new Dictionary<string, bool>(); groupsAllowShort = new Dictionary<string, bool>(); for (int slot = Data.Strategy.OpenSlot; slot < Data.Strategy.CloseSlot; slot++) { if (!groupsAllowLong.ContainsKey(Data.Strategy.Slot[slot].LogicalGroup)) groupsAllowLong.Add(Data.Strategy.Slot[slot].LogicalGroup, false); if (!groupsAllowShort.ContainsKey(Data.Strategy.Slot[slot].LogicalGroup)) groupsAllowShort.Add(Data.Strategy.Slot[slot].LogicalGroup, false); } // List of logical groups openingLogicGroups = new List<string>(); foreach (System.Collections.Generic.KeyValuePair<string, bool> kvp in groupsAllowLong) openingLogicGroups.Add(kvp.Key); // Logical groups of the closing conditions. closingLogicGroups = new List<string>(); for (int slot = Data.Strategy.CloseSlot + 1; slot < Data.Strategy.Slots; slot++) { string group = Data.Strategy.Slot[slot].LogicalGroup; if (!closingLogicGroups.Contains(group) && group != "all") closingLogicGroups.Add(group); // Adds all groups except "all" } if (closingLogicGroups.Count == 0) closingLogicGroups.Add("all"); // If all the slots are in "all" group, adds "all" to the list. } // Search if N Bars Exit is present as CloseFilter, could be any slot after first closing slot. - Krog NBarsExit = 0; for (int slot = Data.Strategy.CloseSlot; slot < Data.Strategy.Slots; slot++) { if (Data.Strategy.Slot[slot].IndicatorName == "N Bars Exit") { NBarsExit = (int)Data.Strategy.Slot[slot].IndParam.NumParam[0].Value; break; } } return; }
public RbacLog Save(string query, string parsedQuery, bool isParsed, string errors, int roleId, int userId, ExecutionTime executionTime) { RbacLog log = new RbacLog(); log.Query = query; log.ParsedQuery = parsedQuery; log.Parsed = isParsed; log.Errors = errors; log.RoleId = roleId; log.UserId = userId; if (executionTime.Items.ContainsKey(ExecutionTimeTrackers.ParseQuery)) { log.ElapsedTimeParseQuery = executionTime.Items[ExecutionTimeTrackers.ParseQuery].ElapsedTicks; } if (executionTime.Items.ContainsKey(ExecutionTimeTrackers.ConditionsNRelations)) { log.ElapsedTimeConditionsNRelations = executionTime.Items[ExecutionTimeTrackers.ConditionsNRelations].ElapsedTicks; } if (executionTime.Items.ContainsKey(ExecutionTimeTrackers.ApplyPermissions)) { log.ElapsedTimeApplyPermission = executionTime.Items[ExecutionTimeTrackers.ApplyPermissions].ElapsedTicks; } if (executionTime.Items.ContainsKey(ExecutionTimeTrackers.ApplyParameters)) { log.ElapsedTimeApplyParameters = executionTime.Items[ExecutionTimeTrackers.ApplyParameters].ElapsedTicks; } return(Save(log)); }
public BenchmarkServer() { SpannerMock = new MockSpannerService(); // Setup standard query results. var selectOneSingerEF = $"SELECT s.SingerId, s.BirthDate, s.FirstName, s.FullName, s.LastName, s.Picture{Environment.NewLine}FROM Singers AS s{Environment.NewLine}WHERE s.SingerId = @__p_0{Environment.NewLine}LIMIT 1"; var selectOneSinger = "SELECT * FROM Singers WHERE SingerId=@id"; AddFindSingerResult(selectOneSingerEF); AddFindSingerResult(selectOneSinger); var insertOneSingerEF = $"INSERT INTO Singers (SingerId, BirthDate, FirstName, LastName, Picture){Environment.NewLine}VALUES (@p0, @p1, @p2, @p3, @p4)"; var selectFullNameEF = AddSelectSingerFullNameResult("Pete Allison", 0); var insertOneSinger = "INSERT INTO Singers (SingerId, FirstName, LastName, BirthDate, Picture) VALUES (@id, @firstName, @lastName, @birthDate, @picture)"; var selectFullName = "SELECT FullName FROM Singers WHERE SingerId=@id"; SpannerMock.AddOrUpdateStatementResult(insertOneSingerEF, StatementResult.CreateUpdateCount(1L)); SpannerMock.AddOrUpdateStatementResult(insertOneSinger, StatementResult.CreateUpdateCount(1L)); SpannerMock.AddOrUpdateStatementResult(selectFullName, CreateFullNameResultSet("Pete Allison")); for (int row = 0; row < 100; row++) { var insertAlbumEF = $"INSERT INTO Albums (AlbumId, ReleaseDate, SingerId, Title){Environment.NewLine}VALUES (@p{row * 4}, @p{row * 4 + 1}, @p{row * 4 + 2}, @p{row * 4 + 3})"; SpannerMock.AddOrUpdateStatementResult(insertAlbumEF, StatementResult.CreateUpdateCount(1L)); SpannerMock.AddOrUpdateExecutionTime(nameof(MockSpannerService.ExecuteBatchDml) + insertAlbumEF, ExecutionTime.FromMillis(0, 1)); } var insertAlbum = "INSERT INTO Albums (AlbumId, Title, ReleaseDate, SingerId) VALUES (@id, @title, @releaseDate, @singerId)"; SpannerMock.AddOrUpdateStatementResult(insertAlbum, StatementResult.CreateUpdateCount(1L)); var selectMultipleSingers = "SELECT * FROM Singers ORDER BY LastName"; var selectMultipleSingersEF = $"SELECT s.SingerId, s.BirthDate, s.FirstName, s.FullName, s.LastName, s.Picture{Environment.NewLine}FROM Singers AS s{Environment.NewLine}ORDER BY s.LastName"; var singers = CreateRandomSingersResults(100); SpannerMock.AddOrUpdateStatementResult(selectMultipleSingersEF, singers); SpannerMock.AddOrUpdateStatementResult(selectMultipleSingers, singers); // Setup standard execution times. SpannerMock.AddOrUpdateExecutionTime(nameof(MockSpannerService.BatchCreateSessions), ExecutionTime.FromMillis(10, 3)); SpannerMock.AddOrUpdateExecutionTime(nameof(MockSpannerService.BeginTransaction), ExecutionTime.FromMillis(1, 1)); SpannerMock.AddOrUpdateExecutionTime(nameof(MockSpannerService.Commit), ExecutionTime.FromMillis(2, 2)); SpannerMock.AddOrUpdateExecutionTime(nameof(MockSpannerService.ExecuteStreamingSql) + selectOneSingerEF, ExecutionTime.FromMillis(2, 2)); SpannerMock.AddOrUpdateExecutionTime(nameof(MockSpannerService.ExecuteStreamingSql) + selectOneSinger, ExecutionTime.FromMillis(2, 2)); SpannerMock.AddOrUpdateExecutionTime(nameof(MockSpannerService.ExecuteBatchDml), ExecutionTime.FromMillis(1, 1)); SpannerMock.AddOrUpdateExecutionTime(nameof(MockSpannerService.ExecuteBatchDml) + insertOneSingerEF, ExecutionTime.FromMillis(2, 1)); SpannerMock.AddOrUpdateExecutionTime(nameof(MockSpannerService.ExecuteStreamingSql) + selectFullNameEF, ExecutionTime.FromMillis(1, 2)); SpannerMock.AddOrUpdateExecutionTime(nameof(MockSpannerService.ExecuteBatchDml) + insertOneSinger, ExecutionTime.FromMillis(2, 1)); SpannerMock.AddOrUpdateExecutionTime(nameof(MockSpannerService.ExecuteStreamingSql) + selectFullName, ExecutionTime.FromMillis(1, 2)); SpannerMock.AddOrUpdateExecutionTime(nameof(MockSpannerService.ExecuteBatchDml) + insertAlbum, ExecutionTime.FromMillis(0, 1)); SpannerMock.AddOrUpdateExecutionTime(nameof(MockSpannerService.ExecuteStreamingSql) + selectMultipleSingersEF, ExecutionTime.FromMillis(4, 2)); SpannerMock.AddOrUpdateExecutionTime(nameof(MockSpannerService.ExecuteStreamingSql) + selectMultipleSingers, ExecutionTime.FromMillis(4, 2)); _server = new Server { Services = { V1.Spanner.BindService(SpannerMock) }, Ports = { new ServerPort("localhost", 0, ServerCredentials.Insecure) } }; _server.Start(); }
public bool Equals(GameEvent other) { return(ExecutionTime.Equals(other.ExecutionTime)); }
public int CompareTo(GameEvent other) { return(ExecutionTime.CompareTo(other.ExecutionTime)); }
public Algorithm(Instance instance, ExecutionTime time, GaSettings settings) : base(instance, time) { _settings = settings; }
public static void Dispatch(Action work, ExecutionTime execTime = ExecutionTime.LateUpdate) { Instance.DispatchInternal(() => { work(); return(null); }, execTime); }
/// <summary> /// Initializes the global variables. /// </summary> private void InitTrade() { // Sets the maximum lots _maximumLots = 100; foreach (IndicatorSlot slot in Data.Strategy.Slot) if (slot.IndicatorName == "Lot Limiter") _maximumLots = (int) slot.IndParam.NumParam[0].Value; _maximumLots = Math.Min(_maximumLots, Data.Strategy.MaxOpenLots); _openTimeExec = Data.Strategy.Slot[Data.Strategy.OpenSlot].IndParam.ExecutionTime; _openStrPriceType = StrategyPriceType.Unknown; if (_openTimeExec == ExecutionTime.AtBarOpening) _openStrPriceType = StrategyPriceType.Open; else if (_openTimeExec == ExecutionTime.AtBarClosing) _openStrPriceType = StrategyPriceType.Close; else _openStrPriceType = StrategyPriceType.Indicator; _closeTimeExec = Data.Strategy.Slot[Data.Strategy.CloseSlot].IndParam.ExecutionTime; _closeStrPriceType = StrategyPriceType.Unknown; if (_closeTimeExec == ExecutionTime.AtBarOpening) _closeStrPriceType = StrategyPriceType.Open; else if (_closeTimeExec == ExecutionTime.AtBarClosing) _closeStrPriceType = StrategyPriceType.Close; else if (_closeTimeExec == ExecutionTime.CloseAndReverse) _closeStrPriceType = StrategyPriceType.CloseAndReverse; else _closeStrPriceType = StrategyPriceType.Indicator; if (Configs.UseLogicalGroups) { Data.Strategy.Slot[Data.Strategy.OpenSlot].LogicalGroup = "All"; // Allows calculation of open slot for each group. Data.Strategy.Slot[Data.Strategy.CloseSlot].LogicalGroup = "All"; // Allows calculation of close slot for each group. _groupsAllowLong = new Dictionary<string, bool>(); _groupsAllowShort = new Dictionary<string, bool>(); for (int slot = Data.Strategy.OpenSlot; slot < Data.Strategy.CloseSlot; slot++) { if (!_groupsAllowLong.ContainsKey(Data.Strategy.Slot[slot].LogicalGroup)) _groupsAllowLong.Add(Data.Strategy.Slot[slot].LogicalGroup, false); if (!_groupsAllowShort.ContainsKey(Data.Strategy.Slot[slot].LogicalGroup)) _groupsAllowShort.Add(Data.Strategy.Slot[slot].LogicalGroup, false); } // List of logical groups _openingLogicGroups = new List<string>(); foreach (var kvp in _groupsAllowLong) _openingLogicGroups.Add(kvp.Key); // Logical groups of the closing conditions. _closingLogicGroups = new List<string>(); for (int slot = Data.Strategy.CloseSlot + 1; slot < Data.Strategy.Slots; slot++) { string group = Data.Strategy.Slot[slot].LogicalGroup; if (!_closingLogicGroups.Contains(group) && group != "all") _closingLogicGroups.Add(group); // Adds all groups except "all" } if (_closingLogicGroups.Count == 0) _closingLogicGroups.Add("all"); // If all the slots are in "all" group, adds "all" to the list. } // Search if N Bars Exit is present as CloseFilter, could be any slot after first closing slot. - Krog _nBarsExit = 0; for (int slot = Data.Strategy.CloseSlot; slot < Data.Strategy.Slots; slot++) { if (Data.Strategy.Slot[slot].IndicatorName == "N Bars Exit") { _nBarsExit = (int) Data.Strategy.Slot[slot].IndParam.NumParam[0].Value; break; } } }
public InputData(string fileName, ExecutionTime time, bool execute) { FileName = fileName; Time = time; ExecuteAlgorithm = execute; }
public void UpdateResult(IStepResult[] steps, ExecutionTime executionTime) { _steps = steps; ExecutionTime = executionTime; CaptureStatus(); }
/// <summary> /// Resets the variables and prepares the arrays /// </summary> private static void ResetStart() { MarginCallBar = 0; SentOrders = 0; _totalPositions = 0; IsScanPerformed = false; _micron = InstrProperties.Point/2d; _lastEntryTime = new DateTime(); // Sets the maximum lots _maximumLots = 100; foreach (IndicatorSlot slot in Strategy.Slot) if (slot.IndicatorName == "Lot Limiter") _maximumLots = (int) slot.IndParam.NumParam[0].Value; _maximumLots = Math.Min(_maximumLots, Strategy.MaxOpenLots); _session = new Session[Bars]; for (int bar = 0; bar < Bars; bar++) _session[bar] = new Session(MaxPositions, MaxOrders); for (int bar = 0; bar < FirstBar; bar++) { _session[bar].Summary.MoneyBalance = Configs.InitialAccount; _session[bar].Summary.MoneyEquity = Configs.InitialAccount; } _ordCoord = new OrderCoordinates[Bars*MaxOrders]; _posCoord = new PositionCoordinates[Bars*MaxPositions]; _openTimeExec = Strategy.Slot[Strategy.OpenSlot].IndParam.ExecutionTime; _closeTimeExec = Strategy.Slot[Strategy.CloseSlot].IndParam.ExecutionTime; _openStrPriceType = StrategyPriceType.Unknown; if (_openTimeExec == ExecutionTime.AtBarOpening) _openStrPriceType = StrategyPriceType.Open; else if (_openTimeExec == ExecutionTime.AtBarClosing) _openStrPriceType = StrategyPriceType.Close; else _openStrPriceType = StrategyPriceType.Indicator; _closeStrPriceType = StrategyPriceType.Unknown; if (_closeTimeExec == ExecutionTime.AtBarOpening) _closeStrPriceType = StrategyPriceType.Open; else if (_closeTimeExec == ExecutionTime.AtBarClosing) _closeStrPriceType = StrategyPriceType.Close; else if (_closeTimeExec == ExecutionTime.CloseAndReverse) _closeStrPriceType = StrategyPriceType.CloseAndReverce; else _closeStrPriceType = StrategyPriceType.Indicator; if (Configs.UseLogicalGroups) { Strategy.Slot[Strategy.OpenSlot].LogicalGroup = "All"; // Allows calculation of open slot for each group. Strategy.Slot[Strategy.CloseSlot].LogicalGroup = "All"; // Allows calculation of close slot for each group. _groupsAllowLong = new Dictionary<string, bool>(); _groupsAllowShort = new Dictionary<string, bool>(); for (int slot = Strategy.OpenSlot; slot < Strategy.CloseSlot; slot++) { if (!_groupsAllowLong.ContainsKey(Strategy.Slot[slot].LogicalGroup)) _groupsAllowLong.Add(Strategy.Slot[slot].LogicalGroup, false); if (!_groupsAllowShort.ContainsKey(Strategy.Slot[slot].LogicalGroup)) _groupsAllowShort.Add(Strategy.Slot[slot].LogicalGroup, false); } // List of logical groups _openingLogicGroups = new List<string>(); foreach (var kvp in _groupsAllowLong) _openingLogicGroups.Add(kvp.Key); // Logical groups of the closing conditions. _closingLogicGroups = new List<string>(); for (int slot = Strategy.CloseSlot + 1; slot < Strategy.Slots; slot++) { string group = Strategy.Slot[slot].LogicalGroup; if (!_closingLogicGroups.Contains(group) && group != "all") _closingLogicGroups.Add(group); // Adds all groups except "all" } if (_closingLogicGroups.Count == 0) _closingLogicGroups.Add("all"); // If all the slots are in "all" group, adds "all" to the list. } // Search for N Bars _hasNBarsExit = false; _slotNBarsExit = -1; foreach (IndicatorSlot slot in Strategy.Slot) if (slot.IndicatorName == "N Bars Exit") { _hasNBarsExit = true; _slotNBarsExit = slot.SlotNumber; break; } // Search for Enter Once indicator _hasEnterOnce = false; _slotEnterOnce = -1; foreach (IndicatorSlot slot in Strategy.Slot) if (slot.IndicatorName == "Enter Once") { _hasEnterOnce = true; _slotEnterOnce = slot.SlotNumber; break; } // Martingale _consecutiveLosses = 0; _consecutiveWins = 0; _moneyManager = new MoneyManager(Strategy.MoneyManagementStrat); }
public void Execute(ExecutionTime _executionTime) { Thread.Sleep(_executionTime.Millisecond); }
/// <summary> /// Resets the variables and prepares the arrays /// </summary> static void ResetStart() { marginCallBar = 0; totalOrders = 0; totalPositions = 0; isScanned = false; micron = InstrProperties.Point / 2d; lastEntryTime = new DateTime(); // Sets the maximum lots maximumLots = 100; foreach (IndicatorSlot slot in Strategy.Slot) if (slot.IndicatorName == "Lot Limiter") maximumLots = (int)slot.IndParam.NumParam[0].Value; maximumLots = Math.Min(maximumLots, Strategy.MaxOpenLots); session = new Session[Bars]; for (int bar = 0; bar < Bars; bar++) session[bar] = new Session(bar, MaxPositions, MaxOrders); for (int bar = 0; bar < FirstBar; bar++) { session[bar].Summary.MoneyBalance = Configs.InitialAccount; session[bar].Summary.MoneyEquity = Configs.InitialAccount; } ordCoord = new OrderCoordinates[Bars * MaxOrders]; posCoord = new PositionCoordinates[Bars * MaxPositions]; openTimeExec = Strategy.Slot[Strategy.OpenSlot ].IndParam.ExecutionTime; closeTimeExec = Strategy.Slot[Strategy.CloseSlot].IndParam.ExecutionTime; openStrPriceType = StrategyPriceType.Unknown; if (openTimeExec == ExecutionTime.AtBarOpening) openStrPriceType = StrategyPriceType.Open; else if (openTimeExec == ExecutionTime.AtBarClosing) openStrPriceType = StrategyPriceType.Close; else openStrPriceType = StrategyPriceType.Indicator; closeStrPriceType = StrategyPriceType.Unknown; if (closeTimeExec == ExecutionTime.AtBarOpening) closeStrPriceType = StrategyPriceType.Open; else if (closeTimeExec == ExecutionTime.AtBarClosing) closeStrPriceType = StrategyPriceType.Close; else if (closeTimeExec == ExecutionTime.CloseAndReverse) closeStrPriceType = StrategyPriceType.CloseAndReverce; else closeStrPriceType = StrategyPriceType.Indicator; if (Configs.UseLogicalGroups) { Strategy.Slot[Strategy.OpenSlot].LogicalGroup = "All"; // Allows calculation of open slot for each group. Strategy.Slot[Strategy.CloseSlot].LogicalGroup = "All"; // Allows calculation of close slot for each group. groupsAllowLong = new Dictionary<string, bool>(); groupsAllowShort = new Dictionary<string, bool>(); for (int slot = Strategy.OpenSlot; slot < Strategy.CloseSlot; slot++) { if (!groupsAllowLong.ContainsKey(Strategy.Slot[slot].LogicalGroup)) groupsAllowLong.Add(Strategy.Slot[slot].LogicalGroup, false); if (!groupsAllowShort.ContainsKey(Strategy.Slot[slot].LogicalGroup)) groupsAllowShort.Add(Strategy.Slot[slot].LogicalGroup, false); } // List of logical groups openingLogicGroups = new List<string>(); foreach (System.Collections.Generic.KeyValuePair<string, bool> kvp in groupsAllowLong) openingLogicGroups.Add(kvp.Key); // Logical groups of the closing conditions. closingLogicGroups = new List<string>(); for (int slot = Strategy.CloseSlot + 1; slot < Strategy.Slots; slot++) { string group = Strategy.Slot[slot].LogicalGroup; if (!closingLogicGroups.Contains(group) && group != "all") closingLogicGroups.Add(group); // Adds all groups except "all" } if (closingLogicGroups.Count == 0) closingLogicGroups.Add("all"); // If all the slots are in "all" group, adds "all" to the list. } // Search for N Bars hasNBarsExit = false; slotNBarsExit = -1; foreach (IndicatorSlot slot in Strategy.Slot) if (slot.IndicatorName == "N Bars Exit") { hasNBarsExit = true; slotNBarsExit = slot.SlotNumber; break; } // Search for Enter Once indicator hasEnterOnce = false; slotEnterOnce = -1; foreach (IndicatorSlot slot in Strategy.Slot) if (slot.IndicatorName == "Enter Once") { hasEnterOnce = true; slotEnterOnce = slot.SlotNumber; break; } return; }
public void UpdateResult(IStepResult[] steps, ExecutionTime executionTime, Exception scenarioInitializationException) { _steps = steps; ExecutionTime = executionTime; CaptureStatus(scenarioInitializationException); }
public void SetExecutionTime(ExecutionTime executionTime) { ExecutionTime = executionTime; }
public static ExecutionTimeAssertions Should(this ExecutionTime executionTime) { return(new ExecutionTimeAssertions(executionTime)); }
public override string ToString() { return(string.Format("Code : {0} - Execution Time : {1} ms ", Code.ToString( ), ExecutionTime.ToString( ))); }