| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452 |
- //+------------------------------------------------------------------+
- //| MetaTrader Server Interface |
- //| Copyright 2001-2015, 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, FW_WHITELIST };
- //+------------------------------------------------------------------+
- //| 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[60]; // reserved
- int timezone_real; // time zone with day light mode
- 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_mode; // rollover mode (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 enumeration MONTHLY_STATEMENT_END_MONTH, MONTHLY_STATEMENT_START_MONTH
- int keepticks; // ticks keep period
- int statement_weekend; // generate statements at weekends
- time_t last_activate; // last activation datetime
- time_t stop_last; // last stop datetime
- int stop_delay; // last stop delay
- int stop_reason; // last stop reason STOP_REASON_NONE, STOP_REASON_RESTART, STOP_REASON_SHUTDOWN, STOP_REASON_LIVEUPDATE
- char account_url[128]; // account allocation URL
- int reserved[16];
- };
- //+------------------------------------------------------------------+
- //| 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
- unsigned long watch_ip; // opposite server IP
- //---
- char archive_shift; // shift of archive backup time (in minutes)
- //---
- char watch_state; // watch dog state WS_DISCONNECTED, WS_SYNCHRONIZING, WS_SYNCHRONIZED
- char watch_failover; // watch dog failover mode
- unsigned char watch_timeout; // watch dog timeout
- int watch_login; // watch dog login
- time_t watch_timestamp; // watch dog timestamp
- };
- //--- 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_RELEASE, LIVE_UPDATE_NO_SERVER, LIVE_UPDATE_BETA };
- //--- demo modes
- enum { DEMO_DISABLED, DEMO_PROLONG, DEMO_FIXED };
- //--- monthly statement mode
- enum { MONTHLY_STATEMENT_END_MONTH, MONTHLY_STATEMENT_START_MONTH };
- //--- watchdog state
- enum { WS_DISCONNECTED, WS_SYNCHRONIZING, WS_SYNCHRONIZED };
- //--- watchdog failover mode
- enum { FAILOVER_OFF, FAILOVER_MOST, FAILOVER_FULL };
- //--- server stop reason
- enum { STOP_REASON_NONE, STOP_REASON_RESTART, STOP_REASON_SHUTDOWN, STOP_REASON_LIVEUPDATE };
- //+------------------------------------------------------------------+
- //| 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; // swap size for long and short positions
- 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 otp_mode; // one-time password mode
- //--- 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 hedge_largeleg; // calculate hedged margin using larger leg
- int unused_rights[2]; // 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,
- ALLOW_FLAG_RISK_WARNING =64,
- ALLOW_FLAG_FORCED_OTP_USAGE=128,
- };
- //--- group one-time password mode
- enum
- {
- OTP_MODE_DISABLED =0,
- OTP_MODE_TOTP_SHA256 =1,
- };
- //+------------------------------------------------------------------+
- //| 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_CLIENT_PPC2002, LIVE_UPDATE_CLIENT_PPC2003, LIVE_UPDATE_MULTI, LIVE_UPDATE_WD,
- LIVE_UPDATE_CLIENT_PHONE, 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 market_watch; // 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 market; // right to access server applications market
- int notifications; // right to push notifications
- int unused[9];
- //--- 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-Sunday,1-Monday,2-Tuesday...
- 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; // hedged 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 swap_variation_margin; // charge variation margin on rollover
- //---
- int unused[21]; // 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
- };
- //+------------------------------------------------------------------+
- //| Gateway configuration |
- //+------------------------------------------------------------------+
- //+------------------------------------------------------------------+
- //| Gateway account configuration |
- //+------------------------------------------------------------------+
- struct ConGatewayAccount
- {
- int enable; // enable flag 0 - disabled, 1 - enabled
- char name[64]; // public name
- int id; // internal id
- int type; // type (obsolete)
- int login; // STP MT4 login
- char address[64]; // MT4 server address
- char password[64]; // STP MT4 password
- int notify_logins[8]; // list of logins for internal email notification
- int flags; // flag fields
- int reserved[23]; // reserved
- };
- //--- gateway account flags
- enum EnGatewayAccountFlags { GATEWAY_FLAG_NONE=0, GATEWAY_FLAG_QUOTES=1 };
- //+------------------------------------------------------------------+
- //| Gateway markup configuration |
- //+------------------------------------------------------------------+
- struct ConGatewayMarkup
- {
- int enable; // enable flag 0 - disabled, 1 - enabled
- char source[128]; // source symbol\symbols mask\symbols group name
- char symbol[12]; // local symbol name
- char account_name[64]; // account name (obsolete)
- int account_id; // account internal id (obsolete)
- int bid_markup; // bid markup in pips
- int ask_markup; // ask markup in pips
- int reserved[16]; // reserved
- };
- //+------------------------------------------------------------------+
- //| Gateway rules configuration |
- //+------------------------------------------------------------------+
- struct ConGatewayRule
- {
- int enable; // enable flag 0 - disabled, 1 - enabled
- char name[64]; // public name
- char request_symbol[128]; // symbol\symbols mask\symbols group name
- char request_group[128]; // group name or group mask
- int request_reserved[32]; // reserved
- char exe_account_name[64]; // account name
- int exe_account_id; // account internal id
- int exe_max_deviation; // max. devation
- int exe_max_profit_slippage; // max profit slippage in pips
- int exe_max_profit_slippage_lots; // max profit slippage volume in lots
- int exe_max_losing_slippage; // max losing slippage in pips
- int exe_max_losing_slippage_lots; // max losing slippage volume in lots
- int exe_account_pos; // account current position
- int exe_volume_percent; // coverage percentage
- int exe_flags; // execution flags
- int exe_reserved[25]; // reserved
- };
- //+------------------------------------------------------------------+
- //| Gateway rules flags |
- //+------------------------------------------------------------------+
- enum EnGatewayRuleFlags
- {
- GATEWAY_RULE_FLAG_NONE =0, // none
- GATEWAY_RULE_FLAG_DEALER=1 // process dealer's trades
- };
- //+------------------------------------------------------------------+
- //| 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
- };
- //+------------------------------------------------------------------+
- //| Tick source constants for FeedTick::feeder |
- //+------------------------------------------------------------------+
- enum EnTickSources
- {
- TICK_SRC_DEALER_AUTO =-1, // tick placed as result of request confirmation with in_stream flag
- TICK_SRC_DEALER_MANUAL=-2, // tick placed manually by dealer
- TICK_SRC_GATEWAY =-128 // base value for gateway ticks
- // gateway index calculated like abs(TICK_SRC_GATEWAY-FeedTick::feeder)
- };
- //+------------------------------------------------------------------+
- //| 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
- };
- //+------------------------------------------------------------------+
- //| Extended news structure |
- //+------------------------------------------------------------------+
- #pragma pack(push,1)
- struct FeedNews
- {
- //--- constants
- enum constants
- {
- MAX_NEWS_BODY_LEN=15*1024*1024 // max. body len
- };
- //--- news topic flags
- enum EnNewsFlags
- {
- FLAG_PRIORITY =1, // priority flag
- FLAG_CALENDAR =2, // calendar item flag
- FLAG_MIME =4, // MIME news content
- FLAG_ALLOW_DEMO =8 // allow body for demo accounts
- };
- UINT language; // news language (WinAPI LANGID)
- wchar_t subject[256]; // news subject
- wchar_t category[256]; // news category
- UINT flags; // EnNewsFlags
- wchar_t *body; // body
- UINT body_len; // body length
- UINT languages_list[32]; // list of languages available for news
- INT64 datetime; // news time
- UINT reserved[30]; // reserved
- };
- #pragma pack(pop)
- //+------------------------------------------------------------------+
- //| 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_otp; // allow to use one-time password
- int enable_reserved[2]; // 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[96]; // address
- char lead_source[32]; // lead source
- 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 last_ip; // last visit ip
- //--- òîðãîâûå äàííûå
- 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 otp_secret[32]; // one-time password secret
- char secure_reserved[240]; // secure data reserved
- int send_reports; // enable send reports by email
- unsigned int mqid; // MQ client identificator
- 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 read; // read 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 flags; // flags
- 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 request flags
- enum EnReqFlags
- {
- TT_FLAG_NONE =0x00000000, // flags none
- TT_FLAG_SIGNAL =0x00000001, // placed by signal
- TT_FLAG_EXPERT =0x00000002, // placed by expert
- TT_FLAG_GATEWAY=0x00000004, // placed by gateway
- TT_FLAG_MOBILE =0x00000008, // placed by mobile terminal
- TT_FLAG_WEB =0x00000010, // placed by web terminal
- TT_FLAG_API =0x00000020, // placed by api
- };
- //--- 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
- 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
- int gw_volume; // gateway order volume
- int gw_order; // gateway order ticket
- short gw_price; // gateway order price deviation (pips) from request price
- short 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
- int gw_volume; // gateway order volume
- time_t expiration; // pending order's expiration time
- char reason; // trade reason
- char conv_reserv[3]; // reserved fields
- 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 gw_order; // gateway order ticket
- int activation; // used by MT Manager
- short gw_open_price; // gateway order price deviation (pips) from order open price
- short gw_close_price; // gateway order price deviation (pips) from order close price
- double margin_rate; // margin cinvertation rate (rate of convertation from margin currency to deposit one)
- time_t timestamp; // timestamp
- int api_data[4]; // for api usage
- 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 *day);
- 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 RequestsFindObsolete(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 *prev_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);
- //--- request base access
- virtual int __stdcall RequestsConfirmPrice(const int id,const UserInfo *us,double price,double *prices);
- //--- check plugin license
- virtual int __stdcall LicenseCheck(LPCSTR license_name);
- //--- gateway account config access
- virtual int __stdcall GatewayAccountsAdd(ConGatewayAccount *cfg);
- virtual int __stdcall GatewayAccountsDelete(const int pos);
- virtual int __stdcall GatewayAccountsNext(const int pos, ConGatewayAccount *cfg);
- virtual int __stdcall GatewayAccountsShift(const int pos,const int shift);
- //--- gateway account config markups
- virtual int __stdcall GatewayMarkupsAdd(ConGatewayMarkup *cfg);
- virtual int __stdcall GatewayMarkupsDelete(const int pos);
- virtual int __stdcall GatewayMarkupsNext(const int pos, ConGatewayMarkup *cfg);
- virtual int __stdcall GatewayMarkupsShift(const int pos,const int shift);
- //--- gateway account config rules
- virtual int __stdcall GatewayRulesAdd(ConGatewayRule *cfg);
- virtual int __stdcall GatewayRulesDelete(const int pos);
- virtual int __stdcall GatewayRulesNext(const int pos, ConGatewayRule *cfg);
- virtual int __stdcall GatewayRulesShift(const int pos,const int shift);
- //--- notifications
- virtual int __stdcall NotificationsSend(LPCWSTR metaquotes_ids,LPCWSTR message);
- virtual int __stdcall NotificationsSend(const int* logins,const UINT logins_total,LPCWSTR message);
- //--- request base - delete request from queue by ID
- virtual int __stdcall RequestsDelete(const int id);
- //--- trade info access with userinfo request
- virtual int __stdcall TradesMarginGet(const int login,UserInfo* user,double *margin,double *freemargin,double *equity);
- };
- //+------------------------------------------------------------------+
- //| 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_WEB =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 };
- //--- trade record reasons
- enum { TR_REASON_CLIENT, TR_REASON_EXPERT, TR_REASON_DEALER,TR_REASON_SIGNAL, TR_REASON_GATEWAY, TR_REASON_MOBILE, TR_REASON_WEB, TR_REASON_API };
- //--- 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 MtSrvPluginCfgSet(const PluginCfg *values,const int total);
- int APIENTRY MtSrvPluginCfgNext(const int index,PluginCfg *value);
- int APIENTRY MtSrvPluginCfgTotal();
- //+------------------------------------------------------------------+
- //| 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);
- int APIENTRY MtSrvUserChangePassExt(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 MtSrvTradesAddExt(TradeRecord *trade,const UserInfo *user,const ConSymbol *symb,const int mode);
- void APIENTRY MtSrvTradesAddRequest(TradeRecord *trade,const RequestInfo* request,const UserInfo *user,const ConSymbol *symb,const int mode);
- void APIENTRY MtSrvTradesUpdate(TradeRecord *trade,UserInfo *user,const int mode);
- void APIENTRY MtSrvTradesRestore(const TradeRecord *trade);
- 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 MtSrvNewsCheckNew(const int feeder,FeedNews *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
- //--- account status
- RET_ACCOUNT_DISABLED =64, // account blocked
- RET_BAD_ACCOUNT_INFO, // bad account info
- RET_PUBLIC_KEY_MISSING, // need public key
- //--- 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
- };
- //+------------------------------------------------------------------+
|