[HttpGet()]  // 为了演示方便,未采用HttpPost
        public async Task <IActionResult> Purchase()
        {
            var x = _context.XHouseInventory.FirstOrDefault(x => x.Name == "XName");

            if (x.Sku > 0)
            {
                x.Sku -= 1;
                var order = new XOrder {
                    Description = $"订单...{DateTime.Now}", XHouseInventory = x,
                };
                _context.XOrders.Add(order);
                await _context.SaveChangesAsync();
            }
            return(Json(x));
        }
Beispiel #2
0
        public XOrder CreateXOrder(BinanceOrder bo, string strategyId = "")
        {
            var xo = new XOrder("BINANCE", strategyId);

            //xo.API = api;
            xo.Amount       = bo.Quantity;          //.OriginalQuantity;
            xo.AmountFilled = bo.QuantityFilled;    //.ExecutedQuantity;
            xo.AveragePrice = bo.Price;
            xo.Fees         = 0;
            xo.FeesCurrency = "";
            xo.IsBuy        = bo.Side == Binance.Net.Enums.OrderSide.Buy;
            xo.Message      = "";
            xo.OrderDate    = bo.CreateTime;        //.Time;
            xo.OrderId      = bo.OrderId.ToString();
            xo.Price        = bo.Price;
            xo.Result       = MapToResult(bo.Status);
            xo.Symbol       = bo.Symbol;

            return(xo);
        }
Beispiel #3
0
        public static XOrder CreateXOrder(string exchange, ExchangeOrderResult eor, string strategyId)
        {
            var xo = new XOrder(exchange, strategyId);

            //m_api = api;

            //xo.API = api;
            xo.Amount       = eor.Amount;
            xo.AmountFilled = eor.AmountFilled;
            xo.AveragePrice = eor.AveragePrice;
            xo.Fees         = eor.Fees;
            xo.FeesCurrency = eor.FeesCurrency;
            xo.IsBuy        = eor.IsBuy;
            xo.Message      = eor.Message;
            xo.OrderDate    = eor.OrderDate;
            xo.OrderId      = eor.OrderId;
            xo.Price        = eor.Price;
            //xo.Result = MapToResult(bo.Status);
            xo.Symbol = eor.Symbol;

            return(xo);
        }