Jump to content
FORUM · BOTBEETLE
Sign in to follow this  
Admin

Close event before start

Recommended Posts

Task - Close the event before the start

As a parameter, I set only one variable:

Time before the event when the closure should occur.

image.png.59e65af46e511538900709538af5d79c.png

Share this post


Link to post
Share on other sites

image.png.db1a26dcd4ac58f838230074bfb53d34.png

 

  1. Among all incoming events, we select only those markets where the variable IsGreen = true, so the market has not closed bets
  2. We check that the market is open
  3. Determine how many minutes are left before the event
  4. Compare with the given parameter TimeEnter
  5. for all lines (Runner) in the market (5),
  6. if runner has IsGreen = true, so the runner has not closed bets
  7. We give the Green() command 

Share this post


Link to post
Share on other sites

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);
                    }
                }
            }
        }
    }
}

 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...