如有疑问请联系v:yunkeji5868
同managerAPI接口一样,下面是serverAPI提供的接口,可以保存为.h文件直接导入到自己工程中使用。具体如果使用可看我的其他文章。
//+------------------------------------------------------------------+ //| MetaTrader Server Interface | //| Copyright 2001-2013, MetaQuotes Software Corp. | //| http://www.metaquotes.net | //+------------------------------------------------------------------+ //| DO NOT EDIT THIS FILE! | //+------------------------------------------------------------------+ #pragma once #define ServerApiVersion 5 //+------------------------------------------------------------------+ //| Memory allocation macro | //+------------------------------------------------------------------+ #define HEAP_ALLOC(size) HeapAlloc(GetProcessHeap(),0,size) #define HEAP_FREE(mem) HeapFree(GetProcessHeap(),0,mem) //+------------------------------------------------------------------+ //| Structures | //+------------------------------------------------------------------+ //| Information about plugin | //+------------------------------------------------------------------+ struct PluginInfo { char name[128]; // plugin name unsigned int version; // plugin version char copyright[128]; // plugin copyright int reserved[32]; // reserved }; //+------------------------------------------------------------------+ //| Plugin configuration structure | //+------------------------------------------------------------------+ struct PluginCfg { char name[32]; char value[128]; int reserved[16]; }; //+------------------------------------------------------------------+ //| Server config structures | //+------------------------------------------------------------------+ //| Access configuration | //+------------------------------------------------------------------+ struct ConAccess { int action; // type of action (FW_BLOCK,FW_PERMIT) unsigned long from,to; // from, to addresses char comment[64]; // comment int reserved[17]; // reserved }; //--- состояние ограничения enum { FW_BLOCK,FW_PERMIT }; //+------------------------------------------------------------------+ //| Common configuration | //+------------------------------------------------------------------+ struct ConCommon { char owner[128]; // servers owner (include version & build) char name[32]; // server name ULONG address; // IP address assigned to the server int port; // port DWORD timeout; // sockets timeout int enable_demo; // enable demo DEMO_DISABLED, DEMO_PROLONG, DEMO_FIXED int timeofdemo; // demo-account living time (days since last connect) int daylightcorrection; // allow daylight correction char internal[64]; // reserved int timezone; // time zone 0-GMT;-1=GMT-1;1=GMT+1; char timesync[64]; // time synchronization server address //--- int minclient; // minimal authorized client version int minapi; // minimal authorized client version DWORD feeder_timeout; // data feed switch timeout int keepemails; // internal mail keep period int endhour,endminute; // end of day time-hour & minute //--- int optimization_time; // optimization start time (minutes) int optimization_lasttime; // optimization last time int optimization_counter; // internal variable int optimization_unused[8];// reserved for future use //--- int antiflood; // enable antiflood control int floodcontrol; // max. antiflood connections //--- int liveupdate_mode; // LiveUpdate mode LIVE_UPDATE_NO,LIVE_UPDATE_ALL,LIVE_UPDATE_NO_SERVER //--- int lastorder; // last order's ticket (read only) int lastlogin; // last account's number (read only) int lostlogin; // lost commission's login (read only) //--- int rollovers_reopen; // reopen orders at time of rollovers ROLLOVER_NORMAL,ROLLOVER_REOPEN_BY_CLOSE_PRICE,ROLLOVER_REOPEN_BY_BID //--- char path_database[256]; // path to databases char path_history[256]; // path to history bases char path_log[256]; // path to log //--- overnigths time_t overnight_last_day; // day of last overnight time_t overnight_last_time; // time of last overnight time_t overnight_prev_time; // time of previous overnight //--- month reports time_t overmonth_last_month; // time of last report //--- performance base char adapters[256]; // network adapters list (read-only) ULONG bind_adresses[8]; // array of available IP addresses short server_version; // server version (filled by server) short server_build; // server build (filled by server) ULONG web_adresses[8]; // array of IP addresses available for Web services int statement_mode; // statements generation mode STATEMENT_END_DAY, STATEMENT_START_DAY int monthly_state_mode; // monthly generation flag int keepticks; // ticks keep period int reserved[53]; }; //+------------------------------------------------------------------+ //| Time config | //+------------------------------------------------------------------+ struct ConTime { int days[7][24]; // server's accessebility(7 days-24 hours, 0-denied, 1-allowed) int dayscontrol; // internal variable int reserved[3]; // reserved }; //+------------------------------------------------------------------+ //| Backup configuration | //+------------------------------------------------------------------+ struct ConBackup { //--- char fullbackup_path[256]; // path to backup int fullbackup_period; // full backup's period-BACKUP_1HOUR, BACKUP_4HOURS, BACKUP_1DAY int fullbackup_store; // full backup's store time-BU_STORE_1MONTH, BU_STORE_3MONTHS, BU_STORE_6MONTHS,BU_STORE_1YEAR time_t fullbackup_lasttime; // full backup's last execution time short fullbackup_shift; // full backup timeshift (minutes) //--- char external_path[256]; // path to external processing directory //--- int archive_period; // period of archive backup-ARC_BACKUP_5MIN, ARC_BACKUP_15MIN, ARC_BACKUP_30MIN, ARC_BACKUP_1HOUR int archive_store; // archive backup's store time-ARC_STORE_1WEEK, ARC_STORE_2WEEKS, ARC_STORE_1MONTH, ARC_STORE_3MONTH, ARC_STORE_6MONTH time_t archive_lasttime; // archive backup's last execution time //--- char export_securities[512];// comma separated list of exported securities char export_path[256]; // path to export script int export_period; // export period-enumeration EXPORT_1MIN, EXPORT_5MIN, EXPORT_15MIN, EXPORT_30MIN,EXPORT_1HOUR time_t export_lasttime; // export's last execution time //--- watch dog int watch_role; // server role WATCH_STAND_ALONE, WATCH_MASTER, WATCH_SLAVE char watch_password[16]; // watch dog password char watch_opposite[24]; // opposite server address int watch_timeout; // watch dog switch timeout //--- int reserved[3]; // reserved }; //--- full backup execution periods: 1 hour, 4 hours, 1 day enum { BACKUP_1HOUR, BACKUP_4HOURS, BACKUP_1DAY }; //--- arc. backup execution periods: 5 min, 15 min, 30 min, 1 hour enum { ARC_BACKUP_DISABLED, ARC_BACKUP_5MIN, ARC_BACKUP_15MIN, ARC_BACKUP_30MIN, ARC_BACKUP_1HOUR }; //--- arc. backup store period: 1 month,3 months, 6 months,1 year enum { ARC_STORE_1DAY, ARC_STORE_3DAYS, ARC_STORE_1WEEK, ARC_STORE_2WEEKS, ARC_STORE_1MONTH, ARC_STORE_3MONTH, ARC_STORE_6MONTH }; //--- export execution period: 1 min, 5 min, 15 min, 30 min, 1 hour enum { EXPORT_1MIN, EXPORT_5MIN, EXPORT_15MIN, EXPORT_30MIN,EXPORT_1HOUR }; //--- rollover mode enum { ROLLOVER_NORMAL, ROLLOVER_REOPEN_BY_CLOSE_PRICE, ROLLOVER_REOPEN_BY_BID }; //--- statement generate mode enum { STATEMENT_END_DAY, STATEMENT_START_DAY }; //--- server role enum { WATCH_STAND_ALONE, WATCH_MASTER, WATCH_SLAVE }; //--- live update modes enum { LIVE_UPDATE_NO, LIVE_UPDATE_ALL, LIVE_UPDATE_NO_SERVER }; //--- demo modes enum { DEMO_DISABLED, DEMO_PROLONG, DEMO_FIXED }; //--- monthly statement mode enum { MONTHLY_STATEMENT_END_MONTH, MONTHLY_STATEMENT_START_MONTH }; //+------------------------------------------------------------------+ //| Datafeed configuration | //+------------------------------------------------------------------+ struct ConFeeder { char name[64]; // name char file[256]; // datafeed filename char server[64]; // server address char login[32]; // datafeed login char pass[32]; // datafeed password char keywords[256]; // keywords (news filtration) int enable; // enable feeder int mode; // datafeed mode-enumeration FEED_QUOTES, FEED_NEWS, FEED_QUOTESNEWS int timeout; // max. freeze time (default ~120 sec.) int timeout_reconnect; // reconnect timeout before attemps_sleep connect attempts (default ~ 5 sec) int timeout_sleep; // reconnect timeout after attemps_sleep connect attempts (default ~ 60 sec) int attemps_sleep; // reconnect count (see timeout_reconnect & timeout_sleep) int news_langid; // news language id int unused[33]; // reserved }; //--- datafeed modes-receive quotes, receive news, receive quotes and news enum { FEED_QUOTES=0, FEED_NEWS=1, FEED_QUOTESNEWS=2 }; //+------------------------------------------------------------------+ //| Security group configuration for client group | //+------------------------------------------------------------------+ #define MAX_SEC_GROUPS (32) #define MAX_SEC_GROPS_MARGIN (128) //--- struct ConGroupSec { int show,trade; // enable show and trade for this group of securites int execution; // dealing mode-EXECUTION_MANUAL,EXECUTION_AUTO,EXECUTION_ACTIVITY //--- comission settings double comm_base; // standart commission int comm_type; // commission type-COMM_TYPE_MONEY,COMM_TYPE_PIPS,COMM_TYPE_PERCENT int comm_lots; // commission lots mode-COMMISSION_PER_LOT,COMMISSION_PER_DEAL double comm_agent; // agent commission int comm_agent_type; // agent commission mode-COMM_TYPE_MONEY, COMM_TYPE_PIPS //--- int spread_diff; // spread difference in compare with default security spread //--- int lot_min,lot_max; // allowed minimal and maximal lot values int lot_step; // allowed step value (10 lot-1000, 1 lot-100, 0.1 lot-10) int ie_deviation; // maximum price deviation in Instant Execution mode int confirmation; // use confirmation in Request mode int trade_rights; // clients trade rights-bit mask see TRADE_DENY_NONE,TRADE_DENY_CLOSEBY,TRADE_DENY_MUCLOSEBY int ie_quick_mode; // int autocloseout_mode; // auto close-out modes see 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 double comm_tax; // commission taxes int comm_agent_lots; // agent commission lots mode-COMMISSION_PER_LOT,COMMISSION_PER_DEAL int freemargin_mode; // free margin check mode //--- резерв int reserved[3]; }; //+------------------------------------------------------------------+ //| Special securities configurations | //+------------------------------------------------------------------+ struct ConGroupMargin { char symbol[12]; // security double swap_long,swap_short; // tickvalue for bid & ask double margin_divider; // margin divider int reserved[7]; }; //--- dealing mode enum { EXECUTION_MANUAL, EXECUTION_AUTO, EXECUTION_ACTIVITY }; //--- commission type enum { COMM_TYPE_MONEY, COMM_TYPE_PIPS, COMM_TYPE_PERCENT }; //--- comission lots mode enum { COMMISSION_PER_LOT, COMMISSION_PER_DEAL }; //--- clients trade rights enum { TRADE_DENY_NONE=0, TRADE_DENY_CLOSEBY=1, TRADE_DENY_MUCLOSEBY=2 }; //--- auto close-out modes 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 }; //+------------------------------------------------------------------+ //| Client group configuration | //+------------------------------------------------------------------+ struct ConGroup { //--- common settings char group[16]; // group name int enable; // enable group int timeout; // trade confirmation timeout (seconds) int adv_security; // enable advanced security //--- statements char company[128]; // company name char signature[128]; // statements signature char support_page[128]; // company support page char smtp_server[64]; // statements SMTP server char smtp_login[32]; // statements SMTP login char smtp_password[32]; // statements SMTP password char support_email[64]; // support email char templates[32]; // path to directory with custom templates int copies; // copy statements on support email int reports; // enable statements //--- default settings int default_leverage; // default leverage (user don't specify leverage himself) double default_deposit; // default deposit (user don't specify balance himself) //--- securities int maxsecurities; // maximum simultaneous securities ConGroupSec secgroups[MAX_SEC_GROUPS]; // security group settings ConGroupMargin secmargins[MAX_SEC_GROPS_MARGIN]; // special securities settings int secmargins_total; // count of special securities settings //--- margin & interest char currency[12]; // deposit currency double credit; // virtual credit int margin_call; // margin call level (percents) int margin_mode; // margin mode-MARGIN_DONT_USE,MARGIN_USE_ALL,MARGIN_USE_PROFIT,MARGIN_USE_LOSS int margin_stopout; // stop out level double interestrate; // annual interest rate (percents) int use_swap; // use rollovers & interestrate //--- rights int news; // news mode int rights; // rights bit mask-ALLOW_FLAG_EMAIL int check_ie_prices; // check by stream prices on IE int maxpositions; // open positions limit (0 - unlimited) int close_reopen; // partial close mode (if !=0 original position will be fully closed and remain position will be fully reopened) int hedge_prohibited; // hedge prohibition flag int close_fifo; // fifo rule int unused_rights[3]; // reserverd char securities_hash[16]; // internal data //--- int margin_type; // stop out calculation mode { MARGIN_TYPE_PERCENT, MARGIN_TYPE_CURRENCY } //--- archive parameters int archive_period; int archive_max_balance; //--- stopout mode int stopout_skip_hedged; int archive_pending_period; // pendings clean period //--- allowed news languages UINT news_languages[8]; // LANGID array UINT news_languages_total; // news languages total //--- reserved int reserved[17]; }; //--- margin mode enum { MARGIN_MODE_DONT_USE,MARGIN_MODE_USE_ALL,MARGIN_MODE_USE_PROFIT,MARGIN_MODE_USE_LOSS }; //--- stop out calculation mode enum { MARGIN_TYPE_PERCENT, MARGIN_TYPE_CURRENCY }; //--- news mode-no news, only topics, full news (topic+body) enum { NEWS_NO, NEWS_TOPICS, NEWS_FULL }; //--- group rights enum { ALLOW_FLAG_EMAIL =1, ALLOW_FLAG_TRAILING =2, ALLOW_FLAG_ADVISOR =4, ALLOW_FLAG_EXPIRATION =8, ALLOW_FLAG_SIGNALS_ALL=16, ALLOW_FLAG_SIGNALS_OWN=32 }; //+------------------------------------------------------------------+ //| Hollidays configuration | //+------------------------------------------------------------------+ struct ConHoliday { int year; // year int month; // month int day; // day int from,to; // work time-from & to (minutes) char symbol[32]; // security name or symbol's group name or "All" char description[128]; // description int enable; // enable int reserved[13]; // reserved ConHoliday *next; // internal data }; //+------------------------------------------------------------------+ //| LiveUpdate configuration | //+------------------------------------------------------------------+ #define LIVE_FILES_MAX 64 //--- struct LiveInfoFile { char file[256]; // file name int size; // file size char hash[36]; // file hash int reserved[10]; // reserved }; //--- struct ConLiveUpdate { char company[128]; // company char path[256]; // path to LiveUpdate int version; // version int build; // build int maxconnect; // max. simultaneous connections int connections; // current connections (read only) int type; // type LIVE_UPDATE_CLIENT, LIVE_UPDATE_MANAGER, LIVE_UPDATE_ADMIN int enable; // enable int totalfiles; // total files count LiveInfoFile files[LIVE_FILES_MAX]; // files' configurations int reserved[16]; // reserved ConLiveUpdate *next; // internal data }; //--- LiveUpdate type enum { LIVE_UPDATE_CLIENT, LIVE_UPDATE_MANAGER, LIVE_UPDATE_ADMIN, LIVE_UPDATE_DATACENTER, LIVE_UPDATE_PPC_ARM, LIVE_UPDATE_PPC_MIPS, LIVE_UPDATE_PPC_SH3, LIVE_UPDATE_LAST }; //+------------------------------------------------------------------+ //| Manager rights for security groups | //+------------------------------------------------------------------+ struct ConManagerSec { int internal; // internal data int enable; // enable int minimum_lots; // min. lots int maximum_lots; // max. lots int unused[16]; // reserved }; //+------------------------------------------------------------------+ //| Manager configuration | //+------------------------------------------------------------------+ struct ConManager { int login; // login //--- rights int manager; // right to add & change client records int money; // right to balance & credit management int online; // right to see online users int riskman; // right to use analyzer int broker; // right to deal int admin; // right to server administration int logs; // right to see logs int reports; // right to see reports int trades; // right to add/modify/delete trades int spread; // right to change spread, spread balance, stop levels, execution mode // and send quotes int email; // right to send internal mail int user_details; // right to see clients private data-name,country,address,phone,email etc. int see_trades; // right to see the trading acitivity int news; // right to send news int plugins; // right to control server plugins int server_reports; // right to receive server reports int techsupport; // right to access to technical support page int unused[11]; //--- IP filtration int ipfilter; // enable IP control unsigned long ip_from,ip_to; // range of allowed IPs //--- char mailbox[64]; // name of mailbof for internal mail char groups[1024]; // comma separated list of managed groups (allowed '*' wildcard) ConManagerSec secgroups[MAX_SEC_GROUPS]; // manager rights for security groups DWORD exp_time; // internal data char name[32]; // manager name (filled from the corresponding UserRecord) int info_depth; // depth of avalaible information //--- int reserved[22]; }; //+------------------------------------------------------------------+ //| Security configurations | //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ //| Security sessions configurations | //+------------------------------------------------------------------+ struct ConSession { short open_hour,open_min; // session open time: hour & minute short close_hour,close_min; // session close time: hour & minute int open,close; // internal data short align[7]; // internal data }; //--- struct ConSessions { //--- ConSession quote[3]; // quote sessions ConSession trade[3]; // trade sessions //--- int quote_overnight; // internal data int trade_overnight; // internal data int reserved[2]; // reserved }; //+------------------------------------------------------------------+ //| Security config | //+------------------------------------------------------------------+ #define MAX_SYMBOLS 1024 //--- struct ConSymbol { //--- common settings char symbol[12]; // name char description[64]; // description char source[12]; // synonym char currency[12]; // currency int type; // security group (see ConSymbolGroup) int digits; // security precision int trade; // trade mode //--- external settings COLORREF background_color; // background color int count; // symbols index int count_original; // symbols index in market watch int external_unused[7]; //--- sessions int realtime; // allow real time quotes time_t starting; // trades starting date (UNIX time) time_t expiration; // trades end date (UNIX time) ConSessions sessions[7]; // quote & trade sessions //--- profits int profit_mode; // profit calculation mode int profit_reserved; // reserved //--- filtration int filter; // filter value int filter_counter; // filtration parameter double filter_limit; // max. permissible deviation from last quote (percents) int filter_smoothing; // smoothing float filter_reserved; // reserved int logging; // enable to log quotes //--- spread & swaps int spread; // spread int spread_balance; // spread balance int exemode; // execution mode int swap_enable; // enable swaps int swap_type; // swap type double swap_long,swap_short; // swaps values for long & short postions int swap_rollover3days; // triple rollover day-0-Monday,1-Tuesday...4-Friday double contract_size; // contract size double tick_value; // one tick value double tick_size; // one tick size int stops_level; // stops deviation value int gtc_pendings; // GTC mode ORDERS_DAILY, ORDERS_GTC, ORDERS_DAILY_NO_STOPS //--- margin calculation int margin_mode; // margin calculation mode double margin_initial; // initial margin double margin_maintenance; // margin maintenance double margin_hedged; // hadget margin double margin_divider; // margin divider //--- calclulated variables (internal data) double point; // point size-(1/(10^digits) double multiply; // multiply 10^digits double bid_tickvalue; // tickvalue for bid double ask_tickvalue; // tickvalue for ask //--- int long_only; // allow only BUY positions int instant_max_volume; // max. volume for Instant Execution //--- char margin_currency[12]; // currency of margin requirments int freeze_level; // modification freeze level (from market price) int margin_hedged_strong; // lock open checking mode time_t value_date; // value date for this security int quotes_delay; // quotes delay int swap_openprice; // use open price at swaps calculation in SWAP_BY_INTEREST mode //--- int unused[22]; // reserved }; //+------------------------------------------------------------------+ //| Symbols enumeration | //+------------------------------------------------------------------+ //--- symbol execution mode enum { EXE_REQUEST,EXE_INSTANT,EXE_MARKET }; //--- trade mode enum { TRADE_NO,TRADE_CLOSE,TRADE_FULL }; //--- swap type enum { SWAP_BY_POINTS,SWAP_BY_DOLLARS, SWAP_BY_INTEREST, SWAP_BY_MARGIN_CURRENCY }; //--- profit calculation mode enum { PROFIT_CALC_FOREX,PROFIT_CALC_CFD,PROFIT_CALC_FUTURES }; //--- margin calculation mode enum { MARGIN_CALC_FOREX,MARGIN_CALC_CFD,MARGIN_CALC_FUTURES,MARGIN_CALC_CFDINDEX,MARGIN_CALC_CFDLEVERAGE }; //--- GTC mode enum { ORDERS_DAILY, ORDERS_GTC, ORDERS_DAILY_NO_STOPS }; //+------------------------------------------------------------------+ //| Symbol groups | //+------------------------------------------------------------------+ struct ConSymbolGroup { char name[16]; // group name char description[64]; // group description }; //+------------------------------------------------------------------+ //| Feeder quote structure | //+------------------------------------------------------------------+ #pragma pack(push,1) struct FeedTick { char symbol[16]; // security time_t ctm; // time (UNIX time) char bank[32]; // source bank double bid,ask; // bid/ask int feeder; // feeder index char reverved[8]; // reserved }; //+------------------------------------------------------------------+ //| Feeder data quote | //+------------------------------------------------------------------+ struct FeedData { //--- quotes data FeedTick ticks[32]; // quotes array int ticks_count; // quotes count //--- news data char news_time[32]; // news time description char subject[256]; // news subject char category[64]; // news category char keywords[256]; // news keywords char *body; // news body int body_len; // news body len int body_maxlen; // max. body len //--- результаты операций int result; // work result char result_string[256]; // error description int feeder; // datafeed index int mode; // internal data int langid; // news LANGID //--- char reserved[64]; // reserved }; //+------------------------------------------------------------------+ //| Log record structure | //+------------------------------------------------------------------+ struct LogInfo { int code; // error code-CmdOK,CmdTrade,CmdLogin,CmdWarn,CmdErr,CmdAtt char ip[64]; // IP address char msg[512]; // error description tm ctm; // time int unused[2]; // reserved }; //--- #pragma pack(pop) //--- error code enum { CmdOK,CmdTrade,CmdLogin,CmdWarn,CmdErr,CmdAtt }; //+------------------------------------------------------------------+ //| Log request record structure | //+------------------------------------------------------------------+ struct LogRequest { char mode; // request mode time_t from; // from time time_t to; // to time char filter[64]; // filter }; //--- log request type enum EnLogType { LOG_TYPE_STANDARD, LOG_TYPE_LOGINS, LOG_TYPE_TRADES, LOG_TYPE_ERRORS, LOG_TYPE_FULL }; //+------------------------------------------------------------------+ //| Perfomance database record | //+------------------------------------------------------------------+ #pragma pack(push,1) struct PerformanceInfo { time_t ctm; // time short users; // connections count short cpu; // cpu usage int freemem; // free memory int network; // network usage byte per.sec. int sockets; // reserved }; #pragma pack(pop) //+------------------------------------------------------------------+ //| Client full description | //+------------------------------------------------------------------+ struct UserRecord { //--- common settings int login; // login char group[16]; // group char password[16]; // password //--- access flags int enable; // enable int enable_change_password; // allow to change password int enable_read_only; // allow to open/positions (TRUE-may not trade) int enable_reserved[3]; // for future use //--- char password_investor[16]; // read-only mode password char password_phone[32]; // phone password char name[128]; // name char country[32]; // country char city[32]; // city char state[32]; // state char zipcode[16]; // zipcode char address[128]; // address char phone[32]; // phone char email[48]; // email char comment[64]; // comment char id[32]; // SSN (IRD) char status[16]; // status time_t regdate; // registration date time_t lastdate; // last coonection time //--- trade settings int leverage; // leverage int agent_account; // agent account time_t timestamp; // timestamp int reserved[1]; // for future use //--- торговые данные double balance; // balance double prevmonthbalance; // previous month balance double prevbalance; // previous day balance double credit; // credit double interestrate; // accumulated interest rate double taxes; // taxes double prevmonthequity; // previous month equity double prevequity; // previous day equity double reserved2[2]; // for future use //--- char publickey[272]; // public key int send_reports; // enable send reports by email int balance_status; // internal use COLORREF user_color; // color got to client (used by MT Manager) //--- char unused[40]; // for future use char api_data[16]; // for APIs usage }; //+------------------------------------------------------------------+ //| Client short description | //+------------------------------------------------------------------+ struct UserInfo { //--- common settings int login; // login char group[16]; // group char password[16]; // password char name[128]; // name char ip[16]; // IP address //--- access flags int enable; // enable int enable_change_password; // allow to change password int enable_read_only; // allow to open/positions (TRUE-may not trade) int flags; // internal data //--- trade parameters int leverage; // leverage int agent_account; // agent account //--- trade data double balance; // balance double credit; // credit double prevbalance; // previous day balance ConGroup grp; // client group }; //+------------------------------------------------------------------+ //| Rate history record | //+------------------------------------------------------------------+ #pragma pack(push,1) struct RateInfo { time_t ctm; // time (UNIX) int open; // open price: 11987 => 119.87 (2 digits), 11987 => 1.1987 (4 digits) int high,low,close; // prices shift in points: open=11987 => open is 119.87; high=5 => open is 119.92 double vol; // volume }; #pragma pack(pop) //+------------------------------------------------------------------+ //| Tick structure | //+------------------------------------------------------------------+ struct TickAPI { time_t ctm; // time double bid,ask; // normalized bid & ask }; //+------------------------------------------------------------------+ //| Internal mail record | //+------------------------------------------------------------------+ struct MailBoxHeader { time_t time; // receive time int sender; // sender login char from[64]; // sender description int to; // addressee login char subject[128]; // subject int readed; // reading flag char *body; // body int bodylen; // body len unsigned short min_build,max_build; // build limitations int reserved[1]; // reserved }; //+------------------------------------------------------------------+ //| Trade transaction structures | //+------------------------------------------------------------------+ #pragma pack(push,1) struct TradeTransInfo { UCHAR type; // trade transaction char reserved; // reserved short cmd; // trade command int order,orderby; // order ticket,"order by" ticket char symbol[12]; // security int volume; // volume double price; // prices double sl,tp; // stop loss & take profit int ie_deviation; // deviation on Instant Execution char comment[32]; // comment time_t expiration; // expiration time (server time in UNIX format) int crc; // CRC }; #pragma pack(pop) //--- trade transactions type enum { //--- TT_PRICES_GET, // prices request TT_PRICES_REQUOTE, // prices requote (for internal usage) //--- client activity TT_ORDER_IE_OPEN=64, // open position at Instant Execution TT_ORDER_REQ_OPEN, // open position at Request Execution TT_ORDER_MK_OPEN, // open position at Market Execution TT_ORDER_PENDING_OPEN, // open pending order //--- TT_ORDER_IE_CLOSE, // close position at Instant Execution TT_ORDER_REQ_CLOSE, // close position at Request Execution TT_ORDER_MK_CLOSE, // close position at Market Execution //--- TT_ORDER_MODIFY, // modify position or pending order TT_ORDER_DELETE, // delete pending order TT_ORDER_CLOSE_BY, // close hedged positions TT_ORDER_CLOSE_ALL, // close all hedged positions for same security //--- manager activity TT_BR_ORDER_OPEN, // open order (by manager) TT_BR_ORDER_CLOSE, // close order (by manager) TT_BR_ORDER_DELETE, // delete ANY open position TT_BR_ORDER_CLOSE_BY, // close hedged positions (by manager) TT_BR_ORDER_CLOSE_ALL, // close all hedged positions for same security (by manager) TT_BR_ORDER_MODIFY, // modify position or pending order (by manager) TT_BR_ORDER_ACTIVATE, // activate pending order (by manager) TT_BR_ORDER_COMMENT, // comment order (by manager) TT_BR_BALANCE // change balance & credit (by manager) }; //--- trade commands enum { OP_BUY=0,OP_SELL,OP_BUY_LIMIT,OP_SELL_LIMIT,OP_BUY_STOP,OP_SELL_STOP,OP_BALANCE,OP_CREDIT }; //+------------------------------------------------------------------+ //| Request queue record | //+------------------------------------------------------------------+ struct RequestInfo { //--- common info int id; // request id int status; // request status DC_EMPTY,DC_REQUEST,DC_LOCKED,DC_ANSWERED,DC_RESETED,DC_CANCELED DWORD time; // request time (GetTickCount) int manager; // login of manager who takes this request //--- client info int login; // client login char group[16]; // client group double balance; // client balance double credit; // client credit //--- processed trade transaction double prices[2]; // prices TradeTransInfo trade; // trade transaction void *internal; // internal data int internal_id; // internal identificator int reserved; // reserved //--- internal data RequestInfo *prev,*next; // internal data }; //--- request status enum { DC_EMPTY,DC_REQUEST,DC_LOCKED,DC_ANSWERED,DC_RESETED,DC_CANCELED }; //+------------------------------------------------------------------+ //| Trade record | //+------------------------------------------------------------------+ #pragma pack(push,1) struct TradeRecord { int order; // order ticket int login; // owner's login char symbol[12]; // security int digits; // security precision int cmd; // trade command int volume; // volume time_t open_time; // open time int state; // trade record state double open_price; // open price double sl,tp; // stop loss & take profit time_t close_time; // close time time_t value_date; // value date time_t expiration; // pending order's expiration time int conv_reserv; // reserved double conv_rates[2]; // convertation rates from profit currency to group deposit currency // (first element-for open time, second element-for close time) double commission; // commission double commission_agent; // agent commission double storage; // order swaps double close_price; // close price double profit; // profit double taxes; // taxes value int magic; // special value used by client experts char comment[32]; // comment int internal_id; // for internal usage (must be used by API) int activation; // used by MT Manager int spread; // used by MT Manager double margin_rate; // margin cinvertation rate (rate of convertation from margin currency to deposit one) time_t timestamp; // timestamp int reserved[4]; // reserved TradeRecord *next; // internal data }; #pragma pack(pop) //+------------------------------------------------------------------+ //| Margin status structure | //+------------------------------------------------------------------+ struct MarginLevel { int login; // login int leverage; // leverage int updated; // internal data double balance; // balance+credit value double margin; // margin requirments double equity; // equity }; //+------------------------------------------------------------------+ //| Overnight calculation data | //+------------------------------------------------------------------+ struct OverNightData { ConSymbol symbol; // symbol double point; // internal data TradeRecord **trades; // internal data int trades_total; // internal data int trades_max; // internal data }; //+------------------------------------------------------------------+ //| Daily report structure | //+------------------------------------------------------------------+ struct DailyReport { int login; // login time_t ctm; // daily report time char group[16]; // user group char bank[64]; // bank info (from UserRecord::Comment) double balance_prev; // balance for previous day double balance; // balance to the end for this day double deposit; // sum of balance operations for this day double credit; // sum of credit operations for this day double profit_closed; // profit of the today closed positions (including swaps & commissions) double profit; // floating profit/loss double equity; // equity double margin; // margin double margin_free; // free margin //--- internal data int next; int reserved[3]; }; //+------------------------------------------------------------------+ //| Client statement summary | //+------------------------------------------------------------------+ struct StateReport { //--- closed positions info double deposit; // Deposit/Withdrawal result double credit; // Credit In/Out result double closed_profit; // closed positions total profit double closed_commission; // closed positions total commission double closed_swap; // closed positions total swap double closed_taxes; // closed positions total taxes //--- open positions info double profit; // profit double commission; // commission double swap; // swap double equity; // Equity double taxes; // taxes double margin; // margin double margin_free; // free margin }; //+------------------------------------------------------------------+ //| Clients group info for statement | //+------------------------------------------------------------------+ struct GroupState { ConGroup group; UserRecord *users; int users_total; TradeRecord *trades; int trades_total; MarginLevel *margins; int margins_total; }; //+------------------------------------------------------------------+ //| Server access class | //+------------------------------------------------------------------+ struct CServerInterface { virtual int __stdcall Version(void); //--- common functions virtual time_t __stdcall TradeTime(void); //--- firewall config access virtual int __stdcall AccessAdd(const int pos,const ConAccess *acc); virtual int __stdcall AccessDelete(const int pos); virtual int __stdcall AccessNext(const int pos,ConAccess *acc); virtual int __stdcall AccessShift(const int pos,const int shift); //--- common config access virtual void __stdcall CommonGet(ConCommon *info); virtual void __stdcall CommonSet(const ConCommon *info); //--- time config access virtual void __stdcall TimeGet(ConTime *info); virtual void __stdcall TimeSet(const ConTime *info); //--- backup config access virtual void __stdcall BackupGet(ConBackup *info); virtual int __stdcall BackupSet(const ConBackup *info); //--- feeders config access virtual int __stdcall FeedersAdd(const ConFeeder *feeder); virtual int __stdcall FeedersDelete(const int pos); virtual int __stdcall FeedersNext(const int pos,ConFeeder *feeder); virtual int __stdcall FeedersGet(LPCSTR name,ConFeeder *feeder); virtual int __stdcall FeedersShift(const int pos,const int shift); virtual int __stdcall FeedersEnable(LPCSTR name,const int mode); //--- groups config access virtual int __stdcall GroupsAdd(ConGroup *group); virtual int __stdcall GroupsDelete(const int pos); virtual int __stdcall GroupsNext(const int pos,ConGroup *group); virtual int __stdcall GroupsGet(LPCSTR name,ConGroup *group); virtual int __stdcall GroupsShift(const int pos,const int shift); //--- holidays config access virtual int __stdcall HolidaysAdd(const int pos,ConHoliday *live); virtual int __stdcall HolidaysDelete(const int pos); virtual int __stdcall HolidaysNext(const int pos,ConHoliday *day); virtual int __stdcall HolidaysShift(const int pos,const int shift); //--- live update config access virtual int __stdcall LiveUpdateAdd(ConLiveUpdate *live); virtual int __stdcall LiveUpdateDelete(const int pos); virtual int __stdcall LiveUpdateNext(const int pos,ConLiveUpdate *live); virtual int __stdcall LiveUpdateGet(LPCSTR server,const int type,ConLiveUpdate *live); //--- managers config access virtual int __stdcall ManagersAdd(ConManager *man); virtual int __stdcall ManagersDelete(const int pos); virtual int __stdcall ManagersNext(const int pos,ConManager *manager); virtual int __stdcall ManagersGet(const int login,ConManager *manager); virtual int __stdcall ManagersShift(const int pos,const int shift); virtual int __stdcall ManagersIsDemo(LPCSTR group,LPCSTR sec,const int volume); //--- symbols config access virtual int __stdcall SymbolsAdd(ConSymbol *sec); virtual int __stdcall SymbolsDelete(const int pos); virtual int __stdcall SymbolsNext(const int pos, ConSymbol *sec); virtual int __stdcall SymbolsGet(LPCSTR symbol,ConSymbol *security); virtual int __stdcall SymbolsShift(const int pos,const int shift); virtual int __stdcall SymbolsGroupsGet(const int index, ConSymbolGroup* group); virtual int __stdcall SymbolsGroupsSet(const int index, ConSymbolGroup* group); //--- log access virtual void __stdcall LogsOut(const int code,LPCSTR ip,LPCSTR msg); //--- client base access-you should use HEAP_FREE on resulted arrays virtual int __stdcall ClientsTotal(void); virtual int __stdcall ClientsAddUser(UserRecord *inf); virtual int __stdcall ClientsDeleteUser(const int login); virtual int __stdcall ClientsUserInfo(const int login,UserRecord *inf); virtual int __stdcall ClientsUserUpdate(const UserRecord *inf); virtual int __stdcall ClientsCheckPass(const int login,LPCSTR password,const int investor); virtual int __stdcall ClientsChangePass(const int login,LPCSTR password,const int change_investor,const int drop_key); virtual int __stdcall ClientsChangeBalance(const int login,const ConGroup *grp,const double value,LPCSTR comment); virtual int __stdcall ClientsChangeCredit(const int login,const ConGroup *grp,const double value,const time_t date,LPCSTR comment); virtual UserRecord* __stdcall ClientsAllUsers(int *totalusers); virtual UserRecord* __stdcall ClientsGroupsUsers(int *totalusers,LPCSTR groups); //--- request base access virtual int __stdcall RequestsAdd(RequestInfo *request,const int isdemo,int *request_id); virtual int __stdcall RequestsGet(int *key,RequestInfo *req,const int maxreq); virtual int __stdcall RequestsFindAbsolete(const int login,LPCSTR symbol,const int volume,double *prices,DWORD *ctm,int *manager); virtual int __stdcall RequestsPrices(const int id,const UserInfo *us,double *prices,const int in_stream); virtual int __stdcall RequestsConfirm(const int id,const UserInfo *us,double *prices); virtual int __stdcall RequestsRequote(const int id,const UserInfo *us,double *prices,const int in_stream); virtual int __stdcall RequestsReset(const int id,const UserInfo *us,const char flag); //--- orders base access-you should use HEAP_FREE on resulted arrays virtual int __stdcall OrdersAdd(const TradeRecord *start,UserInfo* user,const ConSymbol *symb); virtual int __stdcall OrdersUpdate(TradeRecord *order,UserInfo* user,const int mode); //--- virtual int __stdcall OrdersGet(const int ticket,TradeRecord *order); virtual TradeRecord*__stdcall OrdersGet(const time_t from,const time_t to,const int *logins,const int count,int* total); virtual TradeRecord*__stdcall OrdersGetOpen(const UserInfo* user,int* total); virtual TradeRecord*__stdcall OrdersGetClosed(const time_t from,const time_t to,const int *logins,const int count,int* total); //--- trade info access virtual int __stdcall TradesCalcProfit(LPCSTR group,TradeRecord *tpi); virtual int __stdcall TradesMarginInfo(UserInfo *user,double *margin,double *freemargin,double *equity); //--- history center access-you should use HEAP_FREE on resulted arrays virtual void __stdcall HistoryAddTick(FeedData *tick); virtual int __stdcall HistoryLastTicks(LPCSTR symbol,TickAPI *ticks,const int ticks_max); virtual int __stdcall HistoryPrices(LPCSTR symbol,double *prices,time_t *ctm,int *dir); virtual int __stdcall HistoryPricesGroup(LPCSTR symbol,const ConGroup *grp,double *prices); virtual int __stdcall HistoryPricesGroup(RequestInfo *request,double *prices); virtual int __stdcall HistoryUpdateObsolete(LPCSTR symbol,const int period,void *rt,const int total,const int updatemode); virtual void* __stdcall HistoryQuotesObsolete(LPCSTR symbol,const int period,int *count); virtual void __stdcall HistorySync(void); //--- mail&news base access virtual int __stdcall MailSend(MailBoxHeader *mail,int *logins,const int total); virtual int __stdcall NewsSend(FeedData *feeddata); //--- main server access virtual void __stdcall ServerRestart(void); //--- daily base access-you should use HEAP_FREE on resulted arrays! virtual DailyReport* __stdcall DailyGet(LPCSTR group,const time_t from,const time_t to,int* logins,const int logins_total,int *daily_total); //--- select & free request from request queue virtual int __stdcall RequestsLock(const int id,const int manager); virtual int __stdcall RequestsFree(const int id,const int manager); //--- check available margin virtual double __stdcall TradesMarginCheck(const UserInfo *user,const TradeTransInfo *trade,double *profit,double *freemargin,double *new_margin); //--- high level order operations virtual int __stdcall OrdersOpen(const TradeTransInfo *trans,UserInfo *user); virtual int __stdcall OrdersClose(const TradeTransInfo *trans,UserInfo *user); virtual int __stdcall OrdersCloseBy(const TradeTransInfo *trans,UserInfo *user); //--- additional trade functions virtual double __stdcall TradesCalcRates(LPCSTR group,LPCSTR from,LPCSTR to); virtual double __stdcall TradesCalcConvertation(LPCSTR group,const int margin_mode,const double price,const ConSymbol *symbol); virtual double __stdcall TradesCommissionAgent(TradeRecord *trade,const ConSymbol *symbol,const UserInfo *user); virtual void __stdcall TradesCommission(TradeRecord *trade,LPCSTR group,const ConSymbol *symbol); virtual int __stdcall TradesFindLogin(const int order); //--- special checks virtual int __stdcall TradesCheckSessions(const ConSymbol *symbol,const time_t ctm); virtual int __stdcall TradesCheckStops(const TradeTransInfo *trans,const ConSymbol *symbol,const ConGroup *group,const TradeRecord *trade); virtual int __stdcall TradesCheckFreezed(const ConSymbol *symbol,const ConGroup *group,const TradeRecord *trade); virtual int __stdcall TradesCheckSecurity(const ConSymbol *symbol,const ConGroup *group); virtual int __stdcall TradesCheckVolume(const TradeTransInfo *trans,const ConSymbol *symbol,const ConGroup *group,const int check_min); virtual int __stdcall TradesCheckTickSize(const double price,const ConSymbol *symbol); //--- extension virtual int __stdcall RequestsFind(const int login,LPCSTR symbol,const int volume,const UCHAR type,const UCHAR cmd,double *prices,DWORD *ctm,int *manager); virtual int __stdcall HistoryUpdate(LPCSTR symbol,const int period,RateInfo *rt,const int total,const int updatemode); virtual RateInfo* __stdcall HistoryQuotes(LPCSTR symbol,const int period,int *count); //--- tick database access virtual TickAPI* __stdcall HistoryTicksGet(LPCSTR symbol,const time_t from,const time_t to,const char ticks_flags,int* total); //--- request server logs virtual char* __stdcall LogsRequest(const LogRequest *request,int *size); //--- check account's balance virtual int __stdcall ClientsCheckBalance(const int login,int fix_flag,double* difference); }; //+------------------------------------------------------------------+ //| Function parameters enumerations | //+------------------------------------------------------------------+ //--- login types enum { LOGIN_FLAG_CLIENT =0, LOGIN_FLAG_MOBILE =1, LOGIN_FLAG_MULTI =2, LOGIN_FLAG_DC =3, LOGIN_FLAG_ADMIN =4, LOGIN_FLAG_MANAGER =5, LOGIN_FLAG_MANAPI =6, LOGIN_FLAG_WD =7, LOGIN_FLAG_PHONE =8, LOGIN_FLAG_RESERVED=9, LOGIN_FLAG_IPHONE =10, LOGIN_FLAG_ANDROID =11 }; //--- avaible history periods enumeration enum { PERIOD_M1=1,PERIOD_M5=5,PERIOD_M15=15,PERIOD_M30=30,PERIOD_H1=60,PERIOD_H4=240,PERIOD_D1=1440,PERIOD_W1=10080,PERIOD_MN1=43200 }; //--- history updating modes enum { HB_ADD,HB_UPDATE,HB_INSERT,HB_DELETE }; //--- trade add modes enum { OPEN_NEW, OPEN_CLOSE, OPEN_RESTORE, OPEN_API, OPEN_ROLLOVER }; //--- trade update modes enum { UPDATE_NORMAL, UPDATE_ACTIVATE, UPDATE_CLOSE, UPDATE_DELETE }; //--- trade record state enum { TS_OPEN_NORMAL, TS_OPEN_REMAND, TS_OPEN_RESTORED, TS_CLOSED_NORMAL, TS_CLOSED_PART, TS_CLOSED_BY, TS_DELETED }; //--- ticks record flags enum { TICK_FLAG_RAW=1, TICK_FLAG_NORMAL=2 }; //+------------------------------------------------------------------+ //| MT Server API Hook Functions | //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ //| Plugin information | //+------------------------------------------------------------------+ void APIENTRY MtSrvAbout(PluginInfo* info); int APIENTRY MtSrvStartup(CServerInterface *server); void APIENTRY MtSrvCleanup(void); //+------------------------------------------------------------------+ //| Plugin configuration | //+------------------------------------------------------------------+ int APIENTRY MtSrvPluginCfgAdd(const PluginCfg *value); int APIENTRY MtSrvPluginCfgSet(const PluginCfg *values,const int total); int APIENTRY MtSrvPluginCfgGet(LPCSTR name,PluginCfg *value); int APIENTRY MtSrvPluginCfgNext(const int index,PluginCfg *value); int APIENTRY MtSrvPluginCfgDelete(LPCSTR name); int APIENTRY MtSrvPluginCfgTotal(); int APIENTRY MtSrvPluginCfgLog(LPSTR value,int *len); //+------------------------------------------------------------------+ //| Auxiliary Server Hook Functions | //+------------------------------------------------------------------+ void APIENTRY MtSrvLog(const LogInfo *info); void APIENTRY MtSrvScheduler(const time_t curtime); void APIENTRY MtSrvPerformance(const PerformanceInfo *inf); void APIENTRY MtSrvService(const DWORD curtime); //+------------------------------------------------------------------+ //| Client base Hook Functions | //+------------------------------------------------------------------+ int APIENTRY MtSrvUserConnect(const unsigned long ip,LPCSTR ipstring); int APIENTRY MtSrvUserLogin(const UserInfo *info); void APIENTRY MtSrvUserLogout(const UserInfo *info,const UCHAR type); int APIENTRY MtSrvUserLoginExt(const UserInfo *info,const UCHAR type); int APIENTRY MtSrvUserDemo(UserRecord *info); int APIENTRY MtSrvUserCommand(const UserInfo *info,ULONG ip,const unsigned char command); int APIENTRY MtSrvUserChangePass(const UserInfo *info,LPCSTR password,const int change_investor); void APIENTRY MtSrvUserAdd(const UserRecord *info); void APIENTRY MtSrvUserUpdate(const UserRecord *info); void APIENTRY MtSrvUserDelete(const UserRecord *info); int APIENTRY MtSrvUserArchive(const UserRecord *info,const ConGroup *group); void APIENTRY MtSrvUserCompactDemo(const UserRecord *info); void APIENTRY MtSrvUserCompactArchive(const UserRecord *info); void APIENTRY MtSrvUserRestore(const UserRecord *info); int APIENTRY MtSrvUserInterestDaily(UserRecord *user,const ConGroup *group,const double freemargin); int APIENTRY MtSrvUserInterestMonth(UserRecord *user,const ConGroup *group); void APIENTRY MtSrvUserFixBalance(const UserRecord *user,const double prev_balance,const double new_balance); //+------------------------------------------------------------------+ //| Datafeed Hook Functions | //+------------------------------------------------------------------+ void APIENTRY MtSrvFeederData(const ConFeeder *feed,FeedData *inf); int APIENTRY MtSrvFeederStart(const ConFeeder *feed); int APIENTRY MtSrvFeederCheck(const ConFeeder *feed,const DWORD curtime,const DWORD lasttime); void APIENTRY MtSrvFeederStop(const ConFeeder *feed); //+------------------------------------------------------------------+ //| Configuration Hook Functions | //+------------------------------------------------------------------+ int APIENTRY MtSrvGroupsAdd(const ConGroup *group); int APIENTRY MtSrvGroupsDelete(const ConGroup *group); int APIENTRY MtSrvSymbolsAdd(const ConSymbol *symb); int APIENTRY MtSrvSymbolsDelete(const ConSymbol *symb); int APIENTRY MtSrvManagersAdd(const ConManager *man); int APIENTRY MtSrvManagersDelete(const ConManager *man); //+------------------------------------------------------------------+ //| Trade activitiy Hook Functions | //+------------------------------------------------------------------+ int APIENTRY MtSrvTradeRequestFilter(RequestInfo *request,const int isdemo); void APIENTRY MtSrvTradeRequestApply(RequestInfo *request,const int isdemo); void APIENTRY MtSrvTradeRequestRestore(RequestInfo *request); int APIENTRY MtSrvTradeTransaction(TradeTransInfo* trans,const UserInfo *user,int *request_id); int APIENTRY MtSrvTradeCheckIE(TradeTransInfo* trans,const UserInfo *user,const ConSymbol *symbol,double *prices); int APIENTRY MtSrvTradeStopsFilter(const ConGroup *group,const ConSymbol *symbol,const TradeRecord *trade); int APIENTRY MtSrvTradeStopsApply(const UserInfo *user,const ConGroup *group,const ConSymbol *symbol,TradeRecord *trade,const int isTP); int APIENTRY MtSrvTradePendingsFilter(const ConGroup *group,const ConSymbol *symbol,const TradeRecord *trade); int APIENTRY MtSrvTradePendingsApply(const UserInfo *user,const ConGroup *group,const ConSymbol *symbol,const TradeRecord *pending,TradeRecord *trade); int APIENTRY MtSrvTradeStopoutsFilter(const ConGroup *group,const ConSymbol *symbol,const int login,const double equity,const double margin); int APIENTRY MtSrvTradeStopoutsApply(const UserInfo *user,const ConGroup *group,const ConSymbol *symbol,TradeRecord *stopout); void APIENTRY MtSrvTradesAdd(TradeRecord *trade,const UserInfo *user,const ConSymbol *symb); void APIENTRY MtSrvTradesUpdate(TradeRecord *trade,UserInfo *user,const int mode); void APIENTRY MtSrvTradesAddExt(TradeRecord *trade,const UserInfo *user,const ConSymbol *symb,const int mode); void APIENTRY MtSrvTradesCloseBy(TradeRecord *ftrade,TradeRecord *strade,TradeRecord *remaind,ConSymbol *sec,UserInfo *user); //+------------------------------------------------------------------+ //| Commissions & rollover calculation Hook Functions | //+------------------------------------------------------------------+ void APIENTRY MtSrvTradeCommission(TradeRecord *trade,const ConSymbol *sec,const ConGroup *grp); int APIENTRY MtSrvTradeCommissionAgent(TradeRecord *trade,const ConSymbol *sec,const UserInfo* user); int APIENTRY MtSrvTradeRollover(TradeRecord *trade,const double value,const OverNightData *data); //+------------------------------------------------------------------+ //| Statements generation Hook Functions | //+------------------------------------------------------------------+ void APIENTRY MtSrvStatementsBaseAll(const int month_state,const GroupState *groups,const int groups_total,const DailyReport *reports,const int reports_total); void APIENTRY MtSrvStatementsUser(const int month_state,const UserRecord *user,const ConGroup *group,TradeRecord *first_trade,TradeRecord *last_trade,StateReport *state); void APIENTRY MtSrvStatementsRollovers(const int month_state,const time_t ctm,const tm *ttm); //+------------------------------------------------------------------+ //| Dealer activity Hook Functions | //+------------------------------------------------------------------+ int APIENTRY MtSrvDealerConnect(const ConManager *manager); void APIENTRY MtSrvDealerDisconnect(const ConManager *manager); int APIENTRY MtSrvDealerGet(const ConManager *manager,const RequestInfo *request); int APIENTRY MtSrvDealerPrice(const int id,const UserInfo *us,double *prices,const int in_stream); int APIENTRY MtSrvDealerConfirm(const int id,const UserInfo *us,double *prices); int APIENTRY MtSrvDealerRequote(const int id,const UserInfo *us,double *prices,const int in_stream); int APIENTRY MtSrvDealerReset(const int id,const UserInfo *us,const char flag); int APIENTRY MtSrvDealerClientReject(const int id,const UserInfo *us); //+------------------------------------------------------------------+ //| Chart history, ticks filtration | //+------------------------------------------------------------------+ int APIENTRY MtSrvHistoryTickFilter(const ConSymbol *symbol,FeedTick *inf); void APIENTRY MtSrvHistoryTickApply(const ConSymbol *symbol,FeedTick *inf); int APIENTRY MtSrvHistoryCheck(const ConSymbol *symbol,RateInfo *rates,int *total); //+------------------------------------------------------------------+ //| Internal mail & News Hook Functions | //+------------------------------------------------------------------+ int APIENTRY MtSrvNewsCheck(FeedData *inf); int APIENTRY MtSrvMailCheck(MailBoxHeader *mail,int *logins,const int total); //+------------------------------------------------------------------+ //| Protocol extension Hook functions | //+------------------------------------------------------------------+ int APIENTRY MtSrvTelnet(const ULONG ip,char *buf,const int maxlen); char* APIENTRY MtSrvTelnetExt(const ULONG ip,char *buf,int* data_len); int APIENTRY MtSrvManagerProtocol(const ULONG ip,const UserInfo *us,const unsigned char *in_data,const int in_size,unsigned char **out_data,int *out_size); //+------------------------------------------------------------------+ //| Result codes | //+------------------------------------------------------------------+ enum { //--- common errors RET_OK =0, // all OK RET_OK_NONE, // all OK-no operation RET_ERROR, // general error RET_INVALID_DATA, // invalid data RET_TECH_PROBLEM, // server technical problem RET_OLD_VERSION, // old client terminal RET_NO_CONNECT, // no connection RET_NOT_ENOUGH_RIGHTS, // no enough rights RET_TOO_FREQUENT, // too frequently access to server RET_MALFUNCTION, // mulfunctional operation RET_GENERATE_KEY, // need key generation RET_SECURITY_SESSION, // securied session authorization RET_PUBLIC_KEY_MISSING, // need public key //--- account status RET_ACCOUNT_DISABLED =64, // account blocked RET_BAD_ACCOUNT_INFO, // bad account info //--- trade RET_TRADE_TIMEOUT =128, // trade transatcion timeou expired RET_TRADE_BAD_PRICES, // order has wrong prices RET_TRADE_BAD_STOPS, // wrong stops level RET_TRADE_BAD_VOLUME, // wrong lot size RET_TRADE_MARKET_CLOSED, // market closed RET_TRADE_DISABLE, // trade disabled RET_TRADE_NO_MONEY, // no enough money for order execution RET_TRADE_PRICE_CHANGED, // price changed RET_TRADE_OFFQUOTES, // no quotes RET_TRADE_BROKER_BUSY, // broker is busy RET_TRADE_REQUOTE, // requote RET_TRADE_ORDER_LOCKED, // order is proceed by dealer and cannot be changed RET_TRADE_LONG_ONLY, // allowed only BUY orders RET_TRADE_TOO_MANY_REQ, // too many requests from one client //--- order status notification RET_TRADE_ACCEPTED, // trade request accepted by server and placed in request queue RET_TRADE_PROCESS, // trade request accepted by dealerd RET_TRADE_USER_CANCEL, // trade request canceled by client //--- RET_TRADE_MODIFY_DENIED, // modification denied because order too close to market RET_TRADE_CONTEXT_BUSY, // trade context busy (for client terminal only) RET_TRADE_EXPIRATION_DENIED, // expiration specifieng is denied RET_TRADE_TOO_MANY_ORDERS, // too many orders RET_TRADE_HEDGE_PROHIBITED, // hedge is prohibited RET_TRADE_PROHIBITED_BY_FIFO // prohibited by fifo rule }; //+------------------------------------------------------------------+
标签:char,const,int,double,MT4,---,+------------------------------------------------- From: https://www.cnblogs.com/tuxiaomeng-com/p/16757343.html