Skip to content

Instantly share code, notes, and snippets.

@StefanBelo
Created October 2, 2019 13:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save StefanBelo/a7ca0e9cfd67751d1b155a983eda1e72 to your computer and use it in GitHub Desktop.
Save StefanBelo/a7ca0e9cfd67751d1b155a983eda1e72 to your computer and use it in GitHub Desktop.
// Bfexplorer cannot be held responsible for any losses or damages incurred during the use of this betfair bot.
// It is up to you to determine the level of risk you wish to trade under.
// Do not gamble with money you cannot afford to lose.
module BfexplorerBot
//(*
#I @"C:\Program Files (x86)\BeloSoft\Bfexplorer\"
#r "BeloSoft.Data.dll"
#r "BeloSoft.Bfexplorer.Domain.dll"
#r "BeloSoft.Bfexplorer.Trading.dll"
#r "BeloSoft.Bfexplorer.Service.Core.dll"
//*)
open BeloSoft.Bfexplorer.Domain
open BeloSoft.Bfexplorer.Trading
/// <summary>
/// ReportWinner
/// </summary>
type ReportWinner(market : Market, _selection : Selection, botName : string, _botTriggerParameters : BotTriggerParameters, myBfexplorer : IMyBfexplorer) =
let myStrategyResults = myBfexplorer.BfexplorerService |> MyStrategyOperations.RegisterMyStrategy botName
let outputMessage (message : string) =
myBfexplorer.BfexplorerService.OutputMessage(message)
let toMarketResult (myMarket : Market) =
match myMarket.Selections |> Seq.tryFind isWinnerSelection with
| Some winnerSelection -> sprintf "Winner: %s | %.2f" winnerSelection.Name winnerSelection.LastPriceTraded
| None -> "No winner!"
interface IBotTrigger with
/// <summary>
/// Execute
/// </summary>
member __.Execute() =
if myStrategyResults.CanExecuteMyStrategy
then
myStrategyResults.AddMarket(market)
outputMessage <|
if not (Seq.isEmpty myStrategyResults.SettledMarkets)
then
myStrategyResults.SettledMarkets |> Seq.last |> toMarketResult
else
"Nothing to report!"
TriggerResult.EndExecution
else
TriggerResult.EndExecutionWithMessage "Previous result is not yet known!"
/// <summary>
/// EndExecution
/// </summary>
member __.EndExecution() =
()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment