Blog Article

Betfair Bot Programming for Non-Developers

Bfexplorer app already offers more than 20 general bots you can use to setup your betting or trading strategy just by setting bot parameters or orchestrating more bots to your unique strategy.

If you are able to create this way your automated strategy for betfair, then of course no programming is required.

If you are unsuccessful then you can create/program your trigger bot script and execute it with "Execute Trigger Bot".

Well, I know you would say: I am not a programmer. I do not know any programming language. I do not know how to program betfair bot.

Yes, bot script is written in programming language, in F# programming language I had chosen as scripting programming language for bfexplorer app.

Here is the base script you can use, just by changing script file name, and of course programming your trigger code:

MyBotTrigger.fsx

Do not panic now, as you would see some code in F#, to be specific 22 lines of code. What you can read in the bot script code:

Line 1, your bot script is compiled to the module named BfexplorerBot

Line 3, your bot script references external assemblies/code which are located in the folder named by directive #I

Lines 5 – 8, references external assemblies.

Lines 10 – 12, open namespaces for types/objects your script will use.

Line 14, declares your trigger bot type/object and its constructor with objects your trigger code interact with. You can actually read by name what that objects are so market and selection on which your bot script is going to be executed on, bot name, bot trigger parameters, and so on.

Line 16, declares that your bot trigger implements IBotTrigger interface with two functions.  

Lines 18 – 19, implement the first function: Execute, this function is executed by bfexplorer app whenever your bot trigger is excuted and market data are updated.

Lines 21 – 22, implement the second function: EndExecution, this function is executed by bfexplorer app when your bot script execution is ended.

So it is 22 lines of code you can read and maybe understand from naming of functions or some code parts what could actually happen when code is executed.

Use this simple code as template for your bot triggers adding your code in line 15 and under, and of course in lines 19 and 22 under, when required.

If you open the bot trigger script code in Visual Studio, or when you read the script code directly on github web page, then you can see that some words displayed in light red and blue colors. Light red words are F# programming language keywords:

https://en.wikipedia.org/wiki/F_Sharp_(programming_language)

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

If you are interested in F# programming then of course you can learn them all, but actually for base bot trigger programming the first F# keywords you should learn are just: let, if - then - else.

In our first bot trigger we cannot actually find any of the above keywords, as all what bot trigger does when executed is written the “Hello Word” text in Output view and ends its execution.

You can read Execute TriggerResult.EndExecutionWithMessage "Hello World", and that is exactly what will happen.

Why you can write your bot trigger without actually knowing all programming language keywords?

Simply because when using Visual Studio or other IDE, like Visual Code, Atom, or many others like your text editor for written bot trigger code, your written code is checked for errors, and you have got suggestions for properties, functions and methods any used object in your code could expose.

All that helps you program your trigger code, just open this trigger code in Visual Code and try to type:

market.

Immediately after you typed . (dot) in your code editor appears popup dialog window showing which properties, functions and methods are exposed by Market type.

Property in programming is a function which can return/get value, or set one. So for instance, if in my trigger code I need to know how much money has been traded on the market, I will type:

market.TotalMatched

If you are Non-Developer, so having no installation of Visual Studio (Community) with F# on your computer, what can be really huge installation package for you, I suggest installing Visual Code:

https://code.visualstudio.com/

Then install F# compiler and build tools, here is exact step by step instruction:

https://fsharp.org/use/windows/

 

  • Add Your Comment

    +

    Please login to your bfexplorer account, if you want to add a comment to this article.

Comments ( 1 )


  • Mir.
    14.8.2018 18:39:32

    Wow! that´s nice!
    It looks very friendly...
    I think it's worth trying out.