# 金融 / 外汇 / 汇率 ## `forExrateMidPrice(end_t)` 声明:function 指定日汇率中间价,与系统参数(外汇代码)相关 | 参数 | 类型 | 说明 | | ------- | --------- | ------------------ | | `end_t` | tdatetime | 日期类型,截止日期 | 返回:real ### 示例 范例01:2020年4月20日美元/人民币的中间价 ```tsl // 2020年4月20日美元/人民币的中间价 SetSysParam(PN_Stock(), 'FXUSDCNY'); return ForExrateMidPrice(20200420T); // 输出:7.0657 ``` ## `forExrateMidPriceBegTEndT(begt, endt)` 声明:function 区间汇率数据,与系统参数(外汇代码)相关 | 参数 | 类型 | 说明 | | ------ | --------- | ------------------ | | `begt` | tdatetime | 日期类型,开始日期 | | `endt` | tdatetime | 日期类型,截止日期 | 返回:array ### 示例 范例01:2020年4月20日到4月30日美元/人民币的中间价数据 ```tsl // 2020年4月20日到4月30日美元/人民币的中间价数据 SetSysParam(PN_Stock(), 'FXUSDCNY'); begt := 20200420T; endt := 20200430T; return ForExrateMidPriceBegTEndT(begt, endt); ``` ## `forExRateZf(begt, endt)` 声明:function 获取汇率区间收益率,与系统参数(外汇代码)相关 | 参数 | 类型 | 说明 | | ------ | --------- | ------------------ | | `begt` | tdatetime | 日期类型,开始日期 | | `endt` | tdatetime | 日期类型,截止日期 | 返回:real ### 示例 范例01:2020年4月20日到4月30日美元/人民币的收益率 ```tsl // 2020年4月20日到4月30日美元/人民币的收益率 SetSysParam(PN_Stock(), 'FXUSDCNY'); begt := 20200420T; endt := 20200430T; return ForExRateZf(BegT, EndT); // 输出:-0.20786786956644 ``` ## `getCurrencyCodeBySecurityCode(stockid)` 声明:function 根据证券代码得到其币种代码。目前对照包括上交所、深交所、联交所股票 | 参数 | 类型 | 说明 | | --------- | ------ | ---------------- | | `stockid` | string | 字符串,证券代码 | 返回:real ### 示例 范例01:港股长和00001对应的货币对代码 ```tsl // 港股长和00001对应的货币对代码 return GetCurrencyCodeBySecurityCode('HK00001'); // 输出:HKD ```