private bool BarrierIsBreached(CommodityBarrierOption option, FuturesQuote quote) { if (option.Barrier.Direction == BarrierDirection.Down) { return(option.Barrier.Level > quote.Low); } return(option.Barrier.Level < quote.High); }
public static CommodityContract ContractFromQuote(FuturesQuote quote) { try { var year = quote.Symbol.Substring(quote.Symbol.Length - 4); var monthCode = quote.Symbol.Substring(quote.Symbol.Length - 5, 1); var productCode = quote.Symbol.Substring(0, quote.Symbol.Length - 5); return(new CommodityContract { ContractYear = Convert.ToInt32(year), ContractMonth = Months[monthCode], ProductCode = productCode }); } catch { // note of course logging or w/e to notify return(null); } }
private void OnQuote(object sender, FuturesQuote quote) { var contract = NotifyOnBarrierEventsReactive.QuoteWithContract.ContractFromQuote(quote); if (IsValidContract(contract)) { return; } IEnumerable <CommodityBarrierOption> activeBarrierOptionsForContract; if (!_ActiveBarrierOptionsByContract.TryGetValue(contract, out activeBarrierOptionsForContract)) { return; } activeBarrierOptionsForContract .Where(option => BarrierIsBreached(option, quote)) .Where(NoticeNotAlreadySent) .ToList() .ForEach(option => NotifyTheHumans(option, quote)); }
public QuoteWithContract(FuturesQuote quote) { Quote = quote; Contract = ContractFromQuote(quote); }
private void NotifyTheHumans(CommodityBarrierOption option, FuturesQuote quote) { }