/**
* 接口:http://hq.sinajs.cn/list=sz002307,sh600928
* 编码
* 名称
* 今天开盘价
* 昨天收盘价
* 现价
* 今天最高
* 今天最低
*/
type L = {
id: string,
name: string,
tday_open: number,
yday_close: number,
now: number,
tday_ceil: number,
tday_floor: number,
}
export type List = L[]
// var hq_str_sz002307="北新路桥,6.690,6.700,6.600,6.770,6.520,6.590,6.600,25760091,170297909.000,150600,6.590,180500,6.580,64300,6.570,12800,6.560,100300,6.550,153680,6.600,107800,6.610,65300,6.620,55200,6.630,22500,6.640,2020-07-31,15:00:03,00";
// var hq_str_sh600928="西安银行,5.610,5.640,5.630,5.720,5.600,5.620,5.630,13095438,74033723.000,290324,5.620,346100,5.610,453600,5.600,157300,5.590,154100,5.580,45630,5.630,117200,5.640,66601,5.650,69900,5.660,63802,5.670,2020-07-31,15:00:00,00,";
export function stock(data) {
let list: List = []
let desc = ['name', 'tday_open', 'yday_close', 'now', 'tday_ceil', 'tday_floor']
let data_arr = data.split(';')
data_arr.map(d => {
if (d.trim()) {
let l = d.split('=')
let _l = {
id: l[0].trim().replace('var hq_str_', ''),
name: '',
tday_open: NaN,
yday_close: NaN,
now: NaN,
tday_ceil: NaN,
tday_floor: NaN,
}
let d_info = l[1].trim().replace(`"`, '').split(',')
desc.map((v, key) => {
if (v == 'name') {
_l[v] = d_info[key]
} else {
_l[v] = Number(d_info[key])
}
})
list.push(_l)
}
})
return list
}
新浪股票行情API接口附带数据格式化
©著作权归作者所有,转载或内容合作请联系作者
- 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
- 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
- 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...