MenDel
|
Date: 3/9/2013
Не могу понять, откуда взялись эти цифры?
2013/03/07 10:09:32.536|Warning|SSLS_RIH3@RTS_BP8536-RF-02|Отправляю заявку на выход по стопу уровень = 153390,00
2013/03/07 10:09:32.537| |SSLS_RIH3@RTS_BP9312-RF-01|Цена текущей NULL и лучшей 158510.
2013/03/07 10:09:32.537| |SSLS_RIH3@RTS_BP9312-RF-01|Лучший бид 153350и лучший аск 153450.
И что означает Цена текущей NULL и лучшей 158510.
Стоп заявка работает же по последней сделке, если цены выше 153390 не было каким макаром он решил что она была?
График
|
|
|
|
Thanks:
|
|
|
|
|
|
MenDel
|
Date: 3/26/2013
Не могу понять че за фигня, то стоп сразу срабатывает, а сегодня тупо тейк ваще не сработал.
Логи ничего не показывают. Моей ошибки в коде нет. Но раз в 1-2 недели обязательно со стопом и тейком косяк случается, притом что код то я не меняю.
Мож подскажите куда лог можно засунуть чтоб найти причину?
|
|
|
|
Thanks:
|
|
|
|
|
|
esper
|
Date: 3/26/2013
По логу не понятно, что сработало, что не сработало, почему должно было сработать.
|
|
|
|
Thanks:
|
|
|
|
|
|
MenDel
|
Date: 3/26/2013
|
|
|
|
|
esper:
По логу не понятно, что сработало, что не сработало, почему должно было сработать.
2013/03/26 07:03:10.818| |SmartTrader|07:03:10 Соединение установлено
2013/03/26 07:03:10.822| |SmartTrader|Экспорт запущен.
2013/03/26 07:03:18.563| |SmartTrader|07:03:18 Экспорт работает
2013/03/26 07:03:18.576| |SmartTrader|07:03:18 Нет позиций
2013/03/26 07:03:18.599| |SmartTrader|SmartTrader.UpdateOrder: id 0 smartId 1629193606 type StOrder_Type_Stop direction Sell price 0 volume 15 balance 15 time 25.03.2013 12:20:43 security RTS-6.13_FT state StOrder_State_SystemReject
2013/03/26 07:03:18.601| |SmartTrader|SmartTrader.UpdateOrder: id 10188257055 smartId 1630967707 type StOrder_Type_Limit direction Sell price 142530 volume 7 balance 7 time 25.03.2013 23:49:50 security RTS-6.13_FT state StOrder_State_Cancel
2013/03/26 07:03:18.601| |SmartTrader|SmartTrader.UpdateOrder: id 10190725631 smartId 1631176438 type StOrder_Type_Limit direction Buy price 140680 volume 8 balance 0 time 25.03.2013 23:49:50 security RTS-6.13_FT state StOrder_State_Filled
2013/03/26 07:03:18.620| |SmartTrader|New order: 0/10190725631 Покупка Цена=140680 Объем=8 Сост=Done Бал=0
2013/03/26 07:03:18.626| |SmartTrader|SmartTrader.AddTrade: tradeId 712783564 orderId 10190725631 price 140670 volume 7 time 25.03.2013 23:49:50 security RTS-6.13_FT
2013/03/26 07:03:18.631| |SmartTrader|SmartTrader.AddTrade: tradeId 712783565 orderId 10190725631 price 140680 volume 1 time 25.03.2013 23:49:50 security RTS-6.13_FT
2013/03/26 07:03:18.631| |SmartTrader|SmartTrader.AddTrade: tradeId 712087566 orderId 10180589113 price 142350 volume 1 time 22.03.2013 23:49:50 security RTS-6.13_FT
2013/03/26 07:03:18.633| |SmartTrader|SmartTrader.AddTrade: tradeId 712087574 orderId 10180589130 price 142360 volume 7 time 22.03.2013 23:49:50 security RTS-6.13_FT
2013/03/26 08:59:08.422| |SmartTrader|SmartTrader.AddTrade: tradeId 712783564 orderId 10190725631 price 140670 volume 7 time 25.03.2013 23:49:50 security RTS-6.13_FT
2013/03/26 08:59:08.422| |SmartTrader|SmartTrader.AddTrade: tradeId 712783565 orderId 10190725631 price 140680 volume 1 time 25.03.2013 23:49:50 security RTS-6.13_FT
2013/03/26 09:50:05.272| |SmartTrader|SmartTrader.AddTrade: tradeId 712783564 orderId 10190725631 price 140670 volume 7 time 25.03.2013 23:49:50 security RTS-6.13_FT
2013/03/26 09:50:05.273| |SmartTrader|SmartTrader.AddTrade: tradeId 712783565 orderId 10190725631 price 140680 volume 1 time 25.03.2013 23:49:50 security RTS-6.13_FT
2013/03/26 10:01:00.345| |STR_RIM3@RTS_BP9214-RF-01|Стратегия запущена. [0,-1]. Позиция при старте 0.
2013/03/26 10:01:00.347| |SmartTrader|10:01:00 Стратегия запущена
2013/03/26 10:12:56.473| |STR_RIM3@RTS_BP9214-RF-01|Регистрация новой Limit (0xAFDAF6) заявки на Sell с ценой 141300,00 и объемом 7.
2013/03/26 10:12:56.486| |SmartTrader|RegisterOrder: 25386447/0 Продажа Цена=141300,00 Объем=7 Сост=None Бал=7
2013/03/26 10:12:56.580| |SmartTrader|SmartTrader.UpdateOrder: id 0 smartId 1631278042 type StOrder_Type_Limit direction Sell price 141300 volume 7 balance 7 time 26.03.2013 10:12:56 security RTS-6.13_FT state StOrder_State_Pending
2013/03/26 10:12:56.628| |SmartTrader|SmartTrader.UpdateOrder: id 10190939392 smartId 1631278042 type StOrder_Type_Limit direction Sell price 141300 volume 7 balance 7 time 26.03.2013 10:12:56 security RTS-6.13_FT state StOrder_State_Open
2013/03/26 10:12:56.630| |SmartTrader|New order: 25386447/10190939392 Продажа Цена=141300,00 Объем=7 Сост=Active Бал=7
2013/03/26 11:22:45.713| |SmartTrader|SmartTrader.UpdateOrder: id 10190939392 smartId 1631278042 type StOrder_Type_Limit direction Sell price 141300 volume 7 balance 0 time 26.03.2013 11:22:45 security RTS-6.13_FT state StOrder_State_Filled
2013/03/26 11:22:45.713| |SmartTrader|Order changed: 25386447/10190939392 Продажа Цена=141300,00 Объем=7 Сост=Done Бал=0
2013/03/26 11:22:45.716| |STR_RIM3@RTS_BP9214-RF-01|Новая позиция: BP9214-RF-01-RIM3@RTS=-7.
2013/03/26 11:22:45.719| |STR_RIM3@RTS_BP9214-RF-01|Заявка 25386447 больше не активна.
2013/03/26 11:22:45.730| |SmartTrader|SmartTrader.AddTrade: tradeId 712879884 orderId 10190939392 price 141300 volume 7 time 26.03.2013 11:22:45 security RTS-6.13_FT
2013/03/26 11:22:45.733| |STR_RIM3@RTS_BP9214-RF-01|Новая Sell сделка 712879884 по цене 141300 на 7 заявки 25386447.
2013/03/26 11:22:45.746| STR_RIM3@RTS_BP9214-RF-01|Вошли H. Price = 141300 V = 7
2013/03/26 11:22:46.294| |STPS_RIM3@RTS_BP9214-RF-01|Стратегия запущена. [0,2]. Позиция при старте 0.
2013/03/26 11:22:46.294| |STPS_RIM3@RTS_BP9214-RF-01|Защита сделки 712879884 заявки 25386447.
2013/03/26 11:22:46.294| |STPS_RIM3@RTS_BP9214-RF-01|Котирование на Buy объема 7.
2013/03/26 11:22:46.295| |STPS_RIM3@RTS_BP9214-RF-01|Приостановка правил. _rulesSuspendCount 1.
2013/03/26 11:22:46.296| |STPS_RIM3@RTS_BP9214-RF-01|Возобновление правил. _rulesSuspendCount 0.
2013/03/26 11:22:46.304| |SSLS_RIM3@RTS_BP9214-RF-01|Стратегия запущена. [0,2]. Позиция при старте 0.
2013/03/26 11:22:46.304| |SSLS_RIM3@RTS_BP9214-RF-01|Защита сделки 712879884 заявки 25386447.
2013/03/26 11:22:46.304| |SSLS_RIM3@RTS_BP9214-RF-01|Котирование на Buy объема 7.
2013/03/26 11:22:46.304| |SSLS_RIM3@RTS_BP9214-RF-01|Приостановка правил. _rulesSuspendCount 1.
2013/03/26 11:22:46.304| |SSLS_RIM3@RTS_BP9214-RF-01|Возобновление правил. _rulesSuspendCount 0.
2013/03/26 11:22:46.305| |TPSLS_RIM3@RTS_BP9214-RF-01|Стратегия запущена. [2,1]. Позиция при старте 0.
2013/03/26 16:19:38.421| |SmartTrader|SmartTrader.UpdateOrder: id 0 smartId 1633372630 type StOrder_Type_Stop direction Buy price 0 volume 7 balance 7 time 26.03.2013 16:19:38 security RTS-6.13_FT state StOrder_State_Pending
2013/03/26 16:32:31.514| |SmartTrader|SmartTrader.UpdateOrder: id 0 smartId 1633372630 type StOrder_Type_Stop direction Buy price 0 volume 7 balance 7 time 26.03.2013 16:19:38 security RTS-6.13_FT state StOrder_State_Open
2013/03/26 16:32:31.658| |SmartTrader|SmartTrader.UpdateOrder: id 10198277408 smartId 1633372630 type StOrder_Type_Stop direction Buy price 0 volume 7 balance 7 time 26.03.2013 16:19:38 security RTS-6.13_FT state StOrder_State_Open
2013/03/26 16:32:32.315| |SmartTrader|SmartTrader.UpdateOrder: id 10198277408 smartId 1633372630 type StOrder_Type_Stop direction Buy price 146300 volume 7 balance 0 time 26.03.2013 16:32:31 security RTS-6.13_FT state StOrder_State_Filled
2013/03/26 16:32:32.316| |SmartTrader|SmartTrader.AddTrade: tradeId 713283553 orderId 10198277408 price 140020 volume 7 time 26.03.2013 16:32:31 security RTS-6.13_FT
2013/03/26 17:27:56.704| |SmartTrader|Экспорт остановлен.
Тейк должен был сработать в 15:30. Но он не сработал по какой то причине, это уже не в первый раз так.
В 16:32 я руками выставил тейк (к этому моменту он уже в стоп превратился).
Код ТэйкПрофит стратегия, СтопЛосс почти такая же
using System;
using System.Diagnostics;
using Ecng.ComponentModel;
using StockSharp.Algo;
using StockSharp.Algo.Strategies;
using StockSharp.BusinessEntities;
using StockSharp.Logging;
namespace Fisher
{
internal class SmartTakeProfitStrategy : TakeProfitStrategy
{
private readonly MyTrade _trade;
private decimal StopPrice { get; set; }
private decimal Lastprice { get; set; }
public SmartTakeProfitStrategy(MyTrade trade, Unit protectiveLevel)
: base(trade, protectiveLevel)
{
_trade = trade;
StopPrice = (decimal)protectiveLevel;
}
protected override decimal BestPrice
{
get { return Security.LastTrade.Price; }
}
private decimal GetProtectivePrice()
{
return StopPrice;
}
protected override decimal NeedQuoting(decimal currentPrice, decimal currentVolume, Range<decimal> acceptablePriceRange, decimal newVolume)
{
if (BestPrice == Lastprice || currentPrice != 0) return 0;
var price = GetProtectivePrice();
if (!ExchangeBoard.Forts.IsTradeTime(LoggingHelper.Now))
{
return 0;
}
if (_trade.Order.Direction == OrderDirections.Buy)
{
if (BestPrice >= price - 200)
{
this.AddWarningLog("Отправляю заявку на выход по тейку уровень = {0}", price);
Lastprice = BestPrice;
return price;
}
}
else if (_trade.Order.Direction == OrderDirections.Sell)
{
if (BestPrice <= price + 200)
{
this.AddWarningLog("Отправляю заявку на выход по тейку уровень = {0}", price);
Lastprice = BestPrice;
return price;
}
}
Lastprice = BestPrice;
return 0;
}
}
}
|
|
|
|
Thanks:
|
|
|
|
|
|
esper
|
Date: 3/26/2013
Смотрели, почему у вас NeedQuoting в это время возвращает 0?
|
|
|
|
Thanks:
|
|
|
|
|
|
MenDel
|
Date: 3/26/2013
esper:
Смотрели, почему у вас NeedQuoting в это время возвращает 0?
В этот раз не записалось. Я эту строку забыл раскомментировать.
Буду все записывать при каждом изменение цены: GetProtectivePrice(), BestPrice, Lastprice, currentPrice, currentVolume, acceptablePriceRange, newVolume.
При следущем косяке лог выложу.
Еще кстати во время клиринга стоп или тейк выставляется,
пришлось писать
if (!ExchangeBoard.Forts.IsTradeTime(LoggingHelper.Now))
{
return 0;
}
|
|
|
|
Thanks:
|
|
|
|
|
|
MenDel
|
Date: 3/28/2013
|
|
|
|
|
28.03.2013 16:38:24 StopLoss GetProtectivePrice = 138760,00 BestPrice = 140260 Lastprice = 140260 currentPrice = 0 currentVolume = 0 acceptablePriceRange = newVolume = 1
28.03.2013 16:38:24 StopLoss GetProtectivePrice = 138760,00 BestPrice = 140260 Lastprice = 140260 currentPrice = 0 currentVolume = 0 acceptablePriceRange = newVolume = 1
28.03.2013 16:38:24 StopLoss GetProtectivePrice = 138760,00 BestPrice = 140250 Lastprice = 140260 currentPrice = 0 currentVolume = 0 acceptablePriceRange = newVolume = 3
28.03.2013 16:38:24 Отправляю заявку на выход по стопу уровень = 138760.00
28.03.2013 16:38:24 StopLoss GetProtectivePrice = 138760,00 BestPrice = 140260 Lastprice = 140260 currentPrice = 0 currentVolume = 0 acceptablePriceRange = newVolume = 1
28.03.2013 16:38:24 StopLoss GetProtectivePrice = 138760,00 BestPrice = 140260 Lastprice = 140260 currentPrice = 0 currentVolume = 0 acceptablePriceRange = newVolume = 1
28.03.2013 16:38:24 StopLoss GetProtectivePrice = 138760,00 BestPrice = 140260 Lastprice = 140260 currentPrice = 0 currentVolume = 0 acceptablePriceRange = newVolume = 1
28.03.2013 16:38:24 StopLoss GetProtectivePrice = 138760,00 BestPrice = 140260 Lastprice = 140260 currentPrice = 0 currentVolume = 0 acceptablePriceRange = newVolume = 1
28.03.2013 16:38:24 StopLoss GetProtectivePrice = 138760,00 BestPrice = 140260 Lastprice = 140260 currentPrice = 134040 currentVolume = 3 acceptablePriceRange = newVolume = 3
Вышли STR. Price = 140250 V = 3
Остановка STR. Сделка закрыта.
28.03.2013 16:38:24 StopLoss GetProtectivePrice = 138760,00 BestPrice = 140260 Lastprice = 140260 currentPrice = 0 currentVolume = 0 acceptablePriceRange = newVolume = 1
28.03.2013 16:38:24 StopLoss GetProtectivePrice = 138760,00 BestPrice = 140260 Lastprice = 140260 currentPrice = 0 currentVolume = 0 acceptablePriceRange = newVolume = 1
28.03.2013 16:38:25 StopLoss GetProtectivePrice = 138760,00 BestPrice = 140250 Lastprice = 140260 currentPrice = 0 currentVolume = 0 acceptablePriceRange = newVolume = 1
28.03.2013 16:38:25 StopLoss GetProtectivePrice = 138760,00 BestPrice = 140250 Lastprice = 140260 currentPrice = 0 currentVolume = 0 acceptablePriceRange = newVolume = 1
28.03.2013 16:38:25 StopLoss GetProtectivePrice = 138760,00 BestPrice = 140250 Lastprice = 140250 currentPrice = 0 currentVolume = 0 acceptablePriceRange = newVolume = 1
28.03.2013 16:38:25 StopLoss GetProtectivePrice = 138760,00 BestPrice = 140250 Lastprice = 140250 currentPrice = 0 currentVolume = 0 acceptablePriceRange = newVolume = 1
28.03.2013 16:38:25 StopLoss GetProtectivePrice = 138760,00 BestPrice = 140250 Lastprice = 140250 currentPrice = 0 currentVolume = 0 acceptablePriceRange = newVolume = 1
Вот сегодня сработал стоп сам по себе. Причем не по всей позиции, а только по 3 контрактам.
Я не могу понять как так получается.
28.03.2013 16:38:24 Отправляю заявку на выход по стопу уровень = 138760.00
Чтоб это сообщение выскочило, должно сработать условие
protected override decimal NeedQuoting(decimal currentPrice, decimal currentVolume, Range<decimal> acceptablePriceRange, decimal newVolume)
{
Debug.WriteLine(LoggingHelper.Now + " StopLoss" + " GetProtectivePrice = " + GetProtectivePrice() + " BestPrice = " + BestPrice + " Lastprice = " + Lastprice + " currentPrice = " + currentPrice + " currentVolume = " + currentVolume + " acceptablePriceRange = " + acceptablePriceRange + " newVolume = " + newVolume);
if (BestPrice == Lastprice || currentPrice != 0) return 0;
var price = GetProtectivePrice();
if (!ExchangeBoard.Forts.IsTradeTime(LoggingHelper.Now))
{
this.AddWarningLog("StopLoss - не рабочее время - LastTrade = " + BestPrice + " LastPrice = " + Lastprice);
return 0;
}
if (_trade.Order.Direction == OrderDirections.Buy)
{
if (BestPrice <= price)
{
this.AddWarningLog("Отправляю заявку на выход по стопу уровень = {0}", price);
Lastprice = BestPrice;
return Security.MinPrice;
}
}
else if (_trade.Order.Direction == OrderDirections.Sell)
{
if (BestPrice >= price)
{
this.AddWarningLog("Отправляю заявку на выход по стопу уровень = {0}", price);
Lastprice = BestPrice;
return Security.MaxPrice;
}
}
Lastprice = BestPrice;
return 0;
}
Но BestPrice не было меньше price! Как так?!
А этот код мог запутаться? Если вторая стратегия в противоположной позиции была?
|
|
|
|
Thanks:
|
|
|
|
|
|
MenDel
|
Date: 4/3/2013
|
|
|
|
|
protected override decimal NeedQuoting(decimal currentPrice, decimal currentVolume, Range<decimal> acceptablePriceRange, decimal newVolume)
{
Debug.WriteLine(LoggingHelper.Now + " GetProtectivePrice = " + GetProtectivePrice() + " BestPrice = " + BestPrice + " Lastprice = " + Lastprice + " currentPrice = " + currentPrice + " currentVolume = " + currentVolume + " acceptablePriceRange = " + acceptablePriceRange + " newVolume = " + newVolume);
if (BestPrice == Lastprice || currentPrice != 0) return 0;
var price = GetProtectivePrice();
if (_trade.Order.Direction == OrderDirections.Buy)
{
if (BestPrice >= price - 100)
{
Debug.WriteLine(LoggingHelper.Now + " return" + " GetProtectivePrice = " + GetProtectivePrice() + " BestPrice = " + BestPrice + " Lastprice = " + Lastprice + " currentPrice = " + currentPrice + " currentVolume = " + currentVolume + " acceptablePriceRange = " + acceptablePriceRange + " newVolume = " + newVolume);
Debug.WriteLine(LoggingHelper.Now + " Отправляю заявку на выход уровень = {0}", price);
this.AddWarningLog("Отправляю заявку на выход уровень = {0}", price);
Lastprice = BestPrice;
return price;
}
}
else if (_trade.Order.Direction == OrderDirections.Sell)
{
if (BestPrice <= price + 100)
{
Debug.WriteLine(LoggingHelper.Now + " return" + " GetProtectivePrice = " + GetProtectivePrice() + " BestPrice = " + BestPrice + " Lastprice = " + Lastprice + " currentPrice = " + currentPrice + " currentVolume = " + currentVolume + " acceptablePriceRange = " + acceptablePriceRange + " newVolume = " + newVolume);
Debug.WriteLine(LoggingHelper.Now + " Отправляю заявку на выход уровень = {0}", price);
this.AddWarningLog("Отправляю заявку на выход уровень = {0}", price);
Lastprice = BestPrice;
return price;
}
}
Lastprice = BestPrice;
return 0;
}
03.04.2013 20:58:08 GetProtectivePrice = 10 <mark>BestPrice = 137000</mark> Lastprice = 137000 currentPrice = 0 currentVolume = 0 acceptablePriceRange = newVolume = 3
03.04.2013 20:58:08 return GetProtectivePrice = 10 <mark>BestPrice = 0</mark> Lastprice = 137000 currentPrice = 0 currentVolume = 0 acceptablePriceRange = newVolume = 3
03.04.2013 20:58:08 Отправляю заявку на выход уровень = 10
Как могло так получиться? Как BestPrice оказался равным 0 в середине кода?
Да к тому ж у меня написано if (BestPrice == Lastprice || currentPrice != 0) return 0; А BestPrice = LastPrice. Значит должно вернуться 0. И все.
Делаю вывод, BestPrice изменилось после вывода в Debug и до проверки if (BestPrice == Lastprice || currentPrice != 0)
|
|
|
|
Thanks:
|
|
|
|
|
|
VassilSanych
|
Date: 4/4/2013
|
|
|
|
Thanks:
|
|
|
|
|
|
MenDel
|
Date: 4/4/2013
VassilSanych:
Может надо лочить?
Если б я знал где его вставить.
И кстати если lock не будет справляться с потоком сделок, то стратегия начнет запаздывать.
Тут надо если он пропустил сделку, то считай он её пропустил, а не ставил в очередь.
|
|
|
|
Thanks:
|
|
|
|
|