You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Если для стратегии флаг WaitAllTrades = true, и если до момента вызова метода Stop не пришло событие собственных сделок, то стратегия полностью не останавливается - зависает в состоянии Stopping.
Пример кода:
public class SimpleStrategy : Strategy
{
public SimpleStrategy()
{
WaitAllTrades = true;
}
protected override void OnStarted()
{
if (!Connector.RegisteredSecurities.Contains(Security))
Connector.RegisterSecurity(Security);
Order order = null;
this.WhenNewMyTrades().Do(trades =>
{
this.AddInfoLog(string.Format("Моя сделка. {0}", trades.First()));
}).Apply(this);
this.WhenPositionChanged().Do(position =>
{
this.AddInfoLog(string.Format("Изменение позиции. {0}, Позиция {1}", position, this.Position));
}).Apply();
while (order == null)
{
if (Security.BestAsk != null)
{
var price = Security.BestAsk.Price;
order = this.BuyAtLimit(price);
order.WhenMatched(Connector).Do(o =>
{
this.AddInfoLog(string.Format("Заявка полностью исполнена. Позиция: {0}", Position));
this.Stop();
}).Apply(this);
this.RegisterOrder(order);
}
System.Threading.Thread.Sleep(200);
}
base.OnStarted();
}
protected override void OnStopped()
{
base.OnStarted();
}
protected override void OnStopped()
{
this.AddInfoLog("Стратегия остановлена.");
}
protected override void OnStopping()
{
this.AddInfoLog("Стратегия останавливается.");
base.OnStopping();
}
}
Лог прикреплен.
The text was updated successfully, but these errors were encountered:
Если для стратегии флаг WaitAllTrades = true, и если до момента вызова метода Stop не пришло событие собственных сделок, то стратегия полностью не останавливается - зависает в состоянии Stopping.
Пример кода:
Лог прикреплен.
The text was updated successfully, but these errors were encountered: