我正在使用交易平台 MetaTrader 4 的 API 管理器
我需要获得每个组的所有证券
例如 GROUP=preliminary|SECUTIRY_0=外汇|SECUTIRY_1=CFD|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);
}