Overall Statistics |
Total Trades 627 Average Win 0.02% Average Loss -0.10% Annual Return -10.088% Drawdown 25.700% Expectancy -0.292 Net Profit -20.183% Sharpe Ratio -0.857 Loss Rate 43% Win Rate 57% Profit-Loss Ratio 0.24 Alpha -0.053 Beta -0.368 Annual Standard Deviation 0.122 Annual Variance 0.015 Information Ratio -0.838 Tracking Error 0.293 Treynor Ratio 0.285 |
using System; using System.Collections; using System.Collections.Generic; using QuantConnect.Securities; using QuantConnect.Models; namespace QuantConnect { /*************************************************************************** * SECURITY HOLDINGS CLASS SecurityHolding class holds an individual Security fee, quantity and average price information. It is the primary storage for tracking trades profit and loss. You can access it through the public SecurityManager Collection Securities or the public adaptor Portfolio. THIS IS AN EXAMPLE ALGORITHM FROM THE QUANTCONNECT'S API DOCUMENTATION ***************************************************************************/ public class SecurityHoldingExample : QCAlgorithm { string[] securities = {"IBM", "AOL", "MSFT", "AAPL"}; public override void Initialize() { foreach(var security in securities) { AddSecurity(SecurityType.Equity, security, Resolution.Minute); } SetCash(40000); SetStartDate(2010, 3, 3); SetEndDate(2012, 3, 3); } //Example of Holdings Class Usage: public void OnData(TradeBars securityData) { try { //Build a portfolio which 150 stocks of each equity if (!Portfolio.HoldStock) { foreach (var security in securities) { Order(security, 150); } } //Accessing with Public Securities Object, using Holdings property: foreach(string symbol in Securities.Keys) { if (Securities[symbol].Holdings.UnrealizedProfit > 0) { Order(symbol, -Securities[symbol].Holdings.Quantity); } } //Using Portfolio Object: If we have IBM stocks & an unrealized profit: if (Portfolio["IBM"].UnrealizedProfit > 0 && Portfolio["IBM"].HoldStock) { Order("IBM", -Securities["IBM"].Holdings.Quantity); } } catch (Exception err) { Error("OnData Err: " + err.Message); } } } }