Re: [Quickfix-developers] Calculating the profit/lost for anoperation
Brought to you by:
orenmnero
|
From: Scott R. <sri...@fo...> - 2006-08-07 18:41:41
|
For simplicity's sake, you can pair each executed quantity with the = other side in the order they come in, but it doesn't really matter which = sell you pair the buy off with. Since you are clearing back to a zero = position, whichever you pair off with, the other will pair off with the = trade you will inevitably do later. Any gain you show with the first = pair off is going to detract from potential gains from subsequent pairs = (you are left holding a worse price), and vice versa with loses. = Regardless of which you pair off with, at the end of the day, you are = going to end up with the same PnL. Hope this helps. -Scott -----Original Message----- From: qui...@li... = [mailto:qui...@li...] On Behalf Of = Lidia L=F3pez Cuesta Sent: Monday, August 07, 2006 2:10 PM To: or...@qu... Cc: qui...@li... Subject: Re: [Quickfix-developers] Calculating the profit/lost for = anoperation QuickFIX Documentation: = http://www.quickfixengine.org/quickfix/doc/html/index.html QuickFIX Support: http://www.quickfixengine.org/services.html Hi, I think that I haven't explained very well. I am working with futures, = so I=20 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=3D1, market) = and=20 someone buy them at 10, So I have sell 1000 at 10 =3D 10000. After I = want to=20 sell 1000 futures for the best and someone buy them at 11, so I have = selt=20 1000 at 10 (10000) and 1000 at 11 (11000). This means that I have to buy = 200=20 futures before the market closes. When I decide to buy some of my futures, for example I want to buy 1000 = and=20 someone sell this 1000 at 10.5 (10500). In this case I would like to know if the market matches my last bougth = with=20 one of my sells to know how much money I have lost or win for a pair=20 buy-sell. Lidia >From: Oren Miller <or...@qu...> >To: Lidia L=F3pez Cuesta <li...@ho...> >CC: qui...@li... >Subject: Re: [Quickfix-developers] Calculating the profit/lost for an=20 >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 =20 >whole lot of sense, especially when the orders are of varying sizes. = (You=20 >actually shouldn't even be concerned with orders, executions and = positions=20 >are all you really need to look at). You instead need to look at the=20 >number of shares executed, and calculate your realized PnL for what = you=20 >have matched, then calculate your unrealized PnL for what is = unmatched. =20 >Adding these up will get you the total PnL. So in your scenario = (prices=20 >added for to clarify the example) > >Buy 1000 @ 10 =3D Cost Basis 10,000 >Buy 2000 @ 11 =3D Cost Basis 22,000 >Sell 1500 @ 10.5 =3D Cost Basis 15,750 >Market @ 10.75 > >Now, for your realized PnL, it is reasonable to take the stance that = the=20 >earliest shares get 'matched' first. So we get this: > >(1000 @ 10 =3D 10000) + (500 @ 11 =3D 5500 ) =3D Cost Basis 15,500 > >The Cost Basis is the amount of currency (we'll use dollars here) you =20 >spent in order to accumulate the first 1500 shares of your position. = This=20 >is what we will used to calculate the realized PnL. The cost basis = for=20 >the second 1500 shares is 1500 @ 11 =3D 16,500. So we see we payed = $1000=20 >more for the second hundred shares, and this is what we will use to=20 >calculate the unrealized PnL. > >So now we need to take the cost basis of the first 1500 shares, and =20 >subtract them from the cost basis of our sold shares. Or 1500 @ 10.5 = =3D=20 >Cost Basis 15,750. So (15,750 - 15,500) means we made $250 on our = first=20 >1500 shares, and this is our realized PnL. > >For the rest of it, we can use the market price to estimate what our = PnL=20 >might be if we liquidated the position (this is simplistic, much more=20 >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=20 >=3D 16,125. So we have 16,125 - 16,500, giving us an unrealized PnL = of=20 >-375. Now just add the two up, and your total PnL is 250 - 375 =3D = -125. > >I didn't go over them too carefully, but I hope my calculations are =20 >correct. I hope the explanation helps. > >--oren > >On Aug 7, 2006, at 12:09 PM, Lidia L=F3pez Cuesta wrote: > >>QuickFIX Documentation: http://www.quickfixengine.org/quickfix/doc/=20 >>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=20 >>the >>sell order is executed (at 1500), how do I know which the buys orders = is=20 >>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=20 >>order >>is matched with the sell order? >> >>If the sell order is matched with the first one I have earned 500, = but if=20 >>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=20 >>easier >>Download IBM WebSphere Application Server v.1.0.1 based on Apache =20 >>Geronimo >>http://sel.as-us.falkag.net/sel? = cmd=3Dlnk&kid=3D120709&bid=3D263057&dat=3D121642 >>_______________________________________________ >>Quickfix-developers mailing list >>Qui...@li... >>https://lists.sourceforge.net/lists/listinfo/quickfix-developers >> > -------------------------------------------------------------------------= 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=3Dlnk&kid=3D120709&bid=3D263057&dat=3D= 121642 _______________________________________________ Quickfix-developers mailing list Qui...@li... https://lists.sourceforge.net/lists/listinfo/quickfix-developers |