/// <summary> /// Converts ImportedCoin coins into the proper CryptoCoin. /// Then generates the total price paid of the converted coins. Call this after every import. /// </summary> public static List <CryptoCoin> FormatCoinsAndGenerateTotalPricePaid(List <ImportedCoin> importedCoins, Dictionary <int, HistoricCoinPrice> historicCoinPrice) { // Filter: Always need Shares & Total price to be over 0 for each coins List <CryptoCoin> localExtractedCoins = importedCoins.Where(x => x.Shares > 0 && x.TotalPricePaidInCurrency > 0).Select(x => x.ToPOCO()).ToList(); localExtractedCoins.ForEach(x => { x.TotalPricePaidUSD = CryptoLogic.GenerateTotalPricePaidUSD(x, historicCoinPrice); }); return(localExtractedCoins); }
public static CryptoCoin ToPOCO(this ImportedCoin item) { return(new CryptoCoin { Symbol = item.Symbol.Replace("USDT-", "USD-"), CoinCurrency = CryptoLogic.GenerateCoinCurrencyFromSymbol(item.Symbol), PricePerUnit = (item.TotalPricePaidInCurrency / item.Shares), Shares = item.Shares, Exchange = item.Exchange, OrderDate = item.OrderDate, // Closed/Order completed date OrderType = CryptoLogic.GetProperOrderTypeFromString(item.OrderType) }); }