RightEdge Forums
Main     Home          Members     Calendar     Who's On

Welcome Guest
        



Equity Curve by symbol Expand / Collapse
Message
Posted 11/2/2010 12:01:17 Post #12511
 

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie
Hi All,

What is the best way to generate PnL data by symbol within RE so it can be output it to, say, a csv file or other external container? To be more specific I'm looking to output something like this (for daily simulation):

date, pnl, position
yyyymmdd, xxx, yyy

where date set is the union of all dates across bars.

My original thought was to have a results plugin that does it by accessing SystemStatistics.BarStats but the values do not seem to be readily available there. I'd like to be able to implement this 'centrally' for multiple systems, so ResultsPlugin seems like a proper place.. Please help.

Thanks in advance,
Alex

Posted 11/5/2010 07:57:47 Post #12520
 

Lead DeveloperLead DeveloperLead DeveloperLead DeveloperLead DeveloperLead DeveloperLead DeveloperLead Developer
When are you looking to do this? At the end of a simulation? If so, a system results plugin would probably be the best approach. The CreateResultsControl function gets an object named FinalSystemResults. At that point you would iterate over the opened, closed positions and break out stats by Symbol. Something like this:

SortedList<Symbol, List<PositionInfo>> positionCollections = new SortedList<Symbol, List<PositionInfo>>();

IList<Position> positions = systemResults.SystemData.PositionManager.GetOpenPositions();

foreach (Position position in positions)
{
if (!positionCollections.ContainsKey(position.Symbol))
{
positionCollections.Add(position.Symbol, new List<PositionInfo>());
}

positionCollections[position.Symbol].Add(position.Info);
}

positions = systemResults.SystemData.PositionManager.GetClosedPositions();

foreach (Position position in positions)
{
if (!positionCollections.ContainsKey(position.Symbol))
{
positionCollections.Add(position.Symbol, new List<PositionInfo>());
}

positionCollections[position.Symbol].Add(position.Info);
}

foreach (Symbol symbol in systemResults.SystemData.Symbols)
{
if (!SystemUtils.IsTradeableAssetClass(symbol.AssetClass))
{
continue;
}
// Do your P/L processing here.
}



gracha (11/2/2010)
Hi All,

What is the best way to generate PnL data by symbol within RE so it can be output it to, say, a csv file or other external container? To be more specific I'm looking to output something like this (for daily simulation):

date, pnl, position
yyyymmdd, xxx, yyy

where date set is the union of all dates across bars.

My original thought was to have a results plugin that does it by accessing SystemStatistics.BarStats but the values do not seem to be readily available there. I'd like to be able to implement this 'centrally' for multiple systems, so ResultsPlugin seems like a proper place.. Please help.

Thanks in advance,
Alex

« Prev Topic | Next Topic »


Reading This Topic Expand / Collapse
Active Users: 0 (0 guests, 0 members, 0 anonymous members)
No members currently viewing this topic.
Forum Moderators: billb, young, dplaisted

Permissions Expand / Collapse

All times are GMT -5:00, Time now is 4:58pm

2005-2007 © RightEdge Systems