mirror of
https://github.com/StockSharp/StockSharp.git
synced 2026-12-04 00:21:31 +00:00
A run whose market data was all refused for lack of history waited for its first subscription forever. It ends now when it starts with all the market data asked for refused. Whether any is left is decided when the run starts, never at a refusal: a strategy asks for one series after another, so the refusal of a pair's first leg comes before its second is asked for, and stopping there ended a run that had the second leg's history. A run with nothing asked for yet keeps waiting, as a host may start the strategy after the run, as the Studio runner does. Such a run ends with an error rather than as a finished one: Connector. Error says the market data is missing, StopError keeps it for a host that looks once the run has stopped, and the progress does not reach 100. A run stopped on a failed subscription (StopOnSubscriptionError) ends the same way. A strategy that asks for no market data, or whose market data was all refused, is stopped with that error by StrategyHelper.StopIfNoMarketDataAsync once it has started, which ExecAsync and the optimizer use: ExecAsync reported such a run as completed or waited for it forever, and the optimizer's check ran before the connector was connected and left the iteration waiting. Partial history, which the tests never fed a run, had more of the same: - a refused subscription kept the strategy offline for the whole run, so a run that went on with the data it had sent no order. Only a subscription refused before it got going is left out; one that fails after it went online still takes the strategy offline, its data gone; - ticks only a generator made never started the replay; - a series stored only outside the run's dates stood in for the run's own data, so five-minute candles were not built from the run's one-minute candles and none arrived; - a subscription added during the run made the replay send again what it had already sent at that moment, and with the cache of days it got nothing until the next day, the cache knowing a day by its date alone; - history that ended before the run's stop left its progress at a fifth. A run that runs out of history reports the whole way now; one disconnected halfway still reports where it stopped, which the optimizer goes by to stop the strategy of an iteration it cancels; - an instrument whose history ended before the run's kept its last bid and ask, so orders on it filled in any volume at a day-old price. Once its last bar is handed over its market closes: a market order finds no price, a limit waits, a position keeps the value of the quotes the market closed with, and more history opens the market again; - a day without history moved the strategy's clock twice, just after midnight, and the clock reached the stop only after the run had stopped. The replay walks such a day at the pace of the time-frame candles and generators it still replays, the emulator hands the clock on with every bar it releases, and the run's last moment is its stop date, so timers and time rules fire through the gaps. Ticks, quotes and the order log keep no pace, and the days after every history has ended are marked only where they begin, so a long stop after the history costs no more than it did.
45 lines
1.0 KiB
C#
45 lines
1.0 KiB
C#
namespace StockSharp.Algo.Testing;
|
|
|
|
/// <summary>
|
|
/// The replay holds no more history of a security before the run's stop, so the emulator closes its market.
|
|
/// </summary>
|
|
public class HistoryEndMessage : Message, ISecurityIdMessage, IServerTimeMessage
|
|
{
|
|
/// <summary>
|
|
/// Initializes a new instance of the <see cref="HistoryEndMessage"/>.
|
|
/// </summary>
|
|
public HistoryEndMessage()
|
|
: base(HistoryMessageTypes.HistoryEnd)
|
|
{
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public SecurityId SecurityId { get; set; }
|
|
|
|
/// <summary>
|
|
/// The moment of the replay at which the history ran out.
|
|
/// </summary>
|
|
public DateTime ServerTime { get; set; }
|
|
|
|
/// <summary>
|
|
/// Create a copy of <see cref="HistoryEndMessage"/>.
|
|
/// </summary>
|
|
/// <returns>Copy.</returns>
|
|
public override Message Clone()
|
|
{
|
|
var clone = new HistoryEndMessage
|
|
{
|
|
SecurityId = SecurityId,
|
|
ServerTime = ServerTime,
|
|
};
|
|
|
|
CopyTo(clone);
|
|
|
|
return clone;
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public override string ToString()
|
|
=> base.ToString() + $",Sec={SecurityId}";
|
|
}
|