private double AmountQuoteToSell(CurrencyPair currencyPair, double bestPricePerCoin, double USDT) { double amountQuote = 0; // TODO BOOOOOOGUE dans le else? ou dans le if si ça prend le truncate et * 100000000, apparemment juste quand je vends à partir du form // le if... si le usdt a monté plutot?, ben ça vend pas toute... BalanceModel balance = (from x in GetBalances() where x.Type == currencyPair.QuoteCurrency select x).SingleOrDefault(); if (balance == null || balance.USDT_Value < 1) { return(0); } // Quantité que je possède if (USDT == 0 || USDT > balance.USDT_Value) { // La valeur a descendue entre temps //amountQuote = Math.Round(((from x in wc.GetBalances() where x.Type == currencyPair.QuoteCurrency select x.QuoteAvailable).SingleOrDefault() / bestPricePerCoin) * ROUND_FOR_POLONIEX) / ROUND_FOR_POLONIEX; amountQuote = balance.QuoteAvailable; } else { // Transiger le montant spécifié dans le textbox amountQuote = Utilities.TruncateDouble(USDT / bestPricePerCoin); } return(amountQuote); }
private double AmountQuoteToBuy(CurrencyPair currencyPair, double bestPricePerCoin, double USDT) { double amountQuote = 0; BalanceModel balance = (from x in GetBalances() where x.Type == currencyPair.BaseCurrency select x).SingleOrDefault(); if (balance == null || balance.QuoteAvailable < 1) { return(0); } // Quantité à acheter // Quantité que je possède if (USDT == 0 || USDT > balance.QuoteAvailable) { // La valeur a descendue entre temps... on parle ici du USDT... hummm... amountQuote = Utilities.TruncateDouble(balance.QuoteAvailable / bestPricePerCoin); } else { // Transiger le montant spécifié dans le textbox amountQuote = Utilities.TruncateDouble(USDT / bestPricePerCoin); } return(amountQuote); }