Admin 90 Posted December 21, 2019 Task - Close the event before the start As a parameter, I set only one variable: Time before the event when the closure should occur. Quote Share this post Link to post Share on other sites
Admin 90 Posted December 21, 2019 Among all incoming events, we select only those markets where the variable IsGreen = true, so the market has not closed bets We check that the market is open Determine how many minutes are left before the event Compare with the given parameter TimeEnter for all lines (Runner) in the market (5), if runner has IsGreen = true, so the runner has not closed bets We give the Green() command Quote Share this post Link to post Share on other sites
Admin 90 Posted December 21, 2019 Full script using System; using System.Collections.Generic; using System.ComponentModel; using System.Linq; using Botbeetle.Types.BettingEnums; using Botbeetle.Types.BettingTypes; using Botbeetle.Types.Scripts; namespace Botbeetle.Scripts { [Serializable] public class SoccerCloseBeforeStartEventScript : EventScript { protected override Script CreateInstanceForClone() { return new SoccerCloseBeforeStartEventScript(); } [Browsable(false)] public override EventTypeEnum EventType { get; set; } = EventTypeEnum.Soccer; //============================================================================================================= [Category("1. Script")] [DisplayName("Name")] public override string Name { get; set; } = "Close Before Start"; [Category("1. Script")] [DisplayName("Description")] public override string Description { get; set; } = "At a given time, close all bets on the market"; //--------------------------------------------------- [Category("2. Conditions of Enter")] [DisplayName("Time before Event, less (min)")] public int TimeEnter { get; set; } = 1; //============================================================================================================= /// <summary> /// It is called many times when the data is updated. Contains score, prices. /// </summary> public override void UpdateEvents(List<Event> events) { // 1. Choose from all Events the Markets that have bets and it not "Green" List<MarketCatalogue> markets = events.Select(x=>x.MarketCatalogue).Where(x => x.IsGreen).ToList(); foreach (var market in markets) { // 2. Check that the status of the market == OPEN, otherwise skip (SUSPENDED or CLOSED) if (market.Status != MarketStatus.OPEN) continue; // 3. Сalculate the time before the match var time = (market.MarketStartTime.ToLocalTime() - DateTime.Now).TotalMinutes; // 4. Checking "Time before Event" parameter, otherwise skip if (time > TimeEnter) continue; foreach (var runner in market.Runners) { // 5. Choose Runner that have bets and it not "Green" if (runner.IsGreen) { Api.Green(runner); } } } } } } Quote Share this post Link to post Share on other sites