mirror of
https://github.com/vdemydiuk/mtapi.git
synced 2026-08-25 08:38:10 +00:00
Issue #94: Added event handler OnBookEvent (MT5).
This commit is contained in:
@@ -2387,6 +2387,7 @@ namespace MtApi5
|
||||
public event EventHandler<Mt5QuoteEventArgs> QuoteRemoved;
|
||||
public event EventHandler<Mt5ConnectionEventArgs> ConnectionStateChanged;
|
||||
public event EventHandler<Mt5TradeTransactionEventArgs> OnTradeTransaction;
|
||||
public event EventHandler<Mt5BookEventArgs> OnBookEvent;
|
||||
#endregion
|
||||
|
||||
#region Private Methods
|
||||
@@ -2464,6 +2465,9 @@ namespace MtApi5
|
||||
case Mt5EventTypes.OnTradeTransaction:
|
||||
ReceivedOnTradeTransaction(e.ExpertHandle, e.Payload);
|
||||
break;
|
||||
case Mt5EventTypes.OnBookEvent:
|
||||
ReceivedOnBookEvent(e.ExpertHandle, e.Payload);
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
@@ -2481,6 +2485,16 @@ namespace MtApi5
|
||||
});
|
||||
}
|
||||
|
||||
private void ReceivedOnBookEvent(int expertHandler, string payload)
|
||||
{
|
||||
var e = JsonConvert.DeserializeObject<OnBookEvent>(payload);
|
||||
OnBookEvent?.Invoke(this, new Mt5BookEventArgs
|
||||
{
|
||||
ExpertHandle = expertHandler,
|
||||
Symbol = e.Symbol
|
||||
});
|
||||
}
|
||||
|
||||
private void Connect(string host, int port)
|
||||
{
|
||||
var client = new MtClient(host, port);
|
||||
|
||||
Reference in New Issue
Block a user