Esempio n. 1
0
 public void Init(decimal balanceItem1, decimal balanceItem2, decimal buyFee, decimal sellFee)
 {
     _availableItem2 = balanceItem2;
     _availableItem1 = balanceItem1;
     _fee = new Fee
     {
         BuyFee = buyFee,
         SellFee = sellFee
     };
 }
Esempio n. 2
0
 /// <summary>
 /// 
 /// </summary>
 public FakeExchange()
 {
     _availableItem2 = 4000;
     _availableItem1 = 2;
     _fee = new Fee
     {
         BuyFee = 0.5m,
         SellFee = 0.5m
     };
 }
Esempio n. 3
0
        /// <summary>
        /// Updates the user's balance
        /// </summary>
        private void UpdateBalance()
        {
            var tickerRes = _proxy.GetTicker(_selectedPair);
            if (!tickerRes.Success)
            {
                ErrorHelper.DisplayErrorMessage(tickerRes.ErrorMessage);
                return;
            }
            var ticker = tickerRes.Result;
            string currency = _selectedPair.Item2;
            OnTickerUpdate(ticker);

            var balRes = _proxy.GetBalance(_selectedPair);
            if (balRes.Success)
            {
                var bal = balRes.Result;
                _fee = _proxy.GetFee(_selectedPair).Result;
                lblItem1Balance.Text = string.Format(CultureInfo.InvariantCulture, "{0:0.00######} {1}", bal.Balances[_selectedPair.Item1], _selectedPair.Item1);
                lblItem2Balance.Text = string.Format(CultureInfo.InvariantCulture, "{0:0.00######} {1}", bal.Balances[_selectedPair.Item2], currency);
            }
            else
            {
                ErrorHelper.DisplayErrorMessage(balRes.ErrorMessage);
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Clear fields and gets the fee for the selected pair
        /// </summary>
        private void OnPairChanged(PairSelected m)
        {
            if (m.SelectorType != SelectorType.Main)
            {
                return;
            }
            try
            {
                _selectedPair = m.Pair;
                lblItem1Balance.Text = lblItem2Balance.Text = string.Empty;
                txtBuyAmount.Text = txtBuyPrice.Text = txtSellAmount.Text = txtSellPrice.Text = string.Empty;
                var feeRes = _proxy.GetFee(m.Pair);
                lblCurrency1.Text = lblCurrency2.Text = m.Pair.Item2;
                lblSellAmountCurrency.Text = lblBuyAmountCurrency.Text = m.Pair.Item1;

                _fee = feeRes.Success ? feeRes.Result : new Fee { BuyFee = 0.5m, SellFee = 0.5m };
                lblBuyFee.Text = lblSellFee.Text = "0";
                lblBuyTotal.Text = lblSellTotal.Text = "0";
            }
            catch (Exception ex)
            {
                Logger.Log(ex);
                ErrorHelper.DisplayErrorMessage(ex.ToString());
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Updates the user's balance
        /// </summary>
        /// <param name="displayErrorMessages">Whether to display error messages in a popup</param>
        private void UpdateBalance(bool displayErrorMessages = true)
        {
            var tickerRes = _proxy.GetTicker(_selectedPair);
            if (!tickerRes.Success)
            {
                if (displayErrorMessages)
                {
                    ErrorHelper.DisplayErrorMessage(tickerRes);
                }
                return;
            }
            var ticker = tickerRes.Result;
            string currency = _selectedPair.Item2;
            OnTickerUpdate(ticker);

            var balRes = _proxy.GetBalance(_selectedPair);
            if (balRes.Success)
            {
                var bal = balRes.Result;
                _fee = _proxy.GetFee(_selectedPair).Result;
                lblItem1Balance.Text = string.Format("{0} {1}", bal.Balances[_selectedPair.Item1].ToStandardFormat(), _selectedPair.Item1);
                lblItem2Balance.Text = string.Format("{0} {1}", bal.Balances[_selectedPair.Item2].ToStandardFormat(), currency);
            }
            else if(displayErrorMessages)
            {
                ErrorHelper.DisplayErrorMessage(balRes);
            }

        }