public static SwapViewModel CreateSwapViewModel(Swap swap, ICurrencies currencies, IAccount account)
        {
            var soldCurrency      = currencies.GetByName(swap.SoldCurrency);
            var purchasedCurrency = currencies.GetByName(swap.PurchasedCurrency);

            var fromAmount = AmountHelper.QtyToAmount(swap.Side, swap.Qty, swap.Price, soldCurrency.DigitsMultiplier);
            var toAmount   = AmountHelper.QtyToAmount(swap.Side.Opposite(), swap.Qty, swap.Price, purchasedCurrency.DigitsMultiplier);

            var quoteCurrency = swap.Symbol.QuoteCurrency() == swap.SoldCurrency
                ? soldCurrency
                : purchasedCurrency;

            var swapViewModel = new SwapViewModel
            {
                Id   = swap.Id.ToString(),
                Mode = ModeBySwap(swap),
                Time = swap.TimeStamp,

                FromAmount       = fromAmount,
                FromCurrencyCode = soldCurrency.Name,

                ToAmount       = toAmount,
                ToCurrencyCode = purchasedCurrency.Name,

                Price       = swap.Price,
                PriceFormat = $"F{quoteCurrency.Digits}",

                Account = account
            };

            swapViewModel.UpdateSwap(swap);

            return(swapViewModel);
        }
Ejemplo n.º 2
0
 public SwapInfoPage(SwapViewModel swapViewModel)
 {
     InitializeComponent();
     BindingContext = swapViewModel;
     SetVisualState("SwapProgress");
 }