public override int GetHashCode() { unchecked { int hashCode = (StockExchange != null ? StockExchange.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (TradeSector != null ? TradeSector.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (SecurityCode != null ? SecurityCode.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (SecurityName != null ? SecurityName.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (SecurityClass != null ? SecurityClass.GetHashCode() : 0); hashCode = (hashCode * 397) ^ HasOptions.GetHashCode(); hashCode = (hashCode * 397) ^ (SecurityStatus != null ? SecurityStatus.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Currency != null ? Currency.GetHashCode() : 0); hashCode = (hashCode * 397) ^ LimitUpPrice.GetHashCode(); hashCode = (hashCode * 397) ^ LimitDownPrice.GetHashCode(); hashCode = (hashCode * 397) ^ LotSize.GetHashCode(); hashCode = (hashCode * 397) ^ (LotFlag != null ? LotFlag.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (SuspendedFlag != null ? SuspendedFlag.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (SecuritySubClass != null ? SecuritySubClass.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (UnderlyinSecurityCode != null ? UnderlyinSecurityCode.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (SecurityLevel != null ? SecurityLevel.GetHashCode() : 0); hashCode = (hashCode * 397) ^ PreviousClose.GetHashCode(); hashCode = (hashCode * 397) ^ OpenPrice.GetHashCode(); hashCode = (hashCode * 397) ^ Turnover.GetHashCode(); hashCode = (hashCode * 397) ^ HighPrice.GetHashCode(); hashCode = (hashCode * 397) ^ LowPrice.GetHashCode(); hashCode = (hashCode * 397) ^ LastPrice.GetHashCode(); hashCode = (hashCode * 397) ^ CurrentBidPrice.GetHashCode(); hashCode = (hashCode * 397) ^ CurrentAskPrice.GetHashCode(); hashCode = (hashCode * 397) ^ Volume.GetHashCode(); hashCode = (hashCode * 397) ^ PERatio.GetHashCode(); hashCode = (hashCode * 397) ^ BuyVolume1.GetHashCode(); hashCode = (hashCode * 397) ^ SellVolume1.GetHashCode(); hashCode = (hashCode * 397) ^ BuyPrice2.GetHashCode(); hashCode = (hashCode * 397) ^ BuyVolume2.GetHashCode(); hashCode = (hashCode * 397) ^ SellPrice2.GetHashCode(); hashCode = (hashCode * 397) ^ SellVolume2.GetHashCode(); hashCode = (hashCode * 397) ^ BuyPrice3.GetHashCode(); hashCode = (hashCode * 397) ^ BuyVolume3.GetHashCode(); hashCode = (hashCode * 397) ^ SellPrice3.GetHashCode(); hashCode = (hashCode * 397) ^ SellVolume3.GetHashCode(); hashCode = (hashCode * 397) ^ BuyPrice4.GetHashCode(); hashCode = (hashCode * 397) ^ BuyVolume4.GetHashCode(); hashCode = (hashCode * 397) ^ SellPrice4.GetHashCode(); hashCode = (hashCode * 397) ^ SellVolume4.GetHashCode(); hashCode = (hashCode * 397) ^ BuyPrice5.GetHashCode(); hashCode = (hashCode * 397) ^ BuyVolume5.GetHashCode(); hashCode = (hashCode * 397) ^ SellPrice5.GetHashCode(); hashCode = (hashCode * 397) ^ SellVolume5.GetHashCode(); return(hashCode); } }
public override void FillData(string data) { string[] tempContainer = data.Split('\n'); string[] tempSplit; string tempFinder = string.Empty; string tempSecurityName = string.Empty; string tempMaturityDate = string.Empty; double tempMultiplier = 0; int dateTimeIndex = 0; DateTime tempContentDate; Texts = tempContainer.ToList(); lookup.LoadLookUpTables(); aqrIDLookUp.LoadLookUpTables(); for (int i = 0; i < Texts.Count; i++) { if (DateTime.TryParse(Texts[i], out tempContentDate)) { dateTimeIndex = i > 0 ? i : 0; ContentDate = tempContentDate; break; } } // COUNTERPARTY - HARDCODED FOR NOW CounterParty = "JPM"; // FUND is the line after the letter date Fund = Texts[dateTimeIndex + 1]; Fund = lookup.GetFundShortName(Fund); try { // CP REF tempFinder = Texts.Where(x => x.Contains(JPM_CPREF_REFERENCE)).FirstOrDefault(); if (!string.IsNullOrEmpty(tempFinder)) { tempSplit = tempFinder.Split(':'); CPRef = tempSplit.Last().Trim(); } // FUND //tempFinder = Texts.Where(x => x.Contains(FUND_REFERENCE)).FirstOrDefault(); //if (!string.IsNullOrEmpty(tempFinder)) //{ // tempSplit = tempFinder.Split(':'); // Fund = tempSplit.Last(); //} // TRANSACTION TYPE TransactionType = "Open"; // always open // SECURITY NAME // Dropdown (Index: Swiss market Index) We determine the date based on the Valuation date which is also available in the General Terms under Valuation Date at the end of the paragraph, page 2. // TRADE DATE tempFinder = Texts.Where(x => x.Contains(JPM_TRADE_DATE_REFERENCE)).FirstOrDefault(); if (!string.IsNullOrEmpty(tempFinder)) { tempSplit = tempFinder.Split(':'); TradeDate = DateTime.Parse(tempSplit.Last()); } // SETTLEMENT DATE int daysToAdd = 0; SettlementDate = TradeDate; while (daysToAdd < 3) { SettlementDate = SettlementDate.AddDays(1); if (SettlementDate.DayOfWeek != DayOfWeek.Saturday && SettlementDate.DayOfWeek != DayOfWeek.Sunday) { daysToAdd++; } } //SettlementDate = TradeDate.AddDays(3); //if (SettlementDate.DayOfWeek == DayOfWeek.Sunday || SettlementDate.DayOfWeek == DayOfWeek.Saturday) //{ // while (SettlementDate.DayOfWeek == DayOfWeek.Saturday || SettlementDate.DayOfWeek == DayOfWeek.Sunday) // { // SettlementDate = SettlementDate.AddDays(1); // } //} // MATURITY DATE // Valuation date - at the end of the paragraph with this format : 19 December 2014 // TERMINATION DATE tempFinder = Texts.Where(x => x.Contains(TERMINATION_DATE_REFERENCE)).FirstOrDefault(); if (!string.IsNullOrEmpty(tempFinder)) { tempSplit = tempFinder.Split(':'); if (string.Compare(tempSplit.Last(), JPM_TERMINATION_DATE_CASH_SETTLEMENT_PAYMENT_DATE_REFERENCE) == 0) { MaturityDate = SettlementDate; } else { MaturityDate = DateTime.Parse(tempSplit.Last()); } } // MULTIPLIER tempFinder = Texts.Where(x => x.Contains(JPM_MULTIPLIER_REFERENCE)).FirstOrDefault(); if (!string.IsNullOrEmpty(tempFinder)) { if (tempFinder.ToLower().Contains("deal")) { tempFinder = tempFinder.ToLower().Split(new string[] { "deal" }, StringSplitOptions.RemoveEmptyEntries).First(); } tempSplit = tempFinder.Split(':'); double.TryParse(tempSplit.Last(), out tempMultiplier); Multiplier = tempMultiplier; } //lookup.GetMultiplier(tempFund); // PRICE try { tempFinder = Texts.Where(x => x.Contains(JPM_FORWARD_PRICE)).FirstOrDefault(); if (!string.IsNullOrEmpty(tempFinder)) { tempSplit = tempFinder.Split(':'); string[] priceSplit = tempSplit[1].Split(' '); string price = string.Empty; if (!string.IsNullOrEmpty(priceSplit.First())) { price = priceSplit.First().Split(new string[] { "Deal" }, StringSplitOptions.RemoveEmptyEntries).First(); } else { price = priceSplit[1].Split(new string[] { "Deal" }, StringSplitOptions.RemoveEmptyEntries).First(); } Price = Double.Parse(price); } else { // Initial price tempFinder = Texts.Where(x => x.Contains(JPM_HANGSENG_INITIAL_PRICE)).FirstOrDefault(); if (!string.IsNullOrEmpty(tempFinder)) { tempSplit = tempFinder.Split(':'); string[] priceSplit = tempSplit[1].Split(' '); //string price = string.Empty; //if (!string.IsNullOrEmpty(priceSplit.First())) //{ // price = priceSplit.First().Split(new string[] { "Deal" }, StringSplitOptions.RemoveEmptyEntries).First(); //} //else //{ // price = priceSplit[1].Split(new string[] { "Deal" }, StringSplitOptions.RemoveEmptyEntries).First(); //} double price_temp = 0; foreach (string tempPrice in priceSplit) { double.TryParse(tempPrice, out price_temp); if (price_temp > 0) { break; } } Price = price_temp; //Price = Double.Parse(price); } } } finally { } // LOCAL CURRENCY tempFinder = Texts.Where(x => x.Trim().Contains(JPM_SETTLEMENT_CURRENCY)).FirstOrDefault(); if (!string.IsNullOrEmpty(tempFinder)) { //tempSplit = tempFinder.Split(new string[] { ": " }, StringSplitOptions.None); //LocalCurrency = tempSplit.Last(); //if (LocalCurrency.Length > 3) //{ // tempSplit = LocalCurrency.Split(' '); // LocalCCY = tempSplit.First(); //} tempSplit = tempFinder.Split(':'); LocalCurrency = tempSplit.Last().Trim(); LocalCurrency = StripInvalidCharacters(LocalCurrency); tempFinder = GetTextBaseOnReference(JPM_EQUITY_NOTIONAL_AMOUNT); if (!string.IsNullOrEmpty(tempFinder)) { tempSplit = tempFinder.Split(':'); if (tempSplit != null && tempSplit.Count() > 0) { string tempCurrency = tempSplit.Last(); tempSplit = tempCurrency.Split(' '); if (tempSplit != null && tempSplit.Count() > 0) { tempCurrency = StripInvalidCharacters(tempSplit.First() != string.Empty ? tempSplit.First() : tempSplit[1]); if (string.Compare(tempCurrency.ToLower(), LocalCurrency.ToLower()) != 0) { LocalCurrency = tempCurrency; } } } } } // SELLER tempFinder = Texts.Where(x => x.Contains(JPM_SELLER)).FirstOrDefault(); if (!string.IsNullOrEmpty(tempFinder)) { tempSplit = tempFinder.Split(':'); Seller = tempSplit.Last().Trim(); // hard code for now if (string.Compare(StripInvalidCharacters(Seller), "JPMorgan") == 0) { Seller = "JPM"; } else if (string.Compare(StripInvalidCharacters(Seller), "Counterparty") == 0) { Seller = Fund; } } else { tempFinder = Texts.Where(x => x.Contains(JPM_EQUITY_AMOUNT_PAYER)).FirstOrDefault(); if (!string.IsNullOrEmpty(tempFinder)) { tempSplit = tempFinder.Split(':'); Seller = tempSplit.Last().Trim(); // hard code for now if (string.Compare(StripInvalidCharacters(Seller), "JPMorgan") == 0) { Seller = "JPM"; } else if (string.Compare(StripInvalidCharacters(Seller), "Counterparty") == 0) { Seller = Fund; } } } // BUYER // NOTE: Buyer is always the opposite of seller if (string.Compare(Seller, "JPM") == 0) { Buyer = Fund; } else { Buyer = "JPM"; } // MATURITY DATE tempFinder = Texts.Where(x => x.Contains(JPM_VALUATION_DATE_EXPECTED_TO_BE)).FirstOrDefault(); if (!string.IsNullOrEmpty(tempFinder)) { Regex regex = new Regex(@"\d{2}\s\w+\s\d{4}"); Match match = regex.Match(tempFinder); DateTime tempPlaceHolder = DateTime.MinValue; if (match.Success) { DateTime.TryParse(match.Value, out tempPlaceHolder); if (tempPlaceHolder != DateTime.MinValue) { MaturityDate = tempPlaceHolder; } } } // SECURITY NAME tempFinder = Texts.Where(x => x.Replace(" ", "").Contains(JPM_SECURITY_NAME_REFERENCE)).FirstOrDefault(); if (!string.IsNullOrEmpty(tempFinder)) { tempSplit = tempFinder.Split(':'); tempSecurityName = tempSplit.Last(); if (!string.IsNullOrEmpty(tempSecurityName)) { if (tempSecurityName.ToLower().Contains("hang seng")) { if (string.Compare(tempSecurityName.Trim(), "Hang Seng China Enterprises Index", true) == 0) { tempSecurityName = "HSCEI China Index"; } } else if (tempSecurityName.ToLower().Contains("taiex index")) { tempSecurityName = "TAIEX Futures Swap"; } SecurityName = aqrIDLookUp.GetSecurityNameByMatch(tempSecurityName, MaturityDate); } } // SECURITY TYPE SecurityType = aqrIDLookUp.GetSecurityType(SecurityName); // MULTIPLIER tempSecurityName = SecurityName.Split(' ').First(); tempMultiplier = lookup.GetMultiplier(tempSecurityName, SecurityType); if (tempMultiplier == 0) { } // QUANTIY tempFinder = Texts.Where(x => x.Contains(JPM_NUMBER_OF_UNITS)).FirstOrDefault(); if (!string.IsNullOrEmpty(tempFinder)) { tempSplit = tempFinder.Split(':'); NumberOfUnits = Double.Parse(tempSplit.Last()); } if (NumberOfUnits > 0) { Quantity = NumberOfUnits / tempMultiplier; } else { Quantity = Multiplier / tempMultiplier; } // Multiplier Multiplier = tempMultiplier; // NOTIONAL Notional = Quantity * Price * Multiplier; // AQR ID AQRID = aqrIDLookUp.GetAQRID(SecurityName, SecurityType); //Always zero unless otherwise stated in the contract FixedRate = 0; //Always zero unless otherwise stated in the contract FloatRate = 0; //Always zero unless otherwise stated in the contract SettledCash = 0; SettledCurrency = LocalCurrency; Spread = 0; Status = ConfirmsData.RunStatus.Success; } catch (Exception ex) { Status = ConfirmsData.RunStatus.Failed; } }