MT4ManagerAPI.h 99 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848
  1. //+------------------------------------------------------------------+
  2. //| MetaTrader 4 Manager API |
  3. //| Copyright 2001-2017, MetaQuotes Software Corp. |
  4. //| http://www.metaquotes.net |
  5. //+------------------------------------------------------------------+
  6. //| DO NOT EDIT THIS FILE!!! |
  7. //+------------------------------------------------------------------+
  8. // NoStyler
  9. #pragma once
  10. //+------------------------------------------------------------------+
  11. //| API Version |
  12. //+------------------------------------------------------------------+
  13. #define ManAPIProgramVersion 400
  14. #define ManAPIProgramBuild 1090
  15. #define ManAPIVersion MAKELONG(ManAPIProgramBuild,ManAPIProgramVersion)
  16. //+------------------------------------------------------------------+
  17. //| MSVS6 Compatibility |
  18. //+------------------------------------------------------------------+
  19. #if _MSC_VER <= 1200
  20. #define __time32_t time_t
  21. #define __ptr32
  22. #endif
  23. //+------------------------------------------------------------------+
  24. //| Server Configurations |
  25. //+------------------------------------------------------------------+
  26. //| Configuration types |
  27. //+------------------------------------------------------------------+
  28. enum
  29. {
  30. CONFIG_ALL=0, // all configurations
  31. CONFIG_COMMON, // common configuration
  32. CONFIG_ACCESS, // IP access list configuration
  33. CONFIG_SERVERS, // data servers
  34. CONFIG_TIME, // working time configuration
  35. CONFIG_HOLIDAYS, // holidays configuration
  36. CONFIG_SYMBOLS, // symbols configuration
  37. CONFIG_SYMB_GROUPS, // securities configuration
  38. CONFIG_GROUPS, // groups configuration
  39. CONFIG_MANAGERS, // manager's rights configuration
  40. CONFIG_DATAFEEDS, // data feeds configuration
  41. CONFIG_BACKUP, // backups configuration
  42. CONFIG_LIVEUPDATE, // LiveUpdate configuration
  43. CONFIG_SYNC, // synchronization configuration
  44. CONFIG_PLUGINS, // plugins configuration
  45. CONFIG_GATEWAY_ACCOUNTS, // gateway accounts
  46. CONFIG_GATEWAY_MARKUPS, // gateway markups
  47. CONFIG_GATEWAY_RULES, // gateway rules
  48. CONFIG_END=255 // last (unused)
  49. };
  50. //+------------------------------------------------------------------+
  51. //| Configuration structures |
  52. //+------------------------------------------------------------------+
  53. //| Common configuration |
  54. //+------------------------------------------------------------------+
  55. struct ConCommon
  56. {
  57. char owner[128]; // servers owner (include version & build)
  58. char name[32]; // server name
  59. ULONG address; // IP address assigned to the server
  60. int port; // port
  61. DWORD timeout; // sockets timeout
  62. int typeofdemo; // demo-accounts type (DEMO_DISABLED, DEMO_PROLONG, DEMO_FIXED)
  63. int timeofdemo; // demo-account living time
  64. int daylightcorrection; // allow daylight correction
  65. char internal[60]; // reserved
  66. int timezone_real; // time zone with day light mode
  67. int timezone; // time zone 0-GMT;-1=GMT-1;1=GMT+1;
  68. char timesync[64]; // time synchronization server address
  69. //---
  70. int minclient; // minimal authorized client version
  71. int minapi; // minimal authorized client version
  72. DWORD feeder_timeout; // data feed switch timeout
  73. int keepemails; // internal mail keep period
  74. int endhour,endminute; // end of day time-hour & minute
  75. //---
  76. int optimization_time; // optimization start time (minutes)
  77. int optimization_lasttime; // optimization last time
  78. int optimization_counter; // internal variable
  79. int optimization_unused[8];// reserved for future use
  80. //---
  81. int antiflood; // enable antiflood control
  82. int floodcontrol; // max. antiflood connections
  83. //---
  84. int liveupdate_mode; // LiveUpdate mode (LIVE_UPDATE_NO,LIVE_UPDATE_ALL,LIVE_UPDATE_NO_SERVER)
  85. //---
  86. int lastorder; // last order's ticket (read only)
  87. int lastlogin; // last account's number (read only)
  88. int lostlogin; // lost commission's login (read only)
  89. //---
  90. int rollovers_mode; // rollover mode (ROLLOVER_NORMAL,ROLLOVER_REOPEN_BY_CLOSE_PRICE,ROLLOVER_REOPEN_BY_BID)
  91. //---
  92. char path_database[256]; // path to databases
  93. char path_history[256]; // path to history bases
  94. char path_log[256]; // path to log
  95. //--- overnigths
  96. __time32_t overnight_last_day; // day of last overnight
  97. __time32_t overnight_last_time; // time of last overnight
  98. __time32_t overnight_prev_time; // time of next to last overnight
  99. //--- month reports
  100. __time32_t overmonth_last_month; // month of last report
  101. //--- performance base
  102. char adapters[256]; // network adapters list (read-only)
  103. ULONG bind_adresses[8]; // array of avaible IP addresses
  104. short server_version; // server version
  105. short server_build; // server build
  106. ULONG web_adresses[8]; // web services access list (comma separated IP addresses)
  107. int statement_mode; // statement generation time (STATEMENT_END_DAY,STATEMENT_START_DAY)
  108. int monthly_state_mode; // monthly statement generation day (MONTHLY_STATEMENT_END_MONTH,MONTHLY_STATEMENT_START_MONTH)
  109. int keepticks; // ticks keep period
  110. int statement_weekend; // generate statements at weekends
  111. __time32_t last_activate; // last activation datetime
  112. __time32_t stop_last; // last stop datetime
  113. int stop_delay; // last stop delay
  114. int stop_reason; // last stop reason
  115. char account_url[128]; // account allocation URL
  116. int reserved[16];
  117. };
  118. //--- deno-accounts type
  119. enum { DEMO_DISABLED, DEMO_PROLONG, DEMO_FIXED };
  120. //--- rollover mode
  121. enum { ROLLOVER_NORMAL, ROLLOVER_REOPEN_BY_CLOSE_PRICE, ROLLOVER_REOPEN_BY_BID };
  122. //--- LiveUpdate mode
  123. enum { LIVE_UPDATE_NO=0, LIVE_UPDATE_RELEASE=1, LIVE_UPDATE_NO_SERVER=2, LIVE_UPDATE_BETA=3 };
  124. //--- statement mode
  125. enum { STATEMENT_END_DAY, STATEMENT_START_DAY };
  126. //--- monthly statement mode
  127. enum { MONTHLY_STATEMENT_END_MONTH, MONTHLY_STATEMENT_START_MONTH };
  128. //--- server stop reason
  129. enum { STOP_REASON_NONE, STOP_REASON_RESTART, STOP_REASON_SHUTDOWN, STOP_REASON_LIVEUPDATE };
  130. //+------------------------------------------------------------------+
  131. //| Access configuration |
  132. //+------------------------------------------------------------------+
  133. struct ConAccess
  134. {
  135. int action; // type of action (FW_BLOCK,FW_PERMIT)
  136. unsigned long from,to; // from, to addresses
  137. char comment[64]; // comment
  138. int reserved[17]; // reserved
  139. };
  140. //--- access action
  141. enum { FW_BLOCK,FW_PERMIT };
  142. //+------------------------------------------------------------------+
  143. //| Data Servers configuration |
  144. //+------------------------------------------------------------------+
  145. struct ConDataServer
  146. {
  147. char server[64]; // server address (server:ip)
  148. ULONG ip; // server IP
  149. char description[64]; // server description
  150. int isproxy; // can server be proxy?
  151. int priority; // priority: 0-7 base, 255-idle
  152. UINT loading; // server loading (UINT_MAX-server does not inform its loading)
  153. ULONG ip_internal; // internal IP address
  154. int reserved[2]; // reserved
  155. ConDataServer* __ptr32 next; // internal (not used)
  156. };
  157. //+------------------------------------------------------------------+
  158. //| Time configuration |
  159. //+------------------------------------------------------------------+
  160. struct ConTime
  161. {
  162. int days[7][24]; // server's accessebility (7 days-24 hours, 0-denied, 1-allowed)
  163. int dayscontrol; // internal variable
  164. int reserved[3]; // reserved
  165. };
  166. //+------------------------------------------------------------------+
  167. //| Backup configuration |
  168. //+------------------------------------------------------------------+
  169. struct ConBackup
  170. {
  171. //---
  172. char fullbackup_path[256]; // path to backup
  173. int fullbackup_period; // full backup's period-BACKUP_1HOUR, BACKUP_4HOURS, BACKUP_1DAY
  174. int fullbackup_store; // full backup's store time-BU_STORE_1MONTH, BU_STORE_3MONTHS, BU_STORE_6MONTHS,BU_STORE_1YEAR
  175. __time32_t fullbackup_lasttime; // full backup's last execution time
  176. short fullbackup_shift; // full backup timeshift (minutes)
  177. //---
  178. char external_path[256]; // path to external processing directory
  179. //---
  180. int archive_period; // period of archive backup-ARC_BACKUP_5MIN, ARC_BACKUP_15MIN, ARC_BACKUP_30MIN, ARC_BACKUP_1HOUR
  181. int archive_store; // archive backup's store time-ARC_STORE_1WEEK, ARC_STORE_2WEEKS, ARC_STORE_1MONTH, ARC_STORE_3MONTH, ARC_STORE_6MONTH
  182. __time32_t archive_lasttime; // archive backup's last execution time
  183. //---
  184. char export_securities[512]; // comma separated list of exported securities
  185. char export_path[256]; // path to export script
  186. int export_period; // export period-enumeration EXPORT_1MIN, EXPORT_5MIN, EXPORT_15MIN, EXPORT_30MIN,EXPORT_1HOUR
  187. __time32_t export_lasttime; // export's last execution time
  188. //--- watch dog
  189. int watch_role; // server role { WATCH_STAND_ALONE, WATCH_MASTER, WATCH_SLAVE }
  190. char watch_password[16]; // slave server password
  191. char watch_opposite[24]; // opposite server IP address and port
  192. int watch_ip; // opposite server IP
  193. //---
  194. char archive_shift; // shift of archive backup time (in minutes)
  195. //---
  196. char watch_state; // watch dog state
  197. char watch_failover; // watch dog failover mode
  198. unsigned char watch_timeout; // watch dog timeout
  199. int watch_login; // watch dog login
  200. __time32_t watch_timestamp; // watch dog timestamp
  201. };
  202. //--- server role
  203. enum { WATCH_STAND_ALONE,WATCH_MASTER,WATCH_SLAVE };
  204. //--- full backup execution periods: 1 hour, 4 hours, 1 day
  205. enum { BACKUP_1HOUR,BACKUP_4HOURS,BACKUP_1DAY };
  206. //--- full backup store period: 1 month, 3 months, 6 months, 1 year
  207. enum { BU_STORE_1MONTH,BU_STORE_3MONTHS,BU_STORE_6MONTHS,BU_STORE_1YEAR };
  208. //--- arc. backup execution periods: 5 min, 15 min, 30 min, 1 hour
  209. enum { ARC_BACKUP_DISABLED,ARC_BACKUP_5MIN,ARC_BACKUP_15MIN,ARC_BACKUP_30MIN,ARC_BACKUP_1HOUR };
  210. //--- arc. backup store period: 1 day, 3 days, 1 week, 2 weeks, 1 month,3 months, 6 months,1 year
  211. enum { ARC_STORE_1DAY,ARC_STORE_3DAYS,ARC_STORE_1WEEK,ARC_STORE_2WEEKS,ARC_STORE_1MONTH,ARC_STORE_3MONTH,ARC_STORE_6MONTH };
  212. //--- export execution period: 1 min, 5 min, 15 min, 30 min, 1 hour
  213. enum { EXPORT_1MIN,EXPORT_5MIN,EXPORT_15MIN,EXPORT_30MIN,EXPORT_1HOUR };
  214. //--- watchdog state
  215. enum { WS_DISCONNECTED, WS_SYNCHRONIZING, WS_SYNCHRONIZED };
  216. //--- watchdog failover mode
  217. enum { FAILOVER_OFF, FAILOVER_MOST, FAILOVER_FULL };
  218. //+------------------------------------------------------------------+
  219. //| Datafeed configuration |
  220. //+------------------------------------------------------------------+
  221. struct ConFeeder
  222. {
  223. char name[64]; // name
  224. char file[256]; // datafeed filename
  225. char server[64]; // server address
  226. char login[32]; // datafeed login
  227. char pass[32]; // datafeed password
  228. char keywords[256]; // keywords (news filtration)
  229. int enable; // enable feeder
  230. int mode; // datafeed mode-enumeration FEED_QUOTES, FEED_NEWS, FEED_QUOTESNEWS
  231. int timeout; // max. freeze time (default ~120 sec.)
  232. int timeout_reconnect; // reconnect timeout before attemps_sleep connect attempts (default ~ 5 sec)
  233. int timeout_sleep; // reconnect timeout after attemps_sleep connect attempts (default ~ 60 sec)
  234. int attemps_sleep; // reconnect count (see timeout_reconnect & timeout_sleep)
  235. int news_langid; // news language id
  236. int unused[33]; // reserved
  237. };
  238. //--- datafeed modes-receive quotes, receive news, receive quotes and news
  239. enum { FEED_QUOTES=0, FEED_NEWS=1, FEED_QUOTESNEWS=2 };
  240. //+------------------------------------------------------------------+
  241. //| Security group configuration for client group |
  242. //+------------------------------------------------------------------+
  243. #define MAX_SEC_GROUPS (32)
  244. #define MAX_SEC_GROPS_MARGIN (128)
  245. //---
  246. struct ConGroupSec
  247. {
  248. int show,trade; // enable show and trade for this group of securites
  249. int execution; // dealing mode-EXECUTION_MANUAL,EXECUTION_AUTO,EXECUTION_ACTIVITY
  250. //--- comission settings
  251. double comm_base; // standart commission
  252. int comm_type; // commission type-COMM_TYPE_MONEY,COMM_TYPE_PIPS,COMM_TYPE_PERCENT
  253. int comm_lots; // commission lots mode-COMMISSION_PER_LOT,COMMISSION_PER_DEAL
  254. double comm_agent; // agent commission
  255. int comm_agent_type; // agent commission mode-COMM_TYPE_MONEY, COMM_TYPE_PIPS
  256. //---
  257. int spread_diff; // spread difference in compare with default security spread
  258. //---
  259. int lot_min,lot_max; // allowed minimal and maximal lot values
  260. int lot_step; // allowed step value (10 lot-1000, 1 lot-100, 0.1 lot-10)
  261. int ie_deviation; // maximum price deviation in Instant Execution mode
  262. int confirmation; // use confirmation in Request mode
  263. int trade_rights; // clients trade rights-bit mask see TRADE_DENY_NONE,TRADE_DENY_CLOSEBY,TRADE_DENY_MUCLOSEBY
  264. int ie_quick_mode; // do not resend request to the dealer when client uses deviation
  265. int autocloseout_mode; // auto close-out method { CLOSE_OUT_NONE, CLOSE_OUT_HIHI, CLOSE_OUT_LOLO, CLOSE_OUT_HILO, CLOSE_OUT_LOHI, CLOSE_OUT_LOHI, CLOSE_OUT_FIFO, CLOSE_OUT_LIFO, CLOSE_OUT_INTRDAY_FIFO }
  266. double comm_tax; // commission taxes
  267. int comm_agent_lots; // agent commission per lot/per deal { COMMISSION_PER_LOT,COMMISSION_PER_DEAL }
  268. int freemargin_mode; // "soft" margin check
  269. int reserved[3]; // reserved
  270. };
  271. //+------------------------------------------------------------------+
  272. //| Special securities configurations for client group |
  273. //+------------------------------------------------------------------+
  274. struct ConGroupMargin
  275. {
  276. char symbol[12]; // security
  277. double swap_long,swap_short; // swap size for long and short positions
  278. double margin_divider; // margin divider
  279. int reserved[7];
  280. };
  281. //--- dealing mode
  282. enum { EXECUTION_MANUAL, EXECUTION_AUTO, EXECUTION_ACTIVITY };
  283. //--- commission type
  284. enum { COMM_TYPE_MONEY, COMM_TYPE_PIPS, COMM_TYPE_PERCENT };
  285. //--- comission lots mode
  286. enum { COMMISSION_PER_LOT, COMMISSION_PER_DEAL };
  287. //--- clients trade rights
  288. enum { TRADE_DENY_NONE=0, TRADE_DENY_CLOSEBY=1, TRADE_DENY_MUCLOSEBY=2 };
  289. //--- auto close-out method
  290. enum { CLOSE_OUT_NONE, CLOSE_OUT_HIHI, CLOSE_OUT_LOLO, CLOSE_OUT_HILO, CLOSE_OUT_LOHI, CLOSE_OUT_FIFO, CLOSE_OUT_LIFO, CLOSE_OUT_INTRDAY_FIFO };
  291. //+------------------------------------------------------------------+
  292. //| Client group configuration |
  293. //+------------------------------------------------------------------+
  294. struct ConGroup
  295. {
  296. //--- common settings
  297. char group[16]; // group name
  298. int enable; // enable group
  299. int timeout; // trade confirmation timeout (seconds)
  300. int otp_mode; // one-time password mode
  301. //--- statements
  302. char company[128]; // company name
  303. char signature[128]; // statements signature
  304. char support_page[128]; // company support page
  305. char smtp_server[64]; // statements SMTP server
  306. char smtp_login[32]; // statements SMTP login
  307. char smtp_password[32]; // statements SMTP password
  308. char support_email[64]; // support email
  309. char templates[32]; // path to directory with custom templates
  310. int copies; // copy statements on support email
  311. int reports; // enable statements
  312. //--- default settings
  313. int default_leverage; // default leverage (user don't specify leverage himself)
  314. double default_deposit; // default deposit (user don't specify balance himself)
  315. //--- securities
  316. int maxsecurities; // maximum simultaneous securities
  317. ConGroupSec secgroups[MAX_SEC_GROUPS]; // security group settings
  318. ConGroupMargin secmargins[MAX_SEC_GROPS_MARGIN]; // special securities settings
  319. int secmargins_total; // count of special securities settings
  320. //--- margin & interest
  321. char currency[12]; // deposit currency
  322. double credit; // virtual credit
  323. int margin_call; // margin call level (percents)
  324. int margin_mode; // margin mode-MARGIN_DONT_USE,MARGIN_USE_ALL,MARGIN_USE_PROFIT,MARGIN_USE_LOSS
  325. int margin_stopout; // stop out level
  326. double interestrate; // annual interest rate (percents)
  327. int use_swap; // use rollovers & interestrate
  328. //--- rights
  329. int news; // news mode
  330. int rights; // rights bit mask-ALLOW_FLAG_EMAIL
  331. int check_ie_prices; // check IE prices on requests
  332. int maxpositions; // maximum orders and open positions
  333. int close_reopen; // partial close mode (if !=0 original position will be fully closed and remain position will be fully reopened)
  334. int hedge_prohibited; // hedge prohibition flag
  335. int close_fifo; // fifo rule
  336. int hedge_largeleg; // use large leg margin for hedged positions
  337. int unused_rights[2]; // reserved
  338. char securities_hash[16]; // internal data
  339. //---
  340. int margin_type; // margin controlling type { MARGIN_TYPE_PERCENT, MARGIN_TYPE_CURRENCY }
  341. //--- archives
  342. int archive_period; // inactivity period after which account moves to archive base (in days)
  343. int archive_max_balance; // maxumum balance of accounts to move in archive base
  344. //---
  345. int stopout_skip_hedged; // skip fully hedged accounts when checking for stopout
  346. int archive_pending_period; // pendings clean period
  347. //--- allowed news languages
  348. UINT news_languages[8]; // LANGID array
  349. UINT news_languages_total; // news languages total
  350. //--- reserved
  351. int reserved[17];
  352. };
  353. //--- margin calculation mode
  354. enum { MARGIN_MODE_DONT_USE,MARGIN_MODE_USE_ALL,MARGIN_MODE_USE_PROFIT,MARGIN_MODE_USE_LOSS };
  355. //--- margin controlling type
  356. enum { MARGIN_TYPE_PERCENT, MARGIN_TYPE_CURRENCY };
  357. //--- news mode-no news, only topics, full news (topic+body)
  358. enum { NEWS_NO, NEWS_TOPICS, NEWS_FULL };
  359. //--- group rights
  360. enum
  361. {
  362. ALLOW_FLAG_EMAIL =1,
  363. ALLOW_FLAG_TRAILING =2,
  364. ALLOW_FLAG_ADVISOR =4,
  365. ALLOW_FLAG_EXPIRATION =8,
  366. ALLOW_FLAG_SIGNALS_ALL =16,
  367. ALLOW_FLAG_SIGNALS_OWN =32,
  368. ALLOW_FLAG_RISK_WARNING =64,
  369. ALLOW_FLAG_FORCED_OTP_USAGE=128,
  370. };
  371. //--- group one-time password mode
  372. enum
  373. {
  374. OTP_MODE_DISABLED =0,
  375. OTP_MODE_TOTP_SHA256 =1,
  376. };
  377. //+------------------------------------------------------------------+
  378. //| Hollidays configuration |
  379. //+------------------------------------------------------------------+
  380. struct ConHoliday
  381. {
  382. int year; // year
  383. int month; // month
  384. int day; // day
  385. int from,to; // work time-from & to (minutes)
  386. char symbol[32]; // security name or symbol's group name or "All"
  387. char description[128]; // description
  388. int enable; // enable
  389. int reserved[13]; // reserved
  390. ConHoliday * __ptr32 next; // internal data
  391. };
  392. //+------------------------------------------------------------------+
  393. //| LiveUpdate configuration |
  394. //+------------------------------------------------------------------+
  395. #define LIVE_FILES_MAX (128)
  396. //---
  397. struct LiveInfoFile
  398. {
  399. char file[256]; // file name
  400. int size; // file size
  401. char hash[36]; // file hash
  402. int reserved[10]; // reserved
  403. };
  404. //---
  405. struct ConLiveUpdate
  406. {
  407. char company[128]; // company
  408. char path[256]; // path to LiveUpdate
  409. int version; // version
  410. int build; // build
  411. int maxconnect; // max. simultaneous connections
  412. int connections; // current connections (read only)
  413. int type; // type LIVE_UPDATE_*
  414. int enable; // enable
  415. int totalfiles; // total files count
  416. LiveInfoFile files[LIVE_FILES_MAX]; // files' configurations
  417. int reserved[16]; // reserved
  418. ConLiveUpdate * __ptr32 next; // internal data
  419. };
  420. //--- LiveUpdate type
  421. enum
  422. {
  423. LIVE_UPDATE_CLIENT,
  424. LIVE_UPDATE_MANAGER,
  425. LIVE_UPDATE_ADMIN,
  426. LIVE_UPDATE_DATACENTER,
  427. LIVE_UPDATE_CLIENT_PPC2002,
  428. LIVE_UPDATE_CLIENT_PPC2003,
  429. LIVE_UPDATE_MULTI,
  430. LIVE_UPDATE_WD,
  431. LIVE_UPDATE_CLIENT_PHONE,
  432. LIVE_UPDATE_LAST
  433. };
  434. //+------------------------------------------------------------------+
  435. //| Manager rights for security groups |
  436. //+------------------------------------------------------------------+
  437. struct ConManagerSec
  438. {
  439. int internal; // internal data
  440. int enable; // enable
  441. int minimum_lots; // min. lots
  442. int maximum_lots; // max. lots
  443. int unused[16]; // reserved
  444. };
  445. //+------------------------------------------------------------------+
  446. //| Manager configuration |
  447. //+------------------------------------------------------------------+
  448. struct ConManager
  449. {
  450. int login; // login
  451. //--- rights
  452. int manager; // right to add & change client records
  453. int money; // right to balance & credit management
  454. int online; // right to see online users
  455. int riskman; // right to use analyzer
  456. int broker; // right to deal
  457. int admin; // right to server administration
  458. int logs; // right to see logs
  459. int reports; // right to see reports
  460. int trades; // right to add/modify/delete trades
  461. int market_watch; // right to change spread, spread balance, stop levels, execution mode and send quotes
  462. int email; // right to send internal mail
  463. int user_details; // right to see clients private data-name,country,address,phone,email etc.
  464. int see_trades; // right to see trades
  465. int news; // right to send news
  466. int plugins; // right to configure plugins
  467. int server_reports; // right to receive server reports
  468. int techsupport; // right to access to technical support page
  469. int market; // right to access server applications market
  470. int notifications; // right to push notifications
  471. int unused[9];
  472. //--- IP filtration
  473. int ipfilter; // enable IP control
  474. unsigned long ip_from,ip_to; // range of allowed IPs
  475. //---
  476. char mailbox[64]; // name of mailbox for internal mail
  477. char groups[1024]; // comma separated list of managed groups (allowed '*' wildcard)
  478. ConManagerSec secgroups[MAX_SEC_GROUPS]; // manager rights for security groups
  479. DWORD exp_time; // internal data
  480. char name[32]; // manager name (read only)
  481. int info_depth; // maximum available data (in days)
  482. //---
  483. int reserved[22];
  484. };
  485. //+------------------------------------------------------------------+
  486. //| Symbol configurations |
  487. //+------------------------------------------------------------------+
  488. //| Symbol sessions configurations |
  489. //+------------------------------------------------------------------+
  490. struct ConSession
  491. {
  492. short open_hour,open_min; // session open time: hour & minute
  493. short close_hour,close_min; // session close time: hour & minute
  494. int open,close; // internal data
  495. short align[7]; // internal data
  496. };
  497. //---
  498. struct ConSessions
  499. {
  500. //---
  501. ConSession quote[3]; // quote sessions
  502. ConSession trade[3]; // trade sessions
  503. //---
  504. int quote_overnight; // internal data
  505. int trade_overnight; // internal data
  506. int reserved[2]; // reserved
  507. };
  508. //+------------------------------------------------------------------+
  509. //| Symbol configuration |
  510. //+------------------------------------------------------------------+
  511. #define MAX_SYMBOLS 1024
  512. //---
  513. struct ConSymbol
  514. {
  515. //--- common settings
  516. char symbol[12]; // name
  517. char description[64]; // description
  518. char source[12]; // synonym
  519. char currency[12]; // currency
  520. int type; // security group (see ConSymbolGroup)
  521. int digits; // security precision
  522. int trade; // trade mode
  523. //--- external settings
  524. COLORREF background_color; // background color
  525. int count; // symbols index
  526. int count_original; // symbols index in market watch
  527. int external_unused[7];
  528. //--- sessions
  529. int realtime; // allow real time quotes
  530. __time32_t starting; // trades starting date (UNIX time)
  531. __time32_t expiration; // trades end date (UNIX time)
  532. ConSessions sessions[7]; // quote & trade sessions
  533. //--- profits
  534. int profit_mode; // profit calculation mode
  535. int profit_reserved; // reserved
  536. //--- filtration
  537. int filter; // filter value
  538. int filter_counter; // filtration parameter
  539. double filter_limit; // max. permissible deviation from last quote (percents)
  540. int filter_smoothing; // smoothing
  541. float filter_reserved; // reserved
  542. int logging; // enable to log quotes
  543. //--- spread & swaps
  544. int spread; // spread
  545. int spread_balance; // spread balance
  546. int exemode; // execution mode
  547. int swap_enable; // enable swaps
  548. int swap_type; // swap type
  549. double swap_long,swap_short; // swaps values for long & short postions
  550. int swap_rollover3days; // triple rollover day-0-Monday,1-Tuesday...4-Friday
  551. double contract_size; // contract size
  552. double tick_value; // one tick value
  553. double tick_size; // one tick size
  554. int stops_level; // stops deviation value
  555. //---
  556. int gtc_pendings; // GTC mode { ORDERS_DAILY, ORDERS_GTC, ORDERS_DAILY_NO_STOPS }
  557. //--- margin calculation
  558. int margin_mode; // margin calculation mode
  559. double margin_initial; // initial margin
  560. double margin_maintenance; // margin maintenance
  561. double margin_hedged; // hedged margin
  562. double margin_divider; // margin divider
  563. //--- calclulated variables (internal data)
  564. double point; // point size-(1/(10^digits)
  565. double multiply; // multiply 10^digits
  566. double bid_tickvalue; // tickvalue for bid
  567. double ask_tickvalue; // tickvalue for ask
  568. //---
  569. int long_only; // allow only BUY positions
  570. int instant_max_volume; // max. volume for Instant Execution
  571. //---
  572. char margin_currency[12]; // currency of margin requirments
  573. int freeze_level; // modification freeze level
  574. int margin_hedged_strong; // strong hedged margin mode
  575. __time32_t value_date; // value date
  576. int quotes_delay; // quotes delay after session start
  577. int swap_openprice; // use open price at swaps calculation in SWAP_BY_INTEREST mode
  578. int swap_variation_margin; // charge variation margin on rollover
  579. //---
  580. int unused[21]; // reserved
  581. };
  582. //+------------------------------------------------------------------+
  583. //| Symbols enumeration |
  584. //+------------------------------------------------------------------+
  585. //--- symbol execution mode
  586. enum { EXE_REQUEST,EXE_INSTANT,EXE_MARKET };
  587. //--- trade mode
  588. enum { TRADE_NO,TRADE_CLOSE,TRADE_FULL };
  589. //--- swap type
  590. enum { SWAP_BY_POINTS,SWAP_BY_DOLLARS,SWAP_BY_INTEREST,SWAP_BY_MARGIN_CURRENCY };
  591. //--- profit calculation mode
  592. enum { PROFIT_CALC_FOREX,PROFIT_CALC_CFD,PROFIT_CALC_FUTURES };
  593. //--- margin calculation mode
  594. enum { MARGIN_CALC_FOREX,MARGIN_CALC_CFD,MARGIN_CALC_FUTURES,MARGIN_CALC_CFDINDEX,MARGIN_CALC_CFDLEVERAGE };
  595. //--- GTC mode
  596. enum { ORDERS_DAILY, ORDERS_GTC, ORDERS_DAILY_NO_STOPS };
  597. //+------------------------------------------------------------------+
  598. //| Symbol groups |
  599. //+------------------------------------------------------------------+
  600. #define MAX_SEC_GROUP (32)
  601. struct ConSymbolGroup
  602. {
  603. char name[16]; // group name
  604. char description[64]; // group description
  605. };
  606. //+------------------------------------------------------------------+
  607. //| Synchronization configuration |
  608. //+------------------------------------------------------------------+
  609. struct ConSync
  610. {
  611. char server[64]; // name (address
  612. int unusedport; // port
  613. char login[32]; // for future use-login
  614. char password[32]; // for future use=password
  615. int enable; // enable sychronization
  616. int mode; // synchronization mode: HB_ADD,HB_UPDATE,HB_INSERT
  617. __time32_t from,to; // synchronization range (<0-whole chart)
  618. char securities[1024]; // symbols list
  619. int timecorrection; // time correction in minutes
  620. int reserved[13]; // reserved
  621. ConSync * __ptr32 next; // internal (do not use)
  622. };
  623. //--- synchronization mode
  624. enum { HB_ADD,HB_UPDATE,HB_INSERT,HB_DELETE,HB_LAST };
  625. //+------------------------------------------------------------------+
  626. //| Plugin configuration |
  627. //+------------------------------------------------------------------+
  628. //| Plugin description |
  629. //+------------------------------------------------------------------+
  630. struct PluginInfo
  631. {
  632. char name[128]; // plugin name
  633. unsigned int version; // plugin version
  634. char copyright[128]; // plugin copyright
  635. int reserved[32]; // reserved
  636. };
  637. //+------------------------------------------------------------------+
  638. //| Plugin configuration parameter |
  639. //+------------------------------------------------------------------+
  640. struct PluginCfg
  641. {
  642. char name[32]; // parameter name
  643. char value[128]; // parameter value
  644. int reserved[16]; // reserved
  645. };
  646. //+------------------------------------------------------------------+
  647. //| Plugin configuration |
  648. //+------------------------------------------------------------------+
  649. struct ConPlugin
  650. {
  651. char file[256]; // plugin file name
  652. PluginInfo info; // plugin description
  653. int enabled; // plugin enabled/disabled
  654. int configurable; // is plugin configurable
  655. int manager_access; // plugin can be accessed from manager terminal
  656. int reserved[62]; // reserved
  657. };
  658. //--- plugin with parameters
  659. struct ConPluginParam
  660. {
  661. ConPlugin plugin; // plugin configuration
  662. PluginCfg* __ptr32 params; // plugin parameters
  663. int total; // total plugin parameters
  664. };
  665. //+------------------------------------------------------------------+
  666. //| Gateway configuration |
  667. //+------------------------------------------------------------------+
  668. //+------------------------------------------------------------------+
  669. //| Gateway account configuration |
  670. //+------------------------------------------------------------------+
  671. struct ConGatewayAccount
  672. {
  673. int enable; // enable flag 0 - disabled, 1 - enabled
  674. char name[64]; // public name
  675. int id; // internal id
  676. int type; // type (obsolete)
  677. int login; // STP MT4 login
  678. char address[64]; // MT4 server address
  679. char password[64]; // STP MT4 password
  680. int notify_logins[8]; // list of logins for internal email notification
  681. int flags; // flag fields
  682. int reserved[23]; // reserved
  683. };
  684. //--- gateway account flags
  685. enum EnGatewayAccountFlags { GATEWAY_FLAG_NONE=0, GATEWAY_FLAG_QUOTES=1 };
  686. //+------------------------------------------------------------------+
  687. //| Gateway markup configuration |
  688. //+------------------------------------------------------------------+
  689. struct ConGatewayMarkup
  690. {
  691. int enable; // enable flag 0 - disabled, 1 - enabled
  692. char source[128]; // source symbol\symbols mask\symbols group name
  693. char symbol[12]; // local symbol name
  694. char account_name[64]; // account name (obsolete)
  695. int account_id; // account internal id (obsolete)
  696. int bid_markup; // bid markup in pips
  697. int ask_markup; // ask markup in pips
  698. int reserved[16]; // reserved
  699. };
  700. //+------------------------------------------------------------------+
  701. //| Gateway rules configuration |
  702. //+------------------------------------------------------------------+
  703. struct ConGatewayRule
  704. {
  705. int enable; // enable flag 0 - disabled, 1 - enabled
  706. char name[64]; // public name
  707. char request_symbol[128]; // symbol\symbols mask\symbols group name
  708. char request_group[128]; // group name or group mask
  709. int request_reserved[32]; // reserved
  710. char exe_account_name[64]; // account name
  711. int exe_account_id; // account internal id
  712. int exe_max_deviation; // max. devation
  713. int exe_max_profit_slippage; // max profit slippage in pips
  714. int exe_max_profit_slippage_lots; // max profit slippage volume in lots
  715. int exe_max_losing_slippage; // max losing slippage in pips
  716. int exe_max_losing_slippage_lots; // max losing slippage volume in lots
  717. int exe_account_pos; // account current position
  718. int exe_volume_percent; // coverage percentage
  719. int exe_reserved[26]; // reserved
  720. };
  721. //+------------------------------------------------------------------+
  722. //| Result codes |
  723. //+------------------------------------------------------------------+
  724. enum
  725. {
  726. //--- common errors
  727. RET_OK =0, // all OK
  728. RET_OK_NONE, // all OK-no operation
  729. RET_ERROR, // general error
  730. RET_INVALID_DATA, // invalid data
  731. RET_TECH_PROBLEM, // server technical problem
  732. RET_OLD_VERSION, // old client terminal
  733. RET_NO_CONNECT, // no connection
  734. RET_NOT_ENOUGH_RIGHTS, // no enough rights
  735. RET_TOO_FREQUENT, // too frequently access to server
  736. RET_MALFUNCTION, // mulfunctional operation
  737. RET_GENERATE_KEY, // need to send public key
  738. RET_SECURITY_SESSION, // security session start
  739. //--- account status
  740. RET_ACCOUNT_DISABLED =64, // account blocked
  741. RET_BAD_ACCOUNT_INFO, // bad account info
  742. RET_PUBLIC_KEY_MISSING, // public key missing on external auth
  743. //--- trade
  744. RET_TRADE_TIMEOUT =128, // trade transatcion timeou expired
  745. RET_TRADE_BAD_PRICES, // order has wrong prices
  746. RET_TRADE_BAD_STOPS, // wrong stops level
  747. RET_TRADE_BAD_VOLUME, // wrong lot size
  748. RET_TRADE_MARKET_CLOSED, // market closed
  749. RET_TRADE_DISABLE, // trade disabled
  750. RET_TRADE_NO_MONEY, // no enough money for order execution
  751. RET_TRADE_PRICE_CHANGED, // price changed
  752. RET_TRADE_OFFQUOTES, // no quotes
  753. RET_TRADE_BROKER_BUSY, // broker is busy
  754. RET_TRADE_REQUOTE, // requote
  755. RET_TRADE_ORDER_LOCKED, // order is proceed by dealer and cannot be changed
  756. RET_TRADE_LONG_ONLY, // allowed only BUY orders
  757. RET_TRADE_TOO_MANY_REQ, // too many requests from one client
  758. //--- order status notification
  759. RET_TRADE_ACCEPTED, // trade request accepted by server and placed in request queue
  760. RET_TRADE_PROCESS, // trade request accepted by dealerd
  761. RET_TRADE_USER_CANCEL, // trade request canceled by client
  762. //--- additional return codes
  763. RET_TRADE_MODIFY_DENIED, // trade modification denied
  764. RET_TRADE_CONTEXT_BUSY, // trade context is busy (used in client terminal)
  765. RET_TRADE_EXPIRATION_DENIED, // using expiration date denied
  766. RET_TRADE_TOO_MANY_ORDERS, // too many orders
  767. RET_TRADE_HEDGE_PROHIBITED, // hedge is prohibited
  768. RET_TRADE_PROHIBITED_BY_FIFO // prohibited by fifo rule
  769. };
  770. //+------------------------------------------------------------------+
  771. //| Pumping mode flags |
  772. //+------------------------------------------------------------------+
  773. enum
  774. {
  775. //--- user flags
  776. CLIENT_FLAGS_HIDETICKS =1, // do not send ticks
  777. CLIENT_FLAGS_HIDENEWS =2, // do not send news
  778. CLIENT_FLAGS_HIDEMAIL =4, // do not send mails
  779. CLIENT_FLAGS_SENDFULLNEWS=8, // send news body with news header in pumping mode
  780. CLIENT_FLAGS_RESERVED =16, // reserved
  781. //--- manager flags
  782. CLIENT_FLAGS_HIDEONLINE =32, // do not send online users table
  783. CLIENT_FLAGS_HIDEUSERS =64 // do not send users table
  784. };
  785. //+------------------------------------------------------------------+
  786. //| Server datafeed descritopn |
  787. //+------------------------------------------------------------------+
  788. struct FeedDescription
  789. {
  790. int version; // data source version
  791. char name[128]; // data source name
  792. char copyright[128]; // copyright string
  793. char web[128]; // data source web
  794. char email[128]; // data source email
  795. char server[128]; // feeder server
  796. char username[32]; // default feeder name
  797. char userpass[32]; // default feeder password
  798. int modes; // feeder modes (enum FeederModes)
  799. char description[512]; // feeder description
  800. char module[32]; // datafeed name in license
  801. int reserved[54]; // reserved
  802. };
  803. //--- feeder modes
  804. enum FeederModes
  805. {
  806. modeOnlyQuotes =0, // only quotes feeder
  807. modeOnlyNews =1, // only news feeder
  808. modeQuotesAndNews =2, // quotes and news feeder
  809. modeQuotesOrNews =3 // quotes or news feeder
  810. };
  811. //--- server datafeed
  812. struct ServerFeed
  813. {
  814. char file[256]; // feeder file name
  815. FeedDescription feed; // feeder description
  816. };
  817. //+------------------------------------------------------------------+
  818. //| Charts |
  819. //+------------------------------------------------------------------+
  820. //| Request chart history struct |
  821. //+------------------------------------------------------------------+
  822. struct ChartInfo
  823. {
  824. char symbol[12]; // symbol
  825. int period; // period (PERIOD_*)
  826. __time32_t start; // start of chart block
  827. __time32_t end; // end of chart block
  828. __time32_t timesign; // timestamp of existing chart base
  829. int mode; // request mode
  830. };
  831. //--- chart period
  832. enum { PERIOD_M1=1, PERIOD_M5=5, PERIOD_M15=15, PERIOD_M30=30,
  833. PERIOD_H1=60, PERIOD_H4=240, PERIOD_D1=1440, PERIOD_W1=10080,
  834. PERIOD_MN1=43200 };
  835. //--- request mode
  836. enum { CHART_RANGE_IN,CHART_RANGE_OUT,CHART_RANGE_LAST };
  837. //+------------------------------------------------------------------+
  838. //| Rate the in chart base |
  839. //+------------------------------------------------------------------+
  840. #pragma pack(push,1)
  841. struct RateInfoOld
  842. {
  843. __time32_t ctm; // rate time
  844. int open; // open price: 11987=119.87
  845. short high,low,close; // high,low,close shift from open
  846. double vol; // volume
  847. };
  848. struct RateInfo
  849. {
  850. __time32_t ctm; // rate time
  851. int open; // open price: 11987=119.87
  852. int high,low,close; // high,low,close shift from open
  853. double vol; // volume
  854. };
  855. #pragma pack(pop)
  856. //+------------------------------------------------------------------+
  857. //| Tick record in base |
  858. //+------------------------------------------------------------------+
  859. #pragma pack(push,1)
  860. struct TickRecord
  861. {
  862. __time32_t ctm; // tick time
  863. double bid,ask; // bid, ask
  864. int datafeed; // index if datafeed
  865. char flags; // TICK_FLAG_* flags
  866. };
  867. #pragma pack(pop)
  868. //---
  869. enum { TICK_FLAG_RAW=1, TICK_FLAG_NORMAL=2,TICK_FLAG_ALL=TICK_FLAG_RAW+TICK_FLAG_NORMAL };
  870. //+------------------------------------------------------------------+
  871. //| Tick request |
  872. //+------------------------------------------------------------------+
  873. #pragma pack(push,1)
  874. struct TickRequest
  875. {
  876. char symbol[12]; // symbol
  877. __time32_t from; // start of period
  878. __time32_t to; // end of period
  879. char flags; // TICK_FLAG_* flags
  880. };
  881. #pragma pack(pop)
  882. //+------------------------------------------------------------------+
  883. //| Performance information |
  884. //+------------------------------------------------------------------+
  885. #pragma pack(push,1)
  886. struct PerformanceInfo
  887. {
  888. __time32_t ctm;
  889. short users; // online users
  890. short cpu; // processor loading (%)
  891. int freemem; // free memory (Kb)
  892. int network; // network activity (Kb/s)
  893. int sockets; // all open sockets in system
  894. };
  895. #pragma pack(pop)
  896. //+------------------------------------------------------------------+
  897. //| Backup file information |
  898. //+------------------------------------------------------------------+
  899. struct BackupInfo
  900. {
  901. char file[256]; // file name
  902. int size; // file size
  903. __time32_t time; // file time
  904. int reserved[6]; // reserved
  905. };
  906. //--- backup mode
  907. enum
  908. {
  909. BACKUPS_ALL, // all backup
  910. BACKUPS_PERIODICAL, // periodical backups
  911. BACKUPS_STARTUP, // backups on startup
  912. BACKUPS_DELETE // backups on delete
  913. };
  914. //+------------------------------------------------------------------+
  915. //| Databases |
  916. //+------------------------------------------------------------------+
  917. //| Transaction types |
  918. //+------------------------------------------------------------------+
  919. enum { TRANS_ADD, TRANS_DELETE, TRANS_UPDATE, TRANS_CHANGE_GRP };
  920. //+------------------------------------------------------------------+
  921. //| User Record |
  922. //+------------------------------------------------------------------+
  923. #define PUBLIC_KEY_SIZE 272 // RSA key size // (((1024+64)/32)*4*2)
  924. #define USER_COLOR_NONE (0xFF000000) // default user color
  925. //---
  926. struct UserRecord
  927. {
  928. //--- common settings
  929. int login; // login
  930. char group[16]; // group
  931. char password[16]; // password
  932. //--- access flags
  933. int enable; // enable
  934. int enable_change_password; // allow to change password
  935. int enable_read_only; // allow to open/positions (TRUE-may not trade)
  936. int enable_otp; // allow to use one-time password
  937. int enable_reserved[2]; // for future use
  938. //---
  939. char password_investor[16]; // read-only mode password
  940. char password_phone[32]; // phone password
  941. char name[128]; // name
  942. char country[32]; // country
  943. char city[32]; // city
  944. char state[32]; // state
  945. char zipcode[16]; // zipcode
  946. char address[96]; // address
  947. char lead_source[32]; // lead source
  948. char phone[32]; // phone
  949. char email[48]; // email
  950. char comment[64]; // comment
  951. char id[32]; // SSN (IRD)
  952. char status[16]; // status
  953. __time32_t regdate; // registration date
  954. __time32_t lastdate; // last coonection time
  955. //--- trade settings
  956. int leverage; // leverage
  957. int agent_account; // agent account
  958. __time32_t timestamp; // timestamp
  959. int last_ip; // last visit ip
  960. //--- trade data
  961. double balance; // balance
  962. double prevmonthbalance; // previous month balance
  963. double prevbalance; // previous day balance
  964. double credit; // credit
  965. double interestrate; // accumulated interest rate
  966. double taxes; // taxes
  967. double prevmonthequity; // previous month equity
  968. double prevequity; // previous day equity
  969. double reserved2[2]; // for future use
  970. //---
  971. char otp_secret[32]; // one-time password secret
  972. char secure_reserved[240]; // secure data reserved
  973. int send_reports; // enable send reports by email
  974. unsigned int mqid; // MQ client identificator
  975. COLORREF user_color; // color got to client (used by MT Manager)
  976. //---
  977. char unused[40]; // for future use
  978. char api_data[16]; // for API usage
  979. };
  980. //+------------------------------------------------------------------+
  981. //| Users group operation |
  982. //+------------------------------------------------------------------+
  983. #pragma pack(push,1)
  984. struct GroupCommandInfo
  985. {
  986. int len; // length of users list
  987. char command; // group coommand
  988. char newgroup[16]; // new group
  989. int leverage; // new leverage
  990. int reserved[8]; // reserved
  991. };
  992. #pragma pack(pop)
  993. //--- group commands
  994. enum { GROUP_DELETE,GROUP_ENABLE,GROUP_DISABLE,GROUP_LEVERAGE,GROUP_SETGROUP };
  995. //+------------------------------------------------------------------+
  996. //| Online user description |
  997. //+------------------------------------------------------------------+
  998. struct OnlineRecord
  999. {
  1000. int counter; // connections counter
  1001. int reserved; // reserved
  1002. int login; // user login
  1003. UINT ip; // connection ip address
  1004. char group[16]; // user group
  1005. };
  1006. //+------------------------------------------------------------------+
  1007. //| Trade Record |
  1008. //+------------------------------------------------------------------+
  1009. #pragma pack(push,1)
  1010. struct TradeRecord
  1011. {
  1012. int order; // order ticket
  1013. int login; // owner's login
  1014. char symbol[12]; // security
  1015. int digits; // security precision
  1016. int cmd; // trade command
  1017. int volume; // volume
  1018. //---
  1019. __time32_t open_time; // open time
  1020. int state; // reserved
  1021. double open_price; // open price
  1022. double sl,tp; // stop loss & take profit
  1023. __time32_t close_time; // close time
  1024. int gw_volume; // gateway order volume
  1025. __time32_t expiration; // pending order's expiration time
  1026. char reason; // trade reason
  1027. char conv_reserv[3]; // reserved fields
  1028. double conv_rates[2]; // convertation rates from profit currency to group deposit currency
  1029. // (first element-for open time, second element-for close time)
  1030. double commission; // commission
  1031. double commission_agent; // agent commission
  1032. double storage; // order swaps
  1033. double close_price; // close price
  1034. double profit; // profit
  1035. double taxes; // taxes
  1036. int magic; // special value used by client experts
  1037. char comment[32]; // comment
  1038. int gw_order; // gateway order ticket
  1039. int activation; // used by MT Manager
  1040. short gw_open_price; // gateway order price deviation (pips) from order open price
  1041. short gw_close_price; // gateway order price deviation (pips) from order close price
  1042. double margin_rate; // margin convertation rate (rate of convertation from margin currency to deposit one)
  1043. __time32_t timestamp; // timestamp
  1044. int api_data[4]; // for api usage
  1045. TradeRecord *__ptr32 next; // internal data
  1046. };
  1047. #pragma pack(pop)
  1048. //--- trade commands
  1049. enum { OP_BUY=0,OP_SELL,OP_BUY_LIMIT,OP_SELL_LIMIT,OP_BUY_STOP,OP_SELL_STOP,OP_BALANCE,OP_CREDIT };
  1050. //--- trade record state
  1051. enum { TS_OPEN_NORMAL, TS_OPEN_REMAND, TS_OPEN_RESTORED, TS_CLOSED_NORMAL, TS_CLOSED_PART, TS_CLOSED_BY, TS_DELETED };
  1052. //--- trade record reasons
  1053. enum
  1054. {
  1055. TR_REASON_CLIENT =0, // client terminal
  1056. TR_REASON_EXPERT =1, // expert
  1057. TR_REASON_DEALER =2, // dealer
  1058. TR_REASON_SIGNAL =3, // signal
  1059. TR_REASON_GATEWAY=4, // gateway
  1060. TR_REASON_MOBILE =5, // mobile terminal
  1061. TR_REASON_WEB =6, // Web terminal
  1062. TR_REASON_API =7, // API
  1063. };
  1064. //--- activation types
  1065. //--- *_ROLLBACK=current price roll back from activation price level
  1066. enum
  1067. {
  1068. //--- no activation
  1069. ACTIVATION_NONE=0,
  1070. //--- stoploss, takeprofit, pendings
  1071. ACTIVATION_SL,ACTIVATION_TP,ACTIVATION_PENDING,
  1072. //--- stopout
  1073. ACTIVATION_STOPOUT,
  1074. //--- rollbacks
  1075. ACTIVATION_SL_ROLLBACK =-ACTIVATION_SL,
  1076. ACTIVATION_TP_ROLLBACK =-ACTIVATION_TP,
  1077. ACTIVATION_PENDING_ROLLBACK=-ACTIVATION_PENDING,
  1078. ACTIVATION_STOPOUT_ROLLBACK=-ACTIVATION_STOPOUT
  1079. };
  1080. //+------------------------------------------------------------------+
  1081. //| TradeRecord restoring from backup result |
  1082. //+------------------------------------------------------------------+
  1083. #pragma pack(push,1)
  1084. struct TradeRestoreResult
  1085. {
  1086. int order; // order
  1087. UCHAR res; // RET_OK - order restored
  1088. // RET_ERROR - error restoring order
  1089. };
  1090. #pragma pack(pop)
  1091. //+------------------------------------------------------------------+
  1092. //| Trade transaction |
  1093. //+------------------------------------------------------------------+
  1094. #pragma pack(push,1)
  1095. struct TradeTransInfo
  1096. {
  1097. UCHAR type; // trade transaction type
  1098. char flags; // flags
  1099. short cmd; // trade command
  1100. int order,orderby; // order, order by
  1101. char symbol[12]; // trade symbol
  1102. int volume; // trade volume
  1103. double price; // trade price
  1104. double sl,tp; // stoploss, takeprofit
  1105. int ie_deviation; // deviation on IE
  1106. char comment[32]; // comment
  1107. __time32_t expiration; // pending order expiration time
  1108. int crc; // crc
  1109. };
  1110. #pragma pack(pop)
  1111. //--- trade transaction types
  1112. enum
  1113. {
  1114. //---
  1115. TT_PRICES_GET, // prices requets
  1116. TT_PRICES_REQUOTE, // requote
  1117. //--- client trade transaction
  1118. TT_ORDER_IE_OPEN=64, // open order (Instant Execution)
  1119. TT_ORDER_REQ_OPEN, // open order (Request Execution)
  1120. TT_ORDER_MK_OPEN, // open order (Market Execution)
  1121. TT_ORDER_PENDING_OPEN, // open pending order
  1122. //---
  1123. TT_ORDER_IE_CLOSE, // close order (Instant Execution)
  1124. TT_ORDER_REQ_CLOSE, // close order (Request Execution)
  1125. TT_ORDER_MK_CLOSE, // close order (Market Execution)
  1126. //---
  1127. TT_ORDER_MODIFY, // modify pending order
  1128. TT_ORDER_DELETE, // delete pending order
  1129. TT_ORDER_CLOSE_BY, // close order by order
  1130. TT_ORDER_CLOSE_ALL, // close all orders by symbol
  1131. //--- broker trade transactions
  1132. TT_BR_ORDER_OPEN, // open order
  1133. TT_BR_ORDER_CLOSE, // close order
  1134. TT_BR_ORDER_DELETE, // delete order (ANY OPEN ORDER!!!)
  1135. TT_BR_ORDER_CLOSE_BY, // close order by order
  1136. TT_BR_ORDER_CLOSE_ALL, // close all orders by symbol
  1137. TT_BR_ORDER_MODIFY, // modify open price, stoploss, takeprofit etc. of order
  1138. TT_BR_ORDER_ACTIVATE, // activate pending order
  1139. TT_BR_ORDER_COMMENT, // modify comment of order
  1140. TT_BR_BALANCE // balance/credit
  1141. };
  1142. //--- trade request flags
  1143. enum EnReqFlags
  1144. {
  1145. TT_FLAG_NONE =0x00000000, // flags none
  1146. TT_FLAG_SIGNAL =0x00000001, // placed by signal
  1147. TT_FLAG_EXPERT =0x00000002, // placed by expert
  1148. TT_FLAG_GATEWAY=0x00000004, // placed by gateway
  1149. TT_FLAG_MOBILE =0x00000008, // placed by mobile terminal
  1150. TT_FLAG_WEB =0x00000010, // placed by web terminal
  1151. TT_FLAG_API =0x00000020, // placed by api
  1152. };
  1153. //+------------------------------------------------------------------+
  1154. //| Margin level of the user |
  1155. //+------------------------------------------------------------------+
  1156. struct MarginLevel
  1157. {
  1158. int login; // user login
  1159. char group[16]; // user group
  1160. int leverage; // user leverage
  1161. int updated; // (internal)
  1162. double balance; // balance+credit
  1163. double equity; // equity
  1164. int volume; // lots
  1165. double margin; // margin requirements
  1166. double margin_free; // free margin
  1167. double margin_level; // margin level
  1168. int margin_type; // margin controlling type (percent/currency)
  1169. int level_type; // level type(ok/margincall/stopout)
  1170. };
  1171. //--- margin level type
  1172. enum { MARGINLEVEL_OK=0, MARGINLEVEL_MARGINCALL, MARGINLEVEL_STOPOUT };
  1173. //+------------------------------------------------------------------+
  1174. //| Trade request |
  1175. //+------------------------------------------------------------------+
  1176. struct RequestInfo
  1177. {
  1178. //--- general props
  1179. int id; // request id
  1180. char status; // request status
  1181. DWORD time; // request time
  1182. int manager; // manager processing request (if any)
  1183. //--- user info
  1184. int login; // user login
  1185. char group[16]; // user group
  1186. double balance; // user balance
  1187. double credit; // user credit
  1188. //--- processing trade transaction
  1189. double prices[2]; // bid/ask
  1190. TradeTransInfo trade; // trade transaction
  1191. int gw_volume; // gateway order volume
  1192. int gw_order; // gateway order ticket
  1193. short gw_price; // gateway order price deviation (pips) from request price
  1194. //---
  1195. RequestInfo* __ptr32 prev;
  1196. RequestInfo* __ptr32 next; // (internal use)
  1197. };
  1198. //--- trade request status
  1199. enum { DC_EMPTY,DC_REQUEST,DC_LOCKED,DC_ANSWERED,DC_RESETED,DC_CANCELED };
  1200. //--- time conversion ratio
  1201. #define TIME_RATE ((double)1.6777216)
  1202. //--- conversion from our time to standard __time32_t
  1203. #define STDTIME(custom_time) ((DWORD)((double)(custom_time)*TIME_RATE))
  1204. //--- conversion from standard __time32_t to our time
  1205. #define OURTIME(stdtime) ((DWORD)((double)(stdtime)/TIME_RATE))
  1206. //--- request confirmation modes
  1207. enum EnConfirmModes
  1208. {
  1209. CONFIRM_MODE_ADD_PRICES=0x00000001, // throw in prices
  1210. CONFIRM_MODE_PACKET =0x00000002 // multiple execution
  1211. };
  1212. //+------------------------------------------------------------------+
  1213. //| Daily report |
  1214. //+------------------------------------------------------------------+
  1215. struct DailyReport
  1216. {
  1217. int login; // login
  1218. __time32_t ctm; // time
  1219. char group[16]; // group
  1220. char bank[64]; // bank
  1221. double balance_prev; // previous balance
  1222. double balance; // balance
  1223. double deposit; // deposit
  1224. double credit; // credit
  1225. double profit_closed; // closed profit/loss
  1226. double profit; // floating profit/loss
  1227. double equity; // equity
  1228. double margin; // used margin
  1229. double margin_free; // free margin
  1230. //---
  1231. int next; // (internal)
  1232. int reserved[3]; // reserved
  1233. };
  1234. //+------------------------------------------------------------------+
  1235. //| Reports request |
  1236. //+------------------------------------------------------------------+
  1237. #pragma pack(push,1)
  1238. struct ReportGroupRequest
  1239. {
  1240. char name[32]; // request group name
  1241. __time32_t from; // from
  1242. __time32_t to; // to
  1243. int total; // total logins in request group
  1244. };
  1245. #pragma pack(pop)
  1246. //+------------------------------------------------------------------+
  1247. //| Daily reports request |
  1248. //+------------------------------------------------------------------+
  1249. struct DailyGroupRequest
  1250. {
  1251. char name[32]; // group name
  1252. __time32_t from; // from
  1253. __time32_t to; // to
  1254. int total; // total logins in request group
  1255. int reserved; // reserved
  1256. };
  1257. //+------------------------------------------------------------------+
  1258. //| Selected symbol information |
  1259. //+------------------------------------------------------------------+
  1260. struct SymbolInfo
  1261. {
  1262. char symbol[12]; // symbol name
  1263. int digits; // floating point digits
  1264. int count; // symbol counter
  1265. int visible; // visibility
  1266. //---
  1267. int type; // symbol type (symbols group index)
  1268. double point; // symbol point=1/pow(10,digits)
  1269. int spread; // symbol spread
  1270. int spread_balance; // spread balance
  1271. //---
  1272. int direction; // direction
  1273. int updateflag; // update flag
  1274. __time32_t lasttime; // last tick time
  1275. double bid,ask; // bid, ask
  1276. double high,low; // high, low
  1277. double commission; // commission
  1278. int comm_type; // commission type
  1279. };
  1280. //--- symbol price direction
  1281. enum { SDIR_UP,SDIR_DOWN,SDIR_NONE };
  1282. //+------------------------------------------------------------------+
  1283. //| Symbol summary |
  1284. //+------------------------------------------------------------------+
  1285. struct SymbolSummary
  1286. {
  1287. char symbol[12]; // symbol
  1288. int count; // symbol counter
  1289. int digits; // floating point digits
  1290. int type; // symbol type (symbol group index)
  1291. //--- clients summary
  1292. int orders; // number of client orders
  1293. __int64 buylots; // buy volume
  1294. __int64 selllots; // sell volume
  1295. double buyprice; // average buy price
  1296. double sellprice; // average sell price
  1297. double profit; // clients profit
  1298. //--- coverage summary
  1299. int covorders; // number of coverage orders
  1300. __int64 covbuylots; // buy volume
  1301. __int64 covselllots; // sell volume
  1302. double covbuyprice; // average buy price
  1303. double covsellprice; // average sell price
  1304. double covprofit; // coverage profit
  1305. };
  1306. //+------------------------------------------------------------------+
  1307. //| Currence exposure |
  1308. //+------------------------------------------------------------------+
  1309. struct ExposureValue
  1310. {
  1311. char currency[4]; // currency
  1312. double clients; // clients volume
  1313. double coverage; // coverage volume
  1314. };
  1315. //+------------------------------------------------------------------+
  1316. //| Symbol properties |
  1317. //+------------------------------------------------------------------+
  1318. #pragma pack(push,1)
  1319. struct SymbolPropertiesOld
  1320. {
  1321. char symbol[12]; // symbol
  1322. COLORREF color; // symbol color
  1323. int spread; // symbol spread
  1324. int spread_balance; // spread balance
  1325. int stops_level; // stops level
  1326. int exemode; // execution mode
  1327. };
  1328. #pragma pack(pop)
  1329. //---
  1330. #pragma pack(push,1)
  1331. struct SymbolProperties
  1332. {
  1333. char symbol[12]; // symbol
  1334. COLORREF color; // symbol color
  1335. int spread; // symbol spread
  1336. int spread_balance; // spread balance
  1337. int stops_level; // stops level
  1338. int smoothing; // smoothing
  1339. int exemode; // execution mode
  1340. int reserved[8]; // reserved
  1341. };
  1342. #pragma pack(pop)
  1343. //+------------------------------------------------------------------+
  1344. //| Symbol tick |
  1345. //+------------------------------------------------------------------+
  1346. struct TickInfo
  1347. {
  1348. char symbol[12]; // symbol
  1349. __time32_t ctm; // tick time
  1350. double bid; // bid
  1351. double ask; // ask
  1352. };
  1353. //+------------------------------------------------------------------+
  1354. //| Mail |
  1355. //+------------------------------------------------------------------+
  1356. struct MailBox
  1357. {
  1358. __time32_t time; // receive time
  1359. int sender; // mail sender (login)
  1360. char from[64]; // mail sender (name)
  1361. int to; // mail recipient
  1362. char subject[128]; // mail sumbect
  1363. int readed; // readed flag
  1364. char* __ptr32 body; // pointer to mail body
  1365. int bodylen; // mail body length
  1366. short build_min; // minimum build
  1367. short build_max; // maximum build
  1368. int reserved; // reserved
  1369. };
  1370. //+------------------------------------------------------------------+
  1371. //| News topic |
  1372. //+------------------------------------------------------------------+
  1373. struct NewsTopic
  1374. {
  1375. ULONG key; // news key
  1376. __time32_t time; // news time
  1377. char ctm[32]; // news source time ("yyyy/mm/dd hh:mm:ss")
  1378. char topic[256]; // news topic
  1379. char category[64]; // news category
  1380. char keywords[256]; // news keywords
  1381. char* __ptr32 body; // body (if present)
  1382. int bodylen; // body length
  1383. int readed; // readed flag
  1384. int priority; // news priority: 0-general, 1-high
  1385. int langid; // news LANGID
  1386. int reserved[1];
  1387. };
  1388. //+------------------------------------------------------------------+
  1389. //| Extended news structure |
  1390. //+------------------------------------------------------------------+
  1391. #pragma pack(push,1)
  1392. struct NewsTopicNew
  1393. {
  1394. //--- constants
  1395. enum constants
  1396. {
  1397. MAX_NEWS_BODY_LEN=15*1024*1024 // max. body len
  1398. };
  1399. //--- news topic flags
  1400. enum EnNewsFlags
  1401. {
  1402. FLAG_PRIORITY =1, // priority flag
  1403. FLAG_CALENDAR =2, // calendar item flag
  1404. FLAG_MIME =4, // MIME news content
  1405. FLAG_ALLOW_DEMO =8 // allow body for demo accounts
  1406. };
  1407. ULONG key; // news key
  1408. UINT language; // news language (WinAPI LANGID)
  1409. wchar_t subject[256]; // news subject
  1410. wchar_t category[256]; // news category
  1411. UINT flags; // EnNewsFlags
  1412. wchar_t* __ptr32 body; // body
  1413. UINT body_len; // body length
  1414. UINT languages_list[32]; // list of languages available for news
  1415. INT64 datetime; // news time
  1416. UINT reserved[30]; // reserved
  1417. };
  1418. #pragma pack(pop)
  1419. //+------------------------------------------------------------------+
  1420. //| Server journal record |
  1421. //+------------------------------------------------------------------+
  1422. struct ServerLog
  1423. {
  1424. int code; // code
  1425. char time[24]; // time
  1426. char ip[256]; // ip
  1427. char message[512]; // message
  1428. };
  1429. //--- log record codes
  1430. enum EnErrLogTypes {
  1431. CmdOK, // OK
  1432. CmdTrade, // trades only
  1433. CmdLogin, // logins only
  1434. CmdWarn, // warnings
  1435. CmdErr, // errors
  1436. CmdAtt // attention, important errors
  1437. };
  1438. //--- request logs type
  1439. enum EnLogType {
  1440. LOG_TYPE_STANDARD=0, // all except logins
  1441. LOG_TYPE_LOGINS =1, // logins only
  1442. LOG_TYPE_TRADES =2, // trades only
  1443. LOG_TYPE_ERRORS =3, // errors
  1444. LOG_TYPE_FULL =4, // full log
  1445. //---
  1446. LOG_TYPE_UPDATER =16, // live update
  1447. LOG_TYPE_SENDMAIL=17, // send mail
  1448. LOG_TYPE_FAILOVER=18 // failover
  1449. };
  1450. //--- request logs type
  1451. enum EnLogMode {
  1452. LOG_MODE_ENABLED, // manager api logs enabled
  1453. LOG_MODE_DISABLED, // manager api logs disabled
  1454. };
  1455. //+------------------------------------------------------------------+
  1456. //| Balance check |
  1457. //+------------------------------------------------------------------+
  1458. #pragma pack(push,1)
  1459. struct BalanceDiff
  1460. {
  1461. int login;
  1462. double diff;
  1463. };
  1464. #pragma pack(pop)
  1465. //+------------------------------------------------------------------+
  1466. //| Pumping notification codes |
  1467. //+------------------------------------------------------------------+
  1468. enum
  1469. {
  1470. PUMP_START_PUMPING=0, // pumping started
  1471. PUMP_UPDATE_SYMBOLS, // update symbols
  1472. PUMP_UPDATE_GROUPS, // update groups
  1473. PUMP_UPDATE_USERS, // update users
  1474. PUMP_UPDATE_ONLINE, // update online users
  1475. PUMP_UPDATE_BIDASK, // update bid/ask
  1476. PUMP_UPDATE_NEWS, // update news
  1477. PUMP_UPDATE_NEWS_BODY, // update news body
  1478. PUMP_UPDATE_MAIL, // update news
  1479. PUMP_UPDATE_TRADES, // update trades
  1480. PUMP_UPDATE_REQUESTS, // update trade requests
  1481. PUMP_UPDATE_PLUGINS, // update server plugins
  1482. PUMP_UPDATE_ACTIVATION, // new order for activation (sl/sp/stopout)
  1483. PUMP_UPDATE_MARGINCALL, // new margin calls
  1484. PUMP_STOP_PUMPING, // pumping stopped
  1485. PUMP_PING, // ping
  1486. PUMP_UPDATE_NEWS_NEW, // update news in new format (NewsTopicNew structure)
  1487. };
  1488. //+------------------------------------------------------------------+
  1489. //| Dealing notification codes |
  1490. //+------------------------------------------------------------------+
  1491. enum
  1492. {
  1493. DEAL_START_DEALING=0, // dealing dispatcher started
  1494. DEAL_REQUEST_NEW, // new request
  1495. DEAL_STOP_DEALING // dealing dispatcher stopped
  1496. };
  1497. //+------------------------------------------------------------------+
  1498. //| Notification callback function |
  1499. //+------------------------------------------------------------------+
  1500. typedef void (__stdcall *MTAPI_NOTIFY_FUNC)(int code);
  1501. //+------------------------------------------------------------------+
  1502. //| Notification callback function |
  1503. //+------------------------------------------------------------------+
  1504. typedef void (__stdcall *MTAPI_NOTIFY_FUNC_EX)(int code,int type,void * data,void *param);
  1505. //+------------------------------------------------------------------+
  1506. //| MetaTrader Manager Interface |
  1507. //+------------------------------------------------------------------+
  1508. class CManagerInterface
  1509. {
  1510. public:
  1511. //--- dummy methods for delphi
  1512. virtual int __stdcall QueryInterface(REFIID riid,LPVOID* obj)=0;
  1513. virtual int __stdcall AddRef() =0;
  1514. //--- release
  1515. virtual int __stdcall Release()=0;
  1516. //--- service methods
  1517. virtual void __stdcall MemFree(void* ptr) =0;
  1518. virtual LPCSTR __stdcall ErrorDescription(const int code)=0;
  1519. virtual void __stdcall WorkingDirectory(LPCSTR path) =0;
  1520. //--- connection
  1521. virtual int __stdcall Connect(LPCSTR server) =0;
  1522. virtual int __stdcall Disconnect() =0;
  1523. virtual int __stdcall IsConnected() =0;
  1524. virtual int __stdcall Login(const int login,LPCSTR password)=0;
  1525. virtual int __stdcall LoginSecured(LPCSTR key_path) =0;
  1526. virtual int __stdcall KeysSend(LPCSTR key_path) =0;
  1527. virtual int __stdcall Ping() =0;
  1528. virtual int __stdcall PasswordChange(LPCSTR pass,const int is_investor)=0;
  1529. virtual int __stdcall ManagerRights(ConManager *man) =0;
  1530. //--- server administration commands
  1531. virtual int __stdcall SrvRestart() =0;
  1532. virtual int __stdcall SrvChartsSync() =0;
  1533. virtual int __stdcall SrvLiveUpdateStart()=0;
  1534. virtual int __stdcall SrvFeedsRestart() =0;
  1535. //--- server configuration
  1536. //--- configuration request
  1537. virtual int __stdcall CfgRequestCommon(ConCommon *cfg)=0;
  1538. virtual int __stdcall CfgRequestTime(ConTime *cfg) =0;
  1539. virtual int __stdcall CfgRequestBackup(ConBackup *cfg)=0;
  1540. virtual int __stdcall CfgRequestSymbolGroup(ConSymbolGroup *cfg)=0;
  1541. virtual ConAccess* __stdcall CfgRequestAccess(int *total) =0;
  1542. virtual ConDataServer* __stdcall CfgRequestDataServer(int *total)=0;
  1543. virtual ConHoliday* __stdcall CfgRequestHoliday(int *total) =0;
  1544. virtual ConSymbol* __stdcall CfgRequestSymbol(int *total) =0;
  1545. virtual ConGroup* __stdcall CfgRequestGroup(int *total) =0;
  1546. virtual ConManager* __stdcall CfgRequestManager(int *total) =0;
  1547. virtual ConFeeder* __stdcall CfgRequestFeeder(int *total) =0;
  1548. virtual ConLiveUpdate* __stdcall CfgRequestLiveUpdate(int *total)=0;
  1549. virtual ConSync* __stdcall CfgRequestSync(int *total) =0;
  1550. virtual ConPluginParam* __stdcall CfgRequestPlugin(int *total) =0;
  1551. //--- configuration update
  1552. virtual int __stdcall CfgUpdateCommon(const ConCommon* cfg) =0;
  1553. virtual int __stdcall CfgUpdateAccess(const ConAccess* cfg,const int pos) =0;
  1554. virtual int __stdcall CfgUpdateDataServer(const ConDataServer *cfg,const int pos) =0;
  1555. virtual int __stdcall CfgUpdateTime(const ConTime *cfg) =0;
  1556. virtual int __stdcall CfgUpdateHoliday(const ConHoliday *cfg,const int pos) =0;
  1557. virtual int __stdcall CfgUpdateSymbol(const ConSymbol *cfg) =0;
  1558. virtual int __stdcall CfgUpdateSymbolGroup(const ConSymbolGroup *cfg,const int pos)=0;
  1559. virtual int __stdcall CfgUpdateGroup(const ConGroup *cfg) =0;
  1560. virtual int __stdcall CfgUpdateManager(const ConManager *cfg) =0;
  1561. virtual int __stdcall CfgUpdateFeeder(const ConFeeder *cfg) =0;
  1562. virtual int __stdcall CfgUpdateBackup(const ConBackup *cfg) =0;
  1563. virtual int __stdcall CfgUpdateLiveUpdate(const ConLiveUpdate *cfg) =0;
  1564. virtual int __stdcall CfgUpdateSync(const ConSync *cfg) =0;
  1565. virtual int __stdcall CfgUpdatePlugin(const ConPlugin *cfg,const PluginCfg *parupd,const int total)=0;
  1566. //--- configuration delete
  1567. virtual int __stdcall CfgDeleteAccess(const int pos) =0;
  1568. virtual int __stdcall CfgDeleteDataServer(const int pos)=0;
  1569. virtual int __stdcall CfgDeleteHoliday(const int pos) =0;
  1570. virtual int __stdcall CfgDeleteSymbol(const int pos) =0;
  1571. virtual int __stdcall CfgDeleteGroup(const int pos) =0;
  1572. virtual int __stdcall CfgDeleteManager(const int pos) =0;
  1573. virtual int __stdcall CfgDeleteFeeder(const int pos) =0;
  1574. virtual int __stdcall CfgDeleteLiveUpdate(const int pos)=0;
  1575. virtual int __stdcall CfgDeleteSync(const int pos) =0;
  1576. //--- configuration shift
  1577. virtual int __stdcall CfgShiftAccess(const int pos,const int shift) =0;
  1578. virtual int __stdcall CfgShiftDataServer(const int pos,const int shift)=0;
  1579. virtual int __stdcall CfgShiftHoliday(const int pos,const int shift) =0;
  1580. virtual int __stdcall CfgShiftSymbol(const int pos,const int shift) =0;
  1581. virtual int __stdcall CfgShiftGroup(const int pos,const int shift) =0;
  1582. virtual int __stdcall CfgShiftManager(const int pos,const int shift) =0;
  1583. virtual int __stdcall CfgShiftFeeder(const int pos,const int shift) =0;
  1584. virtual int __stdcall CfgShiftLiveUpdate(const int pos,const int shift)=0;
  1585. virtual int __stdcall CfgShiftSync(const int pos,const int shift) =0;
  1586. virtual int __stdcall CfgShiftPlugin(const int pos,const int shift) =0;
  1587. //--- server feeders
  1588. virtual ServerFeed* __stdcall SrvFeeders(int *total) =0;
  1589. virtual LPSTR __stdcall SrvFeederLog(LPCSTR name,int *len)=0;
  1590. //--- chart bases
  1591. virtual RateInfoOld* __stdcall ChartRequestObsolete(const ChartInfo *chart,__time32_t *timesign,int *total) =0;
  1592. virtual int __stdcall ChartAddObsolete(LPCSTR symbol,const int period,const RateInfoOld* rates,int *count) =0;
  1593. virtual int __stdcall ChartUpdateObsolete(LPCSTR symbol,const int period,const RateInfoOld* rates,int *count)=0;
  1594. virtual int __stdcall ChartDeleteObsolete(LPCSTR symbol,const int period,const RateInfoOld* rates,int *count)=0;
  1595. //--- performance info
  1596. virtual PerformanceInfo* __stdcall PerformanceRequest(__time32_t from,int *total)=0;
  1597. //--- users/trades backups
  1598. virtual BackupInfo* __stdcall BackupInfoUsers(const int mode,int *total) =0;
  1599. virtual BackupInfo* __stdcall BackupInfoOrders(const int mode,int *total)=0;
  1600. virtual UserRecord* __stdcall BackupRequestUsers(LPCSTR file,LPCSTR request,int *total) =0;
  1601. virtual TradeRecord* __stdcall BackupRequestOrders(LPCSTR file,LPCSTR request,int *total)=0;
  1602. virtual int __stdcall BackupRestoreUsers(const UserRecord *users,const int total) =0;
  1603. virtual TradeRestoreResult* __stdcall BackupRestoreOrders(const TradeRecord *trades,int *total)=0;
  1604. //--- administrator databases commands
  1605. virtual UserRecord* __stdcall AdmUsersRequest(LPCSTR group,int *total) =0;
  1606. virtual TradeRecord* __stdcall AdmTradesRequest(LPCSTR group,const int open_only,int *total)=0;
  1607. virtual int __stdcall AdmBalanceCheckObsolete(int *logins,int *total) =0;
  1608. virtual int __stdcall AdmBalanceFix(const int *logins,const int total) =0;
  1609. virtual int __stdcall AdmTradesDelete(const int *orders,const int total)=0;
  1610. virtual int __stdcall AdmTradeRecordModify(const TradeRecord *trade) =0;
  1611. //--- symbols
  1612. virtual int __stdcall SymbolsRefresh() =0;
  1613. virtual ConSymbol* __stdcall SymbolsGetAll(int *total) =0;
  1614. virtual int __stdcall SymbolGet(LPCSTR symbol,ConSymbol *cs) =0;
  1615. virtual int __stdcall SymbolInfoGet(LPCSTR symbol,SymbolInfo *si)=0;
  1616. virtual int __stdcall SymbolAdd(LPCSTR symbol) =0;
  1617. virtual int __stdcall SymbolHide(LPCSTR symbol) =0;
  1618. //--- symbol commands
  1619. virtual int __stdcall SymbolChangeObsolete(const SymbolPropertiesOld *prop)=0;
  1620. virtual int __stdcall SymbolSendTick(LPCSTR symbol,const double bid,const double ask)=0;
  1621. //--- manager commands
  1622. virtual ConGroup* __stdcall GroupsRequest(int *total) =0;
  1623. virtual int __stdcall MailSend(const MailBox* mail,const int *logins)=0;
  1624. virtual int __stdcall NewsSend(const NewsTopic *news) =0;
  1625. //--- journal
  1626. virtual ServerLog* __stdcall JournalRequest(const int mode,const __time32_t from,const __time32_t to,LPCSTR filter,int *total)=0;
  1627. //--- databases: direct request to the server
  1628. //--- users
  1629. virtual UserRecord* __stdcall UsersRequest(int *total) =0;
  1630. virtual UserRecord* __stdcall UserRecordsRequest(const int *logins,int *total)=0;
  1631. virtual int __stdcall UserRecordNew(UserRecord *user) =0;
  1632. virtual int __stdcall UserRecordUpdate(const UserRecord *user) =0;
  1633. virtual int __stdcall UsersGroupOp(const GroupCommandInfo *info,const int *logins)=0;
  1634. virtual int __stdcall UserPasswordCheck(const int login,LPCSTR password)=0;
  1635. virtual int __stdcall UserPasswordSet(const int login,LPCSTR password,const int change_investor,const int clean_pubkey)=0;
  1636. virtual OnlineRecord* __stdcall OnlineRequest(int *total) =0;
  1637. //--- orders
  1638. virtual int __stdcall TradeTransaction(TradeTransInfo *info) =0;
  1639. virtual TradeRecord* __stdcall TradesRequest(int *total) =0;
  1640. virtual TradeRecord* __stdcall TradeRecordsRequest(const int *orders,int *total)=0;
  1641. virtual TradeRecord* __stdcall TradesUserHistory(const int login,const __time32_t from,const __time32_t to,int *total)=0;
  1642. virtual int __stdcall TradeCheckStops(const TradeTransInfo *trade,const double price)=0;
  1643. //--- reports
  1644. virtual TradeRecord* __stdcall ReportsRequest(const ReportGroupRequest *req,const int *logins,int *total) =0;
  1645. virtual DailyReport* __stdcall DailyReportsRequest(const DailyGroupRequest *req,const int *logins,int *total)=0;
  1646. //--- external command
  1647. virtual int __stdcall ExternalCommand(LPCSTR data_in,const int size_in,LPSTR *data_out,int *size_out)=0;
  1648. //--- plugins
  1649. virtual int __stdcall PluginUpdate(const ConPluginParam *plugin)=0;
  1650. //--- pumping
  1651. virtual int __stdcall PumpingSwitch(MTAPI_NOTIFY_FUNC pfnFunc,const HWND destwnd,const UINT eventmsg,const int flags)=0;
  1652. virtual ConGroup* __stdcall GroupsGet(int *total) =0;
  1653. virtual int __stdcall GroupRecordGet(LPCSTR name,ConGroup *group) =0;
  1654. virtual int __stdcall SymbolInfoUpdated(SymbolInfo *si,const int max_info) =0;
  1655. virtual UserRecord* __stdcall UsersGet(int *total) =0;
  1656. virtual int __stdcall UserRecordGet(const int login,UserRecord *user) =0;
  1657. virtual OnlineRecord* __stdcall OnlineGet(int *total) =0;
  1658. virtual int __stdcall OnlineRecordGet(const int login,OnlineRecord *user) =0;
  1659. virtual TradeRecord* __stdcall TradesGet(int *total) =0;
  1660. virtual TradeRecord* __stdcall TradesGetBySymbol(LPCSTR symbol,int *total) =0;
  1661. virtual TradeRecord* __stdcall TradesGetByLogin(const int login,LPCSTR group,int *total)=0;
  1662. virtual TradeRecord* __stdcall TradesGetByMarket(int *total) =0;
  1663. virtual int __stdcall TradeRecordGet(const int order,TradeRecord *trade) =0;
  1664. virtual int __stdcall TradeClearRollback(const int order) =0;
  1665. virtual MarginLevel* __stdcall MarginsGet(int *total) =0;
  1666. virtual int __stdcall MarginLevelGet(const int login,LPCSTR group,MarginLevel *margin)=0;
  1667. virtual RequestInfo* __stdcall RequestsGet(int *total) =0;
  1668. virtual int __stdcall RequestInfoGet(const int pos,RequestInfo *info) =0;
  1669. virtual ConPlugin* __stdcall PluginsGet(int *total) =0;
  1670. virtual int __stdcall PluginParamGet(const int pos,ConPluginParam *plugin) =0;
  1671. virtual int __stdcall MailLast(LPSTR path,int *length) =0;
  1672. virtual NewsTopic* __stdcall NewsGet(int *total) =0;
  1673. virtual int __stdcall NewsTotal() =0;
  1674. virtual int __stdcall NewsTopicGet(const int pos,NewsTopic *news) =0;
  1675. virtual void __stdcall NewsBodyRequest(const int key) =0;
  1676. virtual LPSTR __stdcall NewsBodyGet(const int key) =0;
  1677. //--- dealing
  1678. virtual int __stdcall DealerSwitch(MTAPI_NOTIFY_FUNC pfnFunc,const HWND destwnd,const UINT eventmsg)=0;
  1679. virtual int __stdcall DealerRequestGet(RequestInfo *info) =0;
  1680. virtual int __stdcall DealerSend(const RequestInfo *info,const int requote,const int mode)=0;
  1681. virtual int __stdcall DealerReject(const int id) =0;
  1682. virtual int __stdcall DealerReset(const int id) =0;
  1683. //---
  1684. virtual TickInfo* __stdcall TickInfoLast(LPCSTR symbol,int *total)=0;
  1685. virtual int __stdcall SymbolsGroupsGet(ConSymbolGroup *grp) =0;
  1686. virtual __time32_t __stdcall ServerTime() =0;
  1687. virtual MailBox* __stdcall MailsRequest(int *total) =0;
  1688. //--- risk management
  1689. virtual SymbolSummary* __stdcall SummaryGetAll(int *total) =0;
  1690. virtual int __stdcall SummaryGet(LPCSTR symbol,SymbolSummary *info) =0;
  1691. virtual int __stdcall SummaryGetByCount(const int symbol,SymbolSummary *info)=0;
  1692. virtual int __stdcall SummaryGetByType(const int sectype,SymbolSummary *info)=0;
  1693. virtual int __stdcall SummaryCurrency(LPSTR cur,const int maxchars) =0;
  1694. virtual ExposureValue* __stdcall ExposureGet(int *total) =0;
  1695. virtual int __stdcall ExposureValueGet(LPCSTR cur,ExposureValue *info) =0;
  1696. //---
  1697. virtual int __stdcall MarginLevelRequest(const int login,MarginLevel *level) =0;
  1698. virtual int __stdcall HistoryCorrect(LPCSTR symbol,int *updated) =0;
  1699. //--- new chart bases
  1700. virtual RateInfo * __stdcall ChartRequest(const ChartInfo *chart,__time32_t *timesign,int *total) =0;
  1701. virtual int __stdcall ChartAdd(LPCSTR symbol,const int period,const RateInfo *rates,int *count) =0;
  1702. virtual int __stdcall ChartUpdate(LPCSTR symbol,const int period,const RateInfo *rates,int *count)=0;
  1703. virtual int __stdcall ChartDelete(LPCSTR symbol,const int period,const RateInfo *rates,int *count)=0;
  1704. //--- ticks base
  1705. virtual TickRecord* __stdcall TicksRequest(const TickRequest *request,int *total)=0;
  1706. //--- internal methods
  1707. virtual int __stdcall PumpingSwitchEx(MTAPI_NOTIFY_FUNC_EX pfnFunc,const int flags,void *param)=0;
  1708. virtual int __stdcall UsersSyncStart(const __time32_t timestamp)=0;
  1709. virtual UserRecord* __stdcall UsersSyncRead(int* users_total)=0;
  1710. virtual int* __stdcall UsersSnapshot(int* users_total)=0;
  1711. virtual int __stdcall TradesSyncStart(const __time32_t timestamp)=0;
  1712. virtual TradeRecord* __stdcall TradesSyncRead(int* trades_total)=0;
  1713. virtual int* __stdcall TradesSnapshot(int* trades_total)=0;
  1714. virtual int __stdcall DailySyncStart(const __time32_t timestamp)=0;
  1715. virtual DailyReport* __stdcall DailySyncRead(int* daily_total)=0;
  1716. //--- profit recalculation
  1717. virtual int __stdcall TradeCalcProfit(TradeRecord *trade)=0;
  1718. //--- new symbol commands
  1719. virtual int __stdcall SymbolChange(const SymbolProperties *prop) =0;
  1720. //--- network statistics
  1721. virtual int __stdcall BytesSent()=0;
  1722. virtual int __stdcall BytesReceived()=0;
  1723. //---
  1724. virtual int __stdcall ManagerCommon(ConCommon *common)=0;
  1725. //--- log access
  1726. virtual void __stdcall LogsOut(const int code,LPCSTR source,LPCSTR msg)=0;
  1727. virtual void __stdcall LogsMode(const int mode)=0;
  1728. //--- check license
  1729. virtual int __stdcall LicenseCheck(LPCSTR license_name)=0;
  1730. //--- gateway configs
  1731. virtual ConGatewayAccount* __stdcall CfgRequestGatewayAccount(int *total)=0;
  1732. virtual ConGatewayMarkup* __stdcall CfgRequestGatewayMarkup(int *total)=0;
  1733. virtual ConGatewayRule* __stdcall CfgRequestGatewayRule(int *total)=0;
  1734. //--- configuration update
  1735. virtual int __stdcall CfgUpdateGatewayAccount(const ConGatewayAccount* cfg)=0;
  1736. virtual int __stdcall CfgUpdateGatewayMarkup(const ConGatewayMarkup* cfg)=0;
  1737. virtual int __stdcall CfgUpdateGatewayRule(const ConGatewayRule *cfg)=0;
  1738. //--- configuration delete
  1739. virtual int __stdcall CfgDeleteGatewayAccount(const int pos)=0;
  1740. virtual int __stdcall CfgDeleteGatewayMarkup(const int pos)=0;
  1741. virtual int __stdcall CfgDeleteGatewayRule(const int pos)=0;
  1742. //--- configuration shift
  1743. virtual int __stdcall CfgShiftGatewayAccount(const int pos,const int shift)=0;
  1744. virtual int __stdcall CfgShiftGatewayMarkup(const int pos,const int shift)=0;
  1745. virtual int __stdcall CfgShiftGatewayRule(const int pos,const int shift)=0;
  1746. //--- administrator databases commands
  1747. virtual BalanceDiff* __stdcall AdmBalanceCheck(int *logins,int *total)=0;
  1748. //--- notifications
  1749. virtual int __stdcall NotificationsSend(LPWSTR metaquotes_ids,LPCWSTR message)=0;
  1750. virtual int __stdcall NotificationsSend(const int* logins,const UINT logins_total,LPCWSTR message)=0;
  1751. };
  1752. //+------------------------------------------------------------------+
  1753. //| Functions |
  1754. //+------------------------------------------------------------------+
  1755. typedef int (*MtManVersion_t)(void);
  1756. typedef int (*MtManCreate_t)(int version,CManagerInterface **man);
  1757. //+------------------------------------------------------------------+
  1758. //| Factory |
  1759. //+------------------------------------------------------------------+
  1760. #ifndef _MT4MANDLL
  1761. class CManagerFactory
  1762. {
  1763. private:
  1764. HMODULE m_lib;
  1765. MtManVersion_t m_pfnManVersion;
  1766. MtManCreate_t m_pfnManCreate;
  1767. public:
  1768. //--- constructor
  1769. CManagerFactory(LPCSTR lib_path=NULL):m_lib(NULL)
  1770. {
  1771. Init(lib_path);
  1772. }
  1773. //--- destructor
  1774. ~CManagerFactory()
  1775. {
  1776. if(m_lib)
  1777. {
  1778. m_pfnManVersion=NULL;
  1779. m_pfnManCreate =NULL;
  1780. ::FreeLibrary(m_lib);
  1781. m_lib=NULL;
  1782. }
  1783. }
  1784. //--- initialization
  1785. inline void Init(LPCSTR lib_path=NULL)
  1786. {
  1787. char path[256]="";
  1788. //---
  1789. if(lib_path!=NULL)
  1790. {
  1791. strcpy_s(path,lib_path);
  1792. path[sizeof(path)-1]=0;
  1793. }
  1794. else
  1795. {
  1796. #ifndef _WIN64
  1797. strcpy_s(path,"mtmanapi.dll");
  1798. path[sizeof(path)-1]=0;
  1799. #else
  1800. strcpy_s(path,"mtmanapi64.dll");
  1801. path[sizeof(path)-1]=0;
  1802. #endif
  1803. }
  1804. //---
  1805. if(m_lib)
  1806. ::FreeLibrary(m_lib);
  1807. if((m_lib=::LoadLibraryA(path))!=NULL)
  1808. {
  1809. m_pfnManVersion=reinterpret_cast<MtManVersion_t>(::GetProcAddress(m_lib,"MtManVersion"));
  1810. m_pfnManCreate =reinterpret_cast<MtManCreate_t>(::GetProcAddress(m_lib,"MtManCreate"));
  1811. }
  1812. else
  1813. {
  1814. m_pfnManVersion=NULL;
  1815. m_pfnManCreate =NULL;
  1816. }
  1817. //---
  1818. }
  1819. //--- winsock startup/cleanup
  1820. inline int WinsockStartup() const
  1821. {
  1822. WSADATA wsa;
  1823. return(WSAStartup(0x0202,&wsa)!=0 ? RET_ERROR:RET_OK);
  1824. }
  1825. inline void WinsockCleanup() const
  1826. {
  1827. WSACleanup();
  1828. }
  1829. //---
  1830. inline int IsValid() const
  1831. {
  1832. return(m_lib!=NULL && m_pfnManVersion!=NULL && m_pfnManCreate!=NULL) ? TRUE:FALSE;
  1833. }
  1834. inline int Version() const
  1835. {
  1836. return(m_pfnManVersion?(*m_pfnManVersion)():0);
  1837. }
  1838. inline CManagerInterface* Create(const int version) const
  1839. {
  1840. CManagerInterface *man=NULL;
  1841. if(m_pfnManCreate) (*m_pfnManCreate)(version,&man);
  1842. return(man);
  1843. }
  1844. };
  1845. #endif
  1846. //+------------------------------------------------------------------+