Lean  $LEAN_TAG$
ITickGenerator.cs
1 /*
2  * QUANTCONNECT.COM - Democratizing Finance, Empowering Individuals.
3  * Lean Algorithmic Trading Engine v2.0. Copyright 2014 QuantConnect Corporation.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14 */
15 
16 using System;
18 using System.Collections.Generic;
19 
21 {
22  /// <summary>
23  /// Describes main methods for <see cref="TickGenerator"/>
24  /// </summary>
25  public interface ITickGenerator
26  {
27  /// <summary>
28  /// Generates and enumerates data points for current symbol
29  /// </summary>
30  IEnumerable<Tick> GenerateTicks();
31 
32  /// <summary>
33  /// Generates a random <see cref="Tick"/> that is at most the specified <paramref name="maximumPercentDeviation"/> away from the
34  /// previous price and is of the requested <paramref name="tickType"/>
35  /// </summary>
36  /// <param name="dateTime">The time of the generated tick</param>
37  /// <param name="tickType">The type of <see cref="Tick"/> to be generated</param>
38  /// <param name="maximumPercentDeviation">The maximum percentage to deviate from the
39  /// previous price, for example, 1 would indicate a maximum of 1% deviation from the
40  /// previous price. For a previous price of 100, this would yield a price between 99 and 101 inclusive</param>
41  /// <returns>A random <see cref="Tick"/> value that is within the specified <paramref name="maximumPercentDeviation"/>
42  /// from the previous price</returns>
43  Tick NextTick(
44  DateTime dateTime,
45  TickType tickType,
46  decimal maximumPercentDeviation
47  );
48 
49  /// <summary>
50  /// Generates a random <see cref="DateTime"/> suitable for use as a tick's emit time.
51  /// If the density provided is <see cref="DataDensity.Dense"/>, then at least one tick will be generated per <paramref name="resolution"/> step.
52  /// If the density provided is <see cref="DataDensity.Sparse"/>, then at least one tick will be generated every 5 <paramref name="resolution"/> steps.
53  /// if the density provided is <see cref="DataDensity.VerySparse"/>, then at least one tick will be generated every 50 <paramref name="resolution"/> steps.
54  /// Times returned are guaranteed to be within market hours for the specified Symbol
55  /// </summary>
56  /// <param name="previous">The previous tick time</param>
57  /// <param name="resolution">The requested resolution of data</param>
58  /// <param name="density">The requested data density</param>
59  /// <returns>A new <see cref="DateTime"/> that is after <paramref name="previous"/> according to the specified <paramref name="resolution"/>
60  /// and <paramref name="density"/> specified</returns>
61  DateTime NextTickTime(DateTime previous, Resolution resolution, DataDensity density);
62  }
63 }