Не совсем понимаю как дождаться корректного отображения Strategy.Position, простая проверка не работает, иногда проскакивают лишние ордера.
private void ProccesDepth(bool isDirectionBuy)
{
lock (_sync)
{
var order = new Order
{
Direction = isDirectionBuy ? OrderDirections.Buy : OrderDirections.Sell,
Price = isDirectionBuy ? _depth.BestBid.Price : _depth.BestAsk.Price,
Type = OrderTypes.Limit,
Volume = VolumeValue,
Comment = "Entry",
};
order
.WhenActivated()
.Do(() =>
{
if(!checkCondition)
{
CancelOrder(order);
}
})
.Once()
.Apply(this);
order
.WhenNewTrades()
.Do(SetProtectedOrders)
.Apply(this);
// Узкое место
if (checkCondition && Position == 0)
RegisterOrder(order);
}
}
Comentarios (3)
Iniciar sesión o Crear cuenta, Inicie sesión o regístrese para dejar un comentario
Удалось решить глобальным булом который обнуляется при срабатывании тейка или стопа, но если есть какой-то более лаконичный вариант, буду признателен если поделитесь.
private void ProccesDepth(bool isDirectionBuy) { lock (_sync) { var order = new Order { Direction = isDirectionBuy ? OrderDirections.Buy : OrderDirections.Sell, Price = isDirectionBuy ? _depth.BestBid.Price : _depth.BestAsk.Price, Type = OrderTypes.Limit, Volume = VolumeValue, Comment = "Entry", };
Лучше вообще состояния не использовать. Или минимизировать эти места. Event based подход предполагает state less.