diff --git a/MainWindow.xaml b/MainWindow.xaml
index 0a541b8..81d4818 100644
--- a/MainWindow.xaml
+++ b/MainWindow.xaml
@@ -30,10 +30,10 @@
-
+ QSH:
-
+ S#:
@@ -50,14 +50,37 @@
-
+
+
+
+
-
-
+ Board code:
+
-
- Security Code Masks:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -72,7 +95,7 @@
-
+ Output format:
Multi thread convertion
diff --git a/MainWindow.xaml.cs b/MainWindow.xaml.cs
index 6064e6e..7a301a5 100644
--- a/MainWindow.xaml.cs
+++ b/MainWindow.xaml.cs
@@ -42,6 +42,8 @@ private class Settings
public bool MultiThread { get; set; }
public bool OrderLog2OrderBook { get; set; }
public int OrderBookMaxDepth { get; set; } = 5;
+ public string TimeStampZone { get; set; }
+ public string MarketDataZone { get; set; }
}
private readonly LogManager _logManager = new LogManager();
@@ -68,6 +70,9 @@ public MainWindow()
Directory.CreateDirectory(_settingsDir);
+ TimeStampZone.TimeZone = TimeZoneInfo.Utc;
+ MarketDataZone.TimeZone = TimeHelper.Moscow;
+
_logManager.Application.LogLevel = LogLevels.Verbose;
_logManager.Listeners.Add(new GuiLogListener(LogControl));
@@ -96,6 +101,12 @@ public MainWindow()
settings.Board.IsEmpty()
? ExchangeBoard.Forts
: Board.Boards.FirstOrDefault(b => b.Code.CompareIgnoreCase(settings.Board)) ?? ExchangeBoard.Forts;
+
+ if (!settings.TimeStampZone.IsEmpty())
+ TimeStampZone.TimeZone = TimeZoneInfo.FindSystemTimeZoneById(settings.TimeStampZone);
+
+ if (!settings.MarketDataZone.IsEmpty())
+ MarketDataZone.TimeZone = TimeZoneInfo.FindSystemTimeZoneById(settings.MarketDataZone);
}
if (File.Exists(_convertedFilesFile))
@@ -126,6 +137,8 @@ private Settings SaveSettings()
Board = Board.SelectedBoard?.Code,
MultiThread = MultiThread.IsChecked == true,
OrderLog2OrderBook = OrderLog2OrderBook.IsEnabled && OrderLog2OrderBook.IsChecked == true,
+ TimeStampZone = TimeStampZone.TimeZone.Id,
+ MarketDataZone = MarketDataZone.TimeZone.Id,
};
try
@@ -165,6 +178,8 @@ private void Convert_OnClick(object sender, RoutedEventArgs e)
var board = Board.SelectedBoard;
var orderLog2OrderBookBuilders = settings.OrderLog2OrderBook ? new Dictionary() : null;
+ var tz = TimeStampZone.TimeZone;
+ var mz = MarketDataZone.TimeZone;
Task.Factory.StartNew(() =>
{
@@ -179,7 +194,7 @@ private void Convert_OnClick(object sender, RoutedEventArgs e)
_startConvertTime = DateTimeOffset.Now;
- ConvertDirectory(settings.QshFolder, registry, settings.Format, board, settings.SecurityLike, settings.MultiThread, orderLog2OrderBookBuilders, settings.OrderBookMaxDepth);
+ ConvertDirectory(settings.QshFolder, registry, settings.Format, board, settings.SecurityLike, settings.MultiThread, orderLog2OrderBookBuilders, settings.OrderBookMaxDepth, tz, mz);
})
.ContinueWith(t =>
{
@@ -216,7 +231,7 @@ private void Convert_OnClick(object sender, RoutedEventArgs e)
}, TaskScheduler.FromCurrentSynchronizationContext());
}
- private void ConvertDirectory(string path, IStorageRegistry registry, StorageFormats format, ExchangeBoard board, string securityLike, bool multithread, Dictionary orderLog2OrderBookBuilders, int orderBookMaxDepth)
+ private void ConvertDirectory(string path, IStorageRegistry registry, StorageFormats format, ExchangeBoard board, string securityLike, bool multithread, Dictionary orderLog2OrderBookBuilders, int orderBookMaxDepth, TimeZoneInfo tz, TimeZoneInfo mz)
{
if (!_isStarted)
return;
@@ -224,17 +239,17 @@ private void ConvertDirectory(string path, IStorageRegistry registry, StorageFor
var files = Directory.GetFiles(path, "*.qsh");
if (!multithread)
- files.ForEach(f => ConvertFile(f, registry, format, board, securityLike, orderLog2OrderBookBuilders, orderBookMaxDepth));
+ files.ForEach(f => ConvertFile(f, registry, format, board, securityLike, orderLog2OrderBookBuilders, orderBookMaxDepth, tz, mz));
else
{
- Parallel.ForEach(files, file => ConvertFile(file, registry, format, board, securityLike, orderLog2OrderBookBuilders, orderBookMaxDepth));
+ Parallel.ForEach(files, file => ConvertFile(file, registry, format, board, securityLike, orderLog2OrderBookBuilders, orderBookMaxDepth, tz, mz));
}
//пишем имена сконвертированных в деректории файлов qsh, в файл
File.AppendAllLines(_convertedFilesFile, _convertedPerTaskPoolFiles);
_convertedPerTaskPoolFiles.Clear();
- Directory.GetDirectories(path).ForEach(d => ConvertDirectory(d, registry, format, board, securityLike, multithread, orderLog2OrderBookBuilders, orderBookMaxDepth));
+ Directory.GetDirectories(path).ForEach(d => ConvertDirectory(d, registry, format, board, securityLike, multithread, orderLog2OrderBookBuilders, orderBookMaxDepth, tz, mz));
}
private void TryFlushData(IStorageRegistry registry, SecurityId securityId, StorageFormats format, object arg, List messages, QshReader reader)
@@ -251,7 +266,7 @@ private void TryFlushData(IStorageRegistry registry, SecurityId securi
messages.Clear();
}
- private void ConvertFile(string fileName, IStorageRegistry registry, StorageFormats format, ExchangeBoard board, string securityLike, Dictionary orderLog2OrderBookBuilders, int orderBookMaxDepth)
+ private void ConvertFile(string fileName, IStorageRegistry registry, StorageFormats format, ExchangeBoard board, string securityLike, Dictionary orderLog2OrderBookBuilders, int orderBookMaxDepth, TimeZoneInfo tz, TimeZoneInfo mz)
{
if (!_isStarted)
return;
@@ -267,6 +282,9 @@ private void ConvertFile(string fileName, IStorageRegistry registry, StorageForm
var data = new Dictionary, List, List, List>>();
+ DateTimeOffset ToLocalDto(DateTime dt) => dt.ApplyTimeZone(tz);
+ DateTimeOffset ToServerDto(DateTime dt) => dt.ApplyTimeZone(mz);
+
using (var qr = QshReader.Open(fileName))
{
var reader = qr;
@@ -339,15 +357,18 @@ private void ConvertFile(string fileName, IStorageRegistry registry, StorageForm
bids.Add(new QuoteChange(priceStep * q.Price, q.Volume));
break;
default:
- throw new ArgumentException(q.Type.ToString());
+ {
+ continue;
+ //throw new ArgumentException(q.Type.ToString());
+ }
}
}
var md = new QuoteChangeMessage
{
- LocalTime = reader.CurrentDateTime.ApplyTimeZone(TimeHelper.Moscow),
+ LocalTime = ToLocalDto(reader.CurrentDateTime),
SecurityId = securityId,
- ServerTime = reader.CurrentDateTime.ApplyTimeZone(TimeHelper.Moscow),
+ ServerTime = ToLocalDto(reader.CurrentDateTime),
Bids = bids.ToArray(),
Asks = asks.ToArray(),
};
@@ -370,15 +391,15 @@ private void ConvertFile(string fileName, IStorageRegistry registry, StorageForm
{
secData.Item2.Add(new ExecutionMessage
{
- LocalTime = reader.CurrentDateTime.ApplyTimeZone(TimeHelper.Moscow),
+ LocalTime = ToLocalDto(reader.CurrentDateTime),
HasTradeInfo = true,
ExecutionType = ExecutionTypes.Tick,
SecurityId = securityId,
OpenInterest = deal.OI == 0 ? (long?)null : deal.OI,
- ServerTime = deal.DateTime.ApplyTimeZone(TimeHelper.Moscow),
+ ServerTime = ToServerDto(deal.DateTime),
TradeVolume = deal.Volume,
TradeId = deal.Id == 0 ? (long?)null : deal.Id,
- TradePrice = deal.Price,
+ TradePrice = deal.Price * priceStep,
OriginSide =
deal.Type == DealType.Buy
? Sides.Buy
@@ -402,13 +423,13 @@ private void ConvertFile(string fileName, IStorageRegistry registry, StorageForm
var msg = new ExecutionMessage
{
- LocalTime = reader.CurrentDateTime.ApplyTimeZone(TimeHelper.Moscow),
+ LocalTime = ToLocalDto(reader.CurrentDateTime),
ExecutionType = ExecutionTypes.OrderLog,
SecurityId = securityId,
OpenInterest = ol.OI == 0 ? (long?)null : ol.OI,
OrderId = ol.OrderId,
OrderPrice = priceStep * ol.Price,
- ServerTime = ol.DateTime.ApplyTimeZone(TimeHelper.Moscow),
+ ServerTime = ToServerDto(ol.DateTime),
OrderVolume = ol.Amount,
Balance = ol.AmountRest,
TradeId = ol.DealId == 0 ? (long?)null : ol.DealId,
@@ -531,15 +552,17 @@ private void ConvertFile(string fileName, IStorageRegistry registry, StorageForm
{
var l1Msg = new Level1ChangeMessage
{
- LocalTime = reader.CurrentDateTime.ApplyTimeZone(TimeHelper.Moscow),
+ LocalTime = ToLocalDto(reader.CurrentDateTime),
SecurityId = securityId,
- ServerTime = reader.CurrentDateTime.ApplyTimeZone(TimeHelper.Moscow),
+ ServerTime = ToLocalDto(reader.CurrentDateTime),
}
.TryAdd(Level1Fields.LastTradePrice, priceStep * info.Price)
.TryAdd(Level1Fields.BidsVolume, (decimal)info.BidTotal)
.TryAdd(Level1Fields.AsksVolume, (decimal)info.AskTotal)
.TryAdd(Level1Fields.HighPrice, priceStep * info.HiLimit)
.TryAdd(Level1Fields.LowPrice, priceStep * info.LoLimit)
+ .TryAdd(Level1Fields.StepPrice, (decimal)info.Rate)
+ .TryAdd(Level1Fields.OperatingMargin, (decimal)info.Deposit)
.TryAdd(Level1Fields.OpenInterest, (decimal)info.OI);
if (l1Msg.Changes.Count == 0)
@@ -606,7 +629,7 @@ private void ConvertFile(string fileName, IStorageRegistry registry, StorageForm
_logManager.Application.AddInfoLog("Завершена конвертация файла {0}.", fileName);
}
- private SecurityId GetSecurityId(QScalp.Security security, string boardCode)
+ private static SecurityId GetSecurityId(QScalp.Security security, string boardCode)
{
return new SecurityId
{