User Comments

  • Betfair Bot
    1.10.2019 10:16:13

    Peter, it is up to you what homework you do, or what different bot trigger you could offer for other readers, as your bot trigger can evaluate different selection values, and as well evaluation process could be programmed by many different ways.

    I actually separated storing of selection trigger values to different type/class, so code is prepared for different scenarios.

    If you really are able to read the trigger bot code you have to see it, so you can describe those different scenarios to others, but that is up to you.

    I asked for “homework” because you reported problems with compiling bot trigger code, what means you did not understand what were you doing, I hope you do now.

  • Betfair Bot
    1.10.2019 9:21:15

    Ok, it seems you managed to understand the concept of F# programming.

    On the other hand I see you have actually no understanding of betting terminology, as book value is not calculated as you did in your code. The book value in betting is sum of selection’s probabilities.

    Here is my bot trigger code for part 2: HorseRacingBotTrigger2.fs

  • Betfair Bot
    30.9.2019 16:21:59

    Here is my first test that actually triggered some trading session. When testing it is really important how you set all trigger parameters, for testing it is good to set them without limits, so not parameters are tested but code

    I set the fallowing parameters as default ones:

    allowedSelectionIndexes: 1,2,3,4,5,6

    timeToStart: 40.0

    favouritesPrice: 50.0

    When the race started, bot trigger saved position of allowed horses. When timeToStart expired, all allowed horses were evaluated again

    positionDifference <- startPosition – position

    So trigger selected Bianca Minola as nominated selection on which Bot Trigger started lay/back trading session for 4 ticks of profit.

  • Betfair Bot
    30.9.2019 9:56:56

    Peter, I do not want to patronize you, but I have got very simple question?

    Are you satisfied with what you did?

    Why did I ask?

    Because any written source code must be formatted to be readable by other programmers.

    Yes, some programming languages that use for instance { } to separate block of code, could be stripped to one line and compiler successfully build such code, but not F# where code block must be formatted by text/code indentation and you cannot used tabs:

    https://docs.microsoft.com/en-us/dotnet/fsharp/style-guide/formatting

    I mentioned that, because during weekend you posted video showing you edited bot trigger in Notepad text editor. So anyone who would like to use your code you posted in your comment, must copy and paste your text, reformat it correctly, and then will find out that your code does not do what you claim you did.

    So you waste maybe 10 minutes or more, to someone who wants to test your code. English is foreign language for me so is very hard for me to find politically correct words for your behavior.

    Please, install either Visual Code, like I show here:

    Betfair Bot Programming for Non-Developers

    Or Visual Studio Community version:

    Bfexplorer - Betfair BOT SDK

    Both IDE (Integrated Developer Environment) applications are free, unlike Microsoft Excel other betfair app use, where you must buy licenses of Microsoft Excel. Using Bfexplorer BOT SDK all applications or tools helping you to create bot trigger are for free.

    Why is using right programs/applications important when developing/writing code?

    Because like text editors with spellchecking, such IDE checks your code when writing, so any mistake in misspelling anything in code is reported. Visual Studio, or Visual Studio code offer you as well, so called IntelliSense/IntelliCode technology when writing code, so helping you to write the code:

    https://visualstudio.microsoft.com/services/intellicode/

    And finally why did I ask you to make some changes in the code?

    To force you learn something, because bot trigger code in other parts of our tutorial will be more difficult.

    I know you are not software developer, but in part 1 the source code is really readable even by non programmer, it contains plain English words like if, then, else, match, let, try, with, and some words you would maybe need to think about, like open, type, interface, member and map  

    https://en.wikipedia.org/wiki/Map_(higher-order_function)

    Please, when you want to use source code, and want to share it with others, do them favor and share it on http://github.com through Github Gist, like I do:

    https://gist.github.com/StefanBelo

    Again, you can register on github.com for free. Or just use any of other code sharing services on the Internet:

    https://www.google.com/search?q=code+sharing+service&oq=code+sharing+service

  • Betfair Bot
    28.9.2019 0:46:54

    Ok, but you did not specify that you want to check horse's positions in two different times. My first implementation was that bot waits till market is turned at in-play, then saves information about all allowed selections, so horse's positions is saved as well.

    At set time in race, bot checks your conditions, so favourites must be traded at that moment of checking under set price/odds.

    Then allowed selections are sorted by position change difference, so biggest position change is the first one, if this selection is not among the first three favourites, it is nominated as the selection your strategy will be executed on.

    The bot trigger again similar like I explained to you in the part 3, does not have to know anything about your criteria for entry point, so if you allow starting lay/back trading session only when the selection/horse is traded from 10.0 to 20.0, then you can simply set that to Entry Criteria for this lay trading bot.

    Now think a little bit. I hope you already know that Entry Criteria could be evaluated just once, or could be evaluated till all set Entry Criteria are met. This feature gives you two different options for your bot placing a lay bet.

    If you think more, then you will find that bfexplorer offers more bots placing a bet, or starting trading session, namely:

    Place Bet

    Be the First in Queue

    Fill or Kill

    Place Bet and Close Selection Bet Position

    Scratch Trading

    This gives you really big flexibility for different ways your bet is placed on the market selection, and closes your bet position for loss when needed.

    Of course not all of above bot strategies to place a bet are suitable for in-play markets where odds changes so rapidly as on the horse racing, therefore I would suggest to use:

    Place Bet and Close Selection Bet Position

    But of course you can test them all, or other combinations for instance:

    Place Bet, and Trailing Stop Loss

    What is very good news for you is that bot trigger code does not have to implement anything to place a bet and manage its status, so you will get simpler trigger code.

    I really cannot imagine how people could manage such strategies just in Excel spreadsheets, so traders using Bet Angel, Cymatic or Gruss software. I think they cannot run such strategies, am I right?

    Your tutorial in the part 1 is ready, I will post bot trigger code for the part 2, but first test your bot trigger for part 1, and as the simple coding exercise, change the bot trigger code to report not only horse name, but the last traded price as well.

    Here is the hint:

    https://gist.github.com/StefanBelo/a85ee8b9959b841ea423eade056cc762

  • Betfair Bot
    27.9.2019 18:44:20

    How is evaluated “…our selection has dropped in position...”?

  • Betfair Bot
    27.9.2019 17:55:07

    Peter, you do not need to program a trigger or anything for this feature, as your lay trade can be started by bot strategy: “Place Bet and Close Selection Bet Position”, and set your Profit/Loss target as required. So in your case you want to close your bet position, so by your words:

    “… so that if it looks like my trade is not going good, I'd like to limit my losses …”

    You can set Loss parameter, either by (ProfitLossType parameter) Ticks, Percentage, or exact Money value.  As the Profit parameter is required one, (Loss is not, when you set it to 0, your position is not closed for Loss) you must set it to unrealistic value.

    If you want to hedge your bet position, leave HedgingEnabled checked (set to True). When hedge the stake is calculated, I hope that you understand that, other software vendors call this procedure “green up”. Well, in this case I really do not understand your English, as no one is saying about “red up” ;-)

  • Betfair Bot
    27.9.2019 17:15:04

    Yes, one of your requirements for horse racing strategy is to execute only if allowed number of horses will run in the race.

    This can be set in Entry Criteria: NumberOfSelections and for operator you can apply one of 5 relevant options, so this could be removed from the bot trigger code.

    Here is my bot trigger code:

    https://gist.github.com/StefanBelo/71b025e6a4c687fe98f99a258ddb6cb5

    It is 67 lines of code but actual code starts from line 19. The main bot trigger code is executed by Execute function, so algorithm for this bot code is on 11 lines.

    The bot trigger code contains one general functions  getActiveSelections (lines 35-36) as for some markets like horse racing, greyhounds, golf and so on, selections could be withdraw, we must use this function to get only active selections, in our case horses.

    One of requirements is to apply any further evaluation only on specific selections defined by order index in which betfair displays market selections. Peter named that “starting lanes”.  

    In bot trigger, bfexplorer inputs any data to bot trigger through object botTriggerParameters, so any data entered through parameter: TriggerParameters.

    On the line 18 we retrieved such parameter named: AllowedSelectionIndexes. Keep in mind that you must enter exactly this name in the parameter list, it is case sensitive. When no parameter is entered, the bot trigger code implements default value, it is set to: "1,2,3,10,11,12"  

    So horses order indexes separated by comma. As the indexes are enter as text value, the helper method “toIndexes” transforms this text to list of integers.

    The function “getMySelectionsData” (lines 38 – 48) checks whether bot trigger has valid indexes for evaluated race, and returns list of selections, and number of selections, otherwise returns nothing, to be exact in F# programming terms it returns Option.None value.

    And that is all for our first bot trigger, as mentioned before the code is executed by Execute function, and code execution can be described:

    If it is horse racing market and we can get my selections data, then it is displayed message: \nMy selections: name 1, name 2\nNumber of runners: 15”.

    If it is not horse racing market it is displayed message: "You can run this bot on a horse racing market only!".

    If there is any error in getting my selections data, then error message is displayed:

    And bot trigger execution is ended.

  • Betfair Bot
    26.9.2019 11:09:24

    First of all, couple of hints about F# programming.  As with any programming language you can built a lot of different project types. In our case you must create .net C# or F# library project targeting .NET Framework 4.7.2, so as seen in Add a new project in Visual Studio: Library (.NET Framework).

    Ok, you have used Bfexplorer BOT SDK project: MyBotTriggers, so all should be setup. When you set this project be: Set as StartUp Project, and in the project Properties / Debug, you set Start external program:

    C:\Program Files (x86)\BeloSoft\Bfexplorer\Bfexplorer.BotUI.exe

    Then after you click Start (F5) , your project is build and bfexplorer app is executed as external program using your: MyBotTriggers.dll assembly.

    You could read here:

    http://bfexplorer.net/Articles/Content/354

    http://bfexplorer.net/Articles/Content/248

    That when debug in Visual Studio (VS) you can type in Debug / Command line arguments:

    YourUserName YourPassword True

    So when your project is executed/(started for debugging) VS start bfexplorer as well and automatically login with your betfair credentials YourUserName YourPassword. Last argument value True, means that bfexplorer is switched to Practice mode, you do not want to place real bets on betfair when debugging your bot or trigger code, right?

    Let me assume that your trigger code is correct, well actually when there were any problems with your code VS would reported errors.

    What you maybe do not know, F# programming language supports scripting

    https://blogs.msdn.microsoft.com/chrsmith/2008/09/12/scripting-in-f/

    so .fs file is normal F# source code file compiled to your targeted assembly, but .fsx is just scripting file that is actually not compiled. On my githbub:

    https://github.com/StefanBelo/Bfexplorer-BOT-SDK

    https://gist.github.com/StefanBelo

    You can find source code of such F# scripts, for instance:

    https://gist.github.com/StefanBelo/50186494957fa8a1a154866a7319d5e0

     So if you want to execute such bot trigger with "Execute Trigger Bot" as script code, your code must include referenced assemblies, have a look at from lines 7 to 14.

    On the other hand when you want to compile your bot trigger to assembly, and so debug your code like I do on attached video to this post, then you must un-comment lines 7 and 14, and rename your script file to .fs extension.

    When building bot trigger code to assembly, the bot trigger code must be the only one code in your project. It is all fine if rest of files in your project have “.fsx”, as they are not compiled, but if you have got more Bot Trigger source code files in your project with “.fs” extension, then you must set them as Build Action: None (click on file with right mouse button and in context menu: Properties)

    Why in bot trigger assembly must be just one bot trigger code?

    It is the way how bfexplorer instantiate Bot Trigger code. Your bot trigger must implement IBotTrigger interface, so bfexplorer after loading your bot trigger assembly: MyBotTriggers.dll, executes constructor of the first object implementing IBotTrigger.

    Well, yes you can have many bot triggers in your assembly, but as the mechanism of selecting the exact bot trigger just takes the first found, you must use just one bot trigger implementing IBotTrigger in your assembly.

    This mechanism is quite different for bot assemblies, have a look at on projects MyCsharpBot and MyFsharpBot, where you can find interface IBotCreator.

    I do not know what the level of understanding of .net programming, you have got, but any junior software developers should understand what I said up to now. I mean all that said should be clear for junior developer just from browsing Bfexplorer BOT SDK projects code.

    Have a look at attached video to see how easy your can debug any bot trigger code.

    What I can advise you about bot trigger programming, use bot trigger really just for triggering, orchestrating your bots that place bets, like “Place Bet” bot.

    Well, yes you have got in the trigger the option to place a bet directly, using:

    TriggerResult.PlaceBets

    But is it really a good idea, mainly when a lot of things could happen at the moment you place a bet:

    Market can be suspended.

    Your Internet connection could go down.

    Market prices could move rapidly so your bet could be placed bet unmatched.

    Just part of your bet is matched.

    Market is turned at in-play so your unmatched bet is cancelled when your bet was placed without keep attribute, and so on…

    The point is that you must manage bet status in any possible state, and bfexplorer prebuilt bots do so well.

  • Betfair Bot
    25.9.2019 17:13:37

    Not all projects in bfexplorer bot sdk solution are using bfexplorer app as hosting environment.

    Bfexplorer Bot SDK allows you to build your own apps for betfair if for any reason you do not like to use bfexplorer app.

    Projects like:

    BetfairApiConsole, BetfairApiConsoleFSharp, BetfairApiMarketBrowsing, BfexplorerServiceConsole are console apps, so standalone application showing different kind of using bot sdk code.

    JayBeeBot project is winforms app with very simple user interface, integrating existing bot you can find in bfexplorer app.

    Projects like: MyBotTriggers or MyBotTriggersCSharp are bot trigger projects, so yes these two projects could be executing with bfexplorer app as hosting app, and using with bot: “Execute Trigger Bot”

    Projects like: MyCsharpBot or MyFsharpBot are bot assembly projects, and again they can be executed with bfexplorer ap as hosting app, and bots implemented in these projects automatically occur in My Bots to Execute dialog, when adding a new bot strategy. So these kind of bots offer parameters interface for this add bot dialog.

    Project MyConsoleScripts contains scripts that could be executed in Bfexplorer Console tool in bfexplorer app. You can automate bfexplorer tasks or interact with exposed bfexplorer objects.

    You must have at least base understanding of programming in C# or F# programming languge, or any other .net programming languge, for instance Visual basic to use Bfexplorer BOT SDK.

    Please read articles about Bfexplorer BOT SDK:

    http://bfexplorer.net/Articles/Search?text=bot sdk

  • Betfair Bot
    25.9.2019 17:12:48

    In my example I mentioned “Place Bet” or “Place Bet and Close Selection Bet Position” bot strategies, so if you set trigger criteria for one of these bots, it is clear the bot is executed / triggered.

    There are other bots in bfexplorer arsenal that actually do not place bets, but execute other bots, so in your case you can use bot named: “Execute Bots” and set your criteria for this bot, when criteria are met, this bot executes other bot (bots) set by the parameter: BotNames.

    What does it mean?

    Your “Execute Bots” can evaluate different criteria for different selection, and execute another bot that can be executed on the other selection, depending on how you set parameter s and criteria for this action bot.

    Of course all these preprogrammed bot strategies can do what they were programmed for and what set of parameters these bots offer.

    When your strategy needs more, other betfair apps offer Excel scripting, so you must program VBA code to do what you need. In your example you would have to program in Excel VBA, conversion of market name in win horse racing markets, to race distance, and make your trigger work by evaluating race distance to allowed race distances.

    Bfexplorer offers trigger programming, so such short code is then executed by bot named: “Execute Trigger Bot”.

    On the forum you can find a lot of such examples:

    http://bfexplorer.net/Articles/Search?text=bot trigger

  • Betfair Bot
    25.9.2019 10:07:11

    You can execute whatever strategy you want, by other words, actually by your words you could understand:

    A trigger is set of conditions (formulas) which all must be fulfilled the trigger to be activated, fired.

    By my words, so words any software developer could understand:

    A trigger is function returning boolean value, if returned value is true, another action is executed:

    If trigger() then action()
  • Betfair Bot
    25.9.2019 9:27:32

    For your Trigger 2:

    Depending on whether you want to place a bet or trade on specific horse, you can use bot strategy: “Place Bet” or “Place Bet and Close Selection Bet Position” (that is trading bot strategy).

    You set SortSelectionBy Last Price Traded, ExecuteOnSelection to 1, EvaluateEntryCriteriaOnlyOnce set to True (checked), and in Entry Criteria tab you add criteria LastPriceTraded is between 1.5 and 2.0

    Your Trigger 1 can be done by filtering markets in Event Browser and executing your strategy only on selected markets using Bot Executor.

    If you want to fully automate Trigger 1 as well, then you must realize where information about race distance is. It is in market name and is coded in miles and furlongs for GB, US and IE, and meters for the rest of countries, so 6f, 7f, 1m, 1000m and so on.

    It means that you need to transform text of race distance to meters. You did so in custom build triggers like you can see in attached videos.

    When I first executed my strategy on 6f race, and MinimumRaceDistance was set to 1760 meters, the bot did not executed my action bot “Trade 3 ticks”, as race distance did not fulfill set criteria, when I change that to 1000 meters, and top tipster’s selection fulfilled another criteria so Confidence at least 40, the bot strategy chosen nomited horse Holloa and executed trading strategy on this horse.  

    I make simple triggers for free only to my subscribers.

  • Betfair Bot
    22.9.2019 10:43:51

    All live score apps work in bfexplorer.

    I just wonder what your posts are about. Because you must understand that software is not mechanical thing, it cannot wear out, so if worked before it must work. Only input values could change or services could be down.

    All live score data used by betfair are provided by third parties as well, so if score does not work, you must blame data provider not my app or betfair. Do we understand each other?

  • Betfair Bot
    14.9.2019 11:44:22

    If you strategy requires executing only when previous result is known then you can use the bot strategy called: Execute Till Target Profit

    Please read this post: “Closing down trading after reaching a predefined profit” where the bot “Execute Till Target Profit” is used as well.

    The bet result checking mechanism can be used even in strategies requiring a result, so who won or lost, even when a bet was not placed in the market, similar like in this request: “Some Lay Strategy”, but in this case it is necessary to build custom bot trigger script, for instance like here:

    MyWatchedResultsBotTrigger.fs

    For my subscribers I build custom strategy triggers for free if such work requires no more than 2 hours of my work.

    Bfexplorer BOT SDK is free for my subscribers as well:

    http://bfexplorer.net/Products/BfexplorerBotSDK

  • Betfair Bot
    6.9.2019 14:10:13

    There is no need to program anything, and I actually really wonder why you think you need to have programming skills to execute such strategy with bfexplorer.

    To automate your betting or trading strategy you need to use a bot strategy, in this it is named / called:

    “Close Selection Bet Position”

    You need to set the parameter ProfitLossType to Percentage, and set your Profit and/or Loss target (set Loss to 0, if you do not want to close your bet position/ hedge it in loss)

    Now you can execute your bot strategy on all selections on which you placed your bets. Or you can use the bot:  “Execute on Selections”, to execute your “Close Selection Bet Position” on all selections.

  • Betfair Bot
    5.9.2019 12:12:24

    May I ask you what you actually mean?

    I have just made above video showing that all works for me.

  • Betfair Bot
    2.9.2019 10:00:52

    In the application status bar, so in the bottom of the application window, on the right side there is reload button and as well amount showing your available balance to bet. Whenever you click on this button, your balance is reloaded.

  • Betfair Bot
    24.8.2019 9:17:15

    I do not think Bet Angel can execute your fourth strategy:

    Championship: Back Underdog when odds are 3.0 - 3.5

    Because similar like my “Place Bet” bot, when you sort selections, all selections are included. So to get underdog, the naïve approach is to sort selections by Last Traded Price, and the second item in sorted list is underdog, but as all selections are taken, The Draw selection could be second one as well, therefore you need custom script like I did here:

    FootballExecuteOnUnderdogBotTrigger.fsx

    I would suggest you to post your request to market feeder as well. They have similar policy like me, for subscribers they build one simple trigger for free, otherwise you must pay for it.

    I have some case studies for market feeder as well:

    http://bfexplorer.net/Articles/Search?text=feeder

    And bfexplorer could execute any strategy market feeder users have problems with.

    I just wonder if market feeder can manage to execute your strategy simpler way. Your automation script for skilled developer is no problem at all, using Bfexplorer BOT SDK.

    Just for inspiration, your FootballExecuteOnUnderdogBotTrigger.fsx uses: ExecuteActionBotOnSelection to execute your preset strategy, entered by BotName parameter on selection the bot trigger script evaluate.

    As you can setup all your strategies by “Place Bet” bot, your strategy requires choosing exact named bot strategy for exact league.

    The league is stored in the property of BetEvent object:

    market.MarketInfo.BetEvent.Details

    You can get it from Market object. So five lines of code in F# (have a look at match keyword) will give you the name of strategy that should be executed, and in your bot trigger code such bot strategy can be executed by:

    TriggerResult.ExecuteMyActionBotOnSelectionWithParametersAndContinueToExecute (botName, mySelection, None, false)