PoE currency markets
-
Arbitraging cross currency exchange rates: finding a sequence of trades that starts and ends at the same currency resulting in a net increase in wealth.
-
Optimal currency conversion: finding a sequence of trades that optimally converts a given amount of starting currency into a desired currency.
The arbitrage problem is a special case of the currency conversion problem, with start currency = ending currency.
The model assumes input in the form of a .csv file which represents the entire order book of the currency market. Each order specifies a starting currency (called have), an ending currency (called want), a specified ratio of
See the example section for a sample input.
The currency exchange is similar to real life forex/cryptocurrency markets. A few main differences (besides the input format) exist:
- The currency exchange requires gold, a new currency, to trade. Gold is earned by playing the game.
- No fractional trading exists because whole items are transacted (while there are splinters/shards, these would still represent discrete increments in currency).
- There is currently a limit of 10 ongoing trades available at one time, as this is the maximum size of the trading window.
Let
To model no fractional trading, we introduce a variable called
To model the gold constraint, we use a variable
To model the trading window, introduce a new binary variable called
The following construction results in a constraint that any trade made on
-
$l_{i,j}(t) = p_{i,j}(t)$ if$b_{i,j}(t) = 1$ -
$l_{i,j}(t) = 0$ if$b_{i,j}(t) = 0$
We can then write
Constraints (1,2) set initial conditions. Constraint (3) enforces that trades occur in discrete (possibly partial) orders. Constraint (4,5) enforce proper balances after trades are made w.r.t to currencies and hold. Constraint (6) enforces no shorting. Constraint (7) enforces that we consider the stock of each order in the order book. Constraints (8,9,10,11) use the variable
python main.py -f [.csv file]
Alternatively, the src/pot/optimize.py
directory holds the optimization functions.
An example of an optimal conversion is found in tests/currency_market.csv.
have | want | ratio | stock | gold_cost |
---|---|---|---|---|
Divine Orb | Chaos Orb | 100.00000 | 1 | 1000 |
Exalted Orb | Chaos Orb | 25.00000 | 6 | 1000 |
Divine Orb | Exalted Orb | 2.00000 | 4 | 1000 |
Alteration Orb | Chaos Orb | 0.21645 | 1386 | 1000 |
There are 4 resting orders in the order book. Suppose we have 100 chaos orbs, can make at most 10 trades with 100,000 gold. We would like to maximize the conversion from Chaos -> Divine orb. The straightforward trade places a (want=Divine, have=Chaos, ratio=.01, stock=100) order, yielding 1 divine orb. However, the optimal trade sequence is to first convert 100 chaos -> 4 exalted orb, then 4 exalted orb -> 2 divine orb.
- https://mobook.github.io/MO-book/notebooks/04/05-cryptocurrency-arbitrage.html#trading-and-arbitrage
- https://nbviewer.org/github/rcroessmann/sharing_public/blob/master/arbitrage_identification.ipynb#Finding-an-%22Optimal%22-Set-of-Cycles
- https://www.reddit.com/r/pathofexile/comments/1e902zz/path_of_exile_introducing_the_currency_exchange/
- https://or.stackexchange.com/questions/39/how-to-linearize-the-product-of-a-binary-and-a-non-negative-continuous-variable