calculating working capital for money management

Forums ProRealTime English forum ProOrder support calculating working capital for money management

Viewing 15 posts - 1 through 15 (of 25 total)
  • #171240

    I recently changed the Money Management code I had been using, mainly because it couldn’t account for the profit accrued when stopping and restarting an algo.

    Looking at the existing snippets I could find, I opted for a minor variation of one by Vonasi:

    This is a nice piece of code and it works well, but as you can see, positionsize is based on the relation between capital and MinSize.

    MinSize is a given, so what to enter as a value for Capital? It can’t just be the amount you happen to have in your account, as that could be any arbitrary amount –  5000, 10000, 50000 – and that would be the starting point for any positionsize increase: a 10% increment would occur only after a gain of 500, a gain of 1000 or a gain of 5000.

    So how to calculate a useful figure for working capital, as it’s the only variable here with which to alter the speed of increase/decrease ?

    My first thought was to use a factor of the margin cost, eg minsize margin * 15   ???

    But it could also be related to the value of the stoploss ??

    Or the max historical drawdown ??

    Any thoughts on this greatly appreciated…

    #171243

    Well… I can post the one I am using (nLots is the Number of Lots to be traded):

    It is based on the DrawDown (write at line 2 the DrawDown showed with LotManagement=0, disabled) with a multipliying factor (DDmultiplier), sort of leverage or risk aversion factor (I always use 3) AND the margin % required by the broker.

    #171244

    At line 7, each new day, the required Capital is updated (considering the fluctuation of price) to affect calculations.

     

    #171245

    Thanks Roberto, that looks interesting – basing it on DD makes sense.

    The only bit I don’t get is

    what does this achieve?

    Also, could i add

     

    #171246

    Ok, so (high * MyMargin / 100)  just removes the margin cost from your available funds – is that right?

    #171247

    another question: is StrategyProfit calculated in instrument currency or account currency?

    The instruments I trade are either $ or € but my account is in GBP … so this would effect the margin calculation

    #171248

    Yes, it’s the margin calculation. I use HIGH, instead of CLOSE, to be more conservative.

    Yes, you can either:

    • use ProfitAccrued
    • increase the InitialSize

     

    1 user thanked author for this post.
    #171249

    STRATEGYPROFIT is in the currency of your account, while the margin is relative to the price of the instrument.

    That’s a good point. We could change it to use an exchange rate. So if you trade Nikkei you could enter the GBP/JPY exchange rate. The drawback is that ProOrder won’t let you know what that rate is, so you will have to update it regularly (say each month).

    #171250

    Line 16 is to make sure there’s only 1 decimal. If you want to use 2, just replace 10 with 100, in both multiplication and division.

    To use only integers replace 10 with 1 or simply remove both the multiplication and the division.

     

    #171253

    Out of interest, do you get 0.5% margin in Italy? I thought all of the EU was at 5% ?

    My account is in Switzerland and the margin deposit is 0.5%

    #171254

    Sorry, STRATEGYPROFIT is returned according to the involved instrument.

    This could be a solution (not tested):

    #171255

    I’m not sure lines 7 and 9 require ExchangeRate.
    I will test it asap.

    #171256

    If you use the Max Drawdown from a backtest (without MM) then that figure will be in instrument currency, so yes I think lines 7 and 9 would need modification for ExchangeRate.

    But ProfitAccrued would be in account currency, so I would leave it off there.

    Also, if you were going to do a backtest with LotManagement = 1  (not for optimization but just out of curiosity) then you would need to add a limit for MaxSize, otherwise it can go up insanely high…

    #171257

    (high * Margin / 100) would be the margin value of 1 contract, no? … so wouldn’t a proper allowance for margin cost have to be

    (nLots*(high * Margin / 100))

     

    ??

    #171260

    No, the calculation of lots is at lines 16-17.

     

Viewing 15 posts - 1 through 15 (of 25 total)

Create your free account now and post your request to benefit from the help of the community
Register or Login