19 using System.Collections.Generic;
35 private readonly
TickType[] _tickTypes;
45 _tickTypes = tickTypes;
62 var current = _settings.Start;
67 if (_random.NextBool(_settings.HasIpoPercentage))
69 current = _random.NextDate(_settings.Start, _settings.End,
null);
70 Log.
Trace($
"\tSymbol: {Symbol} has delayed IPO at date {current:yyyy MMMM dd}");
74 var deviation = GetMaximumDeviation(_settings.Resolution);
75 while (current <= _settings.End)
78 var next =
NextTickTime(current, _settings.Resolution, _settings.DataDensity);
81 if (next > _settings.End)
86 if (_tickTypes.Contains(
TickType.OpenInterest))
88 if (next.Date != current.Date)
92 yield
return openInterest;
98 if (_tickTypes.Contains(
TickType.Trade) &&
103 var tradeChancePercent = 100 / (1 + _settings.QuoteTradeRatio);
106 _random.NextBool(tradeChancePercent)
111 else if (_tickTypes.Contains(
TickType.Trade))
116 else if (_tickTypes.Contains(
TickType.Quote))
121 if (nextTick !=
null && _priceGenerator.WarmedUp)
123 yield
return nextTick;
144 var next = _priceGenerator.NextValue(maximumPercentDeviation, dateTime);
159 tick.Quantity = _random.NextInt(1, 1500);
164 if (bid > tick.Value)
166 bid = tick.Value - (bid - tick.Value);
169 if (ask < tick.Value)
171 ask = tick.Value + (tick.Value - ask);
175 tick.BidSize = _random.NextInt(1, 1500);
177 tick.AskSize = _random.NextInt(1, 1500);
181 throw new ArgumentOutOfRangeException(nameof(tickType), tickType,
null);
224 var increment = resolution.ToTimeSpan();
225 if (increment == TimeSpan.Zero)
227 increment = TimeSpan.FromMilliseconds(500);
234 steps = 0.5 * _random.NextDouble();
238 steps = 5 * _random.NextDouble();
242 steps = 50 * _random.NextDouble();
246 throw new ArgumentOutOfRangeException(nameof(density), density,
null);
249 var delta = TimeSpan.FromTicks((
long)(steps * increment.Ticks));
250 var tickTime = previous.Add(delta);
251 if (tickTime == previous)
253 tickTime = tickTime.Add(increment);
256 var barStart = tickTime.Subtract(increment);
258 if (!marketHours.IsDateOpen(tickTime) || !marketHours.IsOpen(barStart, tickTime,
false))
268 return NextTickTime(nextMarketOpen, resolution - 1, density);
274 private static decimal GetMaximumDeviation(
Resolution resolution)
276 var incr = ((int)resolution) + 0.15m;
277 var deviation = incr * incr * 0.1m;