mirror of
https://github.com/zhangxiangliang/stock-api.git
synced 2025-02-02 22:43:46 +08:00
feat: 增加 项目结构接口
This commit is contained in:
parent
3e4fbcdce8
commit
2777acb3d1
18
types/index.d.ts
vendored
18
types/index.d.ts
vendored
@ -1,3 +1,15 @@
|
|||||||
export { Stock } from './stock';
|
import StockApi from './stocks/index';
|
||||||
export { Transform } from './transform';
|
|
||||||
export { Dictionary } from './dictionary';
|
export { Stock } from './utils/stock';
|
||||||
|
|
||||||
|
declare namespace Root {
|
||||||
|
export const stocks: {
|
||||||
|
base: StockApi,
|
||||||
|
netease: StockApi,
|
||||||
|
sina: StockApi,
|
||||||
|
tencent: StockApi,
|
||||||
|
xueqiu: StockApi,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export default Root;
|
||||||
|
17
types/stocks/index.d.ts
vendored
Normal file
17
types/stocks/index.d.ts
vendored
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
import Stock from '../utils/stock';
|
||||||
|
|
||||||
|
export interface StockApi {
|
||||||
|
/**
|
||||||
|
* 获取股票数据
|
||||||
|
* @param code 需要获取的股票代码
|
||||||
|
*/
|
||||||
|
getStock(code: string): Promise<Stock>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取股票组数据
|
||||||
|
* @param codes 需要获取的股票组代码
|
||||||
|
*/
|
||||||
|
getStocks(codes: string[]): Promise<Stock[]>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default StockApi;
|
@ -1,10 +1,10 @@
|
|||||||
export interface Transform {
|
export interface ExchangeTransform {
|
||||||
transform(code: string): string;
|
transform(code: string): string;
|
||||||
transforms(codes: string[]): string[];
|
transforms(codes: string[]): string[];
|
||||||
SZExchangeTransform(code: string): string;
|
SZExchangeTransform(code: string): string;
|
||||||
SHExchangeTransform(code: string): string;
|
SHExchangeTransform(code: string): string;
|
||||||
HKExchangeTransform(code: string): string;
|
HKExchangeTransform(code: string): string;
|
||||||
USExchangeTransform(code: string): string;
|
USExchangeTransform(code: string): string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Transform;
|
export default ExchangeTransform;
|
48
types/stocks/transforms/stock.d.ts
vendored
Normal file
48
types/stocks/transforms/stock.d.ts
vendored
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
// Types
|
||||||
|
import Stock from "../../utils/stock";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 基础股票数据解析
|
||||||
|
*/
|
||||||
|
export interface StockTransform {
|
||||||
|
/**
|
||||||
|
* 获取代码
|
||||||
|
*/
|
||||||
|
getCode(): string;
|
||||||
|
/**
|
||||||
|
* 获取名称
|
||||||
|
*/
|
||||||
|
getName(): string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取现价
|
||||||
|
*/
|
||||||
|
getNow(): number;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取最低价
|
||||||
|
*/
|
||||||
|
getLow(): number;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取最高价
|
||||||
|
*/
|
||||||
|
getHigh(): number;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取昨日收盘价
|
||||||
|
*/
|
||||||
|
getYesterday(): number;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取涨跌
|
||||||
|
*/
|
||||||
|
getPercent(): number;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取股票数据
|
||||||
|
*/
|
||||||
|
getStock(): Stock;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default StockTransform;
|
Loading…
Reference in New Issue
Block a user