-
Notifications
You must be signed in to change notification settings - Fork 444
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #484 from enzheng128/master
fix: 替换雪球源为腾讯自选股
- Loading branch information
Showing
3 changed files
with
114 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
"name": "leek-fund", | ||
"displayName": "韭菜盒子", | ||
"description": "韭菜盒子,VSCode 里也可以看股票 & 基金实时数据,做最好用的投资插件", | ||
"version": "3.11.6", | ||
"version": "3.11.7", | ||
"author": "giscafer <[email protected]>", | ||
"repository": { | ||
"type": "git", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import Axios from 'axios'; | ||
import Log from './log'; | ||
import { decode } from 'iconv-lite'; | ||
|
||
const searchUrl = 'https://proxy.finance.qq.com/ifzqgtimg/appstock/smartbox/search/get'; | ||
const stockDataUrl = 'https://qt.gtimg.cn/q='; | ||
export const searchStockList = async (keyword: string) => { | ||
Log.info('searchStockList keyword: ', keyword); | ||
const stockResponse = await Axios.get(searchUrl, { | ||
params: { | ||
q: keyword, | ||
}, | ||
}); | ||
Log.info('stockResponse: ', stockResponse.data); | ||
const stockListArray = stockResponse?.data?.data?.stock || []; | ||
Log.info('stockListStr: ', stockListArray, keyword); | ||
const stockList = stockListArray.map((stockItemArr: string[]) => { | ||
return { | ||
code: stockItemArr[1].toLowerCase(), | ||
name: stockItemArr[2], | ||
market: stockItemArr[0], | ||
abbreviation: stockItemArr[3], | ||
}; | ||
}); | ||
Log.info('stockList: ', stockList, keyword); | ||
return stockList; | ||
}; | ||
|
||
export const getTencentHKStockData = async (codes: string[]) => { | ||
Log.info('getStockData codes: ', codes); | ||
const stockDataResponse = await Axios.get(stockDataUrl, { | ||
responseType: 'arraybuffer', | ||
transformResponse: [ | ||
(data) => { | ||
const body = decode(data, 'GB18030'); | ||
return body; | ||
}, | ||
], | ||
params: { | ||
q: codes.join(','), | ||
}, | ||
}); | ||
Log.info('stockDataResponse: ', stockDataResponse.data); | ||
const stockDataList = (stockDataResponse.data || '').split(';').map((stockItemStr: string) => { | ||
const stockItemArr = stockItemStr.split('~'); | ||
return { | ||
code: 'hk' + stockItemArr[2], | ||
name: stockItemArr[1], | ||
price: stockItemArr[3], | ||
yestclose: stockItemArr[4], | ||
open: stockItemArr[5], | ||
high: stockItemArr[33], | ||
low: stockItemArr[34], | ||
volume: stockItemArr[36], | ||
amount: stockItemArr[37], | ||
buy1: stockItemArr[9], | ||
sell1: stockItemArr[19], | ||
time: stockItemArr[30], | ||
}; | ||
}); | ||
Log.info('stockDataList: ', stockDataList, codes); | ||
return stockDataList; | ||
}; |