Live Chat by Hybrid Solutions
Knowledgebase
ClientAcceptOrder
Posted by Mohammad Rahhal on 31 January 2012 12:52 PM

 

Description

The ClientAcceptOrder operation accepts a re-quoted order.


Request Parameters

Name Description  Required
AccountId
  • The intended account identifier.
  • Type: Long
  • Default: None
  • Constraints: Must be a valid account ID, and accessible by logged in client.
Yes
OrderId
  • The order to be accepted identifier.
  • Type: Long
  • Default: None
  • Constraints: Must be a valid order ID for the given AccountId.
Yes


Response Elements

Name Description 
Result
  • Returns Success Code. Otherwise see Error Codes.
  • Type: String


Sample

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

    <title>ClientAcceptOrder</title>

<script src="http://code.jquery.com/jquery-latest.js"></script>

</head>

<script >

    var urlStr = "http://74.54.46.178/vertexweb10/WebService.svc";

    function AcceptOrder(OrderID) {

        $.getJSON(urlStr + "/ClientAcceptOrder?AccountID=" + $("#txtAccountId").val() + "&OrderID=" + OrderID, onSuccessResultOrder);

        function onSuccessResultOrder(dataResult) {

            var result = eval(dataResult);

            var rst = ""

            if (result > 0) {

                var strAcceptOrder = "The new OrderId is :" + result + "and it has been accepted ... And you can see it in trade panel in client terminal  "

                $("#resultAction").html($("#resultAction").html() + "<br/>" + strAcceptOrder.fontcolor("red"));

            }

            else {

                rst = "http://www.hybrid-solutions.com/support/index.php?/Knowledgebase/Article/View/1964"

                $("#resultAction").html("Error Code : " + result + "<br/>" + " for more details see the follwing link: " + rst.link(rst));

            }

        }

    }

    function onSuccessResultOrder(dataResult) {

        var result = eval(dataResult);

        var rst = ""

        if (result[0] > 0) {

            //if result[6]=1 , then  Open Postion has been done

            if (result[6] == 1) {

                rst += "Order has been done  successfully!  the following is the open position details : </br>"

                rst += "OrderID:" + result[0] + "   Time :" + result[1] + "  Amount :" + result[3] + "   Symbol ID:" + result[4] + "   Open Price:" + result[5]

                $("#resultAction").html(rst);

            }

            //if result[6]=2 , then  pending order has been done

            else if (result[6] == 2) {

                rst += "Order has been done  successfully!  the following is the pending Order details : </br>"

                rst += "OrderID:" + result[0] + "   Time :" + result[1] + "  Amount :" + result[3] + "Symbol ID:" + result[4] + "Open Price:" + result[5]

                $("#resultAction").html(rst);

            }

            else {

                var rst = "www.hybrid-solutions/support/index.php?/knowledgebase/Article/View/1964"

                $("#resultAction").html("Error Code : " + rst + "<br/>" + " for more details see the follwing link: " + rst.link(rst));

            }

        }

        else {

            var rst = "www.hybrid-solutions/support/index.php?/knowledgebase/Article/View/1964"

            $("#resultAction").html("Error Code : " + result[0] + "<br/>" + " for more details see the follwing link: " + rst.link(rst));

        }

    }

    function GetRequotedOrders() {

        $.ajaxSetup({ "cash": false });

        $.getJSON(urlStr + "/GetRequotedOrders?callback=?", onSuccessResultAction);

    }

    function onSuccessResultAction(dataResult) {

        var result = eval(dataResult);

        var strResult = ""

        if (result.length == 0) {

            strResult = "No result ";

        }

        else {

            var note = "Call ClientAcceptOrder() or ClientRejectOrder()  method to accept or reject the Requoted Order "

            for (var i = 0; i < result.length; i++) {

                strResult = strResult + "OrderID :" + result[i].OrderID + "</br>"

                if (parseInt(result[i].BuySell) == 1) {

                    strResult = strResult + "BuySell Type  :" + "Buy" + "</br>"

                }

                else {

                    strResult = strResult + "BuySell Type  :" + "Sell" + "</br>"

                }

                strResult = strResult + "Old Price  :" + result[i].OldSell + "</br>"

                strResult = strResult + "New Price  :" + result[i].NewSell + "</br>"

                strResult = strResult + note.bold() + "</br>" + "</br>" + "</br>"

                // use to Accept order when the dealer requote it

                alert("Press Ok to Accept Order");

                AcceptOrder(result[i].OrderID)

            }

        }

        $("#resultAction").html($("#resultAction").html() + "<br/>" + strResult);

        setTimeout('GetRequotedOrders()', '2000');

    }

    $(document).ready(function () {

        $.support.cors = true;

        $("#progress").ajaxStart(function () { $(this).css("display", "block"); });

        $("#progress").ajaxComplete(function () { $(this).css("display", "none"); });

        $.ajaxSetup({ "cash": false });

        function onSuccessResult(response) {

            response = eval('(' + response + ')')

            if (response.UserId == -1 || response.UserId == -207) {

                $("#resultData").html("Invalid username or password");

            }

            else if (response.UserId == -231) {

                $("#resultData").html("You must have at least one account");

            }

            else if (response == null || response == "" || response.UserId < 0) {

                $("#resultData").html("Error while login.Please try later");

            }

            else {

                $("#resultData").html("SuccessResult ... UserId is :" + response.UserId);

            }

        }

        $("#resultAction").ajaxError(function (result) { $(this).html('An error occured'); });

        function onErrorResult(result) {

            alert('Service call faild : ' + result.status + ' ' + result.statusText);

        }

        $("#btnLogin").click(function () {

            $.getJSON(urlStr + "/Login?username=" + $("#txtusername").val() + "&password=" + $("#txtpassword").val() + "&callback=?", onSuccessResult);

        });

        $("#btnActionNewOrder").click(function () {

            $.getJSON(urlStr + "/NewOrder?AccountId=" + $("#txtAccountId").val() + "&Symbol=" + $("#txtSymbol").val() + "&BuySell=" + $("#txtBuySell").val() + "&lots=" + $("#txtlots").val() + "&callback=?", onSuccessResultOrder);

        });

        $("#btnAction").click(function () {

            GetRequotedOrders();

        });

    });

