Exemplo n.º 1
0
        public async Task DoLimitOrder2(LkeHubLimitOrder2Model model)
        {
            double volume;

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


            double bid;

            try
            {
                bid = model.Bid.ParseAnyDouble();
            }
            catch (Exception)
            {
                SendMessage("#lobid" + model.CurTo, Phrases.InvalidRateFormat);
                return;
            }

            double ask;

            try
            {
                ask = model.Ask.ParseAnyDouble();
            }
            catch (Exception)
            {
                SendMessage("#loask" + model.CurTo, Phrases.InvalidRateFormat);
                return;
            }

            var traderId    = GetTraderId();
            var asset       = Dependencies.AssetPairsDictionary.FindByBasedOrQuotingAsset(model.CurFrom, model.CurTo);
            var limitOrder1 = LimitOrder.Create(traderId, asset.Id, model.CurFrom, OrderAction.Sell, volume, ask);
            var limitOrder2 = LimitOrder.Create(traderId, asset.Id, model.CurFrom, OrderAction.Buy, volume, bid);

            try
            {
                await Dependencies.SrvOrdersRegistrator.RegisterLinkedLimitOrders(limitOrder1, limitOrder2);

                SendMessage("#lobid" + model.CurTo, Phrases.OrderHasBeenRegistered);
            }
            catch (Exception ex)
            {
                SendMessage("#lobid" + model.CurTo, ex.Message);
            }
        }
Exemplo n.º 2
0
        public async Task DoLimitOrder2(LkeHubLimitOrder2Model model)
        {
            double volume;

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


            double bid;

            try
            {
                bid = model.Bid.ParseAnyDouble();
            }
            catch (Exception)
            {
                SendMessage("#lobid" + model.CurTo, Phrases.InvalidRateFormat);
                return;
            }

            double ask;

            try
            {
                ask = model.Ask.ParseAnyDouble();
            }
            catch (Exception)
            {
                SendMessage("#loask" + model.CurTo, Phrases.InvalidRateFormat);
                return;
            }

            var traderId = GetTraderId();
            var asset = Dependencies.AssetPairsDictionary.FindByBasedOrQuotingAsset(model.CurFrom, model.CurTo);
            var limitOrder1 = LimitOrder.Create(traderId, asset.Id, model.CurFrom, OrderAction.Sell, volume, ask);
            var limitOrder2 = LimitOrder.Create(traderId, asset.Id, model.CurFrom, OrderAction.Buy, volume, bid);

            try
            {
                await Dependencies.SrvOrdersRegistrator.RegisterLinkedLimitOrders(limitOrder1, limitOrder2);
                SendMessage("#lobid" + model.CurTo, Phrases.OrderHasBeenRegistered);
            }
            catch (Exception ex)
            {

                SendMessage("#lobid" + model.CurTo, ex.Message);
            }


        }