Beispiel #1
0
 /// <summary>
 ///   Initializes a new instance of the <see cref="Option{T}" /> class.
 /// </summary>
 /// <param name="type"> the type of option </param>
 /// <param name="rights"> The rights. </param>
 /// <param name="underlying"> The underlying. </param>
 /// <param name="strikePrice"> The strike price. </param>
 /// <param name="expiration"> The expiration. </param>
 protected Option(OptionType type, OptionRights rights, Underlying <T> underlying, decimal strikePrice, DateTime expiration)
     : base(OptionName(rights, underlying, strikePrice), OptionTicker(underlying, expiration))
 {
     _underlying  = underlying;
     _strikePrice = strikePrice;
     _expiration  = expiration;
     _type        = type;
     _rights      = rights;
 }
Beispiel #2
0
        public void TestEquityOptionPricing()
        {
            const string expectedName   = "International Business Machines";
            const string expectedTicker = "IBM";

            var ibm = new Underlying <Equity>(new Equity(expectedName, expectedTicker));

            var                expectedExpiration = new DateTime(2015, 01, 01);
            const decimal      expectedStrike     = 100;
            const OptionRights expectedRights     = OptionRights.Call;
            const OptionType   expectedType       = OptionType.American;

            var ibmEquityOption = new EquityOption(expectedType, expectedRights, ibm, expectedStrike, expectedExpiration);

            Assert.IsNotNull(ibmEquityOption);
        }
Beispiel #3
0
        public void EquityOptionSecurityCtorTest()
        {
            const string expectedName   = "International Business Machines";
            const string expectedTicker = "IBM";

            // create the underlying equity
            var ibm = new Underlying <Equity>(new Equity(expectedName, expectedTicker));

            var                expectedExpiration = new DateTime(2015, 01, 01);
            const decimal      expectedStrike     = 100;
            const OptionRights expectedRights     = OptionRights.Call;
            const OptionType   expectedType       = OptionType.American;

            var ibmEquityOption = new EquityOption(expectedType, expectedRights, ibm, expectedStrike, expectedExpiration);

            Assert.AreEqual(expectedName, ibmEquityOption.Underlying.Security.Name);
            Assert.AreEqual(expectedTicker, ibmEquityOption.Underlying.Security.Ticker);
            Assert.AreEqual(expectedRights, ibmEquityOption.Rights);
            Assert.AreEqual(expectedStrike, ibmEquityOption.StrikePrice);
            Assert.AreEqual(expectedType, ibmEquityOption.Type);
        }
Beispiel #4
0
 /// <summary>
 ///   Initializes a new instance of the <see cref="Option{T}" /> class.
 /// </summary>
 /// <param name="type"> the type of option </param>
 /// <param name="rights"> The rights. </param>
 /// <param name="underlying"> The underlying. </param>
 /// <param name="strikePrice"> The strike price. </param>
 /// <param name="expiration"> The expiration. </param>
 public EquityOption(OptionType type, OptionRights rights, Underlying <Equity> underlying, decimal strikePrice, DateTime expiration)
     : base(type, rights, underlying, strikePrice, expiration)
 {
 }
Beispiel #5
0
 /// <summary>
 /// Options the name.
 /// </summary>
 /// <param name="rights">The rights.</param>
 /// <param name="underlying">The underlying.</param>
 /// <param name="strike"> </param>
 /// <returns></returns>
 private static string OptionName(OptionRights rights, Underlying <T> underlying, decimal strike)
 {
     return(rights + " " + underlying.Security.Name + " @ " + strike);
 }