Beispiel #1
0
        private void filterStrikes(MamdaOptionExpirationDateSet dateSet)
        {
            mLowStrike  = Double.MinValue;
            mHighStrike = Double.MaxValue;

            // First calculate the high/low strikes
            SortedSet strikeSet = mChain.getStrikesWithinPercent(mStrikeMargin, mAtTheMoneyType);

            if ((strikeSet == null) || (strikeSet.size() == 0))
            {
                strikeSet = mChain.getStrikesWithinRangeSize(mNumStrikes, mAtTheMoneyType);
            }

            if ((strikeSet == null) || (strikeSet.size() == 0))
            {
                return;
            }

            mLowStrike  = (double)strikeSet.first();
            mHighStrike = (double)strikeSet.last();

            Iterator expireIter = dateSet.values().iterator();

            while (expireIter.hasNext())
            {
                // Filter the strike prices for one expiration date
                MamdaOptionExpirationStrikes expireStrikes = (MamdaOptionExpirationStrikes)expireIter.next();
                expireStrikes.trimStrikes(strikeSet);
            }
        }
Beispiel #2
0
 private MamdaOptionExpirationDateSet filterExpirations(MamdaOptionExpirationDateSet initialSet)
 {
     if (mExpirationDays > 0)
     {
         // Find the subset of expirations between now and some
         // number of days into the future.
         System.Globalization.Calendar c = new System.Globalization.GregorianCalendar(System.Globalization.GregorianCalendarTypes.USEnglish);
         DateTime futureDate             = c.AddDays(DateTime.Today, mExpirationDays);
         return(initialSet.getExpirationsBefore(futureDate));
     }
     else if (mNumExpirations > 0)
     {
         // Explicit number of expiration dates.
         return(initialSet.getExpirations(mNumExpirations));
     }
     else
     {
         // All expiration months.  We *copy* the initial set
         // because we may reduce the set to a particular range of
         // strike prices.
         return(new MamdaOptionExpirationDateSet(initialSet));
     }
 }
 public MamdaOptionExpirationDateSet(MamdaOptionExpirationDateSet copy)
 {
     copyStrikes(copy);
 }
Beispiel #4
0
        private void resetRange()
        {
            mExpirationDateSet = filterExpirations(mChain.getAllExpirations());
            filterStrikes(mExpirationDateSet);

            if ((mExpirationDateSet == null) || (mExpirationDateSet.size() == 0))
            {
                mLowExpireDate = DateTime.Today;
                mHighExpireDate = DateTime.Today.AddYears(1); // new Date(System.currentTimeMillis() + 366*24*60*60*1000);
            }
            else
            {
                mLowExpireDate = (DateTime)mExpirationDateSet.firstKey();
                mHighExpireDate = (DateTime)mExpirationDateSet.lastKey();
            }
        }
Beispiel #5
0
        private void filterStrikes(MamdaOptionExpirationDateSet dateSet)
        {
            mLowStrike  = Double.MinValue;
            mHighStrike = Double.MaxValue;

            // First calculate the high/low strikes
            SortedSet strikeSet = mChain.getStrikesWithinPercent(mStrikeMargin, mAtTheMoneyType);

            if ((strikeSet == null) || (strikeSet.size() == 0))
            {
                strikeSet = mChain.getStrikesWithinRangeSize(mNumStrikes, mAtTheMoneyType);
            }

            if ((strikeSet == null) || (strikeSet.size() == 0))
            {
                return;
            }

            mLowStrike  = (double)strikeSet.first();
            mHighStrike = (double)strikeSet.last();

            Iterator expireIter = dateSet.values().iterator();
            while (expireIter.hasNext())
            {
                // Filter the strike prices for one expiration date
                MamdaOptionExpirationStrikes expireStrikes = (MamdaOptionExpirationStrikes)expireIter.next();
                expireStrikes.trimStrikes(strikeSet);
            }
        }
Beispiel #6
0
 private MamdaOptionExpirationDateSet filterExpirations(MamdaOptionExpirationDateSet initialSet)
 {
     if (mExpirationDays > 0)
     {
         // Find the subset of expirations between now and some
         // number of days into the future.
         System.Globalization.Calendar c = new System.Globalization.GregorianCalendar(System.Globalization.GregorianCalendarTypes.USEnglish);
         DateTime futureDate = c.AddDays(DateTime.Today, mExpirationDays);
         return initialSet.getExpirationsBefore(futureDate);
     }
     else if (mNumExpirations > 0)
     {
         // Explicit number of expiration dates.
         return initialSet.getExpirations(mNumExpirations);
     }
     else
     {
         // All expiration months.  We *copy* the initial set
         // because we may reduce the set to a particular range of
         // strike prices.
         return new MamdaOptionExpirationDateSet(initialSet);
     }
 }
 public MamdaOptionExpirationDateSet(MamdaOptionExpirationDateSet  copy)
 {
     copyStrikes(copy);
 }