Esempio n. 1
0
        private static void CancelOrdersByIds()
        {
            var tradeClient = new OrderClient(Config.AccessKey, Config.SecretKey);

            _logger.Start();
            string[] orderIds = { "1", "2" };
            var      request  = new CancelOrdersByIdsRequest
            {
                OrderIds = orderIds
            };
            var response = tradeClient.CancelOrdersByIdsAsync(request).Result;

            _logger.StopAndLog();

            switch (response.status)
            {
            case "ok":
            {
                if (response.data != null)
                {
                    if (response.data.success != null)
                    {
                        foreach (string s in response.data.success)
                        {
                            AppLogger.Info($"Cancel success: {s}");
                        }
                    }
                    if (response.data.failed != null)
                    {
                        foreach (var f in response.data.failed)
                        {
                            string id = !string.IsNullOrWhiteSpace(f.orderId) ? f.orderId : f.clientOrderId;

                            AppLogger.Info($"Cancel fail, id: {id}, error: {f.errorMessage}");
                        }
                    }
                }
                break;
            }

            case "error":
            {
                AppLogger.Info($"Cancel orders fail, error code: {response.errorCode}, error message: {response.errorMessage}");
                break;
            }
            }
        }