Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Real life Optimization problem

  1. May 28, 2013 #1

    The USD/CNH currency pair has been trending down at an almost linear rate past 3 years, it's safe to assume it will continue to trend downwards for the short term foreseeable future as the Chinese govt slowly allows the Yuan to appreciate to its real value.

    The problem:
    Every initiation of a trade requires a fee thats proportional to the volume of the trade, assume its a static 0.03%, this fee is taken off as soon as you make the trade so to break even after initiating a trade the exchange rate has to move in your favour by at least 0.03%. When you start trades the bank is willing to lend you 200$ for every of your $'s.
    So the best strategy would be to close trades immediately after making a profit and reinvesting it so your profit increases future profits, in effect exponentially increasing the size of your bank account... except this doesnt work, here's why.

    Because of that 0.03% commission you pay to the bank, the first 0.03% profit you make on a trade goes towards breaking even, so you can't spam trades.. taking profit and making a bigger trade straight after. Even if you make a little bit of profit, say you make 0.04% profit, you keep that 0.01% and start a new trade, but once again you have to wait for another 0.03% before you get anything from this new trade... but if you kept the previous trade and the exchange rate went your way for a total of 0.07% then you would get to keep 0.04% for yourself...

    I should mention that the reason it would work exponentially when you reinvest your profits is because every 1$ you put in, the bank puts in 199$ so totalling 200.

    the way profit works is..

    So to trade 100,000$ I put in 500$. Profit I make comes when the actual amount of money I'm trading (100,000) changes in value due to exchange rates.

    so if 100,000 appreciates by 2% then
    profit = 2000 - (100,000 * 0.0003) = 1970

    because I just made 1970 profit I can reinvest all of it (with the bank's generous lending), and trade 494,000$ instead of 100k because I have my previous 500 and my new 1970.

    now if 494k appreciates by 2% then
    profit = 9880 - (494,000 * 0.0003) = 9732

    then reinvest 9732 etc.. you can see how this grows exponentially.. but 2% isn't the best number for maximizing profit over a long period of time and I want to know what is the best %

    the jist of it is, that if you open one trade and wait for a long time assuming the currency will do the same thing it has past 3 years your profit will grow at a linear rate, if you trade very fast then it can increase exponentially, but if you trade too fast then you might not make any money at all, because all your exponential profits get sucked up by commissions to the bank.

    the question:
    what is the optimal profit (as a % of your bank account) for a trade to appreciate, before you close it and use all the profit to reinvest into a new trade.

    let me know if you need more information to solve this problem, I think the only information needed is the leverage and the commission and I don't want to information overload.
  2. jcsd
  3. May 28, 2013 #2
    You need to show work, or we can't help. It's a rule.
  4. May 29, 2013 #3
    if i knew how to do it i wouldnt have posted it?

    what sort of working do you want
  5. May 29, 2013 #4

    Stephen Tashi

    User Avatar
    Science Advisor

    Doesn't what you pay a (real) bank depend on the time you take to repay the loan?
  6. May 29, 2013 #5


    User Avatar
    Staff Emeritus
    Science Advisor

    We want you to try. If you have absolutely no idea how to even start, why are you trying to do such a problem?
  7. May 29, 2013 #6


    User Avatar
    Staff Emeritus
    Science Advisor
    Gold Member

    If I understand your problem correctly, the right answer is that selling your Canadian dollars so you can buy more of them is pointless. Why isn't the bank lending to you based on your Canadian capital?
    Last edited: May 29, 2013
  8. May 29, 2013 #7
    because I know there is a mathematical way of doing it, if one strategy leads to a linear profit over time and the other leads to an exponential one, but every multiplication of the exponent is associated with a cost.. surely there is a way to figure out whats the most I can get.

    it's like a 3D axis, one axis being time, the other being price and the third being frequency of trades, at frequency 1 the graph is linear, at a very high frequency the graph is negative, but before that it's a larger positive than the linear line at frequency 1, so I want to find the highest point which is just a derivative, but involves three variables and I dont know how to describe a function with the required properties (ie exponential increase, but each increment is associated with a cost)
  9. May 29, 2013 #8
    its not a bank, its a broker and they don't "lend" like a bank does they leverage which is slightly different, I didn't want tio mention this because I think it just adds irrelevant information to the problem and allows room for more confusion
  10. May 29, 2013 #9

    Stephen Tashi

    User Avatar
    Science Advisor

    The problem hasn't been state precisely yet.

    Assuming all monetary units are given in the "home" currency, let:

    Tbuy =the time of purchase of the ith investment
    Tsell = the time of the sale of the ith investment
    Invest = the total initial investment amount of the ith investment
    Sale = the total payoff from selling the ith investment
    Stake = the investors share of the initial investment amount in the ith investment
    Leverage = the bank's share of the initial investment amount in the ith investment
    Cost = the cost to the investor of making the ith investment
    Profit = the investors profit on the ith investment

    Does Sale = Invest + Invest * (Tsell - Tbuy) * trend where "trend" is some constant?

    Are we assuming Invest = Stake + Stake*200 for every investment i, or just for i = 1?

    What's the formula for Cost in terms of the other variables?

    Cost = Leverage + comission * Invest, where "comission" = 0.0003 ?

    I gather we are assuming all profit is reinvested, so Stake[i] = Stake[i-1] + Profit[i-1].

    I gather we are assuming a fixed length of time T and asking how trades should be made within that time in order to maximize the total profit to the investor within that length of time. (This is a different question that asking about what frequency of trades maximizes the [i] rate [/i] of increase in the investors funds as T approaches infinity.)[/i]
  11. May 30, 2013 #10
    I'm probably just going to approximate this problem using a brute force search in java. I've started coding it already, but this is what I plan to do.

    let P(t) be the price at time t

    0 ≤ t ≤ 1095

    upper bound - price of USDCNH at time 0
    P(0) = 6.8023

    lower bound - price of USDCNH 3 years later
    P(t) = 6.1441

    assume its linear with some temporary stochastic variance.

    A strategy S is a sequence of Trades T.

    T is a structure that stores a value V and volume λ

    where V is the result of the function
    Δprice * λ * 100,000 - (0.0003 * 100,000)

    and λ is constant for that instance of a Trade

    Each strategy has a constant associated with it, this constant is a percentage or ratio, that goes into a function that is called on the last T in the sequence S per increment of time.

    Function S(t) {
    for the last T in the sequence S, is the change in V [itex]\in[/itex] T between when T was added to the sequence and currently, greater than ( * initial V [itex]\in[/itex] T - current V [itex]\in[/itex] T ).

    if not then just update its value.

    if it is greater then close the trade and take the profit, create a new trade T' with the same , but increase the volume by 0.01 for every 10 units of value gained and add T' to the end of S.

    thats basically it/

    bounds for ...

    upper bound - if ≥ the total change in price (ratio) from P(0) to P(t)
    - you make a single trade over the 3 year period and we assume the profit/time is linear, anything higher than this number does not change the output

    lower bound - if = 0.0003 you break even because the first 0.03% of increase in value goes towards the broker.

    anything smaller than 0.0003 creates a loss, but the more frequently you can trade the more 'exponential' your profit becomes over time because you can use your Δprice to increase volume.

    except at some values of close to 0.0003 the exponential growth is so slow that the linear one is probably better.

    what is the best value for

    ie try maybe I should try many S' with different values for between those two bounds and see which S has the most valuable T at the end of its sequence.. but surely there is a way to derive this. Otherwise I'll just proceed with writing my 4000 b.c. hill climbing algorithm :yuck:
    Last edited: May 30, 2013
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Similar Discussions: Real life Optimization problem
  1. Optimization problem (Replies: 2)

  2. Optimization problems (Replies: 8)