// parses a SecurityTrade from the CSV row private static SecurityTrade parseSecurityTrade(CsvRow row, TradeInfo info, TradeCsvInfoResolver resolver) { string securityIdScheme = row.findValue(SECURITY_ID_SCHEME_FIELD).orElse(DEFAULT_SECURITY_SCHEME); string securityIdValue = row.getValue(SECURITY_ID_FIELD); SecurityId securityId = SecurityId.of(securityIdScheme, securityIdValue); double price = LoaderUtils.parseDouble(row.getValue(PRICE_FIELD)); double quantity = parseTradeQuantity(row); return(SecurityTrade.of(info, securityId, quantity, price)); }
// parses a trade from the CSV row internal static SecurityQuantityTrade parseTrade(CsvRow row, TradeInfo info, TradeCsvInfoResolver resolver) { SecurityTrade trade = parseSecurityTrade(row, info, resolver); SecurityTrade @base = resolver.completeTrade(row, trade); double?tickSizeOpt = row.findValue(TICK_SIZE).map(str => LoaderUtils.parseDouble(str)); Optional <Currency> currencyOpt = row.findValue(CURRENCY).map(str => Currency.of(str)); double?tickValueOpt = row.findValue(TICK_VALUE).map(str => LoaderUtils.parseDouble(str)); double contractSize = row.findValue(CONTRACT_SIZE).map(str => LoaderUtils.parseDouble(str)).orElse(1d); if (tickSizeOpt.HasValue && currencyOpt.Present && tickValueOpt.HasValue) { SecurityPriceInfo priceInfo = SecurityPriceInfo.of(tickSizeOpt.Value, CurrencyAmount.of(currencyOpt.get(), tickValueOpt.Value), contractSize); GenericSecurity sec = GenericSecurity.of(SecurityInfo.of(@base.SecurityId, priceInfo)); return(GenericSecurityTrade.of(@base.Info, sec, @base.Quantity, @base.Price)); } return(@base); }