mirror of
https://github.com/vdemydiuk/mtapi.git
synced 2026-08-15 11:48:09 +00:00
Changed design of monitors for better extensibility
This commit is contained in:
@@ -1,56 +1,13 @@
|
||||
|
||||
using MtApi.Monitors.Triggers;
|
||||
|
||||
namespace MtApi.Monitors
|
||||
{
|
||||
public class TimeframeTradeMonitor : TradeMonitor
|
||||
{
|
||||
#region Fields
|
||||
private volatile bool _isStarted;
|
||||
#endregion
|
||||
|
||||
#region ctor
|
||||
public TimeframeTradeMonitor(MtApiClient apiClient)
|
||||
: base(apiClient)
|
||||
public TimeframeTradeMonitor(MtApiClient apiClient)
|
||||
: base(apiClient, new NewBarTrigger(apiClient))
|
||||
{
|
||||
apiClient.OnLastTimeBar += ApiClient_OnLastTimeBar;
|
||||
SyncTrigger = true; //Sync-Trigger set to true, to have the same behavior as before
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Public Methods
|
||||
//
|
||||
// Summary:
|
||||
// Gets a value indicating whether the TimeframeTradeMonitor should raise checking orders
|
||||
//
|
||||
// Returns:
|
||||
// true if PositionMonitor should check orders
|
||||
// otherwise, false.
|
||||
public override bool IsStarted => _isStarted;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Protected Methods
|
||||
protected override void OnMtConnected() {}
|
||||
|
||||
protected override void OnMtDisconnected() {}
|
||||
|
||||
protected override void OnStart()
|
||||
{
|
||||
_isStarted = true;
|
||||
}
|
||||
|
||||
protected override void OnStop()
|
||||
{
|
||||
_isStarted = false;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Private Methods
|
||||
private void ApiClient_OnLastTimeBar(object sender, TimeBarArgs e)
|
||||
{
|
||||
if (_isStarted)
|
||||
{
|
||||
Check();
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user