8

We actually managed to come up with the answer to this question ourselves but wanted to share the answer since it might be relevant to others as well. The calculation depends on what method is used to calculate the cost. There is the FIFO, LIFO and the average cost method, see: http://www.accounting-basics-for-students.com/fifo-method.html If FIFO or LIFO ...


5

The language would matter but if performance is an issue you would want to make sure that the code is optimal. Optimized assembly code for a single return calculation looks like this (on Godbolt): method1(double, double): divsd xmm0, xmm1 subsd xmm0, QWORD PTR .LC0[rip] ret method2(double, double): subsd xmm0, xmm1 ...


5

For client reporting purposes, it is customary to use discrete returns. For backtesting, it pretty much make no difference.


5

Have you considered the HDF5 data model? Edit for Louis : Why using HDF5 ? As stated in the HFDF short description page : HDF5 is a unique technology suite that makes possible the management of extremely large and complex data collections. HDF5 is a suitable solution when dealing with very large datasets and you need performance. Again, as stated ...


4

Using Andy Flury answer and bit polishing it gives following Python class for PnL calculator: class PnLCalculator: def __init__(self): self.quantity = 0 self.cost = 0.0 self.market_value = 0.0 self.r_pnl = 0.0 self.average_price = 0.0 def fill(self, n_pos, exec_price): pos_change = n_pos - self....


3

As for the book, the best one I have come across is Pricing and Trading Interest Rate Derivatives by Darbyshire, although it's a bit pricey (indeed as most finance books are) (https://www.amazon.com/Pricing-Trading-Interest-Rate-Derivatives/dp/099545552X). I used to trade Xccy Basis Swaps (which is just another name for Cross-Currency Swaps): let me try to ...


3

If you do step 1 and step 2 every day, then you indeed assume that you rebalance the strategy every day. If you want to assume differently, for example monthly, you need to first compound the returns for each asset separately during the whole month and then do a weighted sum of the compounded returns using the weights of each asset at the beginning of the ...


2

There's nothing in the math that says a portfolio can only put non-zero weights on securities where the benchmark puts positive weights. So I'm not sure I understand your problem? Quick math review Let $R$ be a $k \times 1$ random vector denoting next period returns. Let $\mathbf{w}_b$ and $\mathbf{w}_b$ be $k \times 1$ vectors denoting weights of the ...


2

Yes, this is absolutely possible. Here is a simple thought experiment to show how. We want to benchmark to the S&P 500. We allocate 90% of our capital to an index tracking strategy and 10% to some new portfolio manager with a good track record. (We'll call the new PM "Rumplestiltskin," for ease of reference.) Unfortunately, there is a bug in ...


2

You are right that if you use binary dummy variables for $n$ possible values of some feature (the country in your case) you need only $n-1$ variables because the last (or first) country is indicated by all dummy variables equal to zero.


2

I am not an expert on GIPS, with its many pages of rules, but I do remember that under GIPS Private Equity results are to be given in terms of IRR (Internal Rate of Return). In most other cases (stock/bond portfolios for example) GIPS requires TWR (Time Weighted Return) and forbids the use of IRR. To compute the IRR we need the dates and amounts of cash ...


2

The returns (or rather alphas, i.e. returns relative to the benchmark) plotted are logarithmic returns, not the simple returns usually reported by investment managers. This makes them additive over time. The green line is a straight line with slope 18% (the expected annual alpha). The thin purple curve is $\sigma \sqrt{t}$ above and below the green line, ...


2

I believe that cross currency basis swaps are marked to market always. The issue is that theoretical value for an xccy swap is always 0. but they don't trade at 0, that's why there is a premium for this kind of trade. On the fixing side - you are receiving and paying float. So the value is 0. The issue is that the spread is based on market demand, and ...


2

You actually need to consider a 0 return on the periods with no holdings (during that period volatility is 0 and you have a negative return due to the opportunity cost of not holding risk free debt). From that you can compute your daily sharpe ratio and then multiply by $252^{0.5}$ as you mention.


1

Any difference would be negligible. On the other hand, there are statistical advantages when calculating the log return. Remember that the log return is simply the log difference of the value / price from one day to the next. Log returns have some more favorable properties for statistical analysis than the simple net returns as shown by Quigley and Ramsey (...


1

The question is subjective. Suppose you have a USD based accounting framework and an interest rate swap in NOK. At the accounting period 1 the USDNOK is 10, and the IRS is worth 100 NOK (10 USD). At the accounting period 2 the USDNOK is 11, and the IRS is worth 110 NOK (10 USD). In your USD accounting framework there is no reported PnL, but clearly this is ...


1

The best example of an underperforming strategy with big alpha, is insurance. Every year you pay a premium to insure your house. That strategy has negative expected return, negative beta, but super high alpha (as it is uncorrelated with the market and diversifies well your portfolio).


1

It depends what you assume as to rebalancing between the portfolios. Unless these portfolios are being actively rebalanced each quarter to bring them back to exactly 32/68 allocation you should not assume fixed weights of 32 and 68. It is misleading. Here is an alternative calculation assuming no rebalancing: You start on 6/30/2018 with 0.32 million in ...


1

As a simple answer, the covariance matrix should not represent only assets in the benchmark. It should include the universe of assets. As an example, a benchmark might be 60% US Large Stocks and 40% US Aggregate Bonds. A manager might also buy emerging market stocks. One can just use a larger covariance matrix that includes emerging market stocks. The ...


1

Sharpe is (Portfolio Return - RFR) / Standard Deviation. Information Ratio is (Portfolio Return - Benchmark Return) / Tracking Error, where tracking error is the standard deviation of the active return. I don't understand Professor X's comment either.


1

Holding period return would be more appropriate. Calculate your one week return by using your ending portfolio NAV. The easiest way to do this would to be to store number of shares in each position and multiply by price after one week to obtain your new NAV. Yes. Yes. No, subtract it from your ending portfolio NAV. The process is as follows: Estimate ...


1

These are the realized return and standard deviation for the portfolio over the period. Source: Paul Wilmott on Quantitative Finance, sec. ed., p. 329-330


1

Effective PA is dependent on the correct description of the investment process. I am not sure, from what you say, what exactly is your investment process. But let me presume that it is the following: You have chosen the S&P500 as your benchmark. You first distributed your money among sectors. (That you gave many sectors zero weight is not relevant to the ...


1

Using @mde answer's for the average price method and developing it for Fifo method: # avg price based PnLCalculator class PnLCalculator: def __init__(self): self.quantity = 0 self.cost = 0.0 self.market_value = 0.0 self.r_pnl = 0.0 self.average_price = 0.0 def fill(self, pos_change, exec_price): n_pos ...


1

Maybe the following guidelines help: Big picture: For performance measurement purposes you should compare returns not absolute values. You need to convert all time series into percent returns which in itself takes care of normalization. Also as next step you do not only want to measure out or under performance in terms of return performance but in risk-...


1

Regarding storage, I stream real-time updates for exchange listed contracts (outright + exchange listed calendar spreads) to InfluxDB. Its a time-series database, mostly geared towards IT Ops for storing log data, but it works fine with homogeneous finance data. For options strips, due to the sheer amount of data generated per day, I use TeaFiles. Pros for ...


1

Apache Cassandra would be a good fit for storing real-time intraday data. It's a partitioned row store, where rows are organized into table using a partition key. It you use a schema where you store data for one ticker per row with partitioning by day or month (it has a limit of 2B records in a row), the operations in your questions would be very performant....


Only top voted, non community-wiki answers of a minimum length are eligible