Exemple #1
0
    def __init__(self, symbol, long_short=utils.LONG, expiration=None,
                 call_put=None, strike=None, price_range=20, tick_size=0.01,
                 cost_func=tradeking_cost, premium_func=None, **kwargs):

        if premium_func is None:
            premium_func = tradeking_premium(**kwargs)

        price_range = utils.Price(price_range)
        self._tick_size = utils.Price(tick_size)
        self._cost_func = cost_func
        self._premium_func = premium_func

        if not all((expiration, call_put, strike)):
            (symbol, expiration,
             call_put, strike) = utils.parse_option_symbol(symbol)

        self._symbol = utils.option_symbol(symbol, expiration, call_put,
                                           strike)
        self._underlying = symbol
        self._expiration = expiration
        self._call_put = call_put.upper()
        self._long_short = long_short.upper()
        self._strike = utils.Price(strike)
        self._start = self._strike - price_range
        self._stop = self._strike + price_range + 1

        if self._call_put == utils.PUT:
            self._payoff_func = lambda x: max(self._strike - x, 0)
        else:
            self._payoff_func = lambda x: max(x - self._strike, 0)
Exemple #2
0
def _leg(symbol, long_short, call_put, expiration=None, strike=None,
         **leg_kwargs):

    if not all((expiration, strike)):
        (symbol, expiration,
         _call_put, strike) = utils.parse_option_symbol(symbol)

    return Leg(symbol, long_short=long_short, call_put=call_put,
               expiration=expiration, strike=strike, **leg_kwargs)
Exemple #3
0
def Strangle(symbol, call_strike, put_strike, long_short=utils.LONG,
             expiration=None,  **leg_kwargs):
    if not expiration:
        (symbol, expiration,
         _call_put, _strike) = utils.parse_option_symbol(symbol)

    put = _leg(symbol, long_short=long_short, call_put=utils.PUT,
               expiration=expiration, strike=put_strike, **leg_kwargs)
    call = _leg(symbol, long_short=long_short, call_put=utils.CALL,
                expiration=expiration, strike=call_strike, **leg_kwargs)
    return MultiLeg(put, call, **leg_kwargs)
Exemple #4
0
def _leg(symbol,
         long_short,
         call_put,
         expiration=None,
         strike=None,
         **leg_kwargs):

    if not all((expiration, strike)):
        (symbol, expiration, _call_put,
         strike) = utils.parse_option_symbol(symbol)

    return Leg(symbol,
               long_short=long_short,
               call_put=call_put,
               expiration=expiration,
               strike=strike,
               **leg_kwargs)
Exemple #5
0
def Collar(symbol, put_strike, call_strike, expiration=None, **leg_kwargs):

    if not expiration:
        (symbol, expiration, _call_put,
         _strike) = utils.parse_option_symbol(symbol)

    put = _leg(symbol,
               long_short=utils.LONG,
               call_put=utils.PUT,
               expiration=expiration,
               strike=put_strike,
               **leg_kwargs)
    call = _leg(symbol,
                long_short=utils.SHORT,
                call_put=utils.CALL,
                expiration=expiration,
                strike=call_strike,
                **leg_kwargs)

    return MultiLeg(put, call, **leg_kwargs)
Exemple #6
0
    def __init__(self,
                 symbol,
                 long_short=utils.LONG,
                 expiration=None,
                 call_put=None,
                 strike=None,
                 price_range=20,
                 tick_size=0.01,
                 cost_func=tradeking_cost,
                 premium_func=None,
                 **kwargs):

        if premium_func is None:
            premium_func = tradeking_premium(**kwargs)

        price_range = utils.Price(price_range)
        self._tick_size = utils.Price(tick_size)
        self._cost_func = cost_func
        self._premium_func = premium_func

        if not all((expiration, call_put, strike)):
            (symbol, expiration, call_put,
             strike) = utils.parse_option_symbol(symbol)

        self._symbol = utils.option_symbol(symbol, expiration, call_put,
                                           strike)
        self._underlying = symbol
        self._expiration = expiration
        self._call_put = call_put.upper()
        self._long_short = long_short.upper()
        self._strike = utils.Price(strike)
        self._start = self._strike - price_range
        self._stop = self._strike + price_range + 1

        if self._call_put == utils.PUT:
            self._payoff_func = lambda x: max(self._strike - x, 0)
        else:
            self._payoff_func = lambda x: max(x - self._strike, 0)