Take the 2-minute tour ×
Quantitative Finance Stack Exchange is a question and answer site for finance professionals and academics. It's 100% free, no registration required.

I developed an optimization algorithm that uses returns (among other parameters) as input and basically output an allocation.

As I'm pretty happy with the results, I am in the process of putting the algorithm in production. As a matter of fact, I have to embed some checks into the algorithm to make sure that the input was right and that the output makes sense. For example, I check that the allocation sums to 1, I check that the time series provided are all of the same length and so on...

I would like to add another test which allows me to display a warning if the input time series appear to be prices instead of returns (and people will do this mistake one day I'm sure). So, I would like to setup a statistical test on my set of points $x=x_1, ... , x_n$ to determine whether they are likely to be prices.

Formally the statistical test if a function defined as follows:

$$A(x) \rightarrow \{0,1\}$$

Ideally we would like to find a test that is sufficient and necessary for a time series to be returns (as compared to prices, not to "a random time series").

There are three types of interesting statistical tests:

Type I (necessary and sufficient)

$$A(x)=1 \iff x ~ \text{are returns}$$

Type II (sufficient)

$$A(x)=1 \Longrightarrow x ~ \text{are returns}$$

Type III (necessary)

$$A(x) \neq 1 \Longrightarrow x ~ \text{are prices}$$

The following test is a dummy one:

$$A_{\text{dummy}}(x)=\frac{1}{n} \sum_{i=1}^n x_i > 1$$

This is not good because a Forex time series are prices of a currency expressed in the base currency of the portfolio, and such a series would produce a result of 1.

I came up with a Type II test:

$$A_\text{Type II}(x) = \exists i ~ x_i<0$$

Note that I assume that the input could be either prices or returns.

A series of prices with non-negative returns would fool this test so it is not necessary.

I believe it is impossible to come up with a Type I test, which implies that I can't come up with a Type III test either (otherwise I could construct a Type I test easily).

I would be looking for extra Type II tests to improve the probability of wrong input detection.

Have you ever had to do such test? What method would you recommend?

share|improve this question
You could always compare the input values against the security's closing market price to see if they are similar in magnitude. –  chrisaycock Jun 24 '12 at 13:42
I assume that I have no information on what the instruments underlying each time series are. –  SRKX Jun 24 '12 at 14:21
add comment

2 Answers

I think that can never be 100% sure, and the most you could do is raise a warning, and your approach makes perfect sense to me.

I want to point out one thing though. While prices cannot be negative, they are sometimes recorded with a negative sign, where negative sign conveys some other information. For example in CRSP:


Usually, the CRSP price is the closing price, the price of the last reported trade on any given day. However, if no trade is recorded on a given trading day, the reported price will be the negative of the average of the bid and asked prices for that day. The price reported in CRSP monthly files is the price of the last trading day of the month.


share|improve this answer
+1, good to know. I think I can assume I won't have that in my samples though. –  SRKX Jun 24 '12 at 14:23
It's also worth pointing out that "spread" futures can have a negative price too. –  chrisaycock Jun 24 '12 at 16:20
add comment

You could test for whether the input series is I(0) vs the alternative of I(1). Specifically, regress the input series on its own lag, and test whether the coefficient on the lag is significantly different from zero. Price series should have a coefficient close to 1, while return series should have a coefficient close to 0.

share|improve this answer
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.