private SendReply Send(SendOrderParam param) { var path = "/api/order?"; int tradetype = param.side == "buy" ? 1 : 0; string body = "accesskey=" + _config.Key + $"&amount={param.quantity}¤cy={_config.Leg1.ToLower()}_{_config.Leg2.ToLower()}&method=order&price={param.price}&tradeType={tradetype}"; path += body; var req = BuildRequest(path, "GET", body); RestUtil.LogRestRequest(req); SetBaseUrl("trade"); var response = _restClient.Execute(req); if (response == null || response.StatusCode == 0) { Log.Debug($"Zb Send response is null or failed ..."); return(new SendReply() { code = "-1" }); } JObject j = JObject.Parse(response.Content); SendReply reply = j.ToObject <SendReply>(); return(reply); }
public void Send(Order order) { if (order.Broker != Broker) { throw new InvalidOperationException(); } SendOrderParam param = new SendOrderParam(order); var reply = Send(param); if (reply.code.Trim() != "1000") { order.Status = OrderStatus.Rejected; Log.Info("Zb Send: " + reply.message); return; } order.BrokerOrderId = reply.id; order.Status = OrderStatus.New; order.SentTime = DateTime.Now; order.LastUpdated = DateTime.Now; }