0
$\begingroup$

First off I wasn't sure which exchange to ask this on. Eventually this will be turned into code using real data, but for now I just need some advice on how to start so I thought this might be the right place.

Say you have a market where items are traded and there is no currency. It would be useful to calculate an approximate "value" of each item based on how it has been traded in the past.

So you'll have a list of transactions like:

itemA + itemB = itemC + itemC

Where one person traded items A and B to another person for 2 of item C. This list will be of every trade that happened in the market. So once you have a lot of the these transactions there should be some algorithm that calculates a value for each item relative to the others which will get closer to the "true value" of the items every time you add a transaction.

  • 1
    Do you have any ideas for the model? Like if there were a true value that everyone knew and they always traded on it, this would just be a system of equations that would eventually get determined (up to the choice of numeraire). If they all have the same true value, but maybe with some noise or they don't trade on it perfectly perhaps it would then eventually become an overdetermined system and amenable to regression? You might want to go into a little more detail about the model in your head.2017-01-04

2 Answers 2

0

If each trade is written as $$\sum_1^i{(k_i\cdot x_i)} =\sum_1^i{(j_i\cdot x_i)}$$ for $k_i$ the number of $x_i$ provided by the LHS trader and $j_i$ the corresponding amount by the RHS trader, rearranging these to equations with the difference of the sums equal to zero, allows the system to be written as a matrix-vector equation.

From that point you have one of two cases.

  • Everybody knows the true exact value and uses it. Then the system will solve exactly using any preferred method. The solution is the set of true values.

  • Everybody knows the value but don't always use it, or not everybody knows the value and it can't always be used. This introduces noise that will make the solution change depending on which trades are counted or ignored. There are ways to obtain approximate solutions, which have varying requirements and give different qualities of output (some are amazing but only with a lot of data, some are great but are inaccurate outside of their operating conditions, some can't account for additional needs, some just take a very long time to use).

The choice of model depends on factors not provided, but are likely to revolve around closeness of fit (given a set of known true values and arbitrary trades, the solution is very close to matching the true values) and speed (it's not going to take a year to recalculate values when adding a day's worth of trade data), possibly with amenability to iteration (so that having good approximations to true value like yesterday's latest solution, for example make future calculation note accurate) and preferably an easy way to incorporate new data (such as when using the existing mean and count to work out a new mean when adding new data, instead of stating from scratch).

0

Confounding this problem is the fact that value is in the eye of the beholder. One person might value a sack of rice more than a lamb, but another person might be the opposite. In fact, the only reason that the people make such trades is if they would prefer what the other person has, so that each person becomes wealthier after the trade.

But let's suppose for now that all trades are evenly matched and traded according to some latent price, which the villagers all seem to understand, but you the outsider don't. You can solve this using a system of linear equations:
\begin{equation} \sum_{n=1}^N (a_n-b_n) x_n = 0, \end{equation} one for each trade, where a villager gives $a_n$ amount of each $n$th item in exchange for $b_n$ of each $n$th item. You'll also want to include some additional constraint to the system to normalize the value of the currency by some arbitrary constant: \begin{equation} \sum_{n=1}^N x_n = 1 \end{equation}

This system can then be formulated as the matrix equation: $A x = b$ and solved as $x = A^{-1}b$ to obtain the prices of each good.

In the case that insufficient data is available to know all of the values of the goods, you can regularize the system by choosing the solution that minimizes $\|x\|_2$ using least-squares. Alternatively, you can use a linear program to use a different criterion and also constrain the prices to always be positive.