SmartQuant Discussion

Automated Quantitative Strategy Development, SmartQuant Product Discussion and Technical Support Forums
It is currently Wed Sep 23, 2020 12:25 pm

All times are UTC + 3 hours




Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: Recover PnLSeries
PostPosted: Wed Feb 26, 2014 5:47 pm 
Offline

Joined: Sat Sep 08, 2007 11:52 pm
Posts: 1
Hi,

I would like to retrieve the PnLSeries that is shown in the Performance Tab.

I tried this piece of code and it dit not worked. I am using the Simple Moving Average CrossOver sample.


Step 1: Add .Net Libs

using System.IO;
using System.Collections;
using System.Collections.Generic;

Step 2: Add List of Dates

List<DateTime> ldates;

public override void OnStrategyStart()
{
[....]
ldates = new List<DateTime>();
}

public override void OnBar(Bar bar)
{
ldates.Add(bar.DateTime.Date);
[...]
}

public override void OnStrategyStop()
{
string file_name = "equity_series_" + Instrument.Symbol+".txt";

Console.WriteLine(ldates.Count);
Console.WriteLine(this.Performance.PnLSeries.Count);

using(StreamWriter sw = new StreamWriter(@"C:\SmartQuant_Testing\"+file_name))
{
sw.AutoFlush=true;
for(int i=0;i<ldates.Count;i++)
{
DateTime dt = ldates[i];
int iid = this.Performance.EquitySeries.GetIndex(dt);
if(iid>=0)
{
string eqt_name = this.Name;
double eqt_value = this.Performance.PnLSeries[iid];
string eqt_symbol = this.Instrument.Symbol;
string eqt_date = dt.ToString("yyyy-MM-dd HH:mm:ss");
sw.WriteLine("{0};{1};{2};{3}", eqt_name, eqt_symbol, eqt_date, eqt_value);
}
else
{

}
}
}

base.OnStrategyStop();
}


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

All times are UTC + 3 hours


Who is online

Users browsing this forum: No registered users and 4 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