同上篇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];

本文介绍 MetaTrader Server API 的结构和主要接口,包括配置管理、交易活动、历史数据处理等功能。通过这些接口,开发者能够实现对交易系统的高度定制。
最低0.47元/天 解锁文章
1041

被折叠的 条评论
为什么被折叠?



