mirror of
https://github.com/vdemydiuk/mtapi.git
synced 2026-08-15 11:48:09 +00:00
Issue #226: Implemented two modes of lock ticks: LOCK_EVERY_TICK and LOCK_EVERY_CANDLE. Added event OnLockTicks
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using MtApi.Events;
|
||||||
|
|
||||||
namespace MtApi
|
namespace MtApi
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
namespace MtApi
|
namespace MtApi.Events
|
||||||
{
|
{
|
||||||
internal class MtChartEvent
|
internal class MtChartEvent
|
||||||
{
|
{
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
namespace MtApi.Events
|
||||||
|
{
|
||||||
|
public enum MtEventTypes
|
||||||
|
{
|
||||||
|
LastTimeBar = 1,
|
||||||
|
ChartEvent = 2,
|
||||||
|
OnLockTicks = 3
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
namespace MtApi.Events
|
||||||
|
{
|
||||||
|
internal class OnLockTicksEvent
|
||||||
|
{
|
||||||
|
public string Instrument { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
+4
-2
@@ -74,6 +74,7 @@
|
|||||||
<Compile Include="EnumSymbolInfoInteger.cs" />
|
<Compile Include="EnumSymbolInfoInteger.cs" />
|
||||||
<Compile Include="EnumTerminalInfoDouble.cs" />
|
<Compile Include="EnumTerminalInfoDouble.cs" />
|
||||||
<Compile Include="EnumTerminalInfoInteger.cs" />
|
<Compile Include="EnumTerminalInfoInteger.cs" />
|
||||||
|
<Compile Include="Events\OnLockTicksEvent.cs" />
|
||||||
<Compile Include="FlagFontStyle.cs" />
|
<Compile Include="FlagFontStyle.cs" />
|
||||||
<Compile Include="Monitors\AvailabilityOrdersEventArgs.cs" />
|
<Compile Include="Monitors\AvailabilityOrdersEventArgs.cs" />
|
||||||
<Compile Include="Monitors\OrderModification\ModifiedOrdersEventArgs.cs" />
|
<Compile Include="Monitors\OrderModification\ModifiedOrdersEventArgs.cs" />
|
||||||
@@ -86,14 +87,15 @@
|
|||||||
<Compile Include="Monitors\Triggers\TimeElapsedTrigger.cs" />
|
<Compile Include="Monitors\Triggers\TimeElapsedTrigger.cs" />
|
||||||
<Compile Include="MqlRates.cs" />
|
<Compile Include="MqlRates.cs" />
|
||||||
<Compile Include="MqlTick.cs" />
|
<Compile Include="MqlTick.cs" />
|
||||||
<Compile Include="MtChartEvent.cs" />
|
<Compile Include="Events\MtChartEvent.cs" />
|
||||||
<Compile Include="MtConnectionEventArgs.cs" />
|
<Compile Include="MtConnectionEventArgs.cs" />
|
||||||
<Compile Include="MtConnectionException.cs" />
|
<Compile Include="MtConnectionException.cs" />
|
||||||
<Compile Include="MtConnectionState.cs" />
|
<Compile Include="MtConnectionState.cs" />
|
||||||
<Compile Include="MtCommandType.cs" />
|
<Compile Include="MtCommandType.cs" />
|
||||||
<Compile Include="MtErrorCode.cs" />
|
<Compile Include="MtErrorCode.cs" />
|
||||||
<Compile Include="MtEventTypes.cs" />
|
<Compile Include="Events\MtEventTypes.cs" />
|
||||||
<Compile Include="MtExecutionException.cs" />
|
<Compile Include="MtExecutionException.cs" />
|
||||||
|
<Compile Include="MtLockTicksEventArgs.cs" />
|
||||||
<Compile Include="MtOrder.cs" />
|
<Compile Include="MtOrder.cs" />
|
||||||
<Compile Include="MtQuote.cs" />
|
<Compile Include="MtQuote.cs" />
|
||||||
<Compile Include="MtQuoteEventArgs.cs" />
|
<Compile Include="MtQuoteEventArgs.cs" />
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ using MtApi.Requests;
|
|||||||
using MtApi.Responses;
|
using MtApi.Responses;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using MtApi.Events;
|
||||||
|
|
||||||
namespace MtApi
|
namespace MtApi
|
||||||
{
|
{
|
||||||
@@ -3140,6 +3141,9 @@ namespace MtApi
|
|||||||
case MtEventTypes.ChartEvent:
|
case MtEventTypes.ChartEvent:
|
||||||
FireOnChartEvent(e.ExpertHandle, JsonConvert.DeserializeObject<MtChartEvent>(e.Payload));
|
FireOnChartEvent(e.ExpertHandle, JsonConvert.DeserializeObject<MtChartEvent>(e.Payload));
|
||||||
break;
|
break;
|
||||||
|
case MtEventTypes.OnLockTicks:
|
||||||
|
FireOnLockTicks(e.ExpertHandle, JsonConvert.DeserializeObject<OnLockTicksEvent>(e.Payload));
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
throw new ArgumentOutOfRangeException();
|
throw new ArgumentOutOfRangeException();
|
||||||
}
|
}
|
||||||
@@ -3155,6 +3159,11 @@ namespace MtApi
|
|||||||
OnChartEvent?.Invoke(this, new ChartEventArgs(expertHandler, chartEvent));
|
OnChartEvent?.Invoke(this, new ChartEventArgs(expertHandler, chartEvent));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void FireOnLockTicks(int expertHandler, OnLockTicksEvent lockTicksEvent)
|
||||||
|
{
|
||||||
|
OnLockTicks?.Invoke(this, new MtLockTicksEventArgs(expertHandler, lockTicksEvent.Instrument));
|
||||||
|
}
|
||||||
|
|
||||||
private void BacktestingReady()
|
private void BacktestingReady()
|
||||||
{
|
{
|
||||||
SendCommand<object>(MtCommandType.BacktestingReady, null);
|
SendCommand<object>(MtCommandType.BacktestingReady, null);
|
||||||
@@ -3171,6 +3180,7 @@ namespace MtApi
|
|||||||
public event EventHandler<MtConnectionEventArgs> ConnectionStateChanged;
|
public event EventHandler<MtConnectionEventArgs> ConnectionStateChanged;
|
||||||
public event EventHandler<TimeBarArgs> OnLastTimeBar;
|
public event EventHandler<TimeBarArgs> OnLastTimeBar;
|
||||||
public event EventHandler<ChartEventArgs> OnChartEvent;
|
public event EventHandler<ChartEventArgs> OnChartEvent;
|
||||||
|
public event EventHandler<MtLockTicksEventArgs> OnLockTicks;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +0,0 @@
|
|||||||
namespace MtApi
|
|
||||||
{
|
|
||||||
public enum MtEventTypes
|
|
||||||
{
|
|
||||||
LastTimeBar = 1,
|
|
||||||
ChartEvent = 2
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
using System;
|
||||||
|
|
||||||
|
namespace MtApi
|
||||||
|
{
|
||||||
|
public class MtLockTicksEventArgs : EventArgs
|
||||||
|
{
|
||||||
|
internal MtLockTicksEventArgs(int expertHandle, string symbol)
|
||||||
|
{
|
||||||
|
ExpertHandle = expertHandle;
|
||||||
|
Symbol = symbol;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int ExpertHandle { get; }
|
||||||
|
public string Symbol { get; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -44,6 +44,7 @@ namespace TestApiClientUI
|
|||||||
_apiClient.ConnectionStateChanged += apiClient_ConnectionStateChanged;
|
_apiClient.ConnectionStateChanged += apiClient_ConnectionStateChanged;
|
||||||
_apiClient.OnLastTimeBar += _apiClient_OnLastTimeBar;
|
_apiClient.OnLastTimeBar += _apiClient_OnLastTimeBar;
|
||||||
_apiClient.OnChartEvent += _apiClient_OnChartEvent;
|
_apiClient.OnChartEvent += _apiClient_OnChartEvent;
|
||||||
|
_apiClient.OnLockTicks += _apiClient_OnLockTicks;
|
||||||
|
|
||||||
InitOrderCommandsGroup();
|
InitOrderCommandsGroup();
|
||||||
|
|
||||||
@@ -149,6 +150,14 @@ namespace TestApiClientUI
|
|||||||
PrintLog(msg);
|
PrintLog(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void _apiClient_OnLockTicks(object sender, MtLockTicksEventArgs e)
|
||||||
|
{
|
||||||
|
var msg =
|
||||||
|
$"OnLockTicks: ExpertHandle = {e.ExpertHandle}, Symbol = {e.Symbol}";
|
||||||
|
Console.WriteLine(msg);
|
||||||
|
PrintLog(msg);
|
||||||
|
}
|
||||||
|
|
||||||
private void apiClient_QuoteUpdated(object sender, string symbol, double bid, double ask)
|
private void apiClient_QuoteUpdated(object sender, string symbol, double bid, double ask)
|
||||||
{
|
{
|
||||||
Console.WriteLine(@"Quote: Symbol = {0}, Bid = {1}, Ask = {2}", symbol, bid, ask);
|
Console.WriteLine(@"Quote: Symbol = {0}, Bid = {1}, Ask = {2}", symbol, bid, ask);
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user