Hello,
I'm trying to run the C# samples provided in the documentation to try out the API. My program works as expected up until the point it tries to place an order, and placeOrders returns an ACCESS_DENIED exception instead of the expected INVALID_BET_SIZE.
Here is my code (mostly copied from the github samples)
Any help appreciated.
Thank you
I'm trying to run the C# samples provided in the documentation to try out the API. My program works as expected up until the point it tries to place an order, and placeOrders returns an ACCESS_DENIED exception instead of the expected INVALID_BET_SIZE.
Here is my code (mostly copied from the github samples)
Code:
var marketFilter = new MarketFilter();
var eventTypes = jsonClient.listEventTypes(marketFilter);
// forming a eventype id set for the eventype id extracted from the result
ISet<string> eventypeIds = new HashSet<string>();
foreach (EventTypeResult eventType in eventTypes)
{
if (eventType.EventType.Name.Equals("Horse Racing"))
{
Console.WriteLine("\nFound event type for Horse Racing: " + JsonConvert.Serialize<EventTypeResult>(eventType));
//extracting eventype id
eventypeIds.Add(eventType.EventType.Id);
}
}
//ListMarketCatalogue: Get next available horse races, parameters:
var time = new TimeRange();
time.From = DateTime.Now;
time.To = DateTime.Now.AddDays(1);
marketFilter = new MarketFilter();
marketFilter.EventTypeIds = eventypeIds;
marketFilter.MarketStartTime = time;
marketFilter.MarketCountries = new HashSet<string>() { "GB" };
marketFilter.MarketTypeCodes = new HashSet<String>() { "WIN" };
var marketSort = MarketSort.FIRST_TO_START;
var maxResults = "1";
//as an example we requested runner metadata
ISet<MarketProjection> marketProjections = new HashSet<MarketProjection>();
marketProjections.Add(MarketProjection.RUNNER_METADATA);
Console.WriteLine("\nGetting the next available horse racing market");
var marketCatalogues = jsonClient.listMarketCatalogue(marketFilter, marketProjections, marketSort, maxResults);
//extract the marketId of the next horse race
String marketId = marketCatalogues[0].MarketId;
IList<string> marketIds = new List<string>();
marketIds.Add(marketId);
ISet<PriceData> priceData = new HashSet<PriceData>();
//get all prices from the exchange
priceData.Add(PriceData.EX_BEST_OFFERS);
var priceProjection = new PriceProjection();
priceProjection.PriceData = priceData;
Console.WriteLine("\nGetting prices for market: " + marketId);
var marketBook = jsonClient.listMarketBook(marketIds, priceProjection);
if (marketBook.Count != 0)
{
//get the first runner from the market
var runner = marketBook[0].Runners[0];
Console.WriteLine("\nUsing Runner: " + JsonConvert.Serialize<Runner>(runner));
var selectionId = runner.SelectionId;
Console.WriteLine("\nPreparing to place bet on runner with Selection Id: " + selectionId
+ "\nBelonging to marketId: " + marketId
+ "\nBelow minimum betsize and expecting a INVALID_BET_SIZE response");
IList<PlaceInstruction> placeInstructions = new List<PlaceInstruction>();
var placeInstruction = new PlaceInstruction();
placeInstruction.Handicap = 0;
placeInstruction.Side = Side.BACK;
placeInstruction.OrderType = OrderType.LIMIT;
var limitOrder = new LimitOrder();
limitOrder.PersistenceType = PersistenceType.LAPSE;
// place a back bet at rediculous odds so it doesn't get matched
limitOrder.Price = 1000;
limitOrder.Size = 0.1; // placing a bet below minimum stake, expecting a error in report
placeInstruction.LimitOrder = limitOrder;
placeInstruction.SelectionId = selectionId;
placeInstructions.Add(placeInstruction);
var customerRef = "123456";
[COLOR="Red"][B]var placeExecutionReport = jsonClient.placeOrders(marketId, customerRef, placeInstructions); // Fails here with an ACCESS_DENIED response[/B][/COLOR]
ExecutionReportErrorCode executionErrorcode = placeExecutionReport.ErrorCode;
InstructionReportErrorCode instructionErroCode = placeExecutionReport.InstructionReports[0].ErrorCode;
Console.WriteLine("\nPlaceExecutionReport error code is: " + executionErrorcode
+ "\nInstructionReport error code is: " + instructionErroCode);
Console.WriteLine("\nDONE!");
if (executionErrorcode != ExecutionReportErrorCode.BET_ACTION_ERROR && instructionErroCode != InstructionReportErrorCode.INVALID_BET_SIZE)
Console.ReadLine();
}
else
{
Console.Write("\nSorry the market has no runner to place a bet on, try again later");
}
Thank you


Comment