Compute factor values
curl --request POST \
--url https://api.reportify.cn/v1/quant/factors/compute \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"symbols": [
"<string>"
],
"formula": "<string>",
"market": "cn",
"start_date": "2023-12-25",
"end_date": "2023-12-25"
}
'import requests
url = "https://api.reportify.cn/v1/quant/factors/compute"
payload = {
"symbols": ["<string>"],
"formula": "<string>",
"market": "cn",
"start_date": "2023-12-25",
"end_date": "2023-12-25"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
symbols: ['<string>'],
formula: '<string>',
market: 'cn',
start_date: '2023-12-25',
end_date: '2023-12-25'
})
};
fetch('https://api.reportify.cn/v1/quant/factors/compute', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.reportify.cn/v1/quant/factors/compute",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'symbols' => [
'<string>'
],
'formula' => '<string>',
'market' => 'cn',
'start_date' => '2023-12-25',
'end_date' => '2023-12-25'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.reportify.cn/v1/quant/factors/compute"
payload := strings.NewReader("{\n \"symbols\": [\n \"<string>\"\n ],\n \"formula\": \"<string>\",\n \"market\": \"cn\",\n \"start_date\": \"2023-12-25\",\n \"end_date\": \"2023-12-25\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.reportify.cn/v1/quant/factors/compute")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"symbols\": [\n \"<string>\"\n ],\n \"formula\": \"<string>\",\n \"market\": \"cn\",\n \"start_date\": \"2023-12-25\",\n \"end_date\": \"2023-12-25\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.reportify.cn/v1/quant/factors/compute")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"symbols\": [\n \"<string>\"\n ],\n \"formula\": \"<string>\",\n \"market\": \"cn\",\n \"start_date\": \"2023-12-25\",\n \"end_date\": \"2023-12-25\"\n}"
response = http.request(request)
puts response.read_body{
"datas": [
{
"date": "2023-12-25",
"symbol": "<string>",
"name": "<string>",
"name_en": "<string>",
"close": 123,
"factor_value": 123,
"indicators": {}
}
],
"metadata": {
"formula": "<string>",
"start_date": "2023-12-25",
"end_date": "2023-12-25",
"total_rows": 123,
"fields": [
"<string>"
],
"indicators": [
"<string>"
]
}
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}量化分析接口
计算因子数据
计算指定股票的因子数据
POST
/
v1
/
quant
/
factors
/
compute
Compute factor values
curl --request POST \
--url https://api.reportify.cn/v1/quant/factors/compute \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"symbols": [
"<string>"
],
"formula": "<string>",
"market": "cn",
"start_date": "2023-12-25",
"end_date": "2023-12-25"
}
'import requests
url = "https://api.reportify.cn/v1/quant/factors/compute"
payload = {
"symbols": ["<string>"],
"formula": "<string>",
"market": "cn",
"start_date": "2023-12-25",
"end_date": "2023-12-25"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
symbols: ['<string>'],
formula: '<string>',
market: 'cn',
start_date: '2023-12-25',
end_date: '2023-12-25'
})
};
fetch('https://api.reportify.cn/v1/quant/factors/compute', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.reportify.cn/v1/quant/factors/compute",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'symbols' => [
'<string>'
],
'formula' => '<string>',
'market' => 'cn',
'start_date' => '2023-12-25',
'end_date' => '2023-12-25'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.reportify.cn/v1/quant/factors/compute"
payload := strings.NewReader("{\n \"symbols\": [\n \"<string>\"\n ],\n \"formula\": \"<string>\",\n \"market\": \"cn\",\n \"start_date\": \"2023-12-25\",\n \"end_date\": \"2023-12-25\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.reportify.cn/v1/quant/factors/compute")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"symbols\": [\n \"<string>\"\n ],\n \"formula\": \"<string>\",\n \"market\": \"cn\",\n \"start_date\": \"2023-12-25\",\n \"end_date\": \"2023-12-25\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.reportify.cn/v1/quant/factors/compute")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"symbols\": [\n \"<string>\"\n ],\n \"formula\": \"<string>\",\n \"market\": \"cn\",\n \"start_date\": \"2023-12-25\",\n \"end_date\": \"2023-12-25\"\n}"
response = http.request(request)
puts response.read_body{
"datas": [
{
"date": "2023-12-25",
"symbol": "<string>",
"name": "<string>",
"name_en": "<string>",
"close": 123,
"factor_value": 123,
"indicators": {}
}
],
"metadata": {
"formula": "<string>",
"start_date": "2023-12-25",
"end_date": "2023-12-25",
"total_rows": 123,
"fields": [
"<string>"
],
"indicators": [
"<string>"
]
}
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}计算指定股票的因子数据,支持技术因子和基本面因子,公式使用麦语言语法(兼容通达信/同花顺)。
curl -X POST https://api.reportify.cn/v1/quant/factors/compute \
-H "Authorization: Bearer <token>" \
-H "Content-Type: application/json" \
-d '{
"market": "cn",
"symbols": ["000001", "000002"],
"formula": "RSI(14)",
"start_date": "2026-01-01",
"end_date": "2026-01-10"
}'
import requests
response = requests.post(
"https://api.reportify.cn/v1/quant/factors/compute",
headers={"Authorization": "Bearer <token>"},
json={
"market": "cn",
"symbols": ["000001", "000002"],
"formula": "RSI(14)",
"start_date": "2026-01-01",
"end_date": "2026-01-10"
}
)
print(response.json())
const response = await fetch('https://api.reportify.cn/v1/quant/factors/compute', {
method: 'POST',
headers: {
'Authorization': 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
market: 'cn',
symbols: ['000001', '000002'],
formula: 'RSI(14)',
start_date: '2026-01-01',
end_date: '2026-01-10'
})
});
请求参数
string
default:"cn"
股票市场:
cn(A股), hk(港股), us(美股)string[]
required
股票代码列表
string
required
因子公式
string
开始日期,格式:
YYYY-MM-DD(默认:3 个月前)string
结束日期,格式:
YYYY-MM-DD(默认:今天)公式示例
技术因子
| 公式 | 类型 | 描述 |
|---|---|---|
RSI(14) | 数值 | RSI 指标值 |
MACD().dif | 数值 | MACD DIF 线 |
CLOSE > MA(CLOSE, 20) | 布尔 | 收盘价高于 20 日均线 |
(CLOSE - MA(CLOSE, 20)) / MA(CLOSE, 20) * 100 | 数值 | 偏离 MA20 的百分比 |
基本面因子
| 公式 | 类型 | 描述 |
|---|---|---|
PE() | 数值 | 市盈率 |
PE_TTM() | 数值 | 市盈率(TTM) |
PB() | 数值 | 市净率 |
ROE() | 数值 | 净资产收益率 |
ROA() | 数值 | 总资产收益率 |
INCOME.net_profit | 数值 | 利润表 - 净利润 |
BALANCESHEET.total_assets | 数值 | 资产负债表 - 总资产 |
PE() < 20 | 布尔 | 市盈率小于 20 |
ROE() > 0.15 | 布尔 | ROE 大于 15% |
运算符
| 类型 | 运算符 | 示例 |
|---|---|---|
| 比较 | >, <, >=, <=, ==, != | CLOSE > MA(CLOSE, 20) |
| 逻辑与 | & 或 AND | (RSI(14) < 30) & (CLOSE > MA(CLOSE, 20)) |
| 逻辑或 | | 或 OR | (RSI(14) < 30) | (RSI(14) > 70) |
| 逻辑非 | ~ 或 NOT | NOT (CLOSE > MA(CLOSE, 20)) |
| 算术 | +, -, *, / | (CLOSE - MA(CLOSE, 20)) / MA(CLOSE, 20) * 100 |
支持的变量
| 变量 | 别名 | 描述 |
|---|---|---|
CLOSE | C | 收盘价 |
OPEN | O | 开盘价 |
HIGH | H | 最高价 |
LOW | L | 最低价 |
VOLUME | V, VOL | 成交量 |
AMOUNT | - | 成交额 |
支持的函数
| 级别 | 函数 |
|---|---|
| Level 0 | MA, EMA, SMA, REF, HHV, LLV, STD, SUM, ABS, MAX, MIN, IF… |
| Level 1 | CROSS, CROSSDOWN, COUNT, EVERY, EXIST, BARSLAST… |
| Level 2 技术 | RSI, MACD, BOLL, KDJ, WR, ATR, CCI, BIAS, PSY… |
| Level 2 基本面 | PE(), PB(), PS(), ROE(), ROA(), EPS(), BPS(), CURRENT_RATIO()… |
响应参数
array
因子数据列表,包含 symbol、date 和因子值
object
计算元数据
响应示例
数值因子
{
"datas": [
{
"symbol": "000001",
"date": "2026-01-10",
"value": 58.32
},
{
"symbol": "000001",
"date": "2026-01-09",
"value": 56.78
}
],
"metadata": {
"formula": "RSI(14)",
"market": "cn",
"count": 2
}
}
布尔因子
{
"datas": [
{
"symbol": "000001",
"date": "2026-01-10",
"value": true
},
{
"symbol": "000002",
"date": "2026-01-10",
"value": false
}
],
"metadata": {
"formula": "CLOSE > MA(CLOSE, 20)",
"market": "cn",
"count": 2
}
}
基本面因子
{
"datas": [
{
"symbol": "000001",
"date": "2026-01-10",
"value": 8.52
},
{
"symbol": "600519",
"date": "2026-01-10",
"value": 28.65
}
],
"metadata": {
"formula": "PE_TTM()",
"market": "cn",
"count": 2
}
}
MACD DIF 线
{
"datas": [
{
"symbol": "000001",
"date": "2026-01-10",
"value": 0.125
},
{
"symbol": "000001",
"date": "2026-01-09",
"value": 0.118
}
],
"metadata": {
"formula": "MACD().dif",
"market": "cn",
"count": 2
}
}
Authorizations
Enter your Bearer token
Body
application/json
Input for factor computation.
Stock code list, e.g., ["600519", "000001"] for CN market (required)
Factor formula (required)
Stock market
Available options:
cn, hk, us, global Start date (optional, default: 3 months ago)
End date (optional, default: today)
⌘I
