コード例 #1
0
 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);
 }
コード例 #2
0
 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);
     }
 }
コード例 #3
0
        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));
        }
コード例 #4
0
 public QuoteWithContract(FuturesQuote quote)
 {
     Quote    = quote;
     Contract = ContractFromQuote(quote);
 }
コード例 #5
0
 private void NotifyTheHumans(CommodityBarrierOption option, FuturesQuote quote)
 {
 }