コード例 #1
0
        public TradeTaskViewModel(SymbolInformation si, string exchangeName)
        {
            Model               = new TradeTask();
            Model.Id            = Guid.NewGuid();
            Model.Symbol        = si.Symbol;
            Model.Exchange      = exchangeName;
            SymbolInformation   = si;
            QuoteBalance        = si.QuoteAssetBalance.Free;
            QuoteBalancePercent = 0.05;
            Buy = new OrderTaskViewModel(this)
            {
                Price = si.PriceTicker.Ask.GetValueOrDefault()
            };
            StopLoss = new OrderTaskViewModel(this)
            {
                Price = si.ClampPrice(Buy.Price * 0.95m)
            };
            TakeProfit = new ObservableCollection <TakeProfitViewModel>();
            var DEF_TAKE_PRCNTS = new double[] { 0.6, 0.4 };

            for (int ind = 1; ind <= 2; ++ind)
            {
                var tp = new TakeProfitViewModel(this, DEF_TAKE_PRCNTS[ind - 1], ind > 1 ? TakeProfit[ind - 2] : null)
                {
                    Price = Math.Round(Buy.Price * (1.05m + 0.05m * ind), si.PriceDecimals), Caption = $"Тейк {ind}"
                };
                TakeProfit.Add(tp);
            }
            LastPrice            = Buy.Price;
            AddTakeProfitCommand = ReactiveCommand.Create <object>(AddTakeProfitExecute);
            SubmitCommand        = ReactiveCommand.CreateFromTask <string, bool>(SubmitImpl);
            ConnectTrades(edit: true);
        }
コード例 #2
0
 public TradeTaskViewModel(SymbolInformation si, TradeTask model)
 {
     SymbolInformation = si;
     Model             = model;
     Buy        = new OrderTaskViewModel(this, model.Buy);
     StopLoss   = new OrderTaskViewModel(this, model.StopLoss);
     TakeProfit = new ObservableCollection <TakeProfitViewModel>();
     for (int ind = 1; ind <= model.TakeProfit.Count(); ++ind)
     {
         var tp = new TakeProfitViewModel(this, model.TakeProfit[ind - 1], ind > 1 ? TakeProfit[ind - 2] : null);
         TakeProfit.Add(tp);
     }
     LastPrice = si.PriceTicker.LastPrice.GetValueOrDefault();
     ConnectTrades();
 }