Exemple #1
0
        private static void QueryBuyDetailAndUpdate(string userName, long orderId)
        {
            try
            {
                PlatformApi api = PlatformApi.GetInstance(userName);

                var orderDetail = api.QueryOrderDetail(orderId);
                if (orderDetail.Status == "ok" && orderDetail.Data.state == "filled")
                {
                    var orderMatchResult = api.QueryOrderMatchResult(orderId);
                    if (orderMatchResult == null || orderMatchResult.Data == null)
                    {
                        return;
                    }
                    decimal maxPrice = 0;
                    foreach (var item in orderMatchResult.Data)
                    {
                        if (maxPrice < item.price)
                        {
                            maxPrice = item.price;
                        }
                    }
                    if (orderMatchResult.Status == "ok" && maxPrice > 0)
                    {
                        new DogMoreBuyDao().UpdateDogMoreBuySuccess(orderId, orderDetail, orderMatchResult, maxPrice);
                    }
                }

                if (orderDetail.Status == "ok" && orderDetail.Data.state == StateConst.PartialCanceled)
                {
                    var     orderMatchResult = api.QueryOrderMatchResult(orderId);
                    decimal maxPrice         = 0;
                    decimal buyQuantity      = 0;
                    foreach (var item in orderMatchResult.Data)
                    {
                        if (maxPrice < item.price)
                        {
                            maxPrice = item.price;
                        }
                        buyQuantity += item.FilledAmount;
                    }
                    if (orderMatchResult.Status == "ok")
                    {
                        new DogMoreBuyDao().UpdateDogMoreBuySuccess(orderId, buyQuantity, orderDetail, orderMatchResult, maxPrice);
                    }
                }

                if (orderDetail.Status == "ok" && orderDetail.Data.state == StateConst.Canceled)
                {
                    // 完成
                    new DogMoreBuyDao().UpdateDogMoreBuyWhenCancel(orderId);
                }
            }
            catch (Exception ex)
            {
                logger.Error(ex.Message, ex);
                logger.Error($"QueryBuyDetailAndUpdate, orderId:{orderId}  查询数据出错");
            }
        }
Exemple #2
0
        private static void QueryEmptySellDetailAndUpdate(string userName, long orderId)
        {
            try
            {
                PlatformApi api = PlatformApi.GetInstance(userName);

                var orderDetail = api.QueryOrderDetail(orderId);
                if (orderDetail.Status == "ok" && orderDetail.Data.state == "filled")
                {
                    var     orderMatchResult = api.QueryOrderMatchResult(orderId);
                    decimal minPrice         = 25000;
                    foreach (var item in orderMatchResult.Data)
                    {
                        if (minPrice > item.price)
                        {
                            minPrice = item.price;
                        }
                    }
                    if (orderMatchResult.Status == "ok")
                    {
                        // 完成
                        new DogEmptySellDao().UpdateDogEmptySellWhenSuccess(orderId, orderDetail, orderMatchResult, minPrice);
                    }
                }
            }
            catch (Exception ex)
            {
                logger.Error(ex.Message, ex);
            }
        }
Exemple #3
0
        private static void QueryEmptyBuyDetailAndUpdate(string userName, long orderId)
        {
            try
            {
                PlatformApi api = PlatformApi.GetInstance(userName);

                var orderDetail = api.QueryOrderDetail(orderId);

                Console.WriteLine($"orderDetail: {JsonConvert.SerializeObject(orderDetail)}");
                if (orderDetail.Status == "ok" && orderDetail.Data.state == "filled")
                {
                    var     orderMatchResult = api.QueryOrderMatchResult(orderId);
                    decimal maxPrice         = 0;
                    foreach (var item in orderMatchResult.Data)
                    {
                        if (maxPrice < item.price)
                        {
                            maxPrice = item.price;
                        }
                    }
                    if (orderMatchResult.Status == "ok")
                    {
                        // 完成
                        new DogEmptyBuyDao().UpdateDogEmptyBuyWhenSuccess(orderId, orderDetail, orderMatchResult, maxPrice);
                    }
                }
            }
            catch (Exception ex)
            {
                logger.Error(ex.Message, ex);
            }
        }
Exemple #4
0
        private static void QuerySellDetailAndUpdate(string userName, long orderId)
        {
            PlatformApi api = PlatformApi.GetInstance(userName);

            var orderDetail = api.QueryOrderDetail(orderId);

            if (orderDetail.Status == "ok" && orderDetail.Data.state == "filled")
            {
                var     orderMatchResult = api.QueryOrderMatchResult(orderId);
                decimal minPrice         = 99999999;
                foreach (var item in orderMatchResult.Data)
                {
                    if (minPrice > item.price)
                    {
                        minPrice = item.price;
                    }
                }
                // 完成
                new PigMoreDao().UpdateTradeRecordSellSuccess(orderId, orderDetail, orderMatchResult, minPrice);
            }
        }
Exemple #5
0
        private static void QueryBuyDetailAndUpdate(string userName, long orderId)
        {
            PlatformApi api = PlatformApi.GetInstance(userName);

            var orderDetail = api.QueryOrderDetail(orderId);

            if (orderDetail.Status == "ok" && orderDetail.Data.state == "filled")
            {
                var     matchResult = api.QueryOrderMatchResult(orderId);
                decimal maxPrice    = 0;
                foreach (var item in matchResult.Data)
                {
                    if (maxPrice < item.price)
                    {
                        maxPrice = item.price;
                    }
                }
                if (matchResult.Status == "ok")
                {
                    new PigMoreDao().UpdatePigMoreBuySuccess(orderId, orderDetail, matchResult, maxPrice);
                }
            }
        }