Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#I @"C:\Program Files (x86)\BeloSoft\Bfexplorer\"
#r "BeloSoft.Data.dll"
#r "BeloSoft.Betfair.API.dll"
#r "BeloSoft.Bfexplorer.Domain.dll"
#r "BeloSoft.Bfexplorer.Service.Core.dll"
#r "DevExpress.Data.v15.1.dll"
#r "DevExpress.Spreadsheet.v15.1.Core.dll"
#r "DevExpress.Office.v15.1.Core.dll"
open System
open System.Threading
open DevExpress.Spreadsheet
open BeloSoft.Data
open BeloSoft.Bfexplorer.Domain
open BeloSoft.Bfexplorer.Service
//let bfexplorer : IBfexplorerConsole = nil
let setMarketData (worksheet : Worksheet, row : int) (market : Market) =
let marketInfo = market.MarketInfo
worksheet.[row, 0].SetValue(marketInfo.StartTime)
worksheet.[row, 1].SetValue(marketInfo.EventName)
worksheet.[row, 2].SetValue(marketInfo.MarketName)
let mutable column = 3
market.Selections
|> Seq.iter (fun selection ->
worksheet.[row, column].SetValue(selection.Name)
worksheet.[row, column + 1].SetValue(selection.LastPriceTraded)
column <- column + 2
)
let toSpreadsheet (markets : Market list) =
let bfexplorerSpreadsheet = bfexplorer.BfexplorerUI.BfexplorerSpreadsheet
if isNotNullObj bfexplorerSpreadsheet
then
let workbook = bfexplorerSpreadsheet.Document
let worksheetName = DateTime.Today.ToShortDateString()
let worksheet =
if workbook.Worksheets.Contains(worksheetName)
then
workbook.Worksheets.[worksheetName]
else
workbook.Worksheets.Add(worksheetName)
bfexplorerSpreadsheet.BeginUpdate()
try
let mutable row = 0
markets
|> List.iter (fun market ->
market |> setMarketData (worksheet, row)
row <- row + 1
)
with
| ex -> printfn "%s" ex.Message
bfexplorerSpreadsheet.EndUpdate()
else
printfn "Open bfexplorer spreadsheet application!"
async {
match! bfexplorer.OpenMyFavouriteBetEvent("Football") with
| Result.Success ->
let marketInfos =
bfexplorer.BetEventBrowserMarketCatalogs
|> List.filter (fun marketCatalog -> marketCatalog.TotalMatched >= 1000.0)
|> List.map (fun marketCatalog -> marketCatalog.MarketInfo)
match! bfexplorer.GetMyMarkets(marketInfos) with
| DataResult.Success markets ->
do! bfexplorer.BfexplorerService.UiApplication.ExecuteOnUiContext SynchronizationContext.Current <|
fun () -> toSpreadsheet markets
| DataResult.Failure errorMessage -> printfn "%s" errorMessage
| Result.Failure errorMessage -> printfn "%s" errorMessage
}
|> Async.RunSynchronously
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.