void tl_gotSrvFillRequest(Order o) { if (!ok) { debug("not logged in."); return; } string action = o.side ? "buy" : "sell"; string otype = o.isLimit ? "limit" : "market"; if (o.id == 0) { o.id = OrderImpl.Unique; } string route = "auto"; if (o.ex.ToUpper().Contains("ARCA")) { route = "ecn_arca"; } else if (o.ex.ToUpper().Contains("INET")) { route = "inet"; } AmeritradeBrokerAPI.ATradeArgument brokerReplyargs = new AmeritradeBrokerAPI.ATradeArgument(); string cResultMessage = string.Empty; string cEnteredOrderID = string.Empty; StringBuilder cOrderString = new StringBuilder(); if (!chkboxProdEnabled.Checked) { TradelinkMySQL db = new TradelinkMySQL(); brokerReplyargs.ResultsCode = db.OrderToDatabase(o); debug("DEBUG ORDER: " + brokerReplyargs.ResultsCode + " " + o.symbol + " " + o.size + "@" + o.price + "\n"); Trade t = new TradeImpl(); } else { //cOrderString.Append("action=" + api.Encode_URL(action)); //cOrderString.Append("~clientorderid=" + api.Encode_URL(o.id.ToString())); //cOrderString.Append("~accountid=" + api.Encode_URL(api._accountid)); //cOrderString.Append("~actprice=" + api.Encode_URL(string.Empty)); //cOrderString.Append("~expire=" + api.Encode_URL(o.TIF)); //cOrderString.Append("~ordtype=" + api.Encode_URL(otype)); //cOrderString.Append("~price=" + api.Encode_URL(o.price.ToString())); //cOrderString.Append("~quantity=" + api.Encode_URL(o.size.ToString())); //cOrderString.Append("~spinstructions=" + api.Encode_URL("none")); //cOrderString.Append("~symbol=" + api.Encode_URL(o.symbol)); //cOrderString.Append("~routing=" + api.Encode_URL(route)); //cOrderString.Append("~tsparam=" + api.Encode_URL(string.Empty)); //cOrderString.Append("~exmonth=" + api.Encode_URL(string.Empty)); //cOrderString.Append("~exday=" + api.Encode_URL(string.Empty)); //cOrderString.Append("~exyear=" + api.Encode_URL(string.Empty)); //cOrderString.Append("~displaysize=" + api.Encode_URL(string.Empty)); //brokerReplyargs.ResultsCode = // api.TD_sendOrder(_user.Text, _pass.Text, AmeritradeBrokerAPI.SOURCEID, APIVER, cOrderString.ToString(), ref cResultMessage, ref cEnteredOrderID); //if (brokerReplyargs.ResultsCode != OK) // debug(cResultMessage); //else //{ // long tdid = 0; // if (long.TryParse(cEnteredOrderID, out tdid)) // idmap.Add(o.id, tdid); // tl.newOrder(o); //} debug("PROD ORDER: " + brokerReplyargs.ResultsCode + " " + o.symbol + " " + o.size + "@" + o.price + "\n"); } }
void tl_gotSrvFillRequest(Order o) { if (!ok) { debug("not logged in."); return; } string action = o.side ? "buy" : "sell"; string otype = o.isLimit ? "limit" : "market"; if (o.id == 0) o.id = OrderImpl.Unique; string route = "auto"; if (o.ex.ToUpper().Contains("ARCA")) route = "ecn_arca"; else if (o.ex.ToUpper().Contains("INET")) route = "inet"; AmeritradeBrokerAPI.ATradeArgument brokerReplyargs = new AmeritradeBrokerAPI.ATradeArgument(); string cResultMessage = string.Empty; string cEnteredOrderID = string.Empty; StringBuilder cOrderString = new StringBuilder(); if (!chkboxProdEnabled.Checked) { TradelinkMySQL db = new TradelinkMySQL(); brokerReplyargs.ResultsCode = db.OrderToDatabase(o); debug("DEBUG ORDER: " + brokerReplyargs.ResultsCode + " " + o.symbol + " " + o.size + "@" + o.price + "\n"); Trade t = new TradeImpl(); } else { //cOrderString.Append("action=" + api.Encode_URL(action)); //cOrderString.Append("~clientorderid=" + api.Encode_URL(o.id.ToString())); //cOrderString.Append("~accountid=" + api.Encode_URL(api._accountid)); //cOrderString.Append("~actprice=" + api.Encode_URL(string.Empty)); //cOrderString.Append("~expire=" + api.Encode_URL(o.TIF)); //cOrderString.Append("~ordtype=" + api.Encode_URL(otype)); //cOrderString.Append("~price=" + api.Encode_URL(o.price.ToString())); //cOrderString.Append("~quantity=" + api.Encode_URL(o.size.ToString())); //cOrderString.Append("~spinstructions=" + api.Encode_URL("none")); //cOrderString.Append("~symbol=" + api.Encode_URL(o.symbol)); //cOrderString.Append("~routing=" + api.Encode_URL(route)); //cOrderString.Append("~tsparam=" + api.Encode_URL(string.Empty)); //cOrderString.Append("~exmonth=" + api.Encode_URL(string.Empty)); //cOrderString.Append("~exday=" + api.Encode_URL(string.Empty)); //cOrderString.Append("~exyear=" + api.Encode_URL(string.Empty)); //cOrderString.Append("~displaysize=" + api.Encode_URL(string.Empty)); //brokerReplyargs.ResultsCode = // api.TD_sendOrder(_user.Text, _pass.Text, AmeritradeBrokerAPI.SOURCEID, APIVER, cOrderString.ToString(), ref cResultMessage, ref cEnteredOrderID); //if (brokerReplyargs.ResultsCode != OK) // debug(cResultMessage); //else //{ // long tdid = 0; // if (long.TryParse(cEnteredOrderID, out tdid)) // idmap.Add(o.id, tdid); // tl.newOrder(o); //} debug("PROD ORDER: " + brokerReplyargs.ResultsCode + " " + o.symbol + " " + o.size + "@" + o.price + "\n"); } }