Added OrderDeleteRequest. Changed functions OrderDelete to use request pattern. Mark some order functions as obsolete.

This commit is contained in:
DW
2016-04-29 19:10:02 +03:00
parent a52cc001c8
commit 36965bd02c
8 changed files with 190 additions and 106 deletions
+1
View File
@@ -80,6 +80,7 @@
<Compile Include="Requests\GetOrdersRequest.cs" />
<Compile Include="Requests\OrderCloseByRequest.cs" />
<Compile Include="Requests\OrderCloseRequest.cs" />
<Compile Include="Requests\OrderDeleteRequest.cs" />
<Compile Include="Requests\OrderSendRequest.cs" />
<Compile Include="Requests\RequestBase.cs" />
<Compile Include="Requests\RequestType.cs" />
+132 -105
View File
@@ -92,6 +92,127 @@ namespace MtApi
#endregion
#region Deprecated Methods
[Obsolete("OrderCloseByCurrentPrice is deprecated, please use OrderClose instead.")]
public bool OrderCloseByCurrentPrice(int ticket, int slippage)
{
return OrderClose(ticket, slippage);
}
[Obsolete("OrderClosePrice is deprecated, please use GetOrder instead.")]
public double OrderClosePrice()
{
return SendCommand<double>(MtCommandType.OrderClosePrice, null);
}
[Obsolete("OrderClosePrice is deprecated, please use GetOrder instead.")]
public double OrderClosePrice(int ticket)
{
var commandParameters = new ArrayList { ticket };
double retVal = SendCommand<double>(MtCommandType.OrderClosePriceByTicket, commandParameters);
return retVal;
}
[Obsolete("OrderCloseTime is deprecated, please use GetOrder instead.")]
public DateTime OrderCloseTime()
{
var commandResponse = SendCommand<int>(MtCommandType.OrderCloseTime, null);
return MtApiTimeConverter.ConvertFromMtTime(commandResponse);
}
[Obsolete("OrderComment is deprecated, please use GetOrder instead.")]
public string OrderComment()
{
return SendCommand<string>(MtCommandType.OrderComment, null);
}
[Obsolete("OrderCommission is deprecated, please use GetOrder instead.")]
public double OrderCommission()
{
return SendCommand<double>(MtCommandType.OrderCommission, null);
}
[Obsolete("OrderExpiration is deprecated, please use GetOrder instead.")]
public DateTime OrderExpiration()
{
var commandResponse = SendCommand<int>(MtCommandType.OrderExpiration, null);
return MtApiTimeConverter.ConvertFromMtTime(commandResponse);
}
[Obsolete("OrderLots is deprecated, please use GetOrder instead.")]
public double OrderLots()
{
return SendCommand<double>(MtCommandType.OrderLots, null);
}
[Obsolete("OrderMagicNumber is deprecated, please use GetOrder instead.")]
public int OrderMagicNumber()
{
return SendCommand<int>(MtCommandType.OrderMagicNumber, null);
}
[Obsolete("OrderOpenPrice is deprecated, please use GetOrder instead.")]
public double OrderOpenPrice()
{
return SendCommand<double>(MtCommandType.OrderOpenPrice, null);
}
[Obsolete("OrderOpenPrice is deprecated, please use GetOrder instead.")]
public double OrderOpenPrice(int ticket)
{
var commandParameters = new ArrayList { ticket };
double retVal = SendCommand<double>(MtCommandType.OrderOpenPriceByTicket, commandParameters);
return retVal;
}
[Obsolete("OrderOpenTime is deprecated, please use GetOrder instead.")]
public DateTime OrderOpenTime()
{
var commandResponse = SendCommand<int>(MtCommandType.OrderOpenTime, null);
return MtApiTimeConverter.ConvertFromMtTime(commandResponse);
}
[Obsolete("OrderProfit is deprecated, please use GetOrder instead.")]
public double OrderProfit()
{
return SendCommand<double>(MtCommandType.OrderProfit, null);
}
[Obsolete("OrderStopLoss is deprecated, please use GetOrder instead.")]
public double OrderStopLoss()
{
return SendCommand<double>(MtCommandType.OrderStopLoss, null);
}
[Obsolete("OrderSymbol is deprecated, please use GetOrder instead.")]
public string OrderSymbol()
{
return SendCommand<string>(MtCommandType.OrderSymbol, null);
}
[Obsolete("OrderTakeProfit is deprecated, please use GetOrder instead.")]
public double OrderTakeProfit()
{
return SendCommand<double>(MtCommandType.OrderTakeProfit, null);
}
[Obsolete("OrderTicket is deprecated, please use GetOrder instead.")]
public int OrderTicket()
{
return SendCommand<int>(MtCommandType.OrderTicket, null);
}
[Obsolete("OrderType is deprecated, please use GetOrder instead.")]
public TradeOperation OrderType()
{
int retVal = SendCommand<int>(MtCommandType.OrderType, null);
return (TradeOperation)retVal;
}
#endregion
#region Trading functions
public int OrderSend(string symbol, TradeOperation cmd, double volume, double price, int slippage, double stoploss, double takeprofit
@@ -242,12 +363,6 @@ namespace MtApi
return response != null;
}
[Obsolete("OrderCloseByCurrentPrice is deprecated, please use OrderClose instead.")]
public bool OrderCloseByCurrentPrice(int ticket, int slippage)
{
return OrderClose(ticket, slippage);
}
public bool OrderCloseBy(int ticket, int opposite, Color color)
{
var response = SendRequest<ResponseBase>(new OrderCloseByRequest
@@ -269,60 +384,23 @@ namespace MtApi
return response != null;
}
public double OrderClosePrice()
{
return SendCommand<double>(MtCommandType.OrderClosePrice, null);
}
public double OrderClosePrice(int ticket)
{
var commandParameters = new ArrayList { ticket };
double retVal = SendCommand<double>(MtCommandType.OrderClosePriceByTicket, commandParameters);
return retVal;
}
public DateTime OrderCloseTime()
{
var commandResponse = SendCommand<int>(MtCommandType.OrderCloseTime, null);
return MtApiTimeConverter.ConvertFromMtTime(commandResponse);
}
public string OrderComment()
{
return SendCommand<string>(MtCommandType.OrderComment, null);
}
public double OrderCommission()
{
return SendCommand<double>(MtCommandType.OrderCommission, null);
}
public bool OrderDelete(int ticket, Color color)
{
var commandParameters = new ArrayList { ticket, MtApiColorConverter.ConvertToMtColor(color) };
return SendCommand<bool>(MtCommandType.OrderDelete, commandParameters);
var response = SendRequest<ResponseBase>(new OrderDeleteRequest
{
Ticket = ticket,
ArrowColor = MtApiColorConverter.ConvertToMtColor(color),
});
return response != null;
}
public bool OrderDelete(int ticket)
{
return OrderDelete(ticket, Color.Empty);
}
public DateTime OrderExpiration()
{
var commandResponse = SendCommand<int>(MtCommandType.OrderExpiration, null);
return MtApiTimeConverter.ConvertFromMtTime(commandResponse);
}
public double OrderLots()
{
return SendCommand<double>(MtCommandType.OrderLots, null);
}
public int OrderMagicNumber()
{
return SendCommand<int>(MtCommandType.OrderMagicNumber, null);
var response = SendRequest<ResponseBase>(new OrderDeleteRequest
{
Ticket = ticket,
});
return response != null;
}
public bool OrderModify(int ticket, double price, double stoploss, double takeprofit, DateTime expiration, Color arrow_color)
@@ -336,35 +414,11 @@ namespace MtApi
return OrderModify(ticket, price, stoploss, takeprofit, expiration, Color.Empty);
}
public double OrderOpenPrice()
{
return SendCommand<double>(MtCommandType.OrderOpenPrice, null);
}
public double OrderOpenPrice(int ticket)
{
var commandParameters = new ArrayList { ticket };
double retVal = SendCommand<double>(MtCommandType.OrderOpenPriceByTicket, commandParameters);
return retVal;
}
public DateTime OrderOpenTime()
{
var commandResponse = SendCommand<int>(MtCommandType.OrderOpenTime, null);
return MtApiTimeConverter.ConvertFromMtTime(commandResponse);
}
public void OrderPrint()
{
SendCommand<object>(MtCommandType.OrderPrint, null);
}
public double OrderProfit()
{
return SendCommand<double>(MtCommandType.OrderProfit, null);
}
public bool OrderSelect(int index, OrderSelectMode select, OrderSelectSource pool)
{
var commandParameters = new ArrayList { index, (int)select, (int)pool };
@@ -381,11 +435,6 @@ namespace MtApi
return SendCommand<int>(MtCommandType.OrdersHistoryTotal, null);
}
public double OrderStopLoss()
{
return SendCommand<double>(MtCommandType.OrderStopLoss, null);
}
public int OrdersTotal()
{
return SendCommand<int>(MtCommandType.OrdersTotal, null);
@@ -396,28 +445,6 @@ namespace MtApi
return SendCommand<double>(MtCommandType.OrderSwap, null);
}
public string OrderSymbol()
{
return SendCommand<string>(MtCommandType.OrderSymbol, null);
}
public double OrderTakeProfit()
{
return SendCommand<double>(MtCommandType.OrderTakeProfit, null);
}
public int OrderTicket()
{
return SendCommand<int>(MtCommandType.OrderTicket, null);
}
public TradeOperation OrderType()
{
int retVal = SendCommand<int>(MtCommandType.OrderType, null);
return (TradeOperation) retVal;
}
public bool OrderCloseAll()
{
return SendCommand<bool>(MtCommandType.OrderCloseAll, null);
+14
View File
@@ -0,0 +1,14 @@
namespace MtApi.Requests
{
public class OrderDeleteRequest: RequestBase
{
public int Ticket { get; set; }
public int? ArrowColor { get; set; }
public override RequestType RequestType
{
get { return RequestType.OrderDelete; }
}
}
}
+2 -1
View File
@@ -7,6 +7,7 @@
GetOrders = 2,
OrderSend = 3,
OrderClose = 4,
OrderCloseBy = 5
OrderCloseBy = 5,
OrderDelete = 6
}
}