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

Tennis - A simple example.

Recommended Posts

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.

image.png.ffb211ec5330bc551238bee5bf6e5cfd.png

  • Like 1

Share this post


Link to post
Share on other sites

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.

image.png.9700c4b8fe8a3c0138ed5ff6fe0aa1aa.png

Share this post


Link to post
Share on other sites

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.

image.png.c799defb71c002058758a6abfb6fb93b.png

 

Share this post


Link to post
Share on other sites

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) 

image.png.29aca4ab48a4ab20cb2196d22ae51910.png

Share this post


Link to post
Share on other sites

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.

image.png.f8c85b24ee3b3f35b9ba3f64d507f42f.png

 

Share this post


Link to post
Share on other sites

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.

image.png.aff528e551fdd82cc224a654c08c3dee.png


3. We declare a dictionary (Dictionary <long, RunnerHelper> Helpers),

image.png.e0a80d19c09d278e7fbc1f6b0f59fb60.png


4. Add the desired market to the dictionary. The key in the dictionary is a unique market ID.

image.png.ad752c26852560c166b6d9d9f6eb6c9a.png


5. When the script is running, access to data tied to the market is obtained as

image.png.9fce569d2497347af7dce32e32b2e987.png
 

 

 

Share this post


Link to post
Share on other sites

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.

image.png.e9da352b07ddf70c126b93e7d0037d4b.png

 

image.png.7e6d7978d975b1f2e1856b66d3fd62f5.png

 

Share this post


Link to post
Share on other sites

3.4 What is busy?

image.png.cdfd409845b1686a2d6d393df39d29cd.png

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.

Share this post


Link to post
Share on other sites

3.6 Change the number of the game

The game number can be obtained using the function:

image.png.07fd60823606014a0947adc7f37bdff9.png

With each change of the game number:
- remember the number of the game
- reset orders ID (current and green)
- cancel all orders (if any)

image.png.9b0c805eea72cb4236e725c2c5edc0d0.png

image.png.40713e88b8a18b31fa300c48157ab0a4.png

 

Share this post


Link to post
Share on other sites

 

3.7 Tennis serve favourite

The tennis serve can be obtained using the function:

image.png.ec5be0b6ff0efa728040ae18afb959a1.png

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 .

image.png.c52b0bd5e1b27fc7c664c2e766cb2a39.png

image.png.20e90deaf0c2a8548e247c25eb1cbaa7.png

 

Share this post


Link to post
Share on other sites

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.

 image.png.b57eb34dad1a56c47c4450acb430b25b.png

image.png.8cffe90d48fded27510b659bb5cdd5f9.png

Share this post


Link to post
Share on other sites

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.

image.thumb.png.968c39c6f9c0ab5db9796ec85c743bfa.png

image.png.c94d5f39640112ec269f729dc0b03234.png

Share this post


Link to post
Share on other sites

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

image.png.b0f65bbc04346c0845bea232c44c3e6f.png

Share this post


Link to post
Share on other sites

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

image.png.80bbadf9ed7456694dbbc5544d37ca8a.png

Share this post


Link to post
Share on other sites

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

image.png.765885ad7a3e22fc0af140555b48dd78.png

Share this post


Link to post
Share on other sites

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;

image.png.1818cfaae12422f1d2f830755bf2d3fc.png

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...