public void ParseFromRawDataUnexpectedEventTypes() { var realRawIntentionLine = "\"BI12345\"\t\"Some new event\"\t2020-07-27\t2009-11-11\t\"US1234567890\"\t\"\"\t12345\t\"https://smartinsidercompanypage.com\"\t\"Consumer Staples\"\t" + "\"Personal Care, Drug and Grocery Stores\"\t\"Personal Care, Drug and Grocery Stores\"\t\"Personal Products\"\t12345678\t\"Some Company Corp\"\t\"Some-Comapny C\"\t" + "\"\"\t\"\"\t\"\"\t\"\"\t\"Com\"\t\"US\"\t\"SCC\"\t\"\"\t\"\"\t\"\"\t\"\"\t\"\"\t\"\"\t\"\"\t\t\t-999\t\"Some unexpected event.\"\t\"\"\t\"\"\t\"\"\t\"\"\t\"\"\t\"\"\t\"" + "\"\t2020-07-27\t\"\"\t\"\"\t\"\"\t2020-07-27 13:57:37\t\"US\"\t\"https://smartinsiderdatapage.com\"\t\"UnexpectedEvent\"\t\"UnexpectedIssuer\"\t\"UnexpectedReported\"\t\"\"\t\"\"\t\t" + "\"\"\t\t\t\"\"\t\t\t\"\""; var tsv = realRawIntentionLine.Split('\t') .Take(60) .Select(x => x.Replace("\"", "")) .ToList(); // Remove in descending order to maintain index order // while we delete lower indexed values tsv.RemoveAt(46); // ShowOriginal tsv.RemoveAt(36); // PreviousClosePrice tsv.RemoveAt(14); // ShortCompanyName tsv.RemoveAt(7); // CompanyPageURL var filteredRawIntentionLine = string.Join("\t", tsv); var intention = new SmartInsiderIntention(); Assert.DoesNotThrow(() => intention.FromRawData(filteredRawIntentionLine)); Assert.IsTrue(intention.EventType.HasValue); Assert.AreEqual(SmartInsiderEventType.NotSpecified, intention.EventType); Assert.AreEqual(SmartInsiderExecution.Error, intention.Execution); Assert.AreEqual(SmartInsiderExecutionEntity.Error, intention.ExecutionEntity); Assert.AreEqual(SmartInsiderExecutionHolding.Error, intention.ExecutionHolding); }
public void ErrorGetsMappedToSatisfyStockVesting() { var intentionLine = "BIXYZ Downwards Revision 20190101 20190101 USXYZ 1 Some Random Industry US Off Market Agreement Issuer Missing Lookup Formula for BuybackHoldingTypeId 10.00 "; var transactionLine = "BIXYZ Downwards Revision 20190101 20190101 USXYZ 1 Some Random Industry Off Market Agreement Issuer Missing Lookup Formula for BuybackHoldingTypeId 10.00 "; var intention = new SmartInsiderIntention(intentionLine); var transaction = new SmartInsiderTransaction(transactionLine); Assert.IsTrue(intention.ExecutionHolding.HasValue); Assert.IsTrue(transaction.ExecutionHolding.HasValue); Assert.AreEqual(intention.ExecutionHolding, SmartInsiderExecutionHolding.SatisfyStockVesting); Assert.AreEqual(transaction.ExecutionHolding, SmartInsiderExecutionHolding.SatisfyStockVesting); }
/// <summary> /// Initialise the data and resolution required, as well as the cash and start-end dates for your algorithm. All algorithms must initialized. /// </summary> public override void Initialize() { SetStartDate(2010, 1, 1); SetEndDate(2019, 1, 1); var tickers = new List <string> { "AAPL", "AMZN", "MSFT", "IBM", "FB", "QQQ", "IWM", "BAC", "BNO", "AIG", "UW", "WM" }; _securities = new List <Security>(); _customSymbols = new List <Symbol>(); foreach (var ticker in tickers) { var equity = AddEquity(ticker, Resolution.Hour); _securities.Add(equity); _customSymbols.Add( AddData <SmartInsiderIntention>(equity.Symbol, Resolution.Daily).Symbol); _customSymbols.Add( AddData <SmartInsiderTransaction>(equity.Symbol, Resolution.Daily).Symbol); } Schedule.On(DateRules.EveryDay(), TimeRules.At(16, 0), () => { foreach (var slice in History(_customSymbols, TimeSpan.FromDays(5))) { _historySymbolCount += slice.Count; } foreach (var security in _securities) { SmartInsiderIntention intention = security.Data.Get <SmartInsiderIntention>(); SmartInsiderTransaction transaction = security.Data.Get <SmartInsiderTransaction>(); if (!security.HoldStock && intention != null && transaction != null) { SetHoldings(security.Symbol, 1d / _securities.Count); } } }); }
/// <summary> /// Insider intention data will be provided to us here /// </summary> /// <param name="data">Intention data</param> public void OnData(SmartInsiderIntention data) { var hasOpenOrders = Transactions.GetOpenOrders().Any(); if (!Portfolio.Invested && !hasOpenOrders) { if (data.Percentage > 0.0001m) { Log($"Buying {_symbol.Value} due to intention to purchase stock"); SetHoldings(_symbol, 0.50m); } } else if (Portfolio.Invested && !hasOpenOrders) { if (data.Percentage < 0.00m) { Log($"Liquidating {_symbol.Value}"); Liquidate(_symbol); } } }
public void ToLineDoesNotOutputRawNullValues() { var intentionLine = "20200101 01:02:03 BIXYZ 20190101 20190101 USXYZ 1 Some Random Industry US "; var transactionLine = "20200101 01:02:03 BIXYZ 20190101 20190101 USXYZ 1 Some Random Industry "; var intention = new SmartInsiderIntention(intentionLine); var transaction = new SmartInsiderTransaction(transactionLine); Assert.IsNull(intention.EventType); Assert.IsNull(intention.Execution); Assert.IsNull(intention.ExecutionEntity); Assert.IsNull(intention.ExecutionHolding); Assert.IsNull(transaction.EventType); Assert.IsNull(transaction.Execution); Assert.IsNull(transaction.ExecutionEntity); Assert.IsNull(transaction.ExecutionHolding); var intentionLineSerialized = intention.ToLine().Split('\t'); var transactionLineSerialized = transaction.ToLine().Split('\t'); Assert.AreNotEqual(intentionLineSerialized[2], "null"); Assert.AreNotEqual(intentionLineSerialized[26], "null"); Assert.AreNotEqual(intentionLineSerialized[27], "null"); Assert.AreNotEqual(intentionLineSerialized[28], "null"); Assert.AreNotEqual(transactionLineSerialized[2], "null"); Assert.AreNotEqual(transactionLineSerialized[27], "null"); Assert.AreNotEqual(transactionLineSerialized[28], "null"); Assert.AreNotEqual(transactionLineSerialized[29], "null"); Assert.IsTrue(string.IsNullOrWhiteSpace(intentionLineSerialized[2])); Assert.IsTrue(string.IsNullOrWhiteSpace(intentionLineSerialized[26])); Assert.IsTrue(string.IsNullOrWhiteSpace(intentionLineSerialized[27])); Assert.IsTrue(string.IsNullOrWhiteSpace(intentionLineSerialized[28])); Assert.IsTrue(string.IsNullOrWhiteSpace(transactionLineSerialized[2])); Assert.IsTrue(string.IsNullOrWhiteSpace(transactionLineSerialized[27])); Assert.IsTrue(string.IsNullOrWhiteSpace(transactionLineSerialized[28])); Assert.IsTrue(string.IsNullOrWhiteSpace(transactionLineSerialized[29])); }
public void SerializeRoundTripSmartInsiderIntention() { var settings = new JsonSerializerSettings { TypeNameHandling = TypeNameHandling.All }; var time = new DateTime(2020, 3, 19, 10, 0, 0); var underlyingSymbol = Symbols.AAPL; var symbol = Symbol.CreateBase(typeof(SmartInsiderIntention), underlyingSymbol, QuantConnect.Market.USA); var item = new SmartInsiderIntention { Symbol = symbol, LastUpdate = time, Time = time, TransactionID = "123", EventType = SmartInsiderEventType.Intention, Execution = SmartInsiderExecution.Market, ExecutionEntity = SmartInsiderExecutionEntity.Issuer, ExecutionHolding = SmartInsiderExecutionHolding.NotReported, Amount = null }; var serialized = JsonConvert.SerializeObject(item, settings); var deserialized = JsonConvert.DeserializeObject <SmartInsiderIntention>(serialized, settings); Assert.AreEqual(symbol, deserialized.Symbol); Assert.AreEqual("123", deserialized.TransactionID); Assert.AreEqual(SmartInsiderEventType.Intention, deserialized.EventType); Assert.AreEqual(SmartInsiderExecution.Market, deserialized.Execution); Assert.AreEqual(SmartInsiderExecutionEntity.Issuer, deserialized.ExecutionEntity); Assert.AreEqual(SmartInsiderExecutionHolding.NotReported, deserialized.ExecutionHolding); Assert.AreEqual(null, deserialized.Amount); Assert.AreEqual(time, deserialized.LastUpdate); Assert.AreEqual(time, deserialized.Time); Assert.AreEqual(time, deserialized.EndTime); }