Exchange % formula

  • Hello everyone!

    I'm developing a tool with excel, but I don't know how to calculate the resource % in exchanges.

    For example:

    I sell 1.000.000 deut and I buy 40% met & 60%cry. If the exchange rates are 2,5:1,5:1 we have:


    1kk deut for 714.286 met and 1.071.429 cry.


    As you can see, 40% does not mean 0,4*1000. It's the 40% of the total: [714.286 : 1.071.429 = 40 : 60]


    I don't know how to calculate this, is there someone who can help me?

  • You have to work backwards


    You have D total deut. You want to trade it so you get X% metal and Y% crystal at 2.5:1.5:1


    M is the total amount you will trade for metal.


    So the total trade will end up with 2.5M and 1.5(D-M)


    As we know the percentages, 2.5M = X/Y x 1.5(D-M)


    Expand out - 2.5M = (1.5X/Y)D - (1.5X/Y)M


    Move the Ms to one side - (2.5 +1.5X/Y) M = (1.5X/Y)D


    Make the M on it's own - M = (1.5X/Y)D / (2.5+1.5X/Y)


    Now plug X and Y and D (which you know - the amount of deut you want to trade and the ratio you want back) into the formula and you can calculate M from it.


    It's not a pretty formula, but it works :-P


    Edit - dammit the X and Y were the wrong way round - think it's right now...


    Edit 2 - you can also change the trade rate inside the formula - so say you want the trade rate to be A:B:1


    The formula is then M = (BXD/Y) / (A + BX/Y)

  • Desired Resources Ratio / Rate = Ratio in Deuterium Sold (RRiDS)

    {30% , 70 % , 0% } / {2.5 , 1.5 , 1}
    0.12 : 0.46666 : 0


    Convert the RRiDS into a percentage

    {0.12 , 0.46666 , 0 } / 0.58666
    20.45%, 79.55% , 0% = Percentage of Deuterium Sold

    *To verify

    511,364 metal = 20.45% * 1,000,000 * 2.5
    1,193,182 crystal = 79.55% * 1,000,000 * 1.5