feat: 增加 项目结构接口

This commit is contained in:
zhangxiangliang 2020-08-05 23:32:39 +08:00
parent 3e4fbcdce8
commit 2777acb3d1
6 changed files with 90 additions and 13 deletions

18
types/index.d.ts vendored
View File

@ -1,3 +1,15 @@
export { Stock } from './stock';
export { Transform } from './transform';
export { Dictionary } from './dictionary';
import StockApi from './stocks/index';
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
View 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;

View File

@ -1,4 +1,4 @@
export interface Transform {
export interface ExchangeTransform {
transform(code: string): string;
transforms(codes: string[]): string[];
SZExchangeTransform(code: string): string;
@ -7,4 +7,4 @@ export interface Transform {
USExchangeTransform(code: string): string;
}
export default Transform;
export default ExchangeTransform;

48
types/stocks/transforms/stock.d.ts vendored Normal file
View 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;