MT4 交易平台 API 经理 - 按组获取证券
MT4 trading platform API Manager - get securities per group
我正在使用 API 交易平台 MetaTrader 4 的管理器
我需要为每个 GROUP
购买 ALL SECURITIES
例如
GROUP=初步|SECUTIRY_0=外汇|SECUTIRY_1=差价合约|SECUTIRY_2=|
我在下面有一些提示:
- 在使用 CfgRequestSymbolGroup(ConSymbolGroup 配置)请求证券配置后,您获得了所有证券。*
- 因此,您为每种证券获得了 ConSymbolGroup,现在配置 [0] 是外汇,配置 [1] 是 cfd,配置 [2] 是金属。*
- 然后使用 CfgRequestGroup(int total) 请求组配置,您将获得每个组的 ConGroup 结构。
- ConGroup 有 ConGroupSec secgroups[MAX_SEC_GROUPS] 参数 - 安全组设置。*
- 索引将相同,因此 secgroups[0] 是该组的外汇设置,secgroups[1] 是 cfd 等等。*
我的代码在下面,但无法获得所需的结果,在下面的代码中,我获得了包含证券的列表和包含组的列表,但无法根据上面的描述获取索引以获取这种格式的结果
GROUP=初步|SECUTIRY_0=外汇|SECUTIRY_1=差价合约|SECUTIRY_2=|
// 1 step
// request all securities
// list with securities
ConSymbolGroup securities[MAX_SEC_GROUP];
int result = ExtManager->CfgRequestSymbolGroup(securities);
// 2 step
// request all groups
// list with groups
ConGroup *groups = ExtManager->CfgRequestGroup(&total);
ConGroupSec secgroups[MAX_SEC_GROUPS];
int index_secgroup = 0;
int index_security = 0;
for (int i = 0; i < MAX_SEC_GROUP; i++)
for (int i =0; i < total; i++)
ExtProcessor.PrintResponse(size,
"GROUP=%s|"
"SECUTIRY_0=%s|"
"SECUTIRY_1=%s|"
"SECUTIRY_2=%s|\r\n",
groups[i].group,
securities[0].name,
securities[1].name,
securities[2].name);
}
以下代码片段将为您提供所需的数据,因此您可以根据需要输出它:
ConSymbolGroup sgconfigurations[MAX_SEC_GROUP];
_manager->Manager->CfgRequestSymbolGroup(sgconfigurations);
int total = 0;
ConGroup* result = _manager->Manager->CfgRequestGroup(&total);
for (int i = 0; i < total; i++)
{
for (int j = 0; j < MAX_SEC_GROUP; j++) {
if (result[i].secgroups[j].show == 1 && sgconfigurations[j].name != NULL && sgconfigurations[j].name[0] != '[=10=]') {
char* groupName = result[i].group;
char* securityName = sgconfigurations[j].name;
}
}
}
我正在使用 API 交易平台 MetaTrader 4 的管理器
我需要为每个 GROUP
购买 ALL SECURITIES例如 GROUP=初步|SECUTIRY_0=外汇|SECUTIRY_1=差价合约|SECUTIRY_2=|
我在下面有一些提示:
- 在使用 CfgRequestSymbolGroup(ConSymbolGroup 配置)请求证券配置后,您获得了所有证券。*
- 因此,您为每种证券获得了 ConSymbolGroup,现在配置 [0] 是外汇,配置 [1] 是 cfd,配置 [2] 是金属。*
- 然后使用 CfgRequestGroup(int total) 请求组配置,您将获得每个组的 ConGroup 结构。
- ConGroup 有 ConGroupSec secgroups[MAX_SEC_GROUPS] 参数 - 安全组设置。*
- 索引将相同,因此 secgroups[0] 是该组的外汇设置,secgroups[1] 是 cfd 等等。*
我的代码在下面,但无法获得所需的结果,在下面的代码中,我获得了包含证券的列表和包含组的列表,但无法根据上面的描述获取索引以获取这种格式的结果
GROUP=初步|SECUTIRY_0=外汇|SECUTIRY_1=差价合约|SECUTIRY_2=|
// 1 step
// request all securities
// list with securities
ConSymbolGroup securities[MAX_SEC_GROUP];
int result = ExtManager->CfgRequestSymbolGroup(securities);
// 2 step
// request all groups
// list with groups
ConGroup *groups = ExtManager->CfgRequestGroup(&total);
ConGroupSec secgroups[MAX_SEC_GROUPS];
int index_secgroup = 0;
int index_security = 0;
for (int i = 0; i < MAX_SEC_GROUP; i++)
for (int i =0; i < total; i++)
ExtProcessor.PrintResponse(size,
"GROUP=%s|"
"SECUTIRY_0=%s|"
"SECUTIRY_1=%s|"
"SECUTIRY_2=%s|\r\n",
groups[i].group,
securities[0].name,
securities[1].name,
securities[2].name);
}
以下代码片段将为您提供所需的数据,因此您可以根据需要输出它:
ConSymbolGroup sgconfigurations[MAX_SEC_GROUP];
_manager->Manager->CfgRequestSymbolGroup(sgconfigurations);
int total = 0;
ConGroup* result = _manager->Manager->CfgRequestGroup(&total);
for (int i = 0; i < total; i++)
{
for (int j = 0; j < MAX_SEC_GROUP; j++) {
if (result[i].secgroups[j].show == 1 && sgconfigurations[j].name != NULL && sgconfigurations[j].name[0] != '[=10=]') {
char* groupName = result[i].group;
char* securityName = sgconfigurations[j].name;
}
}
}