public Task <BestPriceToSellViewModel> GetBestPriceToSellAsync(TemBTCOrderBook orderBook, double btc_amount) { return(Task.Factory.StartNew(() => { decimal min_value = 2000; double withdrawal_fee_percent = (0.75 / 100); decimal withdrawal_fee_brl = 9; var best_price_to_sell_vm = new BestPriceToSellViewModel(); if (orderBook.Bids != null) { var prices_to_sell = orderBook.Bids; var best_price_to_sell = prices_to_sell.FirstOrDefault(p => p.Quantity >= btc_amount || ((decimal)p.Quantity * p.Price) > min_value); best_price_to_sell_vm.Exchange = "TemBTC"; if (prices_to_sell != null) { best_price_to_sell_vm.Price = best_price_to_sell.Price; best_price_to_sell_vm.Amount = best_price_to_sell.Quantity; var fee = (((decimal)btc_amount * best_price_to_sell.Price) * (decimal)withdrawal_fee_percent) + withdrawal_fee_brl; best_price_to_sell_vm.Valeu = (decimal)btc_amount * best_price_to_sell.Price; best_price_to_sell_vm.Fee = fee; } } return best_price_to_sell_vm; })); }
public Task <BestPriceToBuyViewModel> GetBestPriceToBuyAsync(TemBTCOrderBook orderBook, decimal min_value = 2000) { return(Task.Factory.StartNew(() => { double transaction_fee_percent = (0.50 / 100); var best_price_to_buy_vm = new BestPriceToBuyViewModel(); if (orderBook.Asks != null) { var prices_to_buy = orderBook.Asks; var best_price_to_buy = prices_to_buy.FirstOrDefault(p => ((decimal)p.Quantity * p.Price) > min_value); best_price_to_buy_vm.Exchange = "TemBTC"; if (best_price_to_buy != null) { best_price_to_buy_vm.Amount = (double)(min_value / best_price_to_buy.Price); best_price_to_buy_vm.Valeu = (decimal)best_price_to_buy_vm.Amount * best_price_to_buy.Price; best_price_to_buy_vm.Price = best_price_to_buy.Price; var fee = best_price_to_buy_vm.Valeu * (decimal)transaction_fee_percent; best_price_to_buy_vm.Fee = fee; } } return best_price_to_buy_vm; })); }