Overall Statistics |
Total Orders 127 Average Win 0.91% Average Loss -0.90% Compounding Annual Return -2.626% Drawdown 11.800% Expectancy 0.019 Net Profit -1.102% Sharpe Ratio 0.02 Sortino Ratio 0.026 Probabilistic Sharpe Ratio 22.738% Loss Rate 49% Win Rate 51% Profit-Loss Ratio 1.01 Alpha -0.229 Beta 1.035 Annual Standard Deviation 0.227 Annual Variance 0.051 Information Ratio -1.156 Tracking Error 0.191 Treynor Ratio 0.004 Total Fees $1006.92 Estimated Strategy Capacity $21000000.00 Lowest Capacity Asset AAPL R735QTJ8XC9X Portfolio Turnover 165.92% |
#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 using QuantConnect.DataSource; namespace QuantConnect.Algorithm.CSharp.AltData { public class TiingoNewsDataAlgorithm : QCAlgorithm { private Symbol _aapl; private Symbol _tiingoSymbol; private int _currentHoldings = 0; private int _targetHoldings = 0; private Dictionary<string, int> _wordScores = new Dictionary<string, int>(){ {"good", 1}, {"great", 1}, {"best", 1}, {"growth", 1}, {"bad", -1}, {"terrible", -1}, {"worst", -1}, {"loss", -1} }; public override void Initialize() { SetStartDate(2021, 1, 1); SetEndDate(2021, 6, 1); SetCash(100000); // Requesting data _aapl = AddEquity("AAPL", Resolution.Minute).Symbol; _tiingoSymbol = AddData<TiingoNews>(_aapl).Symbol; // Historical data var history = History<TiingoNews>(_tiingoSymbol, 14, Resolution.Daily); Debug($"We got {history.Count()} items from our history request"); } public override void OnData(Slice slice) { if (slice.ContainsKey(_tiingoSymbol)) { // Assign a sentiment score to the news article var titleWords = slice[_tiingoSymbol].Description.ToLower(); var score = 0; foreach (KeyValuePair<string, int> entry in _wordScores) { if (titleWords.Contains(entry.Key)) { score += entry.Value; } } if (score > 0) { _targetHoldings = 1; } else if (score < 0) { _targetHoldings = -1; } } // Buy or short sell if the sentiment has changed from our current holdings if (slice.ContainsKey(_aapl) && _currentHoldings != _targetHoldings) { SetHoldings(_aapl, _targetHoldings); _currentHoldings = _targetHoldings; } } } }