</script>

<body>

The ClientAcceptOrder operation accepts a re-quoted order.

<table border="1px">

<tbody>

<tr>

<td>

username: <input type="text" id="txtusername" value="support"/>

password: <input type="text" id="txtpassword" value="support"/>

<button id="btnLogin"> Login </button>

</td>

</tr>

  <tr>

      <td>AccountId : <input type="text" id="txtAccountId"  value ="12347298" /> </td> 

      <td>Symbol: <input type="text" id="txtSymbol"  value ="6" /> </td> 

  </tr>

 

  <tr>

      <td>BuySell: <input type="text" id="txtBuySell"  value ="1" /></td>

      <td>lots:<input type="text" id="txtlots"  value ="1.0" /></td>

      <td><button id="btnActionNewOrder"> NewOrder </button></td>

      <td><button id="btnAction"> Start GetRequotedOrders and Accept Orders    </button></td>

  </tr>

</tbody>

</table>

Note:  Press (Start GetRequotedOrders and Accept Orders) button to start listnering, after take order and the dealer Requote it.

<div id="resultData"> </div>

<div id="resultAction"> </div>

<div style="display:none" id="progress">Loading ... </div>

</body>

</html>

 



 

See Also


VertexFX WCF Service Index

(0 votes)
This article was helpful
This article was not helpful

Comments (0)
Post a new comment 
 
Full Name:
Email:
Comments:
CAPTCHA Verification 
 
Please enter the text you see in the image into the textbox below. This is required to prevent automated registrations and form submissions.

Help Desk Software by Hybrid Solutions