Article

MyBotTriggers.dll usage

I am doing something wrong so if someone could help that would be great. I have built the MyBotTriggers.dll. There is a module called TestBotTrigger which has parameter called "execute". I have made a simple bot called "Place Bet" (which when run will place a bet on current selection) and this works every time I run it. Now the next part is where I am failing. I add a new bot and select "Execute Trigger Bot". I enter in the correct location of the MyBotTriggers.dll in TriggerFilePathName. For the Bot Name I enter in "Place Bet". In the TriggerParameters, I enter "execute":true". I save this bot as testExecute and when I run it, no bets are placed. Please tell me what I am doing wrong.

Comments ( 1 )


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