How to open a market for monitoring to Excel worksheet
Posted in Tutorials by StefanBelo Tags: bfexplorer | bot programming
Today I was asked by one of my subscribers the question, how to open markets for monitoring into the Microsoft Excel worksheet automatically using the Trade Opportunity Lookup Service.
The Bfexplorer PRO supports the Microsoft Excel automation so users are able to create their own trading strategies or trigger betting utilizing the Excel macros or VBA code. When implementing this feature into the Bfexplorer PRO I left on a user to decide which markets he wants to monitor in the Excel worksheet as the opposite to the Trade Opportunity Lookup Service that makes it easier to create a fully automated solution simply by setting the bot criteria without any programming of Excel macros or VBA code, just by setting parameters.
What I prefer is of course the Trade Opportunity Lookup Service and bot scripts written in C# or Visual Basic that is just because it is more powerful solution, but for those who likes the Excel automation there is a way how to open markets automatically with the Trade Opportunity Lookup service.
I prepared for Excel users a LookUpBot script:
- Bfexplorer.Scripting.OpenTheMaketInExcelLookUpBot.cs
This bot only opens a market into the Excel worksheet at the preset time before the official event start. If you want to change this preset time, open the script and change the following constant:
private const int StartBeforeInMinutes = 5;
In the bot script code:
using System;
using BeloSoft.Betfair.Data;
using BeloSoft.Betfair.Data.Betting;
using BeloSoft.Betfair.Data.Statistics;
using BeloSoft.Betfair.Trading;
namespace Bfexplorer.Scripting
{
public class OpenTheMaketInExcelLookUpBot : LookUpBot
{
// Const
private const int StartBeforeInMinutes = 5;
public OpenTheMaketInExcelLookUpBot(IBetfairService betfairService)
: base(betfairService)
{
}
public override bool DoYourJob(MonitoredMarket monitoredMarket)
{
if (GetIsTheMarketXMinutesBeforeStart(monitoredMarket))
{
betfairService.StartMonitorThisMarket(monitoredMarket);
betfairService.StartMonitorThisMarketExternal(monitoredMarket);
return false;
}
return true;
}
private bool GetIsTheMarketXMinutesBeforeStart(MonitoredMarket monitoredMarket)
{
return DateTime.Now >= monitoredMarket.MarketDetails.MarketTime.AddMinutes(-StartBeforeInMinutes);
}
}
}
To run this bot with the Trader Opportunity Lookup Service add this bot by clicking on the icon Add a new bot and enter for the Bot Class Name:
- Bfexplorer.Scripting.OpenTheMaketInExcelLookUpBot
Then just select your markets you want to monitor this way with the Microsoft Excel. Read more about the Trader Opportunity Lookup Service here.