mirror of
https://github.com/vdemydiuk/mtapi.git
synced 2026-08-15 11:48:09 +00:00
Issue #91: Added MarketBookGetRequest to perform function MarketBookGet (MT5)
This commit is contained in:
@@ -1,8 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
// ReSharper disable InconsistentNaming
|
||||
namespace MtApi5
|
||||
{
|
||||
public class MqlBookInfo
|
||||
@@ -14,8 +10,13 @@ namespace MtApi5
|
||||
this.volume = volume;
|
||||
}
|
||||
|
||||
public ENUM_BOOK_TYPE type { get; private set; } // Order type from ENUM_BOOK_TYPE enumeration
|
||||
public double price { get; private set; } // Price
|
||||
public long volume { get; private set; } // Volume
|
||||
public ENUM_BOOK_TYPE type { get; } // Order type from ENUM_BOOK_TYPE enumeration
|
||||
public double price { get; } // Price
|
||||
public long volume { get; } // Volume
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"{type}|{price}|{volume}";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -95,7 +95,7 @@ namespace MtApi5
|
||||
SymbolInfoSessionTrade = 59,
|
||||
MarketBookAdd = 60,
|
||||
MarketBookRelease = 61,
|
||||
MarketBookGet = 62,
|
||||
//MarketBookGet = 62,
|
||||
OrderCloseAll = 63,
|
||||
|
||||
//CTrade
|
||||
|
||||
@@ -68,6 +68,7 @@
|
||||
<Compile Include="Mt5Quote.cs" />
|
||||
<Compile Include="Requests\CopyTicksRequest.cs" />
|
||||
<Compile Include="Requests\ICustomRequest.cs" />
|
||||
<Compile Include="Requests\MarketBookGetRequest.cs" />
|
||||
<Compile Include="Requests\OrderCheckRequest.cs" />
|
||||
<Compile Include="Requests\OrderCheckResult.cs" />
|
||||
<Compile Include="Requests\OrderSendRequest.cs" />
|
||||
|
||||
+5
-14
@@ -1434,22 +1434,13 @@ namespace MtApi5
|
||||
///<param name="book">Reference to an array of Depth of Market records.</param>
|
||||
public bool MarketBookGet(string symbol, out MqlBookInfo[] book)
|
||||
{
|
||||
var commandParameters = new ArrayList { symbol };
|
||||
|
||||
var retVal = SendCommand<MtMqlBookInfo[]>(Mt5CommandType.MarketBookGet, commandParameters);
|
||||
|
||||
book = null;
|
||||
if (retVal != null)
|
||||
var response = SendRequest<List<MqlBookInfo>>(new MarketBookGetRequest
|
||||
{
|
||||
book = new MqlBookInfo[retVal.Length];
|
||||
Symbol = symbol
|
||||
});
|
||||
|
||||
foreach (var t in retVal)
|
||||
{
|
||||
book[0] = new MqlBookInfo((ENUM_BOOK_TYPE)t.type, t.price, t.volume);
|
||||
}
|
||||
}
|
||||
|
||||
return book != null;
|
||||
book = response?.ToArray();
|
||||
return response != null;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
namespace MtApi5.Requests
|
||||
{
|
||||
internal class MarketBookGetRequest: RequestBase
|
||||
{
|
||||
public override RequestType RequestType => RequestType.MarketBookGet;
|
||||
|
||||
public string Symbol { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,7 @@ namespace MtApi5.Requests
|
||||
iCustom = 2,
|
||||
OrderSend = 3,
|
||||
PositionOpen = 4,
|
||||
OrderCheck = 5
|
||||
OrderCheck = 5,
|
||||
MarketBookGet = 6
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user