4.14.2010

Bugs be gone!

The past few days have had me chasing down framework bugs. Since I've decided to expand a little on my brokers functionality in order to suite my trading style, I've introduced a bit of an issue. Normally, when you place a long order for lets say EUR/USD, any pre-existing short orders will be closed, up to the available units. For example, if I place a short order for 1000 units EUR/USD and then subsequently place a long order for 1200 units EUR/USD, my new position will be a long order of 200 units EUR/USD. This means that my short order has been closed by my long order.

Anyways, this obviously causes issues when attempting to trade multiple timeframes, strategies, or hedge in a single account. I've gotten around that by using sub accounts, and seamlessly tying them together. Now then, calculating an average position and price is easy when all the positions are in the same direction. It's not quite so easy when you want an average position of your portfolio of positions! My objective here is too avoid calculating the PL of the portfolio on every iteration. I posted about my work earlier. Getting the average position consists of adding up and dividing out the long and short positions to arrive at a net price, units and directions. The trouble comes in when you then try and utilize this "net" position to calculate your PL to exchange rate ratio. In other words, how much profit do I see with each pip? From there it would seem easy enough to predict your profit based on price movements. This is were the trouble seems to be occurring. Given enough positions this profit calculation seems to no longer work. If the math is right, blame the client! I guess my bug hunting will be focused on the client side now.

No comments:

Post a Comment