Skip to content

Instantly share code, notes, and snippets.

@Jay-Jay-D
Created October 15, 2016 13:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Jay-Jay-D/7d45fa642a458a4eaabe40f4558e8441 to your computer and use it in GitHub Desktop.
Save Jay-Jay-D/7d45fa642a458a4eaabe40f4558e8441 to your computer and use it in GitHub Desktop.
/*
* QUANTCONNECT.COM - Democratizing Finance, Empowering Individuals.
* Lean Algorithmic Trading Engine v2.0. Copyright 2014 QuantConnect Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
using QuantConnect.Data;
using QuantConnect.Data.Market;
using QuantConnect.Indicators;
using System;
using System.Collections.Generic;
using System.Linq;
namespace QuantConnect.Algorithm.CSharp
{
/// <summary>
/// Basic template algorithm simply initializes the date range and cash
/// </summary>
public class IndicatorsReflector : QCAlgorithm
{
#region Public Methods
/// <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(2013, 10, 07); //Set Start Date
SetEndDate(2013, 10, 11); //Set End Date
SetCash(100000); //Set Strategy Cash
// Find more symbols here: http://quantconnect.com/data
AddEquity("SPY", Resolution.Minute);
var _indicators = typeof(Indicator).Assembly.GetTypes()
.Where(t => t.BaseType.Name != "CandlestickPattern" && !t.Name.StartsWith("<"))
.OrderBy(t => t.Name)
.ToList();
var baseTypeList = new List<string>();
Console.Title = "Indicators Reflector";
bool condition;
foreach (var indicator in _indicators)
{
//BaseType.GenericTypeArguments.First().Name
object instantiatedIndicator;
try
{
instantiatedIndicator = Activator.CreateInstance(indicator, new object[] { 10 });
}
catch (Exception e)
{
Console.ForegroundColor = ConsoleColor.Magenta;
Console.WriteLine(e.Message);
Console.ResetColor();
continue;
}
Console.Write(string.Format("Indicator {0} is IIndicator<IndicatorDataPoint>: ", indicator.Name));
condition = instantiatedIndicator is IIndicator<IndicatorDataPoint>;
Console.ForegroundColor = condition ? ConsoleColor.Green : ConsoleColor.Red;
Console.WriteLine(condition);
Console.ResetColor();
Console.Write(string.Format("Indicator {0} is IIndicator<TradeBar>: ", indicator.Name));
condition = instantiatedIndicator is IIndicator<TradeBar>;
Console.ForegroundColor = condition ? ConsoleColor.Green : ConsoleColor.Red;
Console.WriteLine(condition);
Console.ResetColor();
Console.Write(string.Format("Indicator {0} is IIndicator<BaseData>: ", indicator.Name));
condition = instantiatedIndicator is IIndicator<BaseData>;
Console.ForegroundColor = condition ? ConsoleColor.Green : ConsoleColor.Red;
Console.WriteLine(condition);
Console.ResetColor();
Console.Write(string.Format("Indicator {0} is IIndicator<IBaseData>: ", indicator.Name));
condition = instantiatedIndicator is IIndicator<IBaseData>;
Console.ForegroundColor = condition ? ConsoleColor.Green : ConsoleColor.Red;
Console.WriteLine(condition);
Console.ResetColor();
Console.Write(string.Format("Indicator {0} is IndicatorBase<BaseData>: ", indicator.Name));
condition = instantiatedIndicator is IndicatorBase<BaseData>;
Console.ForegroundColor = condition ? ConsoleColor.Green : ConsoleColor.Red;
Console.WriteLine(condition);
Console.ResetColor();
Console.Write(string.Format("Indicator {0} is IndicatorBase<IndicatorDataPoint>: ", indicator.Name));
condition = instantiatedIndicator is IndicatorBase<IndicatorDataPoint>;
Console.ForegroundColor = condition ? ConsoleColor.Green : ConsoleColor.Red;
Console.WriteLine(condition);
Console.ResetColor();
Console.Write(string.Format("Indicator {0} is IndicatorBase<TradeBar>: ", indicator.Name));
condition = instantiatedIndicator is IndicatorBase<TradeBar>;
Console.ForegroundColor = condition ? ConsoleColor.Green : ConsoleColor.Red;
Console.WriteLine(condition);
Console.ResetColor();
}
}
/// <summary>
/// OnData event is the primary entry point for your algorithm. Each new data point will be pumped in here.
/// </summary>
/// <param name="data">Slice object keyed by symbol containing the stock data</param>
public override void OnData(Slice data)
{
}
#endregion Public Methods
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment