Created
September 29, 2019 10:27
-
-
Save StefanBelo/3c87d7e6cfe278d320c116eb8fda1605 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 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> | |
| /// ShowPriceTradedHistory | |
| /// </summary> | |
| type ShowPriceTradedHistory(_market : Market, selection : Selection, _botName : string, _botTriggerParameters : BotTriggerParameters, _myBfexplorer : IMyBfexplorer) = | |
| let toPriceTradedRangeAndTrend (priceTradedHistory : PriceTradedHistory) = | |
| sprintf "%.2f - %.2f | %d" priceTradedHistory.MinimalPriceTraded priceTradedHistory.MaximalPriceTraded priceTradedHistory.PriceTrend | |
| let toPriceTradedBackLayVolumePercentage (priceTradedHistory : PriceTradedHistory) = | |
| let tradedVolume = | |
| (struct {| BackVolume = 0.0; LayVolume = 0.0 |}, priceTradedHistory.TradedPrices) | |
| ||> Seq.fold (fun accTraded timePriceTraded -> | |
| if timePriceTraded.BetType = BetType.Back | |
| then | |
| struct {| accTraded with BackVolume = accTraded.BackVolume + timePriceTraded.Volume |} | |
| else | |
| struct {| accTraded with LayVolume = accTraded.LayVolume + timePriceTraded.Volume |} | |
| ) | |
| let totalTradedVolume = tradedVolume.BackVolume + tradedVolume.LayVolume | |
| if totalTradedVolume > 0.0 | |
| then | |
| sprintf "Backed: %.2f | Layed: %.2f" (tradedVolume.BackVolume / totalTradedVolume) (tradedVolume.LayVolume / totalTradedVolume) | |
| else | |
| "No trades!" | |
| interface IBotTrigger with | |
| /// <summary> | |
| /// Execute | |
| /// </summary> | |
| member __.Execute() = | |
| let priceTradedHistory = selection.PriceTradedHistory | |
| sprintf "%s: %s ~ %s" selection.Name (toPriceTradedRangeAndTrend priceTradedHistory) (toPriceTradedBackLayVolumePercentage priceTradedHistory) | |
| |> TriggerResult.EndExecutionWithMessage | |
| /// <summary> | |
| /// EndExecution | |
| /// </summary> | |
| member __.EndExecution() = | |
| () |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment