Overall Statistics
Total Orders
411
Average Win
0.76%
Average Loss
-0.35%
Compounding Annual Return
-18.759%
Drawdown
77.300%
Expectancy
-0.843
Start Equity
100000
End Equity
29151.14
Net Profit
-70.849%
Sharpe Ratio
-0.771
Sortino Ratio
-0.915
Probabilistic Sharpe Ratio
0.000%
Loss Rate
95%
Win Rate
5%
Profit-Loss Ratio
2.14
Alpha
-0.039
Beta
-0.952
Annual Standard Deviation
0.187
Annual Variance
0.035
Information Ratio
-0.753
Tracking Error
0.338
Treynor Ratio
0.152
Total Fees
$423.69
Estimated Strategy Capacity
$690000.00
Lowest Capacity Asset
XLI RGRPZX100F39
Portfolio Turnover
0.56%
#region imports
    using System;
    using System.Collections;
    using System.Collections.Generic;
    using System.Linq;
    using System.Globalization;
    using System.Drawing;
    using QuantConnect;
    using System.Text.RegularExpressions;
    using QuantConnect.Algorithm.Framework;
    using QuantConnect.Algorithm.Framework.Selection;
    using QuantConnect.Algorithm.Framework.Alphas;
    using QuantConnect.Algorithm.Framework.Portfolio;
    using QuantConnect.Algorithm.Framework.Execution;
    using QuantConnect.Algorithm.Framework.Risk;
    using QuantConnect.Algorithm.Selection;
    using QuantConnect.Parameters;
    using QuantConnect.Benchmarks;
    using QuantConnect.Brokerages;
    using QuantConnect.Util;
    using QuantConnect.Interfaces;
    using QuantConnect.Algorithm;
    using QuantConnect.Indicators;
    using QuantConnect.Data;
    using QuantConnect.Data.Consolidators;
    using QuantConnect.Data.Custom;
    using QuantConnect.DataSource;
    using QuantConnect.Data.Fundamental;
    using QuantConnect.Data.Market;
    using QuantConnect.Data.UniverseSelection;
    using QuantConnect.Notifications;
    using QuantConnect.Orders;
    using QuantConnect.Orders.Fees;
    using QuantConnect.Orders.Fills;
    using QuantConnect.Orders.Slippage;
    using QuantConnect.Scheduling;
    using QuantConnect.Securities;
    using QuantConnect.Securities.Equity;
    using QuantConnect.Securities.Future;
    using QuantConnect.Securities.Option;
    using QuantConnect.Securities.Forex;
    using QuantConnect.Securities.Crypto;   
    using QuantConnect.Securities.Interfaces;
    using QuantConnect.Storage;
    using QCAlgorithmFramework = QuantConnect.Algorithm.QCAlgorithm;
    using QCAlgorithmFrameworkBridge = QuantConnect.Algorithm.QCAlgorithm;
#endregion

public class EODHDEconomicEventsAlgorithm : QCAlgorithm
{
    private Symbol _equitySymbol, _datasetSymbol;

    public override void Initialize()
    {
        SetStartDate(2019, 1, 1);
        // Use industrial sector ETF as a vehicle to trade.
        _equitySymbol = AddEquity("XLI").Symbol;
        // Request US PMI economic event data to generate trade signals.
        var ticker = EODHD.Events.UnitedStates.MarkitManufacturingPurchasingManagersIndex;
        _datasetSymbol = AddData<EODHDEconomicEvents>(ticker).Symbol;
    }

    public override void OnData(Slice slice)
    {
        // Trade based on the updated economic events.
        if (slice.Get<EODHDEconomicEvents>().TryGetValue(_datasetSymbol, out var economicEvents))
        {
            var economicEvent = economicEvents.FirstOrDefault() as EODHDEconomicEvent;         
            // Use the Manufacturing Index to generate trade signals on manufacturing industry vehicles.
            // Make sure previous and estimate are available to estimate the direction of the industry.
            if (economicEvent.Previous.HasValue && economicEvent.Estimate.HasValue)
            {
                //If the estimated PMI is higher than the previous PMI, the manufacturing ETF price is expected to rise.
                if (economicEvent.Previous.Value > economicEvent.Estimate.Value)
                {
                    SetHoldings(_equitySymbol, 1);
                }
                // Otherwise, it is expected manufacturing ETF price will drop.
                else
                {
                    SetHoldings(_equitySymbol, -1);
                }
            }
        }
    }
}