1.7 KiB
1.7 KiB
外汇
内容
- 汇率
汇率
内容
- ForExrateMidPrice
- ForExrateMidPriceBegTEndT
- GetCurrencyCodeBySecurityCode
- ForExRateZf
ForExrateMidPrice
范例
//2020年4月20日美元/人民币的中间价
SetSysParam(PN_Stock(),'FXUSDCNY');
return ForExrateMidPrice(20200420T);
//返回7.0657
ForExrateMidPriceBegTEndT
范例
//2020年4月20日到4月30日美元/人民币的中间价数据
SetSysParam(PN_Stock(),'FXUSDCNY');
begt:=20200420T;
endt:=20200430T;
return ForExrateMidPriceBegTEndT(begt,endt);
//返回:
| 日期 | 代码 | 中间价 |
| 20200420 | FXUSDCNY | 7.0657 |
| 20200421 | FXUSDCNY | 7.0752 |
| 20200422 | FXUSDCNY | 7.0903 |
| 20200423 | FXUSDCNY | 7.0887 |
| 20200424 | FXUSDCNY | 7.0803 |
| 20200427 | FXUSDCNY | 7.0703 |
| 20200428 | FXUSDCNY | 7.071 |
| 20200429 | FXUSDCNY | 7.0704 |
| 20200430 | FXUSDCNY | 7.0571 |
GetCurrencyCodeBySecurityCode
范例
//港股长和00001对应的货币对代码
return GetCurrencyCodeBySecurityCode('HK00001');
//返回 HKD
ForExRateZf
算法
(V2-V1)/V1
其中V2是货币对在endt的中间价,V1是begt(需要大于首个交易日,否则begt=首个交易日)的中间价。范例
//2020年4月20日到4月30日美元/人民币的收益率
SetSysParam(PN_Stock(),'FXUSDCNY');
begt:=20200420T;
endt:=20200430T;
return ForExRateZf(BegT,EndT);
//返回 -0.20786786956644