SmartQuant Discussion

Automated Quantitative Strategy Development, SmartQuant Product Discussion and Technical Support Forums
It is currently Wed Oct 28, 2020 11:06 am

All times are UTC + 3 hours




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Fri Jan 11, 2013 8:16 am 
Offline

Joined: Mon Nov 12, 2012 2:38 am
Posts: 59
I want to output the portfolio detail when strategy stops. But it seems that the price of position gets to be zero in memeber function OnStrategyStop(); so I get wrong GetUnrealizedPnL() value.

public override void OnBar(Bar bar)
{
if(!HasPosition)
{
Buy(1);
}
}

public override void OnStrategyStop()
{
if (Portfolio.Positions.Count > 0)
{
Console.WriteLine("====== positions list ======");
foreach (Position pos in Portfolio.Positions)
{
Console.WriteLine("MktPx={0}\tPnL={1:f2}", pos.Amount, pos.GetPrice(), pos.GetUnrealizedPnL());
}
}
}

===== The output ======
MktPx=0 PnL=-987632.32


Top
 Profile  
 
PostPosted: Fri Jan 11, 2013 10:12 am 
Offline

Joined: Wed Oct 08, 2003 1:06 pm
Posts: 833
Hi Grazdigo,

I have done a short test on 1 minute bars and do not see problems. However I have changed your code a bit, I am using this line:

Console.WriteLine("Amount={0}\tMktPx={1}\tPnL={2:f2}", pos.Amount, pos.GetPrice(), pos.GetUnrealizedPnL());

If you still see the problem with this line please e-mail me a .csv file with the data to reproduce the issue to sergey.baraz at smartquant .com

Regards,
Sergey.


Top
 Profile  
 
PostPosted: Wed Jan 16, 2013 9:18 am 
Offline

Joined: Mon Nov 12, 2012 2:38 am
Posts: 59
Thanks for your reminding, my csv data has an error. Now it is OK.


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 3 guests


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