public EDItem(FI databaseObject_, SymmetryEntities dc_, MarketSnap snap_, QuoteSource source_) { Underlying = databaseObject_; Snap = snap_; var px = QuoteHelpers.GetQuoteValue(snap_.MarketSnapID, source_.QuoteSourceID, databaseObject_.FIID, QuoteValueType.Price, dc_, ThrowBehavior.DontThrow); if (px.HasValue) { ClosePrice = Convert.ToDouble(px.Value); SLog.log.DebugFormat("{0} px = {1}", databaseObject_.SymmetryCode, ClosePrice); var opt1Strike = ClosePrice - (ClosePrice % 0.125); OptionBelowPrice = new EDOptionItem(databaseObject_, opt1Strike, ClosePrice, Underlying, snap_.ValueDate); SLog.log.DebugFormat("{0} belowStrikeToQueryFor = {1}", databaseObject_.SymmetryCode, opt1Strike); var opt2Strike = opt1Strike + 0.125; OptionAbovePrice = new EDOptionItem(databaseObject_, opt2Strike, ClosePrice, Underlying, snap_.ValueDate); SLog.log.DebugFormat("{0} aboveStrikeToQueryFor = {1}", databaseObject_.SymmetryCode, opt2Strike); } else { SLog.log.ErrorFormat("No price saved for {0} for marketSnapID = {1}", databaseObject_.SymmetryCode, snap_.MarketSnapID); } }
public static QuoteSource GetOrCreateQuoteSource(string quoteSourceCode, SymmetryEntities dc, ThrowBehavior behavior = ThrowBehavior.Throw) { try { var existingSource = GetQuoteSource(quoteSourceCode, dc, ThrowBehavior.DontThrow); if(existingSource == null) { var newSource = new QuoteSource { QuoteSourceCode = quoteSourceCode, DisplayName = quoteSourceCode, QuoteSourceType = 0 }; dc.QuoteSources.Add(newSource); dc.SaveChanges(); return newSource; } else { return existingSource; } } catch (Exception ex) { Exceptions.Rethrow("GetOrCreateQuoteSource", behavior, ex); } return null; }