Overall Statistics
Total Trades
1
Average Win
82.56%
Average Loss
0%
Compounding Annual Return
36.286%
Drawdown
10.800%
Expectancy
0
Net Profit
82.563%
Sharpe Ratio
1.514
Loss Rate
0%
Win Rate
100%
Profit-Loss Ratio
0
Alpha
0.352
Beta
-0.1
Annual Standard Deviation
0.22
Annual Variance
0.048
Information Ratio
0.563
Tracking Error
0.25
Treynor Ratio
-3.341
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic; 
using QuantConnect.Securities;  
using QuantConnect.Models;   

namespace QuantConnect 
{   
    // Name your algorithm class anything, as long as it inherits QCAlgorithm
    public class MultiplePortfolios : QCAlgorithm
    {
        private List<VirtualPortfolio> _parallelPortfolios;
        
        //Initialize the data and resolution you require for your strategy:
        public override void Initialize()
        {
            SetStartDate(2013, 1, 1);         
            SetEndDate(DateTime.Now.Date.AddDays(-1)); 
            SetCash(25000);
            AddSecurity(SecurityType.Equity, "MSFT", Resolution.Minute);
            
            _parallelPortfolios = new List<VirtualPortfolio>();
            _parallelPortfolios.Add(new VirtualPortfolio());
            _parallelPortfolios.Add(new VirtualPortfolio());
        }

        //Data Event Handler: New data arrives here. "TradeBars" type is a dictionary of strings so you can access it by symbol.
        public void OnData(TradeBars data) 
        {   
            if (!Portfolio.Invested) 
            {
                Order("MSFT", (int)Math.Floor(Portfolio.Cash / data["MSFT"].Close) );
                Debug("Debug Purchased MSFT");
            }
            
            foreach(var portfolio in _parallelPortfolios)
            {
                portfolio.UpdatePrices(data);
            }
        }
    }
    
    public class VirtualPortfolio
    {
        Dictionary<string, VirtualAsset> Assets = new Dictionary<string, VirtualAsset>();
        
        public decimal TotalPortfolioValue {
            get { return (from va in Assets.Values select va.Value).Sum(); }
        }
        
        public void UpdatePrices(TradeBars bars)
        {
            foreach(var bar in bars.Values)
            {
                if (Assets.ContainsKey(bar.Symbol))
                {
                    Assets[bar.Symbol].UpdatePrice(bar.Price);
                }
            }
        }
    }
    
    public class VirtualAsset
    {
        public string Symbol;
        public decimal Quantity;
        public decimal Price;
        public decimal Value { get { return Quantity * Price; } }
        public VirtualAsset(string symbol) { Symbol = symbol; }
        public void UpdatePrice(decimal price) { Price = price; }
    }
}