Example #1
0
    def setUp(self):
        options = [
            option.Option(ticker='AKS',
                          expiry=date(2018, 1, 21),
                          strike=Decimal('3.5'),
                          option_type=option.OptionType.PUT,
                          underlying_type=underlying.UnderlyingType.EQUITY),
            option.Option(ticker='AKS',
                          expiry=date(2018, 2, 21),
                          strike=Decimal(4),
                          option_type=option.OptionType.PUT,
                          underlying_type=underlying.UnderlyingType.EQUITY)
        ]

        self.option_chain = option_chain.OptionChain(options)
    def setUp(self):
        options = [option.Option(
            ticker='AKS',
            expiry=date(2018, 1, 21),
            strike=3.5,
            option_type=option.OptionType.PUT,
            underlying_type=underlying.UnderlyingType.EQUITY
        )]
        options.append(option.Option(
            ticker='AKS',
            expiry=date(2018, 2, 21),
            strike=4,
            option_type=option.OptionType.PUT,
            underlying_type=underlying.UnderlyingType.EQUITY
        ))

        self.option_chain = option_chain.OptionChain(options)
Example #3
0
 def test_get_all_expirations_no_duplicates(self):
     self.option_chain.options.append(
         option.Option(ticker='AKS',
                       expiry=date(2018, 2, 21),
                       strike=Decimal('3.5'),
                       option_type=option.OptionType.PUT,
                       underlying_type=underlying.UnderlyingType.EQUITY))
     expected_result = [date(2018, 1, 21), date(2018, 2, 21)]
     result = self.option_chain.get_all_expirations()
     self.assertListEqual(result, expected_result)
 def test_get_all_strikes_no_duplicates(self):
     self.option_chain.options.append(option.Option(
         ticker='AKS',
         expiry=date(2018, 4, 21),
         strike=3.5,
         option_type=option.OptionType.PUT,
         underlying_type=underlying.UnderlyingType.EQUITY
     ))
     expected_result = [3.5, 4]
     result = self.option_chain.get_all_strikes()
     self.assertListEqual(result, expected_result)
 def setUp(self):
     self.order_details = order.OrderDetails(
         type=order.OrderType.LIMIT,
         price=Decimal(400),
         price_effect=order.OrderPriceEffect.CREDIT,
     )
     self.order_details.legs = [
         option.Option(ticker='AKS',
                       expiry=datetime.date(2018, 8, 31),
                       strike=Decimal('3.5'),
                       option_type=option.OptionType.CALL,
                       underlying_type=underlying.UnderlyingType.EQUITY,
                       quantity=1)
     ]
     self.test_order = order.Order(self.order_details)
Example #6
0
def build_default_order(time_in_force=order.TimeInForce.DAY):
    order_details = order.OrderDetails(
        type=order.OrderType.LIMIT,
        price=Decimal(400),
        price_effect=order.OrderPriceEffect.CREDIT,
        time_in_force=time_in_force,
        gtc_date=datetime.datetime(2019, 2, 12)
        if time_in_force == order.TimeInForce.GTD else None)
    order_details.legs = [
        option.Option(ticker='AKS',
                      expiry=datetime.date(2018, 8, 31),
                      strike=Decimal('3.5'),
                      option_type=option.OptionType.CALL,
                      underlying_type=underlying.UnderlyingType.EQUITY,
                      quantity=1)
    ]
    return order.Order(order_details)