Пример! Я пробовал запускать пример открытия сделки из проекта SampleConnectionGitHub, файла OrdersWindow.xaml.cs. И из документации тоже пробовал примеры. В примерах ниже пробовал различные вариации параметров. Думал может неправильно указывал параметры стоплоса или тейкпрофита/счета или направление сделки, поэтому разные варианты пробовал.
Пробовал делать открытие через окно и через код. Ниже примеры различных вариаций примеров открытия сделок.
Сам коннектор использую тоже из примера, настройки подключение тоже дефолтные.
var lots = 1;
var side = Sides.Buy;
var portf = Connector.Portfolios.ToList();
// portf = L01+00000F00
// sec = "HYDR@TQBR"
//var sec = _settings.DicSecurity.ElementAt(0).Key;
var newOrder = new OrderWindow
{
Order = new Order { Security = sec },
}.Init(Connector);
if (newOrder.ShowModal(this))
Connector.RegisterOrder(newOrder.Order);
// Рыночные заявки открываются без проблем
var order = new Order
{
// устанавливается тип заявки, в данном примере лимитный
Type = OrderTypes.Market,
// устанавливается портфель для исполнения заявки
Portfolio = portf[0],
// устанавливается объём заявки
Volume = 1,
// устанавливается цена заявки
Price = 0,
// устанавливается инструмент
Security = sec,
// устанавливается направление заявки, в данном примере покупка
Direction = Sides.Buy,
};
Connector.RegisterOrder(order);
// А вот стоп заяки не хотят открываться
var order2 = new Order
{
Security = sec,
Portfolio = portf[7],
Price = sec.BestBid.GetValueOrDefault().Price - 10 * GetPriceStep(sec),
Volume = lots,
Balance = lots,
Direction = Sides.Sell,
Type = OrderTypes.Conditional,
Condition = new QuikOrderCondition()
{
Type = QuikOrderConditionTypes.StopLimit,
StopLimitPrice = sec.BestBid.GetValueOrDefault().Price + (side == Sides.Buy ? -15 : 15) * GetPriceStep(sec),
}
};
Connector.RegisterOrder(order2);
var order3 = new Order
{
Security = sec,
Portfolio = portf[2],
Price = 0,//sec.BestBid.GetValueOrDefault().Price - 10 * GetPriceStep(sec),
Volume = lots,
Balance = lots,
Direction = Sides.Sell,
Type = OrderTypes.Conditional,
Condition = new QuikOrderCondition()
{
ActiveTime = null,
ConditionOrderId = 0,
ConditionOrderPartiallyMatched = true,
ConditionOrderSide = Sides.Sell,
ConditionOrderUseMatchedBalance = true,
IsMarketStopLimit = true,
IsMarketTakeProfit = true,
IsNtm = false,
IsRepo = false,
LinkedOrderCancel = false,
LinkedOrderPrice = 0,
Spread = new Unit(0),
Offset = new Unit(0),
OtherSecurityId = sec.ToSecurityId(),
StopLimitPrice = sec.BestBid.GetValueOrDefault().Price + (side == Sides.Sell ? -150 : 150) * GetPriceStep(sec),
StopPrice = sec.BestBid.GetValueOrDefault().Price + (side == Sides.Sell ? 150 : -150) * GetPriceStep(sec),
StopPriceCondition = QuikStopPriceConditions.MoreOrEqual,
Type = QuikOrderConditionTypes.StopLimit,
}
};
Connector.RegisterOrder(order3);
var order4 = new Order
{
Security = sec,
Portfolio = portf[7],
Price = sec.BestBid.GetValueOrDefault().Price - 10 * GetPriceStep(sec),
Volume = lots,
Direction = Sides.Sell,
Type = OrderTypes.Conditional,
Condition = new QuikOrderCondition()
{
Type = QuikOrderConditionTypes.StopLimit,
StopPrice = sec.BestBid.GetValueOrDefault().Price + (side == Sides.Buy ? 15 : -15) * GetPriceStep(sec),
}
};
Connector.RegisterOrder(order4);
var order5 = new Order
{
Security = sec,
Portfolio = portf[7],
Price = sec.BestBid.GetValueOrDefault().Price - 10 * GetPriceStep(sec),
Volume = lots,
Direction = Sides.Sell,
Type = OrderTypes.Conditional,
Condition = new QuikOrderCondition()
{
Type = QuikOrderConditionTypes.StopLimit,
StopPrice = sec.BestBid.GetValueOrDefault().Price + (side == Sides.Buy ? -15 : 15) * GetPriceStep(sec),
}
};
Connector.RegisterOrder(order5);
//decimal price = Sides.Buy == side ? sec.BestBid.Price : sec.BestAsk.Price;
QuikOrderCondition condition = new QuikOrderCondition();
// Не заполнялась в позициях
condition.ConditionOrderSide = side == Sides.Buy ? Sides.Sell : Sides.Buy;
condition.IsMarketStopLimit = true; // цена по рынку сл
condition.IsMarketTakeProfit = true; // цена по рынку тп
//Unit Slippage = GetPriceStep(sec) * 100;
condition.Offset = new Unit(0, UnitTypes.Percent); // отступ от макса
condition.Spread = new Unit(0, UnitTypes.Percent); // отступ от макса
condition.StopPrice = sec.BestAsk.GetValueOrDefault().Price + (side == Sides.Buy ? -10 : 10) * GetPriceStep(sec); // sl
//StopLimitPrice
//condition.StopPrice = sec.BestAsk.GetValueOrDefault().Price + (side == Sides.Buy ? 10 : -10) * GetPriceStep(sec);
//condition.StopPriceCondition = QuikStopPriceConditions.MoreOrEqual;
//condition.Type = QuikOrderConditionTypes.TakeProfitStopLimit;
condition.Type = QuikOrderConditionTypes.StopLimit;
//condition.StopPriceCondition = QuikStopPriceConditions.MoreOrEqual;
Order OrderSLTP = new Order
{
Id = 1,
Security = sec,
Portfolio = portf[2], // mainOrder.Portfolio
Type = OrderTypes.Conditional,
Condition = condition,
ExpiryDate = null,
Volume = 1,
Price = 0,
//Price = (decimal)(condition.StopPrice + (side == Sides.Buy ? -Slippage.Value : Slippage.Value)),
Direction = Sides.Sell,
Comment = "test comment",
};
Connector.RegisterOrder(OrderSLTP);