macrosynergy.pnl.notional_positions#

Module for calculating notional positions based on contract signals, assets-under- management, and other relevant parameters.

notional_positions(df, sname, fids, aum=100, dollar_per_signal=1.0, slip=1, leverage=None, vol_target=None, nan_tolerance=0.25, remove_zeros=True, rebal_freq='m', lback_meth='ma', est_freqs=['D', 'W', 'M'], est_weights=[1, 1, 1], lback_periods=[-1, -1, -1], half_life=[11, 5, 6], rstring='XR', start=None, end=None, blacklist=None, pname='POS', return_pvol=False, return_vcv=False)[source]#

Calculates contract positions based on contract signals, assets under management (AUM) and other specifications.

Parameters:
  • df (QuantamentalDataFrame) – standardized JPMaQS DataFrame with the necessary columns: ‘cid’, ‘xcat’, ‘real_date’ and ‘value’. This dataframe must contain the contract-specific signals and possibly related return series (for vol-targeting).

  • sname (str) – the name of the strategy. It must correspond to contract signals in the dataframe, which have the format “<cid>_<ctype>_CSIG_<sname>”, and which are typically calculated by the function contract_signals().

  • fids (List[str]) – list of financial contract identifiers in the format “<cid>_<ctype>”. It must correspond to contract signals in the dataframe.

  • aum (float) – the assets under management in USD million (for consistency). This is basis for all position sizes. Default is 100.

  • dollar_per_signal (float) – the amount of notional (e.g. USD) per contract signal value. Default is 1. The default scale is arbitrary and is merely a basis for tryouts.

  • leverage (float) – the ratio of the sum of notional positions to AUM. This is the main basis for leveraged-based positioning. Since different contracts have different expected volatility and correlations this method does not control expected volatility. Default is None, i.e. the method is not applied.

  • vol_target (float) – the target volatility of the portfolio in % of AUM (For clarity, vol_target=10 means 10%). This is the main parameter for volatility-targeted positioning. That method estimates the annualized standard deviation of the signal-based portfolio for a 1 USD per signal portfolio based on past variances and covariances of the contract returns. The estimation is managed by the function macrosynergy.pnl.historic_portfolio_vol(). Default is None, i.e. the volatility-targeting is not applied.

  • rebal_freq (str) – the rebalancing frequency. Default is ‘m’ for monthly. Alternatives are ‘w’ for business weekly, ‘d’ for daily, and ‘q’ for quarterly. Contract signals are taken from the end of the holding period and applied to positions at the beginning of the next period, subject to slippage.

  • slip (int) – the number of days to wait before applying the signal. Default is 1. This means that new positions are taken at the very end of the first trading day of the holding period and are the basis of PnL calculation from the second Trading day onward.

  • lback_meth (str) – the method to use for the lookback period of the volatility-targeting method. Default is ‘ma’ for moving average. Alternative is “xma”, for exponential moving average. Again this is passed through to the function macrosynergy.pnl.historic_portfolio_vol().

  • est_freqs (str or list of str) – the frequencies to use for the estimation of the variance-covariance matrix. Default is to use [“D”, “W”, “M”]. This is passed through to the function macrosynergy.pnl.historic_portfolio_vol().

  • est_weights (float or list of float) – the weights to use for the estimation of the variance-covariance matrix. The weights are normalized and are used to calculate the weighted average of the estimated variances and covariances. Default is [1, 1, 1]. This is passed through to the function macrosynergy.pnl.historic_portfolio_vol().

  • lback_periods (int or List[int]) – the number of periods to use for the lookback period of the volatility-targeting method. Each element corresponds to the the same index in est_freqs. Passing a single element will apply the same value to all frequencies. Default is [-1], which means that the lookback period is the full available data for all specified

  • half_life (List[int]) – number of periods in the half-life of the exponential moving average. Each element corresponds to the same index in est_freqs. Default is [11, 5, 6] (for daily, weekly and monthly frequencies respectively). This is passed through to the function macrosynergy.pnl.historic_portfolio_vol().

  • rstring (str) – a general string of the return category. This identifies the contract returns that are required for the volatility-targeting method, based on the category identifier format <cid>_<ctype><rstring>_<rstring> in accordance with JPMaQS conventions. Default is ‘XR’.

  • start (str) – the start date of the data. Default is None, which means that the start date is taken from the dataframe.

  • end (str) – the end date of the data. Default is None, which means that the end date is taken from the dataframe.

  • blacklist (dict) – a dictionary of contract identifiers to exclude from the calculation. Default is None, which means that no contracts are excluded.

  • pname (str) – the name of the position. Default is ‘POS’.

  • return_pvol (bool) – whether to return the historic portfolio volatility. Default is False.

  • return_vcv (bool) – whether to return the variance-covariance matrix. Default is False.

Returns:

a standard Quantamental DataFrame with the positions for all traded contracts and the specified strategy in USD million. The contract signals have the following format “<cid>_<ctype>_<sname>_<pname>”.

Return type:

pd.DataFrame