Example #1
0
    def makeCombo(self, current_date, expiration, position_size):

        # 1x long put delta 20
        lowerlongstrike = self.connector.select_strike_by_delta(
            current_date, self.underlying, expiration, "p", -20)
        if (lowerlongstrike is None):
            print("lowerlongstrike is None")
            return None
        lowerlongposition = util.makePosition(self.connector, current_date,
                                              self.underlying, lowerlongstrike,
                                              expiration, "p", position_size)

        # 2x short put delta 40
        shortstrike = self.connector.select_strike_by_delta(
            current_date, self.underlying, expiration, "p", -40)
        if (shortstrike is None):
            print("shortstrike is None")
            return None
        shortposition = util.makePosition(self.connector, current_date,
                                          self.underlying, shortstrike,
                                          expiration, "p", -2 * position_size)

        # 1x long put delta 60
        upperlongstrike = self.connector.select_strike_by_delta(
            current_date, self.underlying, expiration, "p", -60)
        if (upperlongstrike is None):
            print("upperlongstrike is None")
            return None
        upperlongposition = util.makePosition(self.connector, current_date,
                                              self.underlying, upperlongstrike,
                                              expiration, "p", position_size)

        combo = util.PutButterfly(upperlongposition, shortposition,
                                  lowerlongposition)
        return combo
Example #2
0
    def makeCombo(self, current_date, expiration, position_size):

        current_quote = sql_connector.query_midprice_underlying(
            self.underlying, current_date)
        upperlongstrike = int(round(current_quote, -1))

        # Obere long Puts am Geld
        upperlongposition = util.makePosition(current_date, self.underlying,
                                              upperlongstrike, expiration, "p",
                                              position_size)
        if upperlongposition is None: return None
        # Short Puts 30 Punkte drunter
        shortstrike = int(upperlongstrike - 30)
        shortposition = util.makePosition(current_date, self.underlying,
                                          shortstrike, expiration, "p",
                                          -2 * position_size)
        if shortposition is None: return None

        # Untere long Puts 40 Punkte unter Short Puts
        lowerlongstrike = int(upperlongstrike - 70)
        lowerlongposition = util.makePosition(current_date, self.underlying,
                                              lowerlongstrike, expiration, "p",
                                              position_size)
        if lowerlongposition is None: return None

        combo = util.BWB(upperlongposition, None, shortposition,
                         lowerlongposition)

        return combo
Example #3
0
    def makeCombo(self, current_date, expiration, position_size):

        current_quote = self.connector.query_midprice_underlying(
            self.underlying, current_date)
        upperlongstrike = int(round(current_quote, -1))

        # upper long puts at the money
        upperlongposition = util.makePosition(self.connector, current_date,
                                              self.underlying, upperlongstrike,
                                              expiration, "p", position_size)
        if upperlongposition is None: return None

        # short puts 30 points below
        shortstrike = int(upperlongstrike - 30)
        shortposition = util.makePosition(self.connector, current_date,
                                          self.underlying, shortstrike,
                                          expiration, "p", -2 * position_size)
        if shortposition is None: return None

        # lower long puts 40 points below short puts
        lowerlongstrike = int(upperlongstrike - 70)
        lowerlongposition = util.makePosition(self.connector, current_date,
                                              self.underlying, lowerlongstrike,
                                              expiration, "p", position_size)
        if lowerlongposition is None: return None

        combo = util.BWB(upperlongposition, None, shortposition,
                         lowerlongposition)
        return combo
Example #4
0
def testCombo(closest_strike, current_date, underlying, expiration, position_size): 

    shortposition = util.makePosition(current_date, underlying, closest_strike, expiration, "p", -position_size)
    
    longstrike = (closest_strike - 30)
    longposition = util.makePosition(current_date, underlying, longstrike, expiration, "p", position_size)

    if shortposition is None or longposition is None: return None 
        
    positions = [shortposition, longposition]
    combo = util.Combo(positions)
    return combo