MtApi5: small update in requesting quote

This commit is contained in:
Viacheslav Demydiuk
2024-01-13 14:48:06 +02:00
parent 4f9dc57c25
commit 66d981ca9c
3 changed files with 23 additions and 28 deletions
+1 -4
View File
@@ -1,7 +1,4 @@
// ReSharper disable InconsistentNaming
using System;
namespace MtApi5
namespace MtApi5
{
public class MqlTick
{
+1 -20
View File
@@ -1,6 +1,4 @@
using System;
namespace MtApi5
namespace MtApi5
{
public class Mt5Quote
{
@@ -13,22 +11,5 @@ namespace MtApi5
public ulong Volume { get; set; }
// public long TimeMsc { get; set; }
// public uint Flags { get; set; }
internal Mt5Quote()
{
}
internal Mt5Quote(string instrument, double bid, double ask)
{
Instrument = instrument;
Bid = bid;
Ask = ask;
}
//internal Mt5Quote(MtQuote quote)
// :this(quote.Instrument, quote.Bid, quote.Ask)
//{
// ExpertHandle = quote.ExpertHandle;
//}
}
}
+21 -4
View File
@@ -4,6 +4,7 @@ using Newtonsoft.Json;
using MtApi5.Events;
using MtClient;
using System.Reflection.Metadata;
using System.Collections.Generic;
namespace MtApi5
{
@@ -3478,9 +3479,22 @@ namespace MtApi5
private Mt5Quote? GetQuote(int expertHandle)
{
Log?.Debug($"GetQuote: expertHandle = {expertHandle}");
var quote = SendCommand<Mt5Quote>(expertHandle, Mt5CommandType.GetQuote);
if (quote != null)
quote.ExpertHandle = expertHandle;
var e = SendCommand<OnTickEvent>(expertHandle, Mt5CommandType.GetQuote);
if (e == null || string.IsNullOrEmpty(e.Instrument) || e.Tick == null)
return null;
Mt5Quote quote = new()
{
Instrument = e.Instrument,
Bid = e.Tick.bid,
Ask = e.Tick.ask,
ExpertHandle = expertHandle,
Volume = e.Tick.volume,
Time = e.Tick.time,
Last = e.Tick.last
};
return quote;
}
@@ -3530,8 +3544,11 @@ namespace MtApi5
QuoteUpdated?.Invoke(this, e.Instrument, e.Tick.bid, e.Tick.ask);
var quote = new Mt5Quote(e.Instrument, e.Tick.bid, e.Tick.ask)
Mt5Quote quote = new()
{
Instrument = e.Instrument,
Bid = e.Tick.bid,
Ask = e.Tick.ask,
ExpertHandle = expertHandler,
Volume = e.Tick.volume,
Time = e.Tick.time,