Trader problem

For the discussion of math. Duh.

Moderators: gmalivuk, Moderators General, Prelates

Trader problem

Postby Who, me? » Tue Jun 12, 2012 2:18 am UTC

I'm coding an economy for a game, and I couldn't figure this out, so I need your help on this:
---

There are two systems, Alpha and Beta

Alpha has an amount of credits A_creds, Beta has B_creds credits

Alpha has A_goods goods, Beta has B_goods goods


The price of goods on Alpha is A_creds/A_goods, and the price of goods on Beta is B_creds/B_goods


There is a trader who may continuosly buy as many goods as he wants from Alpha and sell these to Beta, or vice versa


How many goods should the trader buy/sell from Alpha to maximise his profits?

(Buying from a system will give it credits according to the price of what's been purchased, and all transactions are continuous)

--

I'll gladly tell anything else I know if you want

Also, writing your thought processes aloud very welcome

Oh! and thank you for any assistance rendered
Who, me?
 
Posts: 15
Joined: Wed Sep 21, 2011 4:51 am UTC

Re: Trader problem

Postby Who, me? » Tue Jun 12, 2012 2:41 am UTC

Or, a simpler (but still useful) problem to solve would be how much should the trader buy/sell in one chunk, so that the two prices in both systems are equal (He buys/sells at a single, noncontinuous price, the starting price for the sysyems)
Who, me?
 
Posts: 15
Joined: Wed Sep 21, 2011 4:51 am UTC

Re: Trader problem

Postby Who, me? » Tue Jun 12, 2012 7:22 am UTC

Aaand I found (algebraically) how much to buy/sell if the trader is buying/selling at one price, to get both systems to the same price. That solution works fine enough for me, and the solution to either of the above problems isn't necessary for me anymore. I hate when you're stuck on something, ask for help, then you figure it out. Thanks anyways!

edit: Not finished figuring out this economy yet, namely how to set a price for the player when he buys X goods (selling 2 goods should get you more $/good than selling 10 goods, see my last post)
Last edited by Who, me? on Wed Jun 13, 2012 12:13 am UTC, edited 1 time in total.
Who, me?
 
Posts: 15
Joined: Wed Sep 21, 2011 4:51 am UTC

Re: Trader problem

Postby nishank » Tue Jun 12, 2012 7:56 am UTC

Hi, can you specify what is the input/output for alpha and beta.
i.e if goods are replenished etc (conditions)
nishank
 
Posts: 29
Joined: Fri May 11, 2012 9:58 pm UTC

Re: Trader problem

Postby liveboy21 » Tue Jun 12, 2012 2:05 pm UTC

Buying and selling to get both markets to have the same price will probably be the correct solution. You have two markets that have different prices and a trader that has the ability to access both markets. The trader would then choose to buy a good at the lower price and sell the good at the higher price simultaneously. This trading strategy is known as arbitrage.

Since the trader will sell in the more expensive market and buy in the cheaper market, the prices will eventually become the same. There is no difference between the markets and if a difference appears for whatever reason, the trader will take advantage of it and cause the price to equalize once more. This effect is known as the law of one price.

It's hard to say exactly how many trades will happen based on the little information about your ecomony model (eg. where do credits come from, where do goods come from, how fast do they grow, does trading have restraints, etc) but you can expect that there will be arbitrage trading.
liveboy21
 
Posts: 102
Joined: Thu Dec 01, 2011 9:33 am UTC

Re: Trader problem

Postby eSOANEM » Tue Jun 12, 2012 5:24 pm UTC

liveboy21 wrote:Buying and selling to get both markets to have the same price will probably be the correct solution. You have two markets that have different prices and a trader that has the ability to access both markets. The trader would then choose to buy a good at the lower price and sell the good at the higher price simultaneously. This trading strategy is known as arbitrage.

Since the trader will sell in the more expensive market and buy in the cheaper market, the prices will eventually become the same. There is no difference between the markets and if a difference appears for whatever reason, the trader will take advantage of it and cause the price to equalize once more. This effect is known as the law of one price.

It's hard to say exactly how many trades will happen based on the little information about your ecomony model (eg. where do credits come from, where do goods come from, how fast do they grow, does trading have restraints, etc) but you can expect that there will be arbitrage trading.


This is only necessarily the case for goods which are resalable.

Assuming the trader can bring x amount of goods with him when he travels between the two systems, and that all the goods they had in the system before the trader arrived which got sold are replaced by the time he returned and defining the amount of goods in A as a and the amount of money in A as A we get that:

The price of goods in the cheap system (A) is (A/a)*(a+x)/(a-x) and in the expensive system is (B/b)*(b-x)/(b+x) and the trader's profit is x(B/b-A/a) after one trade.

If the goods aren't resalable, then the next time he trades, a'=a and A'=A+x*A/a and b'=b and B'=B-x*B/b.

Now, which direction he trades will depend on the price gap, but, assuming it's still in the same direction, the price of goods and the trader's profits will simply be the result for one trade with A' and B' substituted for A and B so price(A)=((A+x*A/a)/a)*(a+x)/(a-x)=(A/a^2)*(a+x)^2/(a-x).

It's clear where the trend goes so that, after n trades in the same direction, P(A)=(A/a^n)*(a+x)^n/(a-x).

If a trade causes the price difference to switch, the trader's next trade will be in the opposite direction and so will simply be to reverse his previous trade.

Of course, this assumes non-resalable goods, that the goods in the system each time the trader arrives doesn't change and that the trader always trades the same amount of stock and, most importantly, the price only changes after the trade has taken place. In this form of the problem, it is always in the trader's interest to miss equilibrium because then he can make another profit-making trade.

If the goods are resalable, I suspect that you'll end up with the same situation except that instead of the price on each planet oscillating around equality, the actual amount of money and goods will oscillate around equal.

It will still always (for almost all starting values) be possible for the trader to make a profit on a trade and so, in this set up (both the resalable and non-resalable versions), the trader will eventually end up with all of the money in the world.
Gear wrote:I'm not sure if it would be possible to constantly eat enough chocolate to maintain raptor toxicity without killing oneself.
User avatar
eSOANEM
 
Posts: 1927
Joined: Sun Apr 12, 2009 9:39 pm UTC
Location: Grantebrycge

Re: Trader problem

Postby Who, me? » Tue Jun 12, 2012 10:30 pm UTC

It will still always (for almost all starting values) be possible for the trader to make a profit on a trade and so, in this set up (both the resalable and non-resalable versions), the trader will eventually end up with all of the money in the world.


Mm hm, that's actually an issue I was having, where the system would be bled dry. I fixed that by making the two systems trade at the same price, specifically the average of their two prices. (I suppose total credits between them divided by total goods between them would be a better price, but they both work fine), I was also thinking of just splitting the trader's profits evenly between the two systems after they trade once


eSOANEM wrote:The price of goods in the cheap system (A) is (A/a)*(a+x)/(a-x) and in the expensive system is (B/b)*(b-x)/(b+x) and the trader's profit is x(B/b-A/a) after one trade.


Ah, helpful that, but only if the price for the trade is constant. I was defining price more generally as (A+profits)/(a-x), where profits is total credits thus far. Profits was then defined as the sum/integral of prices between 0 and X goods bought (the trader was buying the goods in continuous chunks).

--

I'm actually trying to figure this out, because if the trader (or player) buys as much as he wants for a set price, then he could make a profit by buying a large amount at a cheap price, causing the prices to go up, and sell them again at a higher price. I remember using this to exploit another game for large sums of money.

Namely, if you're buying from a system with credits A, amount of goods a, and cost per good of A/a, how much does it cost to buy X amount of goods, so that it is impossible to give or lose money to the system?

--

I don't necessarily need this, I can do this via an iterative approach or some approximation; players won't be buying enough to manipulate a system's market in such a manner enough to make any profit, but a clean and 100% accurate way of doing this is something I'd like


edit:
Hi, can you specify what is the input/output for alpha and beta.
i.e if goods are replenished etc (conditions)

In this problem it's inconsequential; nobody's producing/consuming goods while they're trading. If you want to know though, consumption/production is a function of stockpile size and a consumption/production modifier. For balance, production->inf and consumption->0 as stockpiles get low, and vice versa when they're high. How large/small (negative) the modifier is affects how fast they go to their extremes. So two systems trading will settle on optimum stockpile sizes that depend on their modifiers, how much trade is allowed/conducted, and the value of what they produce/consume (at an optimum, imports will equal exports in value).
Who, me?
 
Posts: 15
Joined: Wed Sep 21, 2011 4:51 am UTC

Re: Trader problem

Postby erik542 » Thu Jun 14, 2012 4:37 am UTC

You might want to use a different model. The trader will simply take all the money and goods from both providers. The trader will buy all but one good from person alpha (this will cost m_alpha*g_alpha + g_alpha*(g_alpha-1)/2. The price of that last good is now (m_alpha*(g_alpha+1) + g_alpha*(g_alpha-1)/2)/1. The trader will then sell one good to person alpha for m_alpha*(g_alpha+1) + g_alpha*(g_alpha-1)/2, taking all of person alpha's money. Person alpha's good are now worth 0, and the trader just takes them. So the lesson is that sufficiently rich people can just take all your money and stuff.
erik542
 
Posts: 32
Joined: Sat Jul 19, 2008 5:44 am UTC


Return to Mathematics

Who is online

Users browsing this forum: No registered users and 8 guests