Dukascopy Support Board http://www.dukascopy.com/swiss/english/forex/jforex/forum/ |
|
Help with merge order profit and loss calculation http://www.dukascopy.com/swiss/english/forex/jforex/forum/viewtopic.php?f=77&t=45541 |
Page 1 of 1 |
Author: | DEMO2NjPXV [ Thu 19 Jan, 2012, 04:08 ] |
Post subject: | Help with merge order profit and loss calculation |
The very simple strategy below buys 1M GBP, then buys another 1M GBP, then sells 1M GBP and then sells 1M GBP again. So the total position is flat. Then the strategy merges all four orders. Shortly afterwards all orders are closed if they are not already close and finally a summary of the orders is output. The output from the strategy run between 04/10/2011 10:00:00 and 04/10/2011 10:00:40 is: Quote: 2012-01-19 15:44:23.844 INFO Main - Executing onStop Label: BUY1M_1 Amount: 1.0 Open: 1.53932 Close: 1.53932 Commission: 18.47184 PandL: 0.0 Label: BUY1M_2 Amount: 1.0 Open: 1.53927 Close: 1.53927 Commission: 18.471239999999998 PandL: 0.0 Label: SELL1M_1 Amount: 1.0 Open: 1.53905 Close: 1.53905 Commission: 18.468600000000002 PandL: 0.0 Label: SELL1M_2 Amount: 1.0 Open: 1.53909 Close: 1.53909 Commission: 18.46908 PandL: 0.0 Label: MERGE Amount: 0.0 Open: 0.0 Close: 0.0 Commission: 0.0 PandL: 0.0 context.getAccount().getEquity() = 999466.12 profit = 533.8800000000047 commission = 73.88076 profit before commission = 459.99924000003375 2012-01-19 15:44:23.857 INFO Main - Strategy stopped: 1 leaving onstop Can somebody please explain how the number $999,466.12 which is output by getEquity() was calculated? I get $999,476.12 whatever way I try to calculate it. package Strategies; |
Author: | Victor [ Thu 19 Jan, 2012, 08:57 ] |
Post subject: | Re: Help with merge order profit and loss calculation |
your answer is in line 75 System.out.println("profit = " + (1000000 - context.getAccount().getEquity())); 1000,000-533.88 |
Author: | DEMO2NjPXV [ Thu 19 Jan, 2012, 20:05 ] |
Post subject: | Re: Help with merge order profit and loss calculation |
Thanks Victor, but my question is how does getEquity() get to that figure from the IOrder data. In other words, how can we replicate the getEquity() for merge orders by processing the messages which get sent to onMessage() and how can we keep an up-to-date Net Asset Value figure inside onTick() based on the current ITick values? e.g. if we calculate the weighted average BUY price and the weighted average SELL price, then the P/L is before commissions is $450, which is different to the value which getEquity() outputs by $10. |
Author: | DEMO2NjPXV [ Mon 23 Jan, 2012, 07:14 ] |
Post subject: | Re: Help with merge order profit and loss calculation |
Does anybody know what the calculation is to take the fields in the IOrder objects (as given above) which replicates the same number that is in getEquity() in the above example? PS there is no need to replicate the experiment, just to explain the calculation. |
Author: | DEMO2NjPXV [ Wed 25 Jan, 2012, 01:40 ] |
Post subject: | Re: Help with merge order profit and loss calculation |
Can Dukascopy please respond and show how to calculate the same value reported by getEquity() (i.e. 999466.12) in the example above? Where did that extra $10 come from? If the question is not clear enough then please say so and I will attempt to increase clarity but I have posted the strategy file, the conditions of the experiment and the results in as clear a format as I could make. thanks. |
Author: | mtthwbrnd [ Sun 19 Feb, 2012, 02:21 ] |
Post subject: | Re: Help with merge order profit and loss calculation |
Any advances? |
Page 1 of 1 |