UnmatchedBets - monitoring LAY and BACK Unmatched bets

For my new trading strategy I need a monitor Unmatched bets. Especially if there is on selection (market):
no Unmatched bets
only LAY Unmatched bets or
only BACK Unmatched bets or
LAY and BACK Unmatched bets

I know method GetHaveUnmatchedBets() but it returns if exist ANY Unmatched bets. Has anyone an idea how can I monitoring BetType of Unmatched Bets?

Comments (1)

  1. StefanBelo Says:
    Tuesday, April 06, 2010

    Betfair Bot Programming using C# .net and Bfexplorer BOT SDK

    Replying on your question: Stop Loss tick by tick. I already mentioned that bot is signaled its current state by variable tradingState, and it is done so anytime the bot state changes so when bet state changes as well.

    In your code you can override following methods: GetHaveUnmatchedBets, GetHaveMatchedBets, DoSetBetPosition

    So you can change the base behavior of setting your bet position for selection, and returning just filtered bets for instance checking the unmatched bet state only for back bets, or bets placed by bot only, so filtering out all bets with bet id bigger than last placed bet on the selection.

    What does it mean?

    It actually means that you, your bot code does not have to check the bets status itself because it is already done by bfexplorer backend, and your bot code receives such information.

    If you want to browse all bets on your market you can do so using the MyBets property of the MonitoredMarket object.

    MyBets myBets = monitoredMarket.MyBets;
    
    if (myBets.HaveBets)
    {
      foreach (Bet bet in myBets.Bets)
      {
        if (bet.Status == BetStatus.Matched)
        {
          // This bet is matched
        }
        else
        {
          // This bet is unmatched
        }
    
        if (bet.Type == BetType.Back)
        {
          // Back bet
        }
        else
        {
          // Lay bet
        }
      }
    }
    

    You can use other methods of the MyBets object, for instance to get all unmatched bets on selection you can write the code:

    List<Bet> unmatchedBets = myBets.GetBetsBySelectionAndStatus(
        runner.SelectionId, runner.AsianLineId, BetStatus.Unmatched
    );
    
    if (unmatchedBets != null)
    {
      foreach (Bet bet in unmatchedBets)
      {
        if (bet.Type == BetType.Back)
        {
          // Back bet
        }
        else
        {
          // Lay bet
        }
      }
    }
    

    If your code is compiled using the .NET 3.0 you can use something like this:

    var myUnmatchedBets = myBets.Bets
        .Where(bet => bet.Status == BetStatus.Unmatched && bet.BetPrice.Amount > 10);
    

    To get all unmatched bets with stake amount bigger than 10.

     


Do you want to comment this article? Sign up here or login.

User Menu