Profile Picture

Equity Curve by symbol

Posted By gracha 7 Years Ago
Message
Posted Tuesday November 02 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

Posted Friday November 05 2010
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



Similar Topics


Reading This Topic


2005-2017 © RightEdge Systems