MT5APIExecution.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  1. //+------------------------------------------------------------------+
  2. //| MetaTrader 5 API Server |
  3. //| Copyright 2000-2019, MetaQuotes Software Corp. |
  4. //| http://www.metaquotes.net |
  5. //+------------------------------------------------------------------+
  6. #pragma once
  7. //+------------------------------------------------------------------+
  8. //| Trade account interface |
  9. //+------------------------------------------------------------------+
  10. class IMTExecution
  11. {
  12. public:
  13. //--- execution state
  14. enum EnTradeExecutions
  15. {
  16. TE_ORDER_FIRST =0,
  17. //--- order filling
  18. TE_ORDER_NEW_REQUEST =0,
  19. TE_ORDER_NEW =1,
  20. TE_ORDER_FILL =2,
  21. TE_ORDER_REJECT =3,
  22. //--- order modify
  23. TE_ORDER_MODIFY_REQUEST =4,
  24. TE_ORDER_MODIFY =5,
  25. TE_ORDER_MODIFY_REJECT =6,
  26. //--- order cancel
  27. TE_ORDER_CANCEL_REQUEST =7,
  28. TE_ORDER_CANCEL =8,
  29. TE_ORDER_CANCEL_REJECT =9,
  30. //--- order others
  31. TE_ORDER_CHANGE_ID =10,
  32. TE_ORDER_CLOSE_BY =11,
  33. TE_ORDER_LAST =TE_ORDER_CLOSE_BY,
  34. //--- deal modifications
  35. TE_DEAL_FIRST =50,
  36. TE_DEAL_CANCEL =50,
  37. TE_DEAL_CORRECT =51,
  38. TE_DEAL_EXTERNAL =52,
  39. TE_DEAL_REPO =53,
  40. TE_DEAL_COMMISSION =54,
  41. TE_DEAL_LAST =TE_DEAL_COMMISSION,
  42. //--- end of session executions
  43. TE_EOS_FIRST =100,
  44. TE_EOS_CANCEL_DAILY_ORDERS =100,
  45. TE_EOS_VARIATION_MARGIN =101,
  46. TE_EOS_RECALC_DEALS =102,
  47. TE_EOS_SETTLEMENT =103,
  48. TE_EOS_TRANSFER =104,
  49. TE_EOS_CANCEL_ALL_ORDERS =105,
  50. TE_EOS_ROLLOVER =106,
  51. TE_EOS_LAST =TE_EOS_ROLLOVER,
  52. //--- balance operations
  53. TE_BALANCE_FIRST =150,
  54. TE_BALANCE_CHANGE =150,
  55. TE_BALANCE_CORRECT =151,
  56. TE_BALANCE_UNBLOCK_PROFIT =152,
  57. TE_BALANCE_LAST =TE_BALANCE_UNBLOCK_PROFIT,
  58. //--- position modifications
  59. TE_POSITION_FIRST =200,
  60. TE_POSITION_CHANGE_ID =201,
  61. TE_POSITION_LAST =TE_POSITION_CHANGE_ID,
  62. //--- enumeration borders
  63. TE_FIRST =TE_ORDER_FIRST,
  64. TE_LAST =TE_POSITION_LAST
  65. };
  66. //--- execution flags
  67. enum EnFlags
  68. {
  69. TE_FLAG_NONE =0x00000000, // none
  70. TE_FLAG_BROADCAST =0x00000001, // broadcast execution will be send to all trade servers
  71. //--- enumeration borders
  72. TE_FLAG_ALL =TE_FLAG_BROADCAST
  73. };
  74. //--- common methods
  75. virtual void Release(void)=0;
  76. virtual MTAPIRES Assign(const IMTExecution* exec)=0;
  77. virtual MTAPIRES Clear(void)=0;
  78. virtual LPCWSTR Print(MTAPISTR& string) const=0;
  79. //--- id
  80. virtual UINT64 ID(void) const=0;
  81. virtual MTAPIRES ID(const UINT64 id)=0;
  82. //--- execution id in external system (exchange, ECN, etc)
  83. virtual LPCWSTR ExternalID(void) const=0;
  84. virtual MTAPIRES ExternalID(LPCWSTR id)=0;
  85. //--- execution action
  86. virtual UINT Action(void) const=0;
  87. virtual MTAPIRES Action(const UINT action)=0;
  88. //--- datetime
  89. virtual INT64 Datetime(void) const=0;
  90. virtual MTAPIRES Datetime(const INT64 datetime)=0;
  91. //--- login
  92. virtual UINT64 Login(void) const=0;
  93. virtual MTAPIRES Login(const UINT64 login)=0;
  94. //--- group
  95. virtual LPCWSTR Group(void) const=0;
  96. virtual MTAPIRES Group(LPCWSTR group)=0;
  97. //--- flags
  98. virtual UINT64 Flags(void) const=0;
  99. virtual MTAPIRES Flags(const UINT64 flags)=0;
  100. //--- symbol
  101. virtual LPCWSTR Symbol(void) const=0;
  102. virtual MTAPIRES Symbol(LPCWSTR symbol)=0;
  103. //--- digits
  104. virtual UINT Digits(void) const=0;
  105. //--- comment
  106. virtual LPCWSTR Comment(void) const=0;
  107. virtual MTAPIRES Comment(LPCWSTR comment)=0;
  108. //--- MT5 order ticket
  109. virtual UINT64 Order(void) const=0;
  110. virtual MTAPIRES Order(const UINT64 order)=0;
  111. //--- order ticket in external system (exchange, ECN, etc)
  112. virtual LPCWSTR OrderExternalID(void) const=0;
  113. virtual MTAPIRES OrderExternalID(LPCWSTR id)=0;
  114. //--- order type IMTOrder::EnOrderType
  115. virtual UINT OrderType(void) const=0;
  116. virtual MTAPIRES OrderType(const UINT type)=0;
  117. //--- order volume
  118. virtual UINT64 OrderVolume(void) const=0;
  119. virtual MTAPIRES OrderVolume(const UINT64 volume)=0;
  120. //--- order price
  121. virtual double OrderPrice(void) const=0;
  122. virtual MTAPIRES OrderPrice(const double price)=0;
  123. //--- order activation flags
  124. virtual UINT OrderActivationFlags(void) const=0;
  125. virtual MTAPIRES OrderActivationFlags(const UINT activation)=0;
  126. //--- deal ticket in external system (exchange, ECN, etc)
  127. virtual LPCWSTR DealExternalID(void) const=0;
  128. virtual MTAPIRES DealExternalID(LPCWSTR id)=0;
  129. //--- deal action IMTDeal::EnDealAction
  130. virtual UINT DealAction(void) const=0;
  131. virtual MTAPIRES DealAction(const UINT action)=0;
  132. //--- deal volume
  133. virtual UINT64 DealVolume(void) const=0;
  134. virtual MTAPIRES DealVolume(const UINT64 volume)=0;
  135. //--- unfilled order volume
  136. virtual UINT64 DealVolumeRemaind(void) const=0;
  137. virtual MTAPIRES DealVolumeRemaind(const UINT64 volume)=0;
  138. //--- deal price
  139. virtual double DealPrice(void) const=0;
  140. virtual MTAPIRES DealPrice(const double price)=0;
  141. //--- digits set
  142. virtual MTAPIRES Digits(const UINT digits)=0;
  143. //--- external system trade account (exchange, ECN, etc)
  144. virtual LPCWSTR ExternalAccount(void) const=0;
  145. virtual MTAPIRES ExternalAccount(LPCWSTR account)=0;
  146. //--- order trigger price
  147. virtual double OrderPriceTrigger(void) const=0;
  148. virtual MTAPIRES OrderPriceTrigger(const double price)=0;
  149. //--- EnOrderTime
  150. virtual UINT OrderTypeTime(void) const=0;
  151. virtual MTAPIRES OrderTypeTime(const UINT type)=0;
  152. //--- order expiration
  153. virtual INT64 OrderTimeExpiration(void) const=0;
  154. virtual MTAPIRES OrderTimeExpiration(const INT64 time)=0;
  155. //--- EnOrderFilling
  156. virtual UINT OrderTypeFill(void) const=0;
  157. virtual MTAPIRES OrderTypeFill(const UINT type)=0;
  158. //--- session start datetime
  159. virtual INT64 EOSSessionStart(void) const=0;
  160. virtual MTAPIRES EOSSessionStart(const INT64 start)=0;
  161. //--- session end datetime
  162. virtual INT64 EOSSessionEnd(void) const=0;
  163. virtual MTAPIRES EOSSessionEnd(const INT64 end)=0;
  164. //--- session settlement price
  165. virtual double EOSPriceSettlement(void) const=0;
  166. virtual MTAPIRES EOSPriceSettlement(const double price)=0;
  167. //--- profit conversion price
  168. virtual double EOSProfitRateBuy(void) const=0;
  169. virtual double EOSProfitRateSell(void) const=0;
  170. virtual MTAPIRES EOSProfitRate(const double rate_buy,const double rate_sell)=0;
  171. //--- tick value
  172. virtual double EOSTickValue(void) const=0;
  173. virtual MTAPIRES EOSTickValue(const double value)=0;
  174. //--- order price SL
  175. virtual double OrderPriceSL(void) const=0;
  176. virtual MTAPIRES OrderPriceSL(const double price)=0;
  177. //--- order price TP
  178. virtual double OrderPriceTP(void) const=0;
  179. virtual MTAPIRES OrderPriceTP(const double price)=0;
  180. //--- execution price on gateway
  181. virtual double PriceGateway(void) const=0;
  182. virtual MTAPIRES PriceGateway(const double price)=0;
  183. //--- order activation flags
  184. virtual UINT OrderActivationMode(void) const=0;
  185. virtual MTAPIRES OrderActivationMode(const UINT activation)=0;
  186. //--- deal commission
  187. virtual double DealCommission(void) const=0;
  188. virtual MTAPIRES DealCommission(const double comm)=0;
  189. //--- datetime in msc since 1970.01.01
  190. virtual INT64 DatetimeMsc(void) const=0;
  191. virtual MTAPIRES DatetimeMsc(const INT64 datetime)=0;
  192. //--- symbol field new value
  193. virtual LPCWSTR SymbolNew(void) const=0;
  194. virtual MTAPIRES SymbolNew(LPCWSTR symbol)=0;
  195. //--- internal data for API usage
  196. virtual MTAPIRES ApiDataUpdate(const UINT pos,const USHORT app_id,const UCHAR id,const INT64 value)=0;
  197. virtual MTAPIRES ApiDataUpdate(const UINT pos,const USHORT app_id,const UCHAR id,const UINT64 value)=0;
  198. virtual MTAPIRES ApiDataUpdate(const UINT pos,const USHORT app_id,const UCHAR id,const double value)=0;
  199. virtual MTAPIRES ApiDataNext(const UINT pos,USHORT& app_id,UCHAR& id,INT64& value) const=0;
  200. virtual MTAPIRES ApiDataNext(const UINT pos,USHORT& app_id,UCHAR& id,UINT64& value) const=0;
  201. virtual MTAPIRES ApiDataNext(const UINT pos,USHORT& app_id,UCHAR& id,double& value) const=0;
  202. //--- deal storage
  203. virtual double DealStorage(void) const=0;
  204. virtual MTAPIRES DealStorage(const double storage)=0;
  205. //--- rollover values
  206. virtual double EOSRolloverValueLong(void) const=0;
  207. virtual double EOSRolloverValueShort(void) const=0;
  208. virtual MTAPIRES EOSRolloverValue(const double value_long,const double value_short)=0;
  209. //--- deal reason
  210. virtual UINT DealReason(void) const=0;
  211. virtual MTAPIRES DealReason(const UINT reason)=0;
  212. //--- gateway id
  213. virtual UINT64 GatewayID(void) const=0;
  214. virtual MTAPIRES GatewayID(const UINT64 gateway_id)=0;
  215. //--- MT5 position ticket
  216. virtual UINT64 Position(void) const=0;
  217. virtual MTAPIRES Position(const UINT64 position)=0;
  218. //--- MT5 position ticket
  219. virtual UINT64 PositionBy(void) const=0;
  220. virtual MTAPIRES PositionBy(const UINT64 position)=0;
  221. //--- position ticket in external system (exchange, ECN, etc)
  222. virtual LPCWSTR PositionExternalID(void) const=0;
  223. virtual MTAPIRES PositionExternalID(LPCWSTR id)=0;
  224. //--- position ticket in external system (exchange, ECN, etc)
  225. virtual LPCWSTR PositionByExternalID(void) const=0;
  226. virtual MTAPIRES PositionByExternalID(LPCWSTR id)=0;
  227. //--- external trade system return code
  228. virtual int ExternalRetcode(void) const=0;
  229. virtual MTAPIRES ExternalRetcode(const int retcode)=0;
  230. //--- order volume with extendede accuracy
  231. virtual UINT64 OrderVolumeExt(void) const=0;
  232. virtual MTAPIRES OrderVolumeExt(const UINT64 volume)=0;
  233. //--- deal volume with extendede accuracy
  234. virtual UINT64 DealVolumeExt(void) const=0;
  235. virtual MTAPIRES DealVolumeExt(const UINT64 volume)=0;
  236. //--- unfilled order volume with extendede accuracy
  237. virtual UINT64 DealVolumeRemaindExt(void) const=0;
  238. virtual MTAPIRES DealVolumeRemaindExt(const UINT64 volume)=0;
  239. };
  240. //+------------------------------------------------------------------+