SmartQuant Discussion
http://www.smartquant.com/forums/

Recover PnLSeries
http://www.smartquant.com/forums/viewtopic.php?f=60&t=10686
Page 1 of 1

Author:  felipehsantos [ Wed Feb 26, 2014 5:47 pm ]
Post subject:  Recover PnLSeries

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();
}

Page 1 of 1 All times are UTC + 3 hours
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/