SmartQuant Discussion

Automated Quantitative Strategy Development, SmartQuant Product Discussion and Technical Support Forums
It is currently Mon Sep 16, 2019 12:01 pm

All times are UTC + 3 hours




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: stop loss for portfolio
PostPosted: Tue Dec 20, 2011 11:23 pm 
Offline

Joined: Wed May 11, 2011 4:03 pm
Posts: 12
Does anyone know how to write fix stop order code for multiple instruments denominated different currencies ?
ex. I want to put stop market order if my portfolio goes down to $5000 from DAX, S&P combined.

Thanks


Top
 Profile  
 
PostPosted: Wed Dec 21, 2011 2:08 am 
Offline

Joined: Sun Oct 30, 2011 12:12 am
Posts: 220
My first idea would be to monitor current P&L in realtime via OnQuote for both instruments when you have positions opened.

In OnQuote, I would check the P&L for each instrument: for example if you are long S&P and short DAX, compare the S&P bid (= price at which you can exit your long) and the DAX ask (= price at which you can exit your short) to your average entry prices for each instruments. P&L(instrument) = (current price(instrument) - avg entry price(instrument)) x position quantity(instrument).
Only issue remaining is currency conversion: if USD is your account base currency, you have to convert the DAX P&L from EUR to USD before adding it to your S&P P&L (which is already in USD).
Therefore: TotalUSDPnL = S&P PnL + (DAX PnL * EUR/USD).
Either you convert the DAX P&L using realtime rates (ie you have to subscribe to a third instrument: EUR/USD) or on a hard coded basis (ie store a member in your class "double _eurusdRate = 1.30783"). I'd suggest the realtime rates for pair trading.

There are certainly more elegant ways to do that.
For example, P&L is already calculated in Position.GetPnL and a few other methods (GetUnrealizedPnL()...).
If you're pair trading, enter this in Google without quotes: "site:smartquant.com pair trading".

Hope it helps.


Top
 Profile  
 
PostPosted: Thu Dec 22, 2011 9:05 pm 
Offline

Joined: Wed May 11, 2011 4:03 pm
Posts: 12
Hi, Thank you so much your reply.

Is there a way to read directly read or monitor the PnL in execution platform ? I am running OpenQuant with TT API and wondering if OQ can monitor the PnL value in X_Traeder's fill window..

Thanks


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC + 3 hours


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group