コード例 #1
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
コード例 #2
0
ファイル: bf70.py プロジェクト: chandrab/theoptionlab
    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