예제 #1
0
파일: LkHub.cs 프로젝트: PAYMEY/MarketPlace
        public async Task DoLimitOrder(LkeHubLimitOrderModel model)
        {
            var orderAction = model.Action == "sell" ? OrderAction.Sell : OrderAction.Buy;

            double volume;

            try
            {
                volume = model.Volume.ParseAnyDouble();
            }
            catch (Exception)
            {
                SendMessage("#volume" + model.CurTo, Phrases.InvalidAmountFormat);
                return;
            }

            double price;
            var    id = orderAction == OrderAction.Sell ? "#slr" : "#blr";

            try
            {
                price = model.Price.ParseAnyDouble();
            }
            catch (Exception)
            {
                SendMessage(id + model.CurTo, Phrases.InvalidRateFormat);
                return;
            }


            var traderId   = GetTraderId();
            var asset      = Dependencies.AssetPairsDictionary.FindByBasedOrQuotingAsset(model.CurFrom, model.CurTo);
            var limitOrder = LimitOrder.Create(traderId, asset.Id, model.CurFrom, orderAction, volume, price);

            try
            {
                await Dependencies.SrvOrdersRegistrator.RegisterTradeOrderAsync(limitOrder);

                SendMessage(id + model.CurTo, Phrases.OrderHasBeenRegistered);
            }
            catch (Exception ex)
            {
                SendMessage(id + model.CurTo, ex.Message);
            }
        }
예제 #2
0
        public async Task DoLimitOrder(LkeHubLimitOrderModel model)
        {
            var orderAction = model.Action == "sell" ? OrderAction.Sell : OrderAction.Buy;

            double volume;

            try
            {
                volume = model.Volume.ParseAnyDouble();
            }
            catch (Exception)
            {
                SendMessage("#volume" + model.CurTo, Phrases.InvalidAmountFormat);
                return;
            }

            double price;
            var id = orderAction == OrderAction.Sell ? "#slr" : "#blr";
            try
            {
                price = model.Price.ParseAnyDouble();
            }
            catch (Exception)
            {

                SendMessage(id + model.CurTo, Phrases.InvalidRateFormat);
                return;
            }


            var traderId = GetTraderId();
            var asset = Dependencies.AssetPairsDictionary.FindByBasedOrQuotingAsset(model.CurFrom, model.CurTo);
            var limitOrder = LimitOrder.Create(traderId, asset.Id, model.CurFrom, orderAction, volume, price);

            try
            {
                await Dependencies.SrvOrdersRegistrator.RegisterTradeOrderAsync(limitOrder);
                SendMessage(id + model.CurTo, Phrases.OrderHasBeenRegistered);
            }
            catch (Exception ex)
            {

                SendMessage(id + model.CurTo, ex.Message);
            }

        }