public IEnumerable<SpotPriceDto> Sequence()
{
var previousMid = _initial;
while (true)
{
var pow = (decimal) Math.Pow(10, _precision);
var newMid = previousMid + Random.Next(-5, 6)/pow;
// check that the new Mid does not drift too far from sampleRate (3%)
if (Math.Abs(newMid - _initial)/_initial > .03m)
newMid = _initial;
previousMid = newMid;
yield return new SpotPriceDto
{
Symbol = Symbol,
ValueDate = DateTime.UtcNow.AddDays(2).Date.ToWeekday(),
Mid = newMid,
Ask = newMid + _halfSpread/pow,
Bid = newMid - _halfSpread/pow,
CreationTimestamp = Stopwatch.GetTimestamp()
};
}
}
}