Upcoming Splits

Modified on 2018/05/09 11:39 by Eugene — Categorized as: Community Components


public UpcomingSplit

public string Payable; public DateTime ExDate; public string Company; public string Symbol; public string Ratio; public string AnnouncementDate;

public UpcomingSplitDownloader

public static void UpcomingSplitDownloader.DeSerialize()

public List<UpcomingSplit> Splits public UpcomingSplit FindSymbol(string symbol) public bool IsStockSplit(string symbol, DateTime dt) public double SplitFactor(string symbol, DateTime dt)

Parameter Description

symbolA valid U.S. stock symbol to look for the corresponding UpcomingSplit object
dtDate used to determine if a stock splits on given date


Builds a database of U.S. stocks that are about to split in the upcoming month using Yahoo as the primary data source or Briefing and Nasdaq as backup data sources (should Yahoo fail for whatever reason). Call DeSerialize to download and to cache the data in an XML file in Wealth-Lab's AppData directory. On the first call, there's a slight delay while the data is being downloaded from the web service. Subsequent calls are instant provided that the cache exists. If the stored data is older than 1 day, on next call it will be automatically refreshed.

An instance of the UpcomingSplit class contains the following properties for U.S. stocks: payable, ex-date, company, symbol, ratio and announcement date. Before calling the FindSymbol method with a stock symbol to return an instance of UpcomingSplit, call DeSerialize to avoid delays caused by refreshing the data from the internet.

To determine if stock splits on given date, call IsStockSplit. To determine the split factor for a given stock on given date, use SplitFactor.

Finally, the complete classification of all stocks about to split is accessible in the Splits property.


using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using WealthLab;
using Community.Components; /*** Requires installation of Community.Components Extension from www.wealth-lab.com > Extensions ***/

namespace WealthLab.Strategies { public class MyStrategy : WealthScript { protected override void Execute() { ClearDebug(); // Attempts to read splits from cache. Will download and rebuild automatically on absence or obsoleteness (every day) UpcomingSplitDownloader c = UpcomingSplitDownloader.DeSerialize();

DrawLabel(PricePane, "Upcoming splits: " + c.Splits.Count.ToString() + Environment.NewLine); ClearDebug(); PrintDebug( "Upcoming splits: " + c.Splits.Count + "\n" ); foreach( var s in c.Splits ) { PrintDebug( s ); } bool split = c.IsStockSplit( Bars.Symbol, Bars.Date[Bars.Count-1] ); DrawLabel(PricePane, "Current symbol " + (split ? "splits today!" : "doesn't split today") + Environment.NewLine); //TEST: Get ratio of AAPL 2014/06/09 split, if still present in cache double ratio = c.SplitFactor( "AAPL", new DateTime(2014,06,09) ); DrawLabel(PricePane, "AAPL 2014/06/09 split factor: " + Bars.FormatValue(ratio).ToString() + Environment.NewLine); } } }