Re: [Quickfix-developers] Calculating the profit/lost for an operation
Brought to you by:
orenmnero
|
From: <li...@ho...> - 2006-08-07 18:09:51
|
Hi, I think that I haven't explained very well. I am working with futures, so I have to sell and buy the same number of futures at the end of the day. For example I sell 1000 futures for the best (order type=1, market) and someone buy them at 10, So I have sell 1000 at 10 = 10000. After I want to sell 1000 futures for the best and someone buy them at 11, so I have selt 1000 at 10 (10000) and 1000 at 11 (11000). This means that I have to buy 200 futures before the market closes. When I decide to buy some of my futures, for example I want to buy 1000 and someone sell this 1000 at 10.5 (10500). In this case I would like to know if the market matches my last bougth with one of my sells to know how much money I have lost or win for a pair buy-sell. Lidia >From: Oren Miller <or...@qu...> >To: Lidia López Cuesta <li...@ho...> >CC: qui...@li... >Subject: Re: [Quickfix-developers] Calculating the profit/lost for an >operation >Date: Mon, 7 Aug 2006 12:53:36 -0500 > >Lidia, > >Matching a specific sell order to a specific buy order doesn't make a >whole lot of sense, especially when the orders are of varying sizes. (You >actually shouldn't even be concerned with orders, executions and positions >are all you really need to look at). You instead need to look at the >number of shares executed, and calculate your realized PnL for what you >have matched, then calculate your unrealized PnL for what is unmatched. >Adding these up will get you the total PnL. So in your scenario (prices >added for to clarify the example) > >Buy 1000 @ 10 = Cost Basis 10,000 >Buy 2000 @ 11 = Cost Basis 22,000 >Sell 1500 @ 10.5 = Cost Basis 15,750 >Market @ 10.75 > >Now, for your realized PnL, it is reasonable to take the stance that the >earliest shares get 'matched' first. So we get this: > >(1000 @ 10 = 10000) + (500 @ 11 = 5500 ) = Cost Basis 15,500 > >The Cost Basis is the amount of currency (we'll use dollars here) you >spent in order to accumulate the first 1500 shares of your position. This >is what we will used to calculate the realized PnL. The cost basis for >the second 1500 shares is 1500 @ 11 = 16,500. So we see we payed $1000 >more for the second hundred shares, and this is what we will use to >calculate the unrealized PnL. > >So now we need to take the cost basis of the first 1500 shares, and >subtract them from the cost basis of our sold shares. Or 1500 @ 10.5 = >Cost Basis 15,750. So (15,750 - 15,500) means we made $250 on our first >1500 shares, and this is our realized PnL. > >For the rest of it, we can use the market price to estimate what our PnL >might be if we liquidated the position (this is simplistic, much more >complicated models can be used to estimate a more realistic price, but >it's usually not too important to be accurate here). So the market is >trading at 10.75, this means that our cost basis estimate is 1500 @ 10.75 >= 16,125. So we have 16,125 - 16,500, giving us an unrealized PnL of >-375. Now just add the two up, and your total PnL is 250 - 375 = -125. > >I didn't go over them too carefully, but I hope my calculations are >correct. I hope the explanation helps. > >--oren > >On Aug 7, 2006, at 12:09 PM, Lidia López Cuesta wrote: > >>QuickFIX Documentation: http://www.quickfixengine.org/quickfix/doc/ >>html/index.html >>QuickFIX Support: http://www.quickfixengine.org/services.html >> >>Hi all, >> >>If I have sent 2 buy orders to the market. When both has been executed >>(firtst at 1000 and the second one at 2000), I send a sell order. When >>the >>sell order is executed (at 1500), how do I know which the buys orders is >>the >>couple to close the operation? >> >>I need to calculate the partial profit/lost, so I need to know which buy >>order corresponds to this sell order. >> >>Are there any message or field in the execution report to know which >>order >>is matched with the sell order? >> >>If the sell order is matched with the first one I have earned 500, but if >>it >>is the second one I have lost 500 >> >>Lidia >> >> >> >>---------------------------------------------------------------------- --- >>Using Tomcat but need to do more? Need to support web services, security? >>Get stuff done quickly with pre-integrated technology to make your job >>easier >>Download IBM WebSphere Application Server v.1.0.1 based on Apache >>Geronimo >>http://sel.as-us.falkag.net/sel? cmd=lnk&kid=120709&bid=263057&dat=121642 >>_______________________________________________ >>Quickfix-developers mailing list >>Qui...@li... >>https://lists.sourceforge.net/lists/listinfo/quickfix-developers >> > |