Created
May 25, 2018 12:58
-
-
Save StefanBelo/937857533086d8471feb0e51459452a0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 FindingGapsBetweenBackPrices | |
#I @"C:\Program Files (x86)\BeloSoft\Bfexplorer\" | |
//#I @"D:\Projects\Bfexplorer\Development\Applications\BeloSoft.Bfexplorer.App\bin\Debug\" | |
#r "BeloSoft.Data.dll" | |
#r "BeloSoft.Betfair.API.dll" | |
#r "BeloSoft.Bfexplorer.Domain.dll" | |
#r "BeloSoft.Bfexplorer.Trading.dll" | |
#r "BeloSoft.Bfexplorer.Service.Core.dll" | |
open System.Text | |
open BeloSoft.Bfexplorer.Domain | |
open BeloSoft.Bfexplorer.Trading | |
/// <summary> | |
/// FindingGapsBetweenBackPrices | |
/// </summary> | |
type FindingGapsBetweenBackPrices(market : Market, selection : Selection, botName : string, botTriggerParameters : BotTriggerParameters, myBfexplorer : IMyBfexplorer) = | |
let isGapBetweenBackPrices (mySelection : Selection) = | |
let bestOfferedPrices = mySelection.ToBack | |
let bestPrice = bestOfferedPrices.BestPrice | |
let secondBestPrice = bestOfferedPrices.SecondBestPrice | |
if secondBestPrice.IsValid | |
then | |
mySelection.OddsContext.GetOddsDifference(secondBestPrice.Price, bestPrice.Price) > 1 | |
else | |
false | |
let getSelectionsWithGapBetweenBackPrices() = | |
market.Selections | |
|> Seq.filter (fun mySelection -> isActiveSelection mySelection && isGapBetweenBackPrices mySelection) | |
|> Seq.toList | |
let reportMySelection (mySelection : Selection) = | |
let bestOfferedPrices = mySelection.ToBack | |
let bestPrice = bestOfferedPrices.BestPrice.Price | |
let secondBestPrice = bestOfferedPrices.SecondBestPrice.Price | |
sprintf "%s: %.2f - %.2f | %d" mySelection.Name bestPrice secondBestPrice (mySelection.OddsContext.GetOddsDifference(secondBestPrice, bestPrice)) | |
interface IBotTrigger with | |
/// <summary> | |
/// Execute | |
/// </summary> | |
member this.Execute() = | |
let mySelections = getSelectionsWithGapBetweenBackPrices() | |
if not mySelections.IsEmpty | |
then | |
let sb = StringBuilder() | |
mySelections | |
|> List.iter (fun mySelection -> sb.AppendLine(reportMySelection mySelection) |> ignore) | |
myBfexplorer.BfexplorerService.OutputMessage(sb.ToString()) | |
WaitingForOperation | |
/// <summary> | |
/// EndExecution | |
/// </summary> | |
member this.EndExecution() = | |
() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment