Checking Part Matched Orders

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • uncletone1
    Junior Member
    • Oct 2012
    • 24

    #1

    Checking Part Matched Orders

    Hi All,

    I was programming my bot today and I was mainly concerning myself with the "Part Match" problem.

    I'm placing an order and checking the response to ensure the SizeMatched is equal to the Order Amount.

    If these are not equal then the BOT drops into a loop (I assumed the ListCurrentOrders was the call to use) and circles through till the match is made (or cancelled after a period of time).

    To make things easier, I was only passing one BETID (from the successful unmatched bet). So that only one BetResponse should come back.

    Right, that's the back ground. Now when I stepped this through the code by performing some test bets (A bet that was in no way going to get matched) the loop was endless and was working as expected. However, when I attempted to run the code in a live scenario, it was crashing with an error. The error was that it was not bringing back the intended BetResponse in fact it brought back nothing.

    I don't understand why this would not be bringing back details of a bet I know I just made and have had a response too lines of code earlier.

    Sample of Code
    -----------------------------------------------------------
    // Check Bet
    if (BetOrder.result.status == "SUCCESS")
    {
    BetID = BetOrder.result.instructionReports[0].placeInstructionReport.betId;

    //Check Matched Size
    if (BetOrder.result.instructionReports[0].placeInstructionReport.sizeMatched == _OrigSize)
    {
    ReturnDetails.AveragePriceMatched = BetOrder.result.instructionReports[0].placeInstructionReport.averagePriceMatched;
    ReturnDetails.BetId = BetOrder.result.instructionReports[0].placeInstructionReport.betId;
    ReturnDetails.SizeMatched = BetOrder.result.instructionReports[0].placeInstructionReport.sizeMatched;
    ReturnDetails.Status =
    BetOrder.result.status;

    return ReturnDetails;
    }


    // Part Match Checker
    List<String> BetIDs = new List<string>();
    BetIDs.Add(BetID);

    BF.Requests.ReqlistCurrentOrders CheckOrder =
    new Requests.ReqlistCurrentOrders();
    CheckOrder.@params.betIds = BetIDs;
    BF.Responses.RespCurrentOrders CurrentOrders = JsonConvert.DeserializeObject<BF.Responses.RespCur rentOrders>(GetResponse(JsonConvert.SerializeObjec t(CheckOrder)));


    //Loop
    while (CurrentOrders.result.currentOrders[0].sizeMatched != Order.@params.instructions[0].limitOrder.size)
    {
    CurrentOrders = JsonConvert.DeserializeObject<BF.Responses.RespCur rentOrders>(GetResponse(JsonConvert.SerializeObjec t(CheckOrder)));
    }
    ReturnedDetails.AveragePriceMatched = CurrentOrders.result.currentOrders[0].averagePriceMatched;
    ReturnedDetails.BetId =
    CurrentOrders.result.currentOrders[0].betId;
    ReturnedDetails.SizeMatched =
    CurrentOrders.result.currentOrders[0].sizeMatched;
    ReturnedDetails.Status =
    CurrentOrders.result.currentOrders[0].status;

    return ReturnedDetails;

    -----------------------------------------------------------
    Any ideas
  • uncletone1
    Junior Member
    • Oct 2012
    • 24

    #2
    So far I have come up with two possibilities, but i've not confirmed both yet. So if anyone out there can verify this i'd be grateful.

    1, If the market CLOSES hence the bets are cancelled or settled. The betID's are removed and so returns nothing. (This is at least one scenario i'm now checking for, yet the problem still exists in some cases)

    2, The BetID moves from a logical table (or similar) from Unmatched to Matched, and for a brief moment (Say that time of my call) the BetID is not present in either of the locations the LissCurrentOrders looks in. This one i've not been able to test yet, but its the only thing I could come up with. For completeness, when this anomaly occurred (the betID was present in the Matched section (so it must have been unmatched at some point to drop to the loop) through the websites account details / current Bets).

    If anyone else has any ideas I'd be grateful.

    Thanks

    Comment

    • uncletone1
      Junior Member
      • Oct 2012
      • 24

      #3
      Solved

      I had set the ListCurrentOrders object to only show betID's with an unmatched Portion.

      OrderProjection = "Executable"

      Changing this to "All" sorted it.

      Happy Days.

      Comment

      Working...
      X