Skip to content

Commit

Permalink
feat: add useTick hook declaration (#39)
Browse files Browse the repository at this point in the history
  • Loading branch information
zccz14 authored Dec 25, 2023
1 parent 5a3462b commit 342bbdb
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 0 deletions.
1 change: 1 addition & 0 deletions @libs/global.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export const global = {
useLog,
useProduct,
useOHLC,
useTick,
decodePath,
encodePath,
useRecordTable,
Expand Down
1 change: 1 addition & 0 deletions @libs/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export const useAccountInfo = global.useAccountInfo;
export const useLog = global.useLog;
export const useProduct = global.useProduct;
export const useOHLC = global.useOHLC;
export const useTick = global.useTick;
export const useRecordTable = global.useRecordTable;
export const useExchange = global.useExchange;
export const useSeries = global.useSeries;
Expand Down
69 changes: 69 additions & 0 deletions global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,61 @@ declare interface IPosition {
*/
comment?: string;
}
/**
* Tick: Market transaction data at a certain moment
* Tick: 某个时刻的市场成交行情数据
*/

declare interface ITick {
/**
* Data source ID
* 数据源 ID
*/
datasource_id: string;
/**
* Product ID
* 品种 ID
*/
product_id: string;
/**
* Timestamp (in microseconds)
* 时间戳
* @deprecated use updated_at instead
*/
timestamp_in_us: number;
/**
* Timestamp (in ms)
* 时间戳
*/
updated_at?: number;
/**
* Price
* 成交价
*/
price: number;
/**
* Volume
* 成交量
*/
volume: number;
/**
* Open interest
* 持仓量
*/
open_interest?: number;
/**
* Spread
* 点差
*/
spread?: number;
/**
* Ask price
* 卖一价
*/
ask?: number;
/** 买一价 */
bid?: number;
}
/**
* Account fund information
*
Expand Down Expand Up @@ -518,6 +573,20 @@ declare const useOHLC: (
volume: Series;
};

/**
* Use Tick
*
* @param account_id - The AccountID in Agent
* @param datasource_id - The DataSourceID in Host
* @param product_id - The ProductID in the Data Source
* @returns the Tick data. undefined if not loaded
*/
declare const useTick: (
account_id: string,
datasource_id: string,
product_id: string
) => ITick | undefined;

/** Use Account Info */
declare const useAccountInfo: (options?: {
account_id?: string;
Expand Down

0 comments on commit 342bbdb

Please sign in to comment.