Comments

  • peteresgate@outlook.com
    20.10.2019 12:54:25

    I have tried both the MyF#bot and MyC#Bot for showSelectionSP, and I tried the HorseRacingSPBotTrigger and moved showHorseData to show before inPlay the Near and Far SP, but I have never achieved to show the Near/Far Projected SP or the actual SP when inPlay (the horse metadata works).  I was wondering if there has been a change in the method to receive the SP prices?

  • Stefan
    20.10.2019 10:38:19

    Actually, there are such bot triggers:

    HorseRacingSpFavouriteBotTrigger.fsx

    HorseRacingSpBotTrigger.fsx

    As an example you could create a bot trigger showing for active selections near BSP and actual BSP after race is turned at in-play. You can show prices on ladder, like in this example:

    Horse Racing - Oddschecker Favourite Trigger

  • Stefan
    20.10.2019 10:24:09

    Yes, placing betfair sp bet returns matched bet with matched amount zero, as SP bet is fully matched only after race is turned at in-play and all betfair start price bets are processed.  This be cannot be cancelled I believe, well have never try that.

    You can place normal bet with Take SP, such bet can be cancelled and unmatched part of bet is turned to SP at the moment race is turned at in-play.

    Have a look at UpdateSpPricesMarketBot.fs if you want to update sp prices, but that is bot assembly, not bot trigger code. You have got access to betfair api in bot trigger code, so you need to study betfair documentation and then you can replicated code working with sp prices in bot trigger as well.

     

  • Stefan
    17.10.2019 9:41:41

    That is great Peter.

    I would really suggest you to set breakpoint in your code and then debug it and browse available data offered by bfexplorer.

    You must know what data you have got, visualize them in your head, and then you know what you can do with data.

    Your approach for now is browsing existing code, so when you did not find similar one you cannot make progress, but data you have got, so working with data is the way to go.

  • peteresgate@outlook.com
    17.10.2019 9:13:56

    I got it to work using another of your codes that I found from weight of money :)

     

  • peteresgate@outlook.com
    17.10.2019 7:48:57

    Hi Stefan,

    Yes thanks it will get the odds at specified levels now thanks. 

    But with the volume it is different.  

    https://github.com/PeterEsgate/BfexplorerTestBots/blob/master/Market%20Depth%20Volume

     

    On Line 35 and 27, why I can't I just substitute the "priceData.Price" with "priceData.ToBack" ?

    With the PriceGridData.GetOfferedPriceData(), there is no method (that I could find) to go to different levels like with priceGridData.GetPriceData(index)

     

     

  • Stefan
    16.10.2019 20:38:18

    On the line 3 of your code, there are set three values: startIndex, nextIndex, findFun

    The findFun is function used to evaluate the place with empty offer. So when you want to place back bet, it must be checked lay offer and wise versa.

    You change that code, therefore your findFun function returns true on offer with available offer. Actually in your code I cannot see logical problem because you start iterating through data on the best offer, so price must be set.

    If you code does not go to the line 23, as you say price returned is always 0.0

    Peter, how/where you execute your bot trigger?

    The full market depth is updated only for active market, so for the market that is currently open in Bet Event/Trader.

    It means that if you run your bot by Bot Executor tool you will get updates only for 3 best offered prices.

    I would suggest you to debug code, only this way you can find your problem in the code.

    Hint: There is function selection.PriceGridData.GetOfferedPriceData()

    You can use to get all offered prices. I do not know what you want to make in your code, so this function: GetOfferedPriceData returns all offered prices, and you can filter whatever criteria you use.

    Here is bot trigger code:

    ShowOfferedPrices.fsx

    Peter, please use VS debugger when testing your code.

  • peteresgate@outlook.com
    16.10.2019 3:13:24

    Please see the code here:

    https://github.com/PeterEsgate/BfexplorerTestBots/blob/master/Market%20Depth%20Levels

    I run it like this:

    let mutable odds = defaultArg (botTriggerParameters.GetParameter<float>("Odds")) 1.0

    odds <- getMarketDepthPrice(BetType.Back) (myLaySelection) 1
    outputMessage (sprintf "Lay Odds at Level 0 %.2f" odds)
    odds <- getMarketDepthPrice(BetType.Back) (myLaySelection) 2
    outputMessage (sprintf "Lay Odds at Level 1 %.2f" odds)

    but the result of odds is always 0.0

    I am trying to find the available odds at different market depth levels

    Could you please tell me what is wrong with the code?

  • Stefan
    14.10.2019 13:04:41

    I have just updated Bfexplorer BOT SDK source code adding MyFootballStrategy projects showing how to use Bfexplorer Plugin integration.

    The MyFootballStrategy.App is working example. If you trade football matches on betfair you can use it to monitor all matches live score and match statistics.

    https://github.com/StefanBelo/Bfexplorer-BOT-SDK/tree/master/MyFootballStrategy

    If anyone wants to collaborate on this project adding new features, and is able to program, then of course you can clone entire Bfexplorer BOT SDK solution.

    Those of you who just want to use this app, and are not able to build plugin from the source code, just contact me through support page and I will send you app/plugin files.

  • Stefan
    14.10.2019 10:29:39

    One of TriggerResult discriminated unions entry is:

    TriggerResult.OpenAssociatedMarkets of string[] * (DataResult<Market list> -> unit)

    Allowing requesting associated markets to the market you are running your bot on.

    Every market is open as bet event on betfair, and you have got access to this information:

    market.MarketInfo.BetEvent

    So bfexplorer when you request TriggerResult.OpenAssociatedMarkets knows for which bet event id the associated markets should be queried.

    Please have a look at on this bot trigger script:

    HorseRacingWinToBePlacedData.fsx

    Basically your bot has access to all betfair api methods:

    myBfexplorer.BfexplorerService.BetfairServiceProvider

    So you could be able to write any code against betfair api. The question is, is this approach practical?

    Your bot is executed on exact type of market, for instance on horse racing win market, so what markets would you like to open in Bet Event view? Tennis match odds market, or football match odds market?

    In any such scenario common sense dictates that you want to open associated market for bet event on which your bot is running, for instance place horse racing market, when your bot runs on win horse racing market and so on.

    If you want to build your bespoke app on bfexplorer app, you can do so like I present in this article:

    Bfexplorer Plugin Support

  • Stefan
    11.10.2019 12:13:53

    Peter, post on github your code you want to review, and please add to files extension, then github code preview can highlight the syntax, as from ending .fs, or ,fsx it is known that code is F#.

    You can debug your code in Visual Studio, so you can really test each line of your bot trigger code, and so learn how your code works.

  • peteresgate@outlook.com
    11.10.2019 11:54:39

     That is a great explanation thanks :). I have noticed 1 thing with my bot and I see it doesn't seem to do what I think it should (I'm blaming my code) so I just wanted to ask that after it performs an executeOnSelection, mySelection1 and I change status <- goToMyNextTrigger and I have another executeOnSelection mySelection2 (when new conditions are true), it can do multiple executions with different selections right?  It may be because my action happens near the end of the race but I only ever see 1 bet.

  • Stefan
    11.10.2019 10:28:42

    I created ScalpingTradingStrategyBot.fsx bot trigger as a case study for some trading strategy I read about on other forum. Unfortunately I forget to put link to that forum but posted on my blog this article:

    Greyhounds Racing - Scalping Trading Strategy Bot

    Please read it first if you did not do so before.

    So in the bot trigger code I created MyTraderBot taking selection and stake amount as entry parameters, lines from 50 (the bot constructor) to 86.

    As mentioned MyTraderBot orchestrates two “PlaceBetBot”s The parameter setting is created by function createBotParameters, lines from 27 to 38. As you may noticed (have a look at on the line 52) any bfexplorer bot is created as bot type, and uses its parameters, so in this case for PlaceBetBot, there is bot implementation type PlaceBetBot, and parameters the type (class) PlaceBetBotParameters. PlaceBetBot implements all bot logic, and parameters just describer set of parameters the bot can use, for instance BetType and Stake the bot places bet with.

    Bot must be executed on exact market and selection, therefore for instance of the bot object is created (lines 52 and 53), the bot comstructor takes market, selection, botPrameters and bfexplorerService.

    BfexplorerService object implements betfair api and application domain. When you run your bot trigger, actually your code uses BfexplorerService to interact with betfair api.

    The other used bot is: ClosePositionOnMarketBot, and from the name of this bot type, you can judge what this bot does. Therefore the bot constructor does not take any selection as entry value. The bot parameters are implemented by type: ClosePositionOnMarketBotParameters.

    The bot closes bet position when required profit is reached (Profit parameter, the line 102), and well ends execution of all running bots, that is executed before the bet closes selections bet position.

    Finally fot trigger code, the lines from 133 to 159. When bot trigger is executed, on all active selections there is created instance of MyTraderBot and one instance of ClosePositionOnMarketBot, the code line 145. When checking the code in createMyBots function, you can see that starting a bot is done by adding to the market, the line 111, the same in lines 65 and 66.

    When is actually your bot executed?

    Well, it is done by BfexplorerService after market prices have been updated, your bot is actually just object instance, and its execution time is limited only by short time when BfexplorerService updates entire status of market and bets data.

    The bot strategy is to place back and lay bets on selections, and as the bets are placed by PlaceBetBot, we need to update range of allowed odds range, the lines from 68 to 86, the method Update. We need to update this parameters on for running bots, lines from 149 to 153.

    Why bot trigger ScalpingTradingStrategyBot does not implement any logic to ends its execution? It can be simply done by checking if there is still MyTraderBot running on some selection.

    Well, because we orchestrate in this case two types of bots, and one of them closes/ends execution of all other bots before closing bet position on the market.

    This bot trigger code is nice example of advantages of using bfexplorer action bots, as nay strategy can be executed by these action bots. Your trigger strategy should define/implements just entry and exit criteria in time. The rest is executed by action bots.

    Use the code only as inspiration, as there is no logic in entry points implemented by MyTraderBot.

  • peteresgate@outlook.com
    11.10.2019 6:32:39

    I didn't explain properly sorry.  What I mean is I can see it create the bot and it has bot.Start to place the trades.  Then the next part I don't understand.  You run Update, which from what I can see only changes the parameters, so how did the bot place trades again and use the new parameters?  I can't see how it executed new trades based on what is in  the Update()

  • Stefan
    10.10.2019 13:50:57

    I do not understand in what context you want to execute your bots and what method you want to use, because ScalpingTradingStrategyBot.fsx uses direct initialization of PlaceBet bot instances and ClosePositionOnMarketBot bot instance.

    For now you worked only with action bots, changing their parameters.

    Why do you need directly to create your bots?

    In your bot trigger code I already mentioned that you repeat the code, is the question about this issue?

  • peteresgate@outlook.com
    10.10.2019 11:28:39

    I've been looking at the scalping bot and the way it creates the bots, I like it a lot.  Do you have another example of creating a bot with parameters like the scalping bot, but with a method call to execute on mySelection from within member_execute?  For example 1 method call I would have parameters and betType lay for mySelection and another method call would have different parameters for a different mySelection betType back  etc.  From your examples I am learning a lot, but I couldn't find one like this.

  • Stefan
    9.10.2019 9:52:19

    Programming languages use different syntax, and of course set of types. In F# float is C# double, and as F# is .net language you have got access to anything from .net framework.

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

  • Stefan
    8.10.2019 15:51:11

    I do not know why you need two other lists to make your new list having only selections with profit and unmatched lay bets.

    Any information you need are in Selection object. I created short console script where you can see how to make different filter functions:

    ShowSelectionsWithProfitAndUnmatchedBets.fsx

    Basically you should orchestrate bot strategy(ies) execution in your trigger code, so the same way you can query for running bots, and running bot on a selection is still indication that your trading session, or bet placing is not yet finished.

    Another hint, please really use Visual Studio InteliSense support, as typing . (dot) in the name of object variable gives you all properties or methods you can use on the object. I mean what I created you could figure out as well.

  • Stefan
    7.10.2019 10:48:02

    For the property BetType, the BetType is not string/text value. It is enumeration value, so you must assign BetType.Back or BetType.Lay

    For “Place Bet and Close Selection Bet Position Bot” you have got OpenBetPosition or CloseBetPosition properties, so exact path to particular parameters, in OpenBetPosition is:

    “OpenBetPosition.Stake”

    “OpenBetPosition.BetType”

    And for “Place Bet” bot the parameter names are simple:

    “Stake”

    “BetType”

    Only you know what action bot you will use, so therefore you must know names of action bot parameters. When you always use just “Place Bet” bot then you do not have to code it naming convention of parameters, but when your bot trigger can execute trading bots, then introduce to your bot trigger parameters for instance parameter: “IsTradingActionBot” and when you set it to True, you must add OpenBetPosition. or CloseBetPosition. prefix to the parameter names you want to change. 

    There are of course different ways to create bot instance and execute them, please have a look at here: ScalpingTradingStrategyBot.fsx

    Or just investigate all options for TriggerResult discriminated union type, there are 10 different options for TriggerResult.Execute..

    You are using the option to edit parameters of set action bot, so what you set in “BotName” parameter of "Execute Trigger Bot".

  • Stefan
    5.10.2019 12:13:52

    Just a hint, you really overcomplicate your code. You should separate logic part/s in your code to function/s. For instance you introduced new parameter and named it strategy.

    From your code I can estimate that your intention was to generate allowedSelectionIndexes when the parameter AllowedSelectionIndexes is not entered.

    So you could take this code out from getMySelections function and create a new function that will return just text representation of your strategy number to text representation of allowed selections, so function:

    val strategyToIndexes : int -> string

    That is function signature. Please, maybe you should read this article:

    https://fsharpforfunandprofit.com/posts/how-types-work-with-functions/

    So simply said everything in F# is function, and returns some value, if nothing is return it is called unit.

    Then even “if else then”, is function and returns value, and it is clear that all blocks of if evaluation must return the same value, but I think you already noticed that, but your coding style did not change because you repeatedly type too much code.

    Ok, that is not a problem for now because bot trigger code will work anyway, but on the other hand your code would be shorter, maybe even more than 50% of current code.

    I do not know why would you need to evaluate what is retuned by getMySelection()  function, that other comment with match expression.

    Just hover with your mouse over getMySelection and read tooltip VS shows, it shows function signature:

    val : getMySelection : (unit -> Selection option)

    So what does it mean?

    getMySelection is function taking no input value/s (unit) and returning option type of Selection

    Option can be Some value or None, so in this context getMySelection returns Some selection on which your want to trigger your action bot. If no qualified selection is evaluated by your trigger code than it returns None.

    When starting to build/develop a new trigger you can create functions so they all describe your entire algorithm, and in Execute function then you should see/read your algorithm just by reading function names, all functions could be declared as empty code, just with correct function signature, so in the first stage of development you would just express your trigger algorithm by pure functions, then later start to implement the code to all functions and when necessary adds new ones.

    As your bot trigger cannot be executed in one market update call, it is good idea to introduce trigger status value like I did with TriggerStatus (discriminated union type):

    https://fsharpforfunandprofit.com/posts/discriminated-unions/

    It is clear that I created domain of that discriminated union in the domain of your horse racing trigger, therefore you can see that I named one status:  WaitForRaceStart (and I could name it more generally)

    Now you want to add a new status to your trigger, as you want to evaluate previous bet results, the question is where in the status queue you add this new one, and it is up to you.

    I already described necessary code in my previous comment, but here is another version:

    HorseRacingAndPreviousResultsBotTrigger.fsx