// Sold end value. Full value of the coin you've sold. For example, Bought for $100, sold for $120. Returns $120. private decimal GetGeneratedSoldEndValue() { decimal profit = TotalSoldPricePaidUSD.GetValueOrDefault(); if (profit == 0 || TotalPricePaidUSD.GetValueOrDefault() == 0) { return(0); } // If TotalBoughtPrice is 0, it's a transfer coin. Not sure of profit. if (DisplayCurrency == Types.CoinCurrency.USD) { return(profit); } if (DisplayCurrency == Types.CoinCurrency.BTC) { return((profit / OrderedDateUSDPriceOfBTC).ToDecimalPrecision(8)); } if (DisplayCurrency == Types.CoinCurrency.ETH) { return((profit / OrderedDateUSDPriceOfETH).ToDecimalPrecision(6)); } if (DisplayCurrency == Types.CoinCurrency.EUR) { return(profit.UsdToEuro()); } return(0); }
public decimal GenerateCurrentTotalPriceInUSD() { if (TotalPricePaidUSD.GetValueOrDefault() == 0 || TotalSoldPricePaidUSD.GetValueOrDefault() == 0) { return(0); } return(TotalSoldPricePaidUSD.Value - TotalPricePaidUSD.Value); }
public decimal CalculatePercentageChange() { if (TotalPricePaidUSD.GetValueOrDefault() == 0 || Shares == 0 || CoinCurrency == Types.CoinCurrency.Unknown) { return(0); } var change = CalculateCurrentTotalPrice_USD() - TotalPricePaidUSD.GetValueOrDefault(); return((change / TotalPricePaidUSD.GetValueOrDefault()) * 100); }
} // Currently this coin is combined with similar transaction. It can't be edited. #endregion #region Logics #region Current Holding Calculation /// <summary> /// Calculate the current profit of this coin/transaction in USD. CurrentMarketValue - InitialPricePaid. /// </summary> /// <returns></returns> protected decimal CalculateCurrentProfit() { if (TotalPricePaidUSD.GetValueOrDefault() == 0 || Shares == 0 || CoinCurrency == Types.CoinCurrency.Unknown) { return(0); } decimal profitLoss = CalculateCurrentTotalPrice_USD() - TotalPricePaidUSD.GetValueOrDefault(); return(profitLoss); }
public decimal CalculateSoldPercentageChange() { if (TotalPricePaidUSD.GetValueOrDefault() == 0 || TotalSoldPricePaidUSD.GetValueOrDefault() == 0) { return(0); } var change = TotalSoldPricePaidUSD - TotalPricePaidUSD; var percentageChange = (change / TotalPricePaidUSD) * 100; return(percentageChange.GetValueOrDefault()); }
// --- Initial price paid private decimal GetGeneratedInitialPricePaid() { if (DisplayCurrency == Types.CoinCurrency.USD) { return(TotalPricePaidUSD.GetValueOrDefault()); } if (DisplayCurrency == Types.CoinCurrency.BTC) { return((GetGeneratedCorrectInitialPricePerUnit()).ToDecimalPrecision(8)); } if (DisplayCurrency == Types.CoinCurrency.ETH) { return((GetGeneratedCorrectInitialPricePerUnit()).ToDecimalPrecision(6)); } if (DisplayCurrency == Types.CoinCurrency.EUR) { return(TotalPricePaidUSD.GetValueOrDefault().UsdToEuro()); } return(0); }
// ---------- Logic private decimal GetGeneratedCorrectInitialPricePerUnit() { if (CoinCurrency == Types.CoinCurrency.USD) { if (TotalPricePaidUSD == 0) { return(0); } if (DisplayCurrency == Types.CoinCurrency.BTC) { return(TotalPricePaidUSD.GetValueOrDefault() / OrderedDateUSDPriceOfBTC); } if (DisplayCurrency == Types.CoinCurrency.ETH) { return(TotalPricePaidUSD.GetValueOrDefault() / OrderedDateUSDPriceOfETH); } } if (DisplayCurrency == Types.CoinCurrency.ETH) { return(GeneratedPricePerUnitETH * Shares); } return(PricePerUnit * Shares); }