MT5APIConfigGateway.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. //+------------------------------------------------------------------+
  2. //| MetaTrader 5 API |
  3. //| Copyright 2000-2019, MetaQuotes Software Corp. |
  4. //| http://www.metaquotes.net |
  5. //+------------------------------------------------------------------+
  6. #pragma once
  7. //+------------------------------------------------------------------+
  8. //| Gateway module config |
  9. //+------------------------------------------------------------------+
  10. class IMTConGatewayModule
  11. {
  12. //--- changeable fields flags
  13. enum EnGatewayFieldMask
  14. {
  15. GATEWAY_FIELD_SERVER=1, // server field
  16. GATEWAY_FIELD_LOGIN =2, // login field
  17. GATEWAY_FIELD_PASS =4, // password field
  18. GATEWAY_FIELD_PARAM =8, // parameters
  19. //--- enumeration borders
  20. GATEWAY_FIELD_NONE =0,
  21. GATEWAY_FIELD_ALL =GATEWAY_FIELD_SERVER|GATEWAY_FIELD_LOGIN|GATEWAY_FIELD_PASS|GATEWAY_FIELD_PARAM
  22. };
  23. public:
  24. //--- common methods
  25. virtual void Release(void)=0;
  26. virtual MTAPIRES Assign(const IMTConGatewayModule* param)=0;
  27. virtual MTAPIRES Clear(void)=0;
  28. //--- default gateway name
  29. virtual LPCWSTR Name(void) const=0;
  30. //--- vendor name
  31. virtual LPCWSTR Vendor(void) const=0;
  32. //--- gateway description
  33. virtual LPCWSTR Description(void) const=0;
  34. //--- gateway file name
  35. virtual LPCWSTR Module(void) const=0;
  36. //--- gateway default server address for trading
  37. virtual LPCWSTR TradingServer(void) const=0;
  38. //--- gateway default login for trading
  39. virtual LPCWSTR TradingLogin(void) const=0;
  40. //--- gateway default password for trading
  41. virtual LPCWSTR TradingPassword(void) const=0;
  42. //--- gateway version
  43. virtual UINT Version(void) const=0;
  44. //--- gateway available flags (IMTConGateway::EnGatewayFlags)
  45. virtual UINT Flags(void) const=0;
  46. //--- changeable EnFeedersFieldFlags
  47. virtual UINT Fields(void) const=0;
  48. //--- default gateway parameters
  49. virtual UINT ParameterTotal(void) const=0;
  50. virtual MTAPIRES ParameterNext(const UINT pos,IMTConParam* param) const=0;
  51. virtual MTAPIRES ParameterGet(LPCWSTR name,IMTConParam* param) const=0;
  52. //--- gateway given name
  53. virtual LPCWSTR Gateway(void) const=0;
  54. };
  55. //+------------------------------------------------------------------+
  56. //| Symbols name and price translation config |
  57. //+------------------------------------------------------------------+
  58. class IMTConGatewayTranslate
  59. {
  60. public:
  61. //--- common methods
  62. virtual void Release(void)=0;
  63. virtual MTAPIRES Assign(const IMTConGatewayTranslate* param)=0;
  64. virtual MTAPIRES Clear(void)=0;
  65. //--- symbol name in datafeed
  66. virtual LPCWSTR Source(void) const=0;
  67. virtual MTAPIRES Source(LPCWSTR source)=0;
  68. //--- symbol name in MT5
  69. virtual LPCWSTR Symbol(void) const=0;
  70. virtual MTAPIRES Symbol(LPCWSTR symbol)=0;
  71. //--- bid markup in points
  72. virtual INT BidMarkup(void) const=0;
  73. virtual MTAPIRES BidMarkup(const INT markup)=0;
  74. //--- ask markup in points
  75. virtual INT AskMarkup(void) const=0;
  76. virtual MTAPIRES AskMarkup(const INT markup)=0;
  77. //--- digits
  78. virtual UINT Digits(void) const=0;
  79. };
  80. //+------------------------------------------------------------------+
  81. //| Gateway config interface |
  82. //+------------------------------------------------------------------+
  83. class IMTConGateway
  84. {
  85. public:
  86. //--- gateway working flags
  87. enum EnGatewayFlags
  88. {
  89. GATEWAY_FLAG_REMOTE =1, // gateway works as remote service
  90. GATEWAY_FLAG_IMPORT_SYMBOLS =2, // gateway can import symbols to MetaTrader platform
  91. GATEWAY_FLAG_IGNORE_QUOTES =4, // ignore quotes from gateway
  92. GATEWAY_FLAG_IMPORT_BALANCES=8, // gateway can import client balances to MetaTrader platform
  93. GATEWAY_FLAG_EXTENDED_LOG =16, // gateway writes extended log
  94. GATEWAY_FLAG_SUPP_POSITIONS =32, // gateway support request of trading positions from external trading system
  95. //--- flags borders
  96. GATEWAY_FLAG_NONE =0,
  97. GATEWAY_FLAG_ALL =GATEWAY_FLAG_REMOTE|GATEWAY_FLAG_IMPORT_SYMBOLS|
  98. GATEWAY_FLAG_IGNORE_QUOTES|GATEWAY_FLAG_IMPORT_BALANCES|
  99. GATEWAY_FLAG_EXTENDED_LOG|GATEWAY_FLAG_SUPP_POSITIONS
  100. };
  101. //--- gateway modes
  102. enum EnGatewayMode
  103. {
  104. GATEWAY_DISABLED =0,
  105. GATEWAY_ENABLED =1,
  106. //--- enumeration borders
  107. GATEWAY_FIRST =GATEWAY_DISABLED,
  108. GATEWAY_LAST =GATEWAY_ENABLED
  109. };
  110. //--- common methods
  111. virtual void Release(void)=0;
  112. virtual MTAPIRES Assign(const IMTConGateway* param)=0;
  113. virtual MTAPIRES Clear(void)=0;
  114. //--- gateway name
  115. virtual LPCWSTR Name(void) const=0;
  116. virtual MTAPIRES Name(LPCWSTR name)=0;
  117. //--- gateway trade request routing id (dealer id)
  118. virtual UINT64 ID(void) const=0;
  119. virtual MTAPIRES ID(const UINT64 id)=0;
  120. //--- gateway module name
  121. virtual LPCWSTR Module(void) const=0;
  122. virtual MTAPIRES Module(LPCWSTR name)=0;
  123. //--- gateway server address for trading
  124. virtual LPCWSTR TradingServer(void) const=0;
  125. virtual MTAPIRES TradingServer(LPCWSTR server)=0;
  126. //--- gateway login for trading
  127. virtual LPCWSTR TradingLogin(void) const=0;
  128. virtual MTAPIRES TradingLogin(LPCWSTR login)=0;
  129. //--- gateway password for trading
  130. virtual LPCWSTR TradingPassword(void) const=0;
  131. virtual MTAPIRES TradingPassword(LPCWSTR password)=0;
  132. //--- gateway server address
  133. virtual LPCWSTR GatewayServer(void) const=0;
  134. virtual MTAPIRES GatewayServer(LPCWSTR server)=0;
  135. //--- EnGatewayMode
  136. virtual UINT Mode(void) const=0;
  137. virtual MTAPIRES Mode(const UINT mode)=0;
  138. //--- EnGatewayFlags
  139. virtual UINT Flags(void) const=0;
  140. virtual MTAPIRES Flags(const UINT flags)=0;
  141. //--- obsolete value
  142. virtual UINT ObsoleteValue(void) const=0;
  143. virtual MTAPIRES ObsoleteValue(const UINT value)=0;
  144. //--- gateway reconnect timeout
  145. virtual UINT TimeoutReconnect(void) const=0;
  146. virtual MTAPIRES TimeoutReconnect(const UINT timeout)=0;
  147. //--- gateway sleep timeout
  148. virtual UINT TimeoutSleep(void) const=0;
  149. virtual MTAPIRES TimeoutSleep(const UINT timeout)=0;
  150. //--- gateway attempts before timeout
  151. virtual UINT TimeoutAttempts(void) const=0;
  152. virtual MTAPIRES TimeoutAttempts(const UINT attempts)=0;
  153. //--- gateway additional parameters access
  154. virtual MTAPIRES ParameterAdd(IMTConParam* param)=0;
  155. virtual MTAPIRES ParameterUpdate(const UINT pos,const IMTConParam* param)=0;
  156. virtual MTAPIRES ParameterDelete(const UINT pos)=0;
  157. virtual MTAPIRES ParameterClear(void)=0;
  158. virtual MTAPIRES ParameterShift(const UINT pos,const int shift)=0;
  159. virtual UINT ParameterTotal(void) const=0;
  160. virtual MTAPIRES ParameterNext(const UINT pos,IMTConParam* param) const=0;
  161. virtual MTAPIRES ParameterGet(LPCWSTR name,IMTConParam* param) const=0;
  162. //--- list of symbols for translating quotes
  163. virtual MTAPIRES SymbolAdd(LPCWSTR path)=0;
  164. virtual MTAPIRES SymbolUpdate(const UINT pos,LPCWSTR path)=0;
  165. virtual MTAPIRES SymbolDelete(const UINT pos)=0;
  166. virtual MTAPIRES SymbolClear(void)=0;
  167. virtual MTAPIRES SymbolShift(const UINT pos,const int shift)=0;
  168. virtual UINT SymbolTotal(void) const=0;
  169. virtual LPCWSTR SymbolNext(const UINT pos) const=0;
  170. //--- list of users groups who works through gateway
  171. virtual MTAPIRES GroupAdd(LPCWSTR path)=0;
  172. virtual MTAPIRES GroupUpdate(const UINT pos,LPCWSTR path)=0;
  173. virtual MTAPIRES GroupDelete(const UINT pos)=0;
  174. virtual MTAPIRES GroupClear(void)=0;
  175. virtual MTAPIRES GroupShift(const UINT pos,const int shift)=0;
  176. virtual UINT GroupTotal(void) const=0;
  177. virtual LPCWSTR GroupNext(const UINT pos) const=0;
  178. //--- list of symbols translations
  179. virtual MTAPIRES TranslateAdd(IMTConGatewayTranslate* param)=0;
  180. virtual MTAPIRES TranslateUpdate(const UINT pos,const IMTConGatewayTranslate* param)=0;
  181. virtual MTAPIRES TranslateDelete(const UINT pos)=0;
  182. virtual MTAPIRES TranslateClear(void)=0;
  183. virtual MTAPIRES TranslateShift(const UINT pos,const int shift)=0;
  184. virtual UINT TranslateTotal(void) const=0;
  185. virtual MTAPIRES TranslateNext(const UINT pos,IMTConGatewayTranslate* param) const=0;
  186. virtual MTAPIRES TranslateGet(LPCWSTR symbol,IMTConGatewayTranslate* param) const=0;
  187. //--- gateway server login
  188. virtual UINT64 GatewayLogin(void) const=0;
  189. virtual MTAPIRES GatewayLogin(UINT64 login)=0;
  190. //--- gateway server password
  191. virtual LPCWSTR GatewayPassword(void) const=0;
  192. virtual MTAPIRES GatewayPassword(LPCWSTR password)=0;
  193. //--- list of symbols translations
  194. virtual MTAPIRES TranslateGetSource(LPCWSTR source,IMTConGatewayTranslate* param) const=0;
  195. //--- gateway given name
  196. virtual LPCWSTR Gateway(void) const=0;
  197. //--- gateway state information
  198. virtual bool StateConnected(void) const=0;
  199. virtual UINT StateReceivedTicks(void) const=0;
  200. virtual UINT StateReceivedBooks(void) const=0;
  201. virtual UINT StateTrafficIn(void) const=0;
  202. virtual UINT StateTrafficOut(void) const=0;
  203. virtual UINT StateTradesTotal(void) const=0;
  204. virtual UINT StateTradesAverageTime(void) const=0;
  205. };
  206. //+------------------------------------------------------------------+
  207. //| Gateway config events notification interface |
  208. //+------------------------------------------------------------------+
  209. class IMTConGatewaySink
  210. {
  211. public:
  212. virtual void OnGatewayAdd(const IMTConGateway* /*gateway*/) { }
  213. virtual void OnGatewayUpdate(const IMTConGateway* /*gateway*/) { }
  214. virtual void OnGatewayDelete(const IMTConGateway* /*gateway*/) { }
  215. virtual void OnGatewaySync(void) { }
  216. };
  217. //+------------------------------------------------------------------+