Exemple #1
0
        private SendReply Send(SendOrderParam param)
        {
            var    path      = "/api/order?";
            int    tradetype = param.side == "buy" ? 1 : 0;
            string body      = "accesskey=" + _config.Key + $"&amount={param.quantity}&currency={_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);
        }
Exemple #2
0
        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;
        }