Exemplo n.º 1
0
        public Main()
        {
            InitializeComponent();
            try
            {
                String hotWalletAddress = cardClient.GetHotWalletAddress();

                if (!String.IsNullOrEmpty(hotWalletAddress))
                {
                    // No Sale or Transfers
                    btnSell.Enabled = false;
                }

                DCDiagnostics.TerminalSettings settings = diagnosticClient.GetSettings(this.TerminalId);

                this.CryptoCurrency = new Models.Bitcoin(settings.DefaultFiatCurrency);
                DCExchange.ExchangeClient ExchangeClient = new DCExchange.ExchangeClient();

                this.AtmMargin = ExchangeClient.GetMargin(settings.DefaultFiatCurrency, this.TerminalId);
            }
            catch (Exception ex)
            {
                GeneralExceptions("Initialise", System.Diagnostics.TraceEventType.Critical, ex);
            }
        }
Exemplo n.º 2
0
        private async void GetQuote()
        {
            try
            {
                // Gets a quote for bitcoins - Not a balance.  Bad Method Name - TODO
                if (!String.IsNullOrEmpty(txtFiat.Text) && Convert.ToInt32(txtFiat.Text) > 0)
                {
                    // CryptoCurrency.Amount = Convert.ToDecimal(txtFiat.Text);
                    DCExchange.ExchangeClient ExchangeClient = new DCExchange.ExchangeClient();

                    if (Operation == Enums.State.Buy)
                    {
                        Price = ExchangeClient.GetSpotPrice("EUR", Convert.ToDecimal(txtFiat.Text), TerminalId);

                        CryptoCurrency.Amount = Convert.ToDecimal(txtFiat.Text) * Price;

                        CryptoCurrency.Fiat = Convert.ToDecimal(txtFiat.Text);


                        // CryptoCurrency.Amount = Math.Round(await client.(CryptoCurrency.Fiat, CryptoCurrency.FiatCode) * (1m - Margin.Buy), 8);

                        // Price = Math.Round(CryptoCurrency.Fiat / CryptoCurrency.Amount, 8);
                    }
                    else if (Operation == Enums.State.Sell)
                    {
                        //CryptoCurrency.Amount = Math.Round(await client.GetBitcoinAmountAsync(CryptoCurrency.Fiat, CryptoCurrency.FiatCode) * (1m - Margin.Sell), 8);
                        // Price = Math.Round(CryptoCurrency.Fiat / CryptoCurrency.Amount, 8);

                        Price = ExchangeClient.GetSpotPrice("EUR", Convert.ToDecimal(txtFiat.Text), TerminalId);

                        CryptoCurrency.Amount = Convert.ToDecimal(txtFiat.Text) * Price;
                        CryptoCurrency.Fiat   = Convert.ToDecimal(txtFiat.Text);
                    }
                    txtBitcoins.Text = CryptoCurrency.Amount.ToString();
                    txtRate.Text     = Price.ToString();
                }
            }
            catch (Exception ex)
            {
                GeneralExceptions("GetQuote", System.Diagnostics.TraceEventType.Critical, ex);
                ReturnToMainMenu();
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Get quote off our exchange.  Note the exchange adds margin based on terminal id.
        /// </summary>
        /// <param name="fiatAmount"></param>
        /// <returns></returns>
        public Models.Quote GetQuote(Int32 fiatAmount)
        {
            if (fiatAmount > 0)
            {
                // CryptoCurrency.Amount = Convert.ToDecimal(txtFiat.Text);
                using (DCExchange.ExchangeClient ExchangeClient = new DCExchange.ExchangeClient())
                {
                    //This method gets the buy and sell prices off 1.0 unit.
                    DCExchange.Margin margin = ExchangeClient.GetMargin(this.Settings.DefaultFiatCurrency, TerminalId);

                    Decimal rate = 0.0M;

                    if (Operation == Enums.State.Buy)
                    {
                        rate = margin.Buy;
                        CryptoCurrency.Amount = Convert.ToDecimal(fiatAmount) * margin.Buy;
                        CryptoCurrency.Fiat   = Convert.ToDecimal(fiatAmount);
                    }
                    else if (Operation == Enums.State.Sell)
                    {
                        rate = margin.Sell;
                        CryptoCurrency.Amount = Convert.ToDecimal(fiatAmount) * margin.Sell;
                        CryptoCurrency.Fiat   = Convert.ToDecimal(fiatAmount);
                    }

                    Models.Quote currentQuote = new Models.Quote()
                    {
                        Amount = CryptoCurrency.Amount,
                        Rate   = rate
                    };

                    return(currentQuote);
                }
            }
            else
            {
                throw new ArgumentOutOfRangeException();
            }
        }