예제 #1
0
        /// <summary>
        /// Emits contract details with the n'th expiry.
        /// The default is 0, the next expiry.
        /// </summary>
        public static IObservable <IReadOnlyList <ContractDetails> > ContractDetailsExpirySelect(
            this IObservable <IReadOnlyList <ContractDetails> > source, int offset = 0)
        {
            if (offset < 0)
            {
                throw new ArgumentException("Offset must be >= 0.");
            }

            return(ThrowIf.ThrowIfEmpty(source).Select(cds => ContractDetailsExpiryFilter(cds, offset)));
        }
예제 #2
0
 /// <summary>
 /// Completes successfully if the sequence contains exactly one contract details object.
 /// Otherwise, OnError is called containing an exception with a message indicating which properties are different.
 /// </summary>
 public static IObservable <ContractDetails> ContractDetailsSingle(this IObservable <IReadOnlyList <ContractDetails> > source)
 {
     return(ThrowIf.ThrowIfEmpty(source).Select(cds =>
     {
         if (cds.Count == 1)
         {
             return cds.Single();
         }
         throw new InvalidDataException(ErrorMessage(cds));
     }));
 }
예제 #3
0
 /// <summary>
 /// Selects contract(s) from a list of contracts with varying expiry dates.
 /// The reference price, in combination with the offset, is used to select contract(s) depending on strike.
 /// An offset of 0 returns contract(s) with a strike which is equal of greater to the reference price.
 /// An offset of +1 returns contract(s) with the next greater strike.
 /// Negative Values select contract(s) with strikes below the reference price.
 /// </summary>
 public static IObservable <IReadOnlyList <ContractDetails> > ContractDetailsStrikeSelect(
     this IObservable <IReadOnlyList <ContractDetails> > source, int offset, double referencePrice)
 => ThrowIf.ThrowIfEmpty(source).Select(cds => SelectStrike(cds, offset, referencePrice));
예제 #4
0
 /// <summary>
 /// For each particular contractId, if SMART is one of the exchanges, this filter removes the contracts with other exchanges.
 /// </summary>
 public static IObservable <IReadOnlyList <ContractDetails> > ContractDetailsSmartFilter(this IObservable <IReadOnlyList <ContractDetails> > source)
 => ThrowIf.ThrowIfEmpty(source).Select(ContractDetailsSmartFilter);