nfragrans_stock
v1.0.0
Published
读取stock数据,基于新浪和搜狐的stockAPI
Readme
读取stock数据,基于新浪和搜狐的stockAPI
都存在跨域问题,需要在网站上后端获取,或者使用nodejs生成的网站作为代理服务器(https://gitee.com/QGISER/nfragrans_proxy-server.git)
搜狐数据
1.获取历史数据
getSOHistoryData(symbol, startDate, endDate = getFormattedDate())
url = https://q.stock.sohu.com/hisHq?code=${symbol}&start=${startDate}&end=${endDate};
返回:
[{
date: '2024-11-14',
open: '8.30',
close: '8.26',
change: '-0.09',
changePercent: '-1.08%',
low: '8.25',
high: '8.36',
volume: '661416',
amount: '54910.66',
turnover: '0.27%'
},
......
]
2.读取某年数据
getSOByYear(symbol, year=null)
3.读取近5年数据
async function getSOBynYears(symbol, year = null, n = 5)
新浪数据
1.读取实时数据
getSNCurrenData(symbol)
symbol为股票名称,标准格式sh600519,可输入cn_600519或sh600519或600519,代码自动检测修正。
url=https://hq.sinajs.cn/etag.php?list=${symbol}
返回:
[
0.'"����ę́'//名称,
1.'1467.950'//开盘价,
2.'1467.980'//昨日收盘价,
3.'1450.000'//当前价,
4.'1478.880'//最高价,
5.'1449.340'//最低价,
6.'1450.000'//“买一”报价,
7.'1450.060'//“买一”报价,
8.'3822583'//成交的股票数(股),
9.'5578603148.000'//成交金额(元),
10.'4746'//买1股数,
11.'1450.000'//买1价格,
12.'500'//买2股数,
13.'1449.990'//买2价格,
14.'700'//买3价格,
15.'1449.980'//买3价格,
16.'100'//买4股数,
17.'1449.970'//买4价格,
18.'300'//买5股数,
19.'1449.960'//买5价格,
20.'300'//卖1股数,
21.'1450.060'//卖1价格,
22.'400'//卖2股数,
23.'1450.070'//卖2价格,
24.'100'//卖3股数,
25.'1450.220'//卖3价格,
26.'100'//卖4股数,
27.'1450.660'//卖4价格,
28.'300'//卖5股数,
29.'1450.800'//卖5价格,
30.'2025-10-24'//日期,
31.'15:00:03'//时间,
32.'00',
33.'";\n'
]
2.读取股票分价统计情况
getSNPriceDistribution(symbol, startDate) https://market.finance.sina.com.cn/pricehis.php?symbol=sh600900&startdate=2025-01-01 返回:[ { price: '30.52', volume: '418500' }, { price: '30.51', volume: '718100' }, { price: '30.50', volume: '3202700' }, { price: '30.49', volume: '4873900' }, { price: '30.48', volume: '3723550' }, { price: '30.47', volume: '2221500' }, { price: '30.46', volume: '1215736' }, { price: '30.45', volume: '1464636' }, .... ]
vue element-plus UI
股票代码检索:frvStCode
<frvStCode type="sohu" @getcode="handleGetCode" style="display: inline-block;"> type=sina/sohu/code/name,分别返回sh600519,cn_600519,600519,贵州茅台 handleGetCode(value,name)
