Admin 90 Posted February 3, 2019 The first example is how to make a script for tennis. The main feature is the possibility of multiple bets in one market. The strategy is very simple: - choose favorites - make bet on the favorite when he serving, - hedge when an outsider is serving. Important. This is not a winning strategy. This is an example of how to make a script for tennis, how to make multiple bets and hedge. 1 Quote Share this post Link to post Share on other sites
Admin 90 Posted February 3, 2019 1. Script Parameters Parameters are variables that the program user can set in the program interface and change the logic of the script. 1.1. Name In this block we set the type, name, and description of the script, these parameters do not affect the operation. Logs and parameters will be saved under the specified name. Quote Share this post Link to post Share on other sites
Admin 90 Posted February 3, 2019 1.2. Order settings The bet must be more than $5, because when the favorite loses, we close by a bet of about 4.20. Bet less than $4, runs 3 times longer. Quote Share this post Link to post Share on other sites
Admin 90 Posted February 3, 2019 1.3. Condition of selection The script will select only markets where: there is money in the market more than specified in variable TotalMatched (Default value = $20000) value LAY for a favorite is less than specified in variable FavPriceLay (Default value = 1.9) Quote Share this post Link to post Share on other sites
Admin 90 Posted February 3, 2019 1.4. Conditions of entering The variables PriceHight (Default value = 1.10) and PriceLow (Default value = 3.00) set the price range when a bet can be made. Quote Share this post Link to post Share on other sites
Admin 90 Posted February 3, 2019 2. Script execution 2.1 Full script code Quote Share this post Link to post Share on other sites
Admin 90 Posted February 3, 2019 3. Explanations 3.1 Market data binding To link any data to the market, you can use the following technique: 1. We declare any class (for example RunnerHelper) 2. In the class, declare any variables you may need. 3. We declare a dictionary (Dictionary <long, RunnerHelper> Helpers), 4. Add the desired market to the dictionary. The key in the dictionary is a unique market ID. 5. When the script is running, access to data tied to the market is obtained as Quote Share this post Link to post Share on other sites
Admin 90 Posted February 3, 2019 3.2 Select Favorite Standard favorite selection Quote Share this post Link to post Share on other sites
Admin 90 Posted February 3, 2019 3.3 Work with a favorite 1. Check that the market has moved to Live; 2. The market has Live Score. 3. Check that the market has been added to the dictionary, if not we add 4. Check that the market is open 5. Check that the market is not busy. Quote Share this post Link to post Share on other sites
Admin 90 Posted February 3, 2019 3.4 What is busy? Functions working with orders are asynchronous. When calling any functions to work with orders placement, change, cancel Api.PlaceLimitOrder(runner, Api.UpdatePrice(runner, Api.CancelOrder(runner, This function (IsBusy) will return true: Api.IsBusy(runner) == true When the response from the server (betfair) is received, this function will return false Api .IsBusy(runner) == false The use is necessary to exclude a double command on the same order. Quote Share this post Link to post Share on other sites
Admin 90 Posted February 3, 2019 3.5 General algorithm Quote Share this post Link to post Share on other sites
Admin 90 Posted February 4, 2019 3.6 Change the number of the game The game number can be obtained using the function: With each change of the game number: - remember the number of the game - reset orders ID (current and green) - cancel all orders (if any) Quote Share this post Link to post Share on other sites
Admin 90 Posted February 4, 2019 3.7 Tennis serve favourite The tennis serve can be obtained using the function: When the tennis serve goes to the favorite: - we produce market hedge (if necessary) - if it was hedged, save a sign of a tennis serve . Quote Share this post Link to post Share on other sites
Admin 90 Posted February 4, 2019 3.8 Execution bet if favorite is on the tennis serve - we make a bet, if the outsider is on the serve - we make a hedging market. Quote Share this post Link to post Share on other sites
Admin 90 Posted February 4, 2019 3.9 Place, update bets How do we bet: - if the bet ID (helper.CurrentId) is empty, then we make a bet, no, we get an order and change it. Quote Share this post Link to post Share on other sites
Admin 90 Posted February 4, 2019 3.9.1 Place bet To make a bet: We get the best price Lay var lay = Api.GetBestLay(runner); Using the function var price = Api.Get Price (lay, -1); reduce the price by one point If the price is in the specified range if (PriceLow < lay && lay < PriceHight) create a unique order ID helper.CurrentId = Api.CreateBetOrderId(); place a bet Api.PlaceLimitOrder(runner, Side.BACK, price, OrderSize, helper.CurrentId); Quote Share this post Link to post Share on other sites
Admin 90 Posted February 4, 2019 3.9.1 Update bet To update a bet: By the order id (helper.CurrentId) get an order If the order exists and its status is "EXECUTABLE" if (order?.Status == OrderStatus.EXECUTABLE) We get the best price Lay var lay = Api.GetBestLay(runner); If the order price is greater than the current LAY if (order.Price > lay) Reduce the price by one point var price = Api.GetPrice(lay, -1); Update bet Api.UpdatePrice(runner, order, price); Quote Share this post Link to post Share on other sites
Admin 90 Posted February 4, 2019 3.10 Hedging market Quote Share this post Link to post Share on other sites
Admin 90 Posted February 4, 2019 3.10.1 Creat green bet if green order ID is Empty: We get the best price Back var back = Api.GetBestBack(runner); Increases price by one point var price = Api.GetPrice(back, 1); We get the SIZE of the hedging and SIDE Side side; var size = Api.GetGreenSize(runner, price, out side); If the size more than 0.01 if (size >= 0.01M) create a unique green order ID helper.CurrentId = Api.CreateGreenOrderId(); place a green bet Api.PlaceLimitOrder(runner, side, price, size, helper.GreenId); Quote Share this post Link to post Share on other sites
Admin 90 Posted February 4, 2019 3.10.2 Check and Cancel green bet By the order id (helper.GreenId) get an order var order = Api.GetOrder(runner, helper.GreenId); If the order exists and its status is "EXECUTABLE" if (order?.Status == OrderStatus.EXECUTABLE) if order side is Lay: We get the best price Lay var back = Api.GetBestBack(runner); If the current Back is greater than the order price if (back > order.Price) We cancel order and set order id (helper.GreenId) to Empty; helper.GreenId = string.Empty; if order side is Back: We get the best price Lay var lay = Api.GetBestLay(runner); If the current Lay is less than the order price if (lay < order.Price) We cancel order and set order id (helper.GreenId) to Empty; helper.GreenId = string.Empty; Quote Share this post Link to post Share on other sites
Admin 90 Posted February 4, 2019 The algorithm in Visio 2013 Tennis.vsdx Quote Share this post Link to post Share on other sites
vshtip 2 Posted February 5, 2019 OK! But have you a winning strategy ? Quote Share this post Link to post Share on other sites
vshtip 2 Posted February 5, 2019 By the way in my parameters I went to profit and for two hours I am with 2 euros on top. 1 Quote Share this post Link to post Share on other sites