public async Task <CreateTradeResponseModel> CreateTrade(string userId, CreateTradeModel model, bool isApi)
        {
            try
            {
                using (var tradeService = CreateService())
                {
                    var response = await tradeService.SubmitTradeAsync(new SubmitTradeItemRequest
                    {
                        Amount      = model.Amount,
                        IsBuy       = model.IsBuy,
                        Rate        = model.Price,
                        UserId      = new Guid(userId),
                        TradePairId = model.TradePairId,
                        IsApi       = isApi
                    }).ConfigureAwait(false);

                    return(new CreateTradeResponseModel
                    {
                        Error = response.Error,
                        OrderId = response.OrderId,
                        FillerOrders = response.FilledOrderIds,
                        DataUpdates = await ProcessDataUpdates(response),
                        Notifications = await ProcessNotifications(response)
                    });
                }
            }
            catch (Exception)
            {
                return(new CreateTradeResponseModel {
                    Error = "An Error occurred placing trade, if problem persist please contact Cryptopia Support"
                });
            }
        }
Beispiel #2
0
        private async Task <bool> CreateTradeAsync()
        {
            try
            {
                decimal price;
                decimal volume;
                if (!decimal.TryParse(_createTradeModel.Price, out price) ||
                    !decimal.TryParse(_createTradeModel.Volume, out volume))
                {
                    return(false);
                }
                bool result = await TradeOrderServices.CreateTradeAsync(CurrencyType.bcc_cny, price, volume, CurrencyRepository.GetCurrency("BCC").DefaultProfit);

                if (result)
                {
                    //更新活跃订单列表
                    LoadData();
                    CreateTradeModel = new CreateTradeModel();
                }
                return(result);
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
                return(false);
            }
        }
 public ActionResult addtrade([Bind(
                                   nameof(CreateTradeModel.trade_code))]
                              CreateTradeModel model)
 {
     if (ModelState.IsValid)
     {
         model.Create();
         return(RedirectToAction("index"));
     }
     return(View(model));
 }
Beispiel #4
0
        public async Task <ActionResult> CreateTrade(CreateTradeModel model)
        {
            var result = await TradeWriter.CreateTrade(User.Id(), model);

            if (result.HasErrors)
            {
                return(JsonError());
            }

            return(JsonSuccess());
        }
Beispiel #5
0
        public async Task <IWriterResult <bool> > CreateTrade(string userId, CreateTradeModel model)
        {
            model.UserId = userId;
            var result = await TradeService.QueueTrade(model);

            if (result.HasError)
            {
                return(WriterResult <bool> .ErrorResult(result.Error));
            }

            return(WriterResult <bool> .SuccessResult());
        }
        public async Task <ActionResult> CreateTrade(CreateTradeModel model)
        {
            if (!ModelState.IsValid)
            {
                return(PartialView("_CreateTradePartial", model));
            }

            var result = await TradeWriter.CreateTrade(User.Id(), model);

            if (!ModelState.IsWriterResultValid(result))
            {
                return(PartialView("_CreateTradePartial", model));
            }

            return(PartialView("_CreateTradePartial", model));
        }
Beispiel #7
0
 public MainWindowViewModel()
 {
     try
     {
         //初始化数据库连接
         DataProvider.GetConnection();
         //开启多线程,加快启动速度
         CreateTradeModel = new CreateTradeModel();
         Task.Run(() => { LoadData(); });
         Task.Run(() => CheckOrder());
     }
     catch (Exception ex)
     {
         Logger.Error(ex);
         AssetInfo = new AssetModel();
     }
 }
        public IActionResult addtrade()
        {
            var model = new CreateTradeModel();

            return(View(model));
        }