コード例 #1
0
 public override string ToString()
 {
     return("InstumentName=" + InstrumentName
            + "|" + "ExpirationDateTime=" + ExpirationDateTime.ToShortDateString()
            + "|" + "LastMarketPrice=" + LastMarketPrice.ToString()
            + "|" + "LastUpdateDateTime=" + LastUpdateDateTime.ToString());
 }
コード例 #2
0
        public double AnnualizedForwardPremiumInCurrency(string currency)
        {
            try
            {
                /*
                 *  The ninety-day yen to dollar (¥ / $) forward exchange rate is 109.50.
                 *  The spot rate ¥ / $ rate is = 109.38.
                 *  Calculation for annualized forward premium = ((109.50-109.38÷109.38) x (360 ÷ 90) x 100% = 0.44%
                 * // return AnnualizedForwardPremium((decimal) 109.38, (decimal) 109.50, 90);
                 */
                DateTimeOffset lastUpdate       = DateTimeOffset.Parse(LastUpdateDateTime.ToString());
                double         secondsRemaining = ExpirationTimestamp - lastUpdate.ToUnixTimeSeconds();
                double         daysRemaining    = ((secondsRemaining / 60) / 60) / 24;

                if (daysRemaining != 0 && UnderlyingPriceInCurrency(currency) != 0)
                {
                    double annualizedForwardPremium =
                        (((LastMarketPriceInCurrency(currency) - UnderlyingPriceInCurrency(currency)) / UnderlyingPriceInCurrency(currency)) *
                         (360 / daysRemaining) * 100);
                    return(annualizedForwardPremium);
                }
                return(0);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                Console.WriteLine(InstrumentName);
                Console.WriteLine(LastUpdateDateTime);
                Console.WriteLine(ExpirationTimestamp);
                return(0);
            }
        }