Overall Statistics |
Total Trades 3 Average Win 0% Average Loss -16.61% Compounding Annual Return 10.981% Drawdown 22.800% Expectancy -1 Net Profit 3.542% Sharpe Ratio 0.498 Probabilistic Sharpe Ratio 36.739% Loss Rate 100% Win Rate 0% Profit-Loss Ratio 0 Alpha 0.113 Beta 0.071 Annual Standard Deviation 0.247 Annual Variance 0.061 Information Ratio -0.05 Tracking Error 0.293 Treynor Ratio 1.729 Total Fees $7.50 |
namespace QuantConnect { public partial class BootCampTask : QCAlgorithm { OrderEvent lastOrderEvent; public override void Initialize() { SetStartDate(2018, 12, 1); SetEndDate(2019, 4, 1); SetCash(100000); var spy = AddSecurity(SecurityType.Equity, "SPY", Resolution.Daily); spy.SetDataNormalizationMode(DataNormalizationMode.Raw); } public override void OnData(Slice slice) { if (!Portfolio.Invested) { MarketOrder("SPY", 500); StopMarketOrder("SPY", -500, 0.90m * Securities["SPY"].Close); } } public override void OnOrderEvent(OrderEvent orderEvent) { //Some debugging to assist you. Debug(orderEvent.ToString()); //1. Write code to only act on fills if(orderEvent.Status!=OrderStatus.Filled) { return; } //2. Use debug to print the order id, and save the order event to lastOrderEvent lastOrderEvent = orderEvent; } } }