(self)
return delta
Calculate currency delta for portfolio
Calculate currency delta for portfolio
Calculate currency delta for portfolio
def calc_delta(self):
        """Calculate currency delta for portfolio"""
        portfolio = self.get_portfolio()
        spot_delta = 0
        mark_delta = 0
        for symbol in portfolio:
            item = portfolio[symbol]
            if item['futureType'] == "Quanto":
                spot_delta += item['currentQty'] * item['multiplier'] * item['spot']
                mark_delta += item['currentQty'] * item['multiplier'] * item['markPrice']
            elif item['futureType'] == "Inverse":
                spot_delta += (item['multiplier'] / item['spot']) * item['currentQty']
                mark_delta += (item['multiplier'] / item['markPrice']) * item['currentQty']
        basis_delta = mark_delta - spot_delta
        delta = {
            "spot": spot_delta,
            "mark_price": mark_delta,
            "basis": basis_delta
        }
        return delta
def calc_delta ( self ) : portfolio = self . get_portfolio ( ) spot_delta = 0 mark_delta = 0 for symbol in portfolio : item = portfolio [ symbol ] if item [ 'futureType' ] == "Quanto" : spot_delta += item [ 'currentQty' ] * item [ 'multiplier' ] * item [ 'spot' ] mark_delta += item [ 'currentQty' ] * item [ 'multiplier' ] * item [ 'markPrice' ] elif item [ 'futureType' ] == "Inverse" : spot_delta += ( item [ 'multiplier' ] / item [ 'spot' ] ) * item [ 'currentQty' ] mark_delta += ( item [ 'multiplier' ] / item [ 'markPrice' ] ) * item [ 'currentQty' ] basis_delta = mark_delta - spot_delta delta = { "spot" : spot_delta , "mark_price" : mark_delta , "basis" : basis_delta } return delta