@yuants/data-model
Advanced tools
Comparing version 0.1.7 to 0.2.0
@@ -101,3 +101,13 @@ /** | ||
*/ | ||
updated_at: number; | ||
updated_at?: number; | ||
/** | ||
* Timestamp when the account information was generated. | ||
* 账户信息产生的时间戳 | ||
* | ||
* (Used to handle conflicts: always accept the latest information) | ||
* (用于处理冲突: 应当总是接受最新的信息) | ||
* | ||
* @deprecated use updated_at instead | ||
*/ | ||
timestamp_in_us: number; | ||
} | ||
@@ -264,2 +274,20 @@ | ||
/** | ||
* Client order ID. | ||
* 客户端订单ID | ||
* @deprecated use order_id instead. | ||
*/ | ||
client_order_id: string; | ||
/** | ||
* Exchange order ID (if any). | ||
* 交易所订单ID (如果有) | ||
* @deprecated use order_id instead. | ||
*/ | ||
exchange_order_id?: string; | ||
/** | ||
* Order source specified by the order placer. | ||
* 下单器指定的订单来源 | ||
* @deprecated to remove | ||
*/ | ||
originator?: string; | ||
/** | ||
* Account ID. | ||
@@ -287,7 +315,13 @@ * 账户 ID | ||
*/ | ||
position_id: string; | ||
position_id?: string; | ||
/** | ||
* Order type. | ||
* 订单类型 | ||
* @deprecated use order_type instead | ||
*/ | ||
type: OrderType; | ||
/** | ||
* Order matching type. | ||
* | ||
* - `LIMIT`: Limits the price at which the order can be executed | ||
* - `LIMIT`: Limits the price at which the order can be executed (default) | ||
* - `MARKET`: Executed at the current market price | ||
@@ -298,5 +332,11 @@ * - `STOP`: Triggers a market order when the market price reaches the order price | ||
*/ | ||
order_type: string; | ||
order_type?: string; | ||
/** | ||
* Order direction. | ||
* 订单方向 | ||
* @deprecated use order_direction instead | ||
*/ | ||
direction: OrderDirection; | ||
/** | ||
* Order direction. | ||
* | ||
@@ -308,3 +348,3 @@ * - `OPEN_LONG`: Open long position | ||
*/ | ||
order_direction: string; | ||
order_direction?: string; | ||
/** | ||
@@ -316,2 +356,8 @@ * Order volume. | ||
/** | ||
* Order timestamp / trade timestamp. | ||
* 下单时间戳 / 成交时间戳 | ||
* @deprecated use submit_at, filled_at instead | ||
*/ | ||
timestamp_in_us?: number; | ||
/** | ||
* Submit order timestamp. | ||
@@ -341,2 +387,8 @@ */ | ||
* Order status. | ||
* 订单状态 | ||
* @deprecated use order_status instead | ||
*/ | ||
status?: OrderStatus; | ||
/** | ||
* Order status. | ||
* | ||
@@ -347,3 +399,3 @@ * - `ACCEPTED`: Order accepted by the exchange | ||
*/ | ||
status?: string; | ||
order_status?: string; | ||
/** | ||
@@ -398,2 +450,14 @@ * Order comment. | ||
inferred_base_currency_price?: number; | ||
/** | ||
* Take profit price (ignored for now). | ||
* 止盈价 (暂时不可用) | ||
* @deprecated to remove | ||
*/ | ||
take_profit_price?: number; | ||
/** | ||
* Stop loss price (ignored for now). | ||
* 止损价 (暂时不可用) | ||
* @deprecated to remove | ||
*/ | ||
stop_loss_price?: number; | ||
} | ||
@@ -432,7 +496,19 @@ | ||
*/ | ||
duration: string; | ||
duration?: string; | ||
/** | ||
* Period (in seconds) | ||
* 时间周期 (秒) | ||
* @deprecated use duration instead | ||
*/ | ||
period_in_sec: number; | ||
/** | ||
* Start timestamp (open, in microseconds) | ||
* 开始时间戳 (open) | ||
* @deprecated use start_at instead | ||
*/ | ||
timestamp_in_us: number; | ||
/** | ||
* Start timestamp (in ms) | ||
*/ | ||
start_at: number; | ||
start_at?: number; | ||
/** | ||
@@ -496,2 +572,6 @@ * Open price | ||
/** | ||
* Position direction (LONG | SHORT) | ||
*/ | ||
direction?: string; | ||
/** | ||
* Position variant. | ||
@@ -505,4 +585,6 @@ * 仓位类型 | ||
* - `SHORT`: Short position | ||
* | ||
* @deprecated use direction instead | ||
*/ | ||
variant: string; | ||
variant: PositionVariant; | ||
/** | ||
@@ -590,2 +672,24 @@ * Position volume (non-negative). | ||
/** | ||
* Is the underlying asset the base currency? | ||
* 标的物是基准货币吗? | ||
* | ||
* One lot corresponds to the quantity of the underlying asset specified by value_speed, which can be the base currency or other commodities. | ||
* 1 手对应 value_speed 数量的标的物,此标的物可以是基准货币或其他商品。 | ||
* | ||
* - For commodities, including spot and futures, this value is usually false, because one lot corresponds to a multiple of value_speed of the commodity quantity. | ||
* - 对于商品,包括现货和期货,此值通常为 false,因为 1 手对应着 value_speed 倍数的商品数量。 | ||
* | ||
* - For forex, this value is usually true, because one lot corresponds to a multiple of value_speed of the equivalent of the base currency in any currency. | ||
* - 对于外汇,此值通常为 true,因为 1 手对应着 value_speed 倍数的基础货币等值的任一货币。 | ||
* | ||
* If the value is empty, it is semantically equivalent to false. | ||
* 如果值为空,语义上等同于 false. | ||
* | ||
* If this value is true, an additional division by the "closing price" of this product is required in the standard yield formula. | ||
* 如果此值为 true,需要在标准收益公式中额外除以本品种的"平仓时的价格"。 | ||
* | ||
* @deprecated use value_unit instead | ||
*/ | ||
is_underlying_base_currency?: boolean; | ||
/** | ||
* price step, default is 1 | ||
@@ -607,2 +711,14 @@ * 报价单位,默认为 1 | ||
/** | ||
* Value speed, default is 1 | ||
* 价值速率,默认为 1 | ||
* | ||
* The quantity of the underlying asset specified by one lot. | ||
* 1 手对应的标的物的数量 | ||
* | ||
* ~~For every 1 lot increase in price, the settlement asset income obtained~~ | ||
* ~~每做多 1 手,价格每上升 1,获得的结算资产收益~~ | ||
* @deprecated use value_scale instead | ||
*/ | ||
value_speed?: number; | ||
/** | ||
* Value unit, default is "NORM" | ||
@@ -665,8 +781,189 @@ * | ||
/** | ||
* Tick: Market transaction data at a certain moment | ||
* Tick: 某个时刻的市场成交行情数据 | ||
* @public | ||
*/ | ||
export 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; | ||
} | ||
/** | ||
* Merge Positions by their product_id and variant | ||
* @public | ||
*/ | ||
export declare const mergeAccountInfoPositions: (info: IAccountInfo) => Observable<IAccountInfo>; | ||
/** | ||
* 订单方向 | ||
* @public | ||
* @deprecated use string instead | ||
*/ | ||
export declare enum OrderDirection { | ||
/** | ||
* Open long position | ||
* 开多 | ||
*/ | ||
OPEN_LONG = 0, | ||
/** | ||
* Close long position | ||
* 平多 | ||
*/ | ||
CLOSE_LONG = 1, | ||
/** | ||
* Open short position | ||
* 开空 | ||
*/ | ||
OPEN_SHORT = 2, | ||
/** | ||
* Close short position | ||
* 平空 | ||
*/ | ||
CLOSE_SHORT = 3 | ||
} | ||
/** | ||
* 订单状态 | ||
* @public | ||
* @deprecated use string instead | ||
*/ | ||
export declare enum OrderStatus { | ||
/** | ||
* Order accepted by the exchange | ||
* 交易所已接受委托 | ||
*/ | ||
ACCEPTED = 0, | ||
/** | ||
* Order partially filled | ||
* 已成交 | ||
*/ | ||
TRADED = 1, | ||
/** | ||
* Order cancelled | ||
* 已撤单 | ||
*/ | ||
CANCELLED = 2 | ||
} | ||
/** | ||
* 订单类型 | ||
* Order Type | ||
* @public | ||
* @deprecated use string instead | ||
*/ | ||
export declare enum OrderType { | ||
/** | ||
* Market Order: Executed at the current market price | ||
* 市价单: 以市场价格成交 | ||
* | ||
* The most common and simple order type, no need to specify an order price | ||
* 最普遍而简单的订单类型,不需要指定委托价 | ||
*/ | ||
MARKET = 0, | ||
/** | ||
* Limit Order: Limits the price at which the order can be executed | ||
* 限价单: 限制成交的价格 | ||
* | ||
* - BUY LIMIT: The execution price will not be higher than the order price | ||
* - SELL LIMIT: The execution price will not be lower than the order price | ||
* | ||
* - BUY LIMIT: 成交价不会高于委托价 | ||
* - SELL LIMIT: 成交价不会低于委托价 | ||
*/ | ||
LIMIT = 1, | ||
/** | ||
* Stop Order: Triggers a market order when the market price reaches the order price | ||
* 触发单: 市场价达到委托价时触发市价单 | ||
* | ||
* - BUY STOP: Place an order when the market price is higher than the order price | ||
* - SELL STOP: Place an order when the market price is lower than the order price | ||
* | ||
* - BUY STOP: 市场价高于委托价时下单 | ||
* - SELL STOP: 市场价低于委托价时下单 | ||
*/ | ||
STOP = 2, | ||
/** | ||
* Fill or Kill: Requires immediate and complete | ||
* 即成或撤单: Fill or Kill | ||
* | ||
* It is required to be executed immediately and completely when placing an order, otherwise it will be cancelled | ||
* 下单时要求立即全部成交,否则撤单 | ||
*/ | ||
FOK = 3, | ||
/** | ||
* Immediate or Cancel: Requires immediate execution, allows partial execution, and cancels the rest | ||
* 即成余撤单: Immediate or Cancel | ||
* | ||
* It is required to be executed immediately when placing an order, allows partial execution, and cancels the rest | ||
* 下单时要求立即成交,允许部分成交,未成交的直接撤单 | ||
*/ | ||
IOC = 4 | ||
} | ||
/** | ||
* Position variant. | ||
* @public | ||
* @deprecated use Position.direction instead | ||
*/ | ||
export declare enum PositionVariant { | ||
/** | ||
* Long position. | ||
* 做多 | ||
*/ | ||
LONG = 0, | ||
/** | ||
* Short position. | ||
* 做空 | ||
*/ | ||
SHORT = 1 | ||
} | ||
/** | ||
* @public | ||
* @returns Universal Unique ID string | ||
@@ -673,0 +970,0 @@ */ |
@@ -1,2 +0,125 @@ | ||
export {}; | ||
/** | ||
* 订单类型 | ||
* Order Type | ||
* @public | ||
* @deprecated use string instead | ||
*/ | ||
export var OrderType; | ||
(function (OrderType) { | ||
/** | ||
* Market Order: Executed at the current market price | ||
* 市价单: 以市场价格成交 | ||
* | ||
* The most common and simple order type, no need to specify an order price | ||
* 最普遍而简单的订单类型,不需要指定委托价 | ||
*/ | ||
OrderType[OrderType["MARKET"] = 0] = "MARKET"; | ||
/** | ||
* Limit Order: Limits the price at which the order can be executed | ||
* 限价单: 限制成交的价格 | ||
* | ||
* - BUY LIMIT: The execution price will not be higher than the order price | ||
* - SELL LIMIT: The execution price will not be lower than the order price | ||
* | ||
* - BUY LIMIT: 成交价不会高于委托价 | ||
* - SELL LIMIT: 成交价不会低于委托价 | ||
*/ | ||
OrderType[OrderType["LIMIT"] = 1] = "LIMIT"; | ||
/** | ||
* Stop Order: Triggers a market order when the market price reaches the order price | ||
* 触发单: 市场价达到委托价时触发市价单 | ||
* | ||
* - BUY STOP: Place an order when the market price is higher than the order price | ||
* - SELL STOP: Place an order when the market price is lower than the order price | ||
* | ||
* - BUY STOP: 市场价高于委托价时下单 | ||
* - SELL STOP: 市场价低于委托价时下单 | ||
*/ | ||
OrderType[OrderType["STOP"] = 2] = "STOP"; | ||
/** | ||
* Fill or Kill: Requires immediate and complete | ||
* 即成或撤单: Fill or Kill | ||
* | ||
* It is required to be executed immediately and completely when placing an order, otherwise it will be cancelled | ||
* 下单时要求立即全部成交,否则撤单 | ||
*/ | ||
OrderType[OrderType["FOK"] = 3] = "FOK"; | ||
/** | ||
* Immediate or Cancel: Requires immediate execution, allows partial execution, and cancels the rest | ||
* 即成余撤单: Immediate or Cancel | ||
* | ||
* It is required to be executed immediately when placing an order, allows partial execution, and cancels the rest | ||
* 下单时要求立即成交,允许部分成交,未成交的直接撤单 | ||
*/ | ||
OrderType[OrderType["IOC"] = 4] = "IOC"; | ||
})(OrderType || (OrderType = {})); | ||
/** | ||
* 订单方向 | ||
* @public | ||
* @deprecated use string instead | ||
*/ | ||
export var OrderDirection; | ||
(function (OrderDirection) { | ||
/** | ||
* Open long position | ||
* 开多 | ||
*/ | ||
OrderDirection[OrderDirection["OPEN_LONG"] = 0] = "OPEN_LONG"; | ||
/** | ||
* Close long position | ||
* 平多 | ||
*/ | ||
OrderDirection[OrderDirection["CLOSE_LONG"] = 1] = "CLOSE_LONG"; | ||
/** | ||
* Open short position | ||
* 开空 | ||
*/ | ||
OrderDirection[OrderDirection["OPEN_SHORT"] = 2] = "OPEN_SHORT"; | ||
/** | ||
* Close short position | ||
* 平空 | ||
*/ | ||
OrderDirection[OrderDirection["CLOSE_SHORT"] = 3] = "CLOSE_SHORT"; | ||
})(OrderDirection || (OrderDirection = {})); | ||
/** | ||
* 订单状态 | ||
* @public | ||
* @deprecated use string instead | ||
*/ | ||
export var OrderStatus; | ||
(function (OrderStatus) { | ||
/** | ||
* Order accepted by the exchange | ||
* 交易所已接受委托 | ||
*/ | ||
OrderStatus[OrderStatus["ACCEPTED"] = 0] = "ACCEPTED"; | ||
/** | ||
* Order partially filled | ||
* 已成交 | ||
*/ | ||
OrderStatus[OrderStatus["TRADED"] = 1] = "TRADED"; | ||
/** | ||
* Order cancelled | ||
* 已撤单 | ||
*/ | ||
OrderStatus[OrderStatus["CANCELLED"] = 2] = "CANCELLED"; | ||
})(OrderStatus || (OrderStatus = {})); | ||
/** | ||
* Position variant. | ||
* @public | ||
* @deprecated use Position.direction instead | ||
*/ | ||
export var PositionVariant; | ||
(function (PositionVariant) { | ||
/** | ||
* Long position. | ||
* 做多 | ||
*/ | ||
PositionVariant[PositionVariant["LONG"] = 0] = "LONG"; | ||
/** | ||
* Short position. | ||
* 做空 | ||
*/ | ||
PositionVariant[PositionVariant["SHORT"] = 1] = "SHORT"; | ||
})(PositionVariant || (PositionVariant = {})); | ||
//# sourceMappingURL=interfaces.js.map |
@@ -9,2 +9,3 @@ import { format } from 'date-fns'; | ||
export const createEmptyAccountInfo = (account_id, currency, leverage = 1, initial_balance = 0) => ({ | ||
timestamp_in_us: 0, | ||
updated_at: 0, | ||
@@ -25,2 +26,3 @@ account_id, | ||
/** | ||
* Merge Positions by their product_id and variant | ||
* @public | ||
@@ -27,0 +29,0 @@ */ |
@@ -40,2 +40,24 @@ /** | ||
/** | ||
* Is the underlying asset the base currency? | ||
* 标的物是基准货币吗? | ||
* | ||
* One lot corresponds to the quantity of the underlying asset specified by value_speed, which can be the base currency or other commodities. | ||
* 1 手对应 value_speed 数量的标的物,此标的物可以是基准货币或其他商品。 | ||
* | ||
* - For commodities, including spot and futures, this value is usually false, because one lot corresponds to a multiple of value_speed of the commodity quantity. | ||
* - 对于商品,包括现货和期货,此值通常为 false,因为 1 手对应着 value_speed 倍数的商品数量。 | ||
* | ||
* - For forex, this value is usually true, because one lot corresponds to a multiple of value_speed of the equivalent of the base currency in any currency. | ||
* - 对于外汇,此值通常为 true,因为 1 手对应着 value_speed 倍数的基础货币等值的任一货币。 | ||
* | ||
* If the value is empty, it is semantically equivalent to false. | ||
* 如果值为空,语义上等同于 false. | ||
* | ||
* If this value is true, an additional division by the "closing price" of this product is required in the standard yield formula. | ||
* 如果此值为 true,需要在标准收益公式中额外除以本品种的"平仓时的价格"。 | ||
* | ||
* @deprecated use value_unit instead | ||
*/ | ||
is_underlying_base_currency?: boolean; | ||
/** | ||
* price step, default is 1 | ||
@@ -57,2 +79,14 @@ * 报价单位,默认为 1 | ||
/** | ||
* Value speed, default is 1 | ||
* 价值速率,默认为 1 | ||
* | ||
* The quantity of the underlying asset specified by one lot. | ||
* 1 手对应的标的物的数量 | ||
* | ||
* ~~For every 1 lot increase in price, the settlement asset income obtained~~ | ||
* ~~每做多 1 手,价格每上升 1,获得的结算资产收益~~ | ||
* @deprecated use value_scale instead | ||
*/ | ||
value_speed?: number; | ||
/** | ||
* Value unit, default is "NORM" | ||
@@ -144,7 +178,19 @@ * | ||
*/ | ||
duration: string; | ||
duration?: string; | ||
/** | ||
* Period (in seconds) | ||
* 时间周期 (秒) | ||
* @deprecated use duration instead | ||
*/ | ||
period_in_sec: number; | ||
/** | ||
* Start timestamp (open, in microseconds) | ||
* 开始时间戳 (open) | ||
* @deprecated use start_at instead | ||
*/ | ||
timestamp_in_us: number; | ||
/** | ||
* Start timestamp (in ms) | ||
*/ | ||
start_at: number; | ||
start_at?: number; | ||
/** | ||
@@ -187,2 +233,105 @@ * Open price | ||
/** | ||
* 订单类型 | ||
* Order Type | ||
* @public | ||
* @deprecated use string instead | ||
*/ | ||
export declare enum OrderType { | ||
/** | ||
* Market Order: Executed at the current market price | ||
* 市价单: 以市场价格成交 | ||
* | ||
* The most common and simple order type, no need to specify an order price | ||
* 最普遍而简单的订单类型,不需要指定委托价 | ||
*/ | ||
MARKET = 0, | ||
/** | ||
* Limit Order: Limits the price at which the order can be executed | ||
* 限价单: 限制成交的价格 | ||
* | ||
* - BUY LIMIT: The execution price will not be higher than the order price | ||
* - SELL LIMIT: The execution price will not be lower than the order price | ||
* | ||
* - BUY LIMIT: 成交价不会高于委托价 | ||
* - SELL LIMIT: 成交价不会低于委托价 | ||
*/ | ||
LIMIT = 1, | ||
/** | ||
* Stop Order: Triggers a market order when the market price reaches the order price | ||
* 触发单: 市场价达到委托价时触发市价单 | ||
* | ||
* - BUY STOP: Place an order when the market price is higher than the order price | ||
* - SELL STOP: Place an order when the market price is lower than the order price | ||
* | ||
* - BUY STOP: 市场价高于委托价时下单 | ||
* - SELL STOP: 市场价低于委托价时下单 | ||
*/ | ||
STOP = 2, | ||
/** | ||
* Fill or Kill: Requires immediate and complete | ||
* 即成或撤单: Fill or Kill | ||
* | ||
* It is required to be executed immediately and completely when placing an order, otherwise it will be cancelled | ||
* 下单时要求立即全部成交,否则撤单 | ||
*/ | ||
FOK = 3, | ||
/** | ||
* Immediate or Cancel: Requires immediate execution, allows partial execution, and cancels the rest | ||
* 即成余撤单: Immediate or Cancel | ||
* | ||
* It is required to be executed immediately when placing an order, allows partial execution, and cancels the rest | ||
* 下单时要求立即成交,允许部分成交,未成交的直接撤单 | ||
*/ | ||
IOC = 4 | ||
} | ||
/** | ||
* 订单方向 | ||
* @public | ||
* @deprecated use string instead | ||
*/ | ||
export declare enum OrderDirection { | ||
/** | ||
* Open long position | ||
* 开多 | ||
*/ | ||
OPEN_LONG = 0, | ||
/** | ||
* Close long position | ||
* 平多 | ||
*/ | ||
CLOSE_LONG = 1, | ||
/** | ||
* Open short position | ||
* 开空 | ||
*/ | ||
OPEN_SHORT = 2, | ||
/** | ||
* Close short position | ||
* 平空 | ||
*/ | ||
CLOSE_SHORT = 3 | ||
} | ||
/** | ||
* 订单状态 | ||
* @public | ||
* @deprecated use string instead | ||
*/ | ||
export declare enum OrderStatus { | ||
/** | ||
* Order accepted by the exchange | ||
* 交易所已接受委托 | ||
*/ | ||
ACCEPTED = 0, | ||
/** | ||
* Order partially filled | ||
* 已成交 | ||
*/ | ||
TRADED = 1, | ||
/** | ||
* Order cancelled | ||
* 已撤单 | ||
*/ | ||
CANCELLED = 2 | ||
} | ||
/** | ||
* Order: Changes the {@link IPosition} of the {@link IAccountInfo} in the account through a trading command. | ||
@@ -198,2 +347,20 @@ * 订单: 通过交易命令改变账户内 {@link IAccountInfo} 头寸 {@link IPosition} | ||
/** | ||
* Client order ID. | ||
* 客户端订单ID | ||
* @deprecated use order_id instead. | ||
*/ | ||
client_order_id: string; | ||
/** | ||
* Exchange order ID (if any). | ||
* 交易所订单ID (如果有) | ||
* @deprecated use order_id instead. | ||
*/ | ||
exchange_order_id?: string; | ||
/** | ||
* Order source specified by the order placer. | ||
* 下单器指定的订单来源 | ||
* @deprecated to remove | ||
*/ | ||
originator?: string; | ||
/** | ||
* Account ID. | ||
@@ -221,7 +388,13 @@ * 账户 ID | ||
*/ | ||
position_id: string; | ||
position_id?: string; | ||
/** | ||
* Order type. | ||
* 订单类型 | ||
* @deprecated use order_type instead | ||
*/ | ||
type: OrderType; | ||
/** | ||
* Order matching type. | ||
* | ||
* - `LIMIT`: Limits the price at which the order can be executed | ||
* - `LIMIT`: Limits the price at which the order can be executed (default) | ||
* - `MARKET`: Executed at the current market price | ||
@@ -232,5 +405,11 @@ * - `STOP`: Triggers a market order when the market price reaches the order price | ||
*/ | ||
order_type: string; | ||
order_type?: string; | ||
/** | ||
* Order direction. | ||
* 订单方向 | ||
* @deprecated use order_direction instead | ||
*/ | ||
direction: OrderDirection; | ||
/** | ||
* Order direction. | ||
* | ||
@@ -242,3 +421,3 @@ * - `OPEN_LONG`: Open long position | ||
*/ | ||
order_direction: string; | ||
order_direction?: string; | ||
/** | ||
@@ -250,2 +429,8 @@ * Order volume. | ||
/** | ||
* Order timestamp / trade timestamp. | ||
* 下单时间戳 / 成交时间戳 | ||
* @deprecated use submit_at, filled_at instead | ||
*/ | ||
timestamp_in_us?: number; | ||
/** | ||
* Submit order timestamp. | ||
@@ -275,2 +460,8 @@ */ | ||
* Order status. | ||
* 订单状态 | ||
* @deprecated use order_status instead | ||
*/ | ||
status?: OrderStatus; | ||
/** | ||
* Order status. | ||
* | ||
@@ -281,3 +472,3 @@ * - `ACCEPTED`: Order accepted by the exchange | ||
*/ | ||
status?: string; | ||
order_status?: string; | ||
/** | ||
@@ -332,4 +523,33 @@ * Order comment. | ||
inferred_base_currency_price?: number; | ||
/** | ||
* Take profit price (ignored for now). | ||
* 止盈价 (暂时不可用) | ||
* @deprecated to remove | ||
*/ | ||
take_profit_price?: number; | ||
/** | ||
* Stop loss price (ignored for now). | ||
* 止损价 (暂时不可用) | ||
* @deprecated to remove | ||
*/ | ||
stop_loss_price?: number; | ||
} | ||
/** | ||
* Position variant. | ||
* @public | ||
* @deprecated use Position.direction instead | ||
*/ | ||
export declare enum PositionVariant { | ||
/** | ||
* Long position. | ||
* 做多 | ||
*/ | ||
LONG = 0, | ||
/** | ||
* Short position. | ||
* 做空 | ||
*/ | ||
SHORT = 1 | ||
} | ||
/** | ||
* Position: Atomic position information. | ||
@@ -355,2 +575,6 @@ * 原子性的持仓头寸信息 | ||
/** | ||
* Position direction (LONG | SHORT) | ||
*/ | ||
direction?: string; | ||
/** | ||
* Position variant. | ||
@@ -364,4 +588,6 @@ * 仓位类型 | ||
* - `SHORT`: Short position | ||
* | ||
* @deprecated use direction instead | ||
*/ | ||
variant: string; | ||
variant: PositionVariant; | ||
/** | ||
@@ -512,3 +738,13 @@ * Position volume (non-negative). | ||
*/ | ||
updated_at: number; | ||
updated_at?: number; | ||
/** | ||
* Timestamp when the account information was generated. | ||
* 账户信息产生的时间戳 | ||
* | ||
* (Used to handle conflicts: always accept the latest information) | ||
* (用于处理冲突: 应当总是接受最新的信息) | ||
* | ||
* @deprecated use updated_at instead | ||
*/ | ||
timestamp_in_us: number; | ||
} | ||
@@ -587,2 +823,57 @@ /** | ||
} | ||
/** | ||
* Tick: Market transaction data at a certain moment | ||
* Tick: 某个时刻的市场成交行情数据 | ||
* @public | ||
*/ | ||
export 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; | ||
} | ||
//# sourceMappingURL=interfaces.d.ts.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.PositionVariant = exports.OrderStatus = exports.OrderDirection = exports.OrderType = void 0; | ||
/** | ||
* 订单类型 | ||
* Order Type | ||
* @public | ||
* @deprecated use string instead | ||
*/ | ||
var OrderType; | ||
(function (OrderType) { | ||
/** | ||
* Market Order: Executed at the current market price | ||
* 市价单: 以市场价格成交 | ||
* | ||
* The most common and simple order type, no need to specify an order price | ||
* 最普遍而简单的订单类型,不需要指定委托价 | ||
*/ | ||
OrderType[OrderType["MARKET"] = 0] = "MARKET"; | ||
/** | ||
* Limit Order: Limits the price at which the order can be executed | ||
* 限价单: 限制成交的价格 | ||
* | ||
* - BUY LIMIT: The execution price will not be higher than the order price | ||
* - SELL LIMIT: The execution price will not be lower than the order price | ||
* | ||
* - BUY LIMIT: 成交价不会高于委托价 | ||
* - SELL LIMIT: 成交价不会低于委托价 | ||
*/ | ||
OrderType[OrderType["LIMIT"] = 1] = "LIMIT"; | ||
/** | ||
* Stop Order: Triggers a market order when the market price reaches the order price | ||
* 触发单: 市场价达到委托价时触发市价单 | ||
* | ||
* - BUY STOP: Place an order when the market price is higher than the order price | ||
* - SELL STOP: Place an order when the market price is lower than the order price | ||
* | ||
* - BUY STOP: 市场价高于委托价时下单 | ||
* - SELL STOP: 市场价低于委托价时下单 | ||
*/ | ||
OrderType[OrderType["STOP"] = 2] = "STOP"; | ||
/** | ||
* Fill or Kill: Requires immediate and complete | ||
* 即成或撤单: Fill or Kill | ||
* | ||
* It is required to be executed immediately and completely when placing an order, otherwise it will be cancelled | ||
* 下单时要求立即全部成交,否则撤单 | ||
*/ | ||
OrderType[OrderType["FOK"] = 3] = "FOK"; | ||
/** | ||
* Immediate or Cancel: Requires immediate execution, allows partial execution, and cancels the rest | ||
* 即成余撤单: Immediate or Cancel | ||
* | ||
* It is required to be executed immediately when placing an order, allows partial execution, and cancels the rest | ||
* 下单时要求立即成交,允许部分成交,未成交的直接撤单 | ||
*/ | ||
OrderType[OrderType["IOC"] = 4] = "IOC"; | ||
})(OrderType = exports.OrderType || (exports.OrderType = {})); | ||
/** | ||
* 订单方向 | ||
* @public | ||
* @deprecated use string instead | ||
*/ | ||
var OrderDirection; | ||
(function (OrderDirection) { | ||
/** | ||
* Open long position | ||
* 开多 | ||
*/ | ||
OrderDirection[OrderDirection["OPEN_LONG"] = 0] = "OPEN_LONG"; | ||
/** | ||
* Close long position | ||
* 平多 | ||
*/ | ||
OrderDirection[OrderDirection["CLOSE_LONG"] = 1] = "CLOSE_LONG"; | ||
/** | ||
* Open short position | ||
* 开空 | ||
*/ | ||
OrderDirection[OrderDirection["OPEN_SHORT"] = 2] = "OPEN_SHORT"; | ||
/** | ||
* Close short position | ||
* 平空 | ||
*/ | ||
OrderDirection[OrderDirection["CLOSE_SHORT"] = 3] = "CLOSE_SHORT"; | ||
})(OrderDirection = exports.OrderDirection || (exports.OrderDirection = {})); | ||
/** | ||
* 订单状态 | ||
* @public | ||
* @deprecated use string instead | ||
*/ | ||
var OrderStatus; | ||
(function (OrderStatus) { | ||
/** | ||
* Order accepted by the exchange | ||
* 交易所已接受委托 | ||
*/ | ||
OrderStatus[OrderStatus["ACCEPTED"] = 0] = "ACCEPTED"; | ||
/** | ||
* Order partially filled | ||
* 已成交 | ||
*/ | ||
OrderStatus[OrderStatus["TRADED"] = 1] = "TRADED"; | ||
/** | ||
* Order cancelled | ||
* 已撤单 | ||
*/ | ||
OrderStatus[OrderStatus["CANCELLED"] = 2] = "CANCELLED"; | ||
})(OrderStatus = exports.OrderStatus || (exports.OrderStatus = {})); | ||
/** | ||
* Position variant. | ||
* @public | ||
* @deprecated use Position.direction instead | ||
*/ | ||
var PositionVariant; | ||
(function (PositionVariant) { | ||
/** | ||
* Long position. | ||
* 做多 | ||
*/ | ||
PositionVariant[PositionVariant["LONG"] = 0] = "LONG"; | ||
/** | ||
* Short position. | ||
* 做空 | ||
*/ | ||
PositionVariant[PositionVariant["SHORT"] = 1] = "SHORT"; | ||
})(PositionVariant = exports.PositionVariant || (exports.PositionVariant = {})); | ||
//# sourceMappingURL=interfaces.js.map |
@@ -8,2 +8,3 @@ import { Observable } from 'rxjs'; | ||
/** | ||
* Merge Positions by their product_id and variant | ||
* @public | ||
@@ -10,0 +11,0 @@ */ |
@@ -12,2 +12,3 @@ "use strict"; | ||
const createEmptyAccountInfo = (account_id, currency, leverage = 1, initial_balance = 0) => ({ | ||
timestamp_in_us: 0, | ||
updated_at: 0, | ||
@@ -29,2 +30,3 @@ account_id, | ||
/** | ||
* Merge Positions by their product_id and variant | ||
* @public | ||
@@ -31,0 +33,0 @@ */ |
{ | ||
"name": "@yuants/data-model", | ||
"version": "0.1.7", | ||
"version": "0.2.0", | ||
"main": "lib/index.js", | ||
@@ -5,0 +5,0 @@ "module": "dist/index.js", |
@@ -45,3 +45,5 @@ ## API Report File for "@yuants/data-model" | ||
positions: IPosition[]; | ||
updated_at: number; | ||
// @deprecated | ||
timestamp_in_us: number; | ||
updated_at?: number; | ||
} | ||
@@ -75,9 +77,18 @@ | ||
account_id: string; | ||
// @deprecated | ||
client_order_id: string; | ||
comment?: string; | ||
// @deprecated | ||
direction: OrderDirection; | ||
// @deprecated | ||
exchange_order_id?: string; | ||
filled_at?: number; | ||
inferred_base_currency_price?: number; | ||
order_direction: string; | ||
order_direction?: string; | ||
order_id?: string; | ||
order_type: string; | ||
position_id: string; | ||
order_status?: string; | ||
order_type?: string; | ||
// @deprecated | ||
originator?: string; | ||
position_id?: string; | ||
price?: number; | ||
@@ -87,6 +98,15 @@ product_id: string; | ||
real_profit?: number; | ||
status?: string; | ||
// @deprecated | ||
status?: OrderStatus; | ||
// @deprecated | ||
stop_loss_price?: number; | ||
submit_at?: number; | ||
// @deprecated | ||
take_profit_price?: number; | ||
// @deprecated | ||
timestamp_in_us?: number; | ||
traded_price?: number; | ||
traded_volume?: number; | ||
// @deprecated | ||
type: OrderType; | ||
volume: number; | ||
@@ -99,3 +119,3 @@ } | ||
datasource_id: string; | ||
duration: string; | ||
duration?: string; | ||
high: number; | ||
@@ -105,5 +125,9 @@ low: number; | ||
open_interest?: number; | ||
// @deprecated | ||
period_in_sec: number; | ||
product_id: string; | ||
spread?: number; | ||
start_at: number; | ||
start_at?: number; | ||
// @deprecated | ||
timestamp_in_us: number; | ||
volume: number; | ||
@@ -116,2 +140,3 @@ } | ||
comment?: string; | ||
direction?: string; | ||
floating_profit: number; | ||
@@ -122,3 +147,4 @@ free_volume: number; | ||
product_id: string; | ||
variant: string; | ||
// @deprecated | ||
variant: PositionVariant; | ||
volume: number; | ||
@@ -133,2 +159,4 @@ } | ||
datasource_id: string; | ||
// @deprecated | ||
is_underlying_base_currency?: boolean; | ||
margin_rate?: number; | ||
@@ -144,2 +172,4 @@ max_position?: number; | ||
value_scale?: number; | ||
// @deprecated | ||
value_speed?: number; | ||
value_unit?: string; | ||
@@ -150,5 +180,50 @@ volume_based_cost?: number; | ||
// @public (undocumented) | ||
// @public | ||
export interface ITick { | ||
ask?: number; | ||
bid?: number; | ||
datasource_id: string; | ||
open_interest?: number; | ||
price: number; | ||
product_id: string; | ||
spread?: number; | ||
// @deprecated | ||
timestamp_in_us: number; | ||
updated_at?: number; | ||
volume: number; | ||
} | ||
// @public | ||
export const mergeAccountInfoPositions: (info: IAccountInfo) => Observable<IAccountInfo>; | ||
// @public @deprecated | ||
export enum OrderDirection { | ||
CLOSE_LONG = 1, | ||
CLOSE_SHORT = 3, | ||
OPEN_LONG = 0, | ||
OPEN_SHORT = 2 | ||
} | ||
// @public @deprecated | ||
export enum OrderStatus { | ||
ACCEPTED = 0, | ||
CANCELLED = 2, | ||
TRADED = 1 | ||
} | ||
// @public @deprecated | ||
export enum OrderType { | ||
FOK = 3, | ||
IOC = 4, | ||
LIMIT = 1, | ||
MARKET = 0, | ||
STOP = 2 | ||
} | ||
// @public @deprecated | ||
export enum PositionVariant { | ||
LONG = 0, | ||
SHORT = 1 | ||
} | ||
// @public (undocumented) | ||
@@ -155,0 +230,0 @@ export const UUID: () => string; |
{ | ||
"libraries/data-model/CHANGELOG.json": "5e8bab59c84df24b7826704c1be9a2bff6d4864b", | ||
"libraries/data-model/CHANGELOG.md": "9774e89b6c113df939d484190d936fe9f3ec0421", | ||
"libraries/data-model/CHANGELOG.json": "93c84fc3249439314247d03cecfa9c2e35999336", | ||
"libraries/data-model/CHANGELOG.md": "880100390bd694965f1db9fc767462d3c9ae47f0", | ||
"libraries/data-model/api-extractor.json": "62f4fd324425b9a235f0c117975967aab09ced0c", | ||
@@ -8,8 +8,8 @@ "libraries/data-model/config/jest.config.json": "4bb17bde3ee911163a3edb36a6eb71491d80b1bd", | ||
"libraries/data-model/config/typescript.json": "854907e8a821f2050f6533368db160c649c25348", | ||
"libraries/data-model/etc/data-model.api.md": "9462d9468bd88d114b0ee7191d8d268482239140", | ||
"libraries/data-model/package.json": "3c07fd775efd3496a080799454d14cef8c167959", | ||
"libraries/data-model/etc/data-model.api.md": "731523226202dfd693733c590127881b066053e3", | ||
"libraries/data-model/package.json": "4fafe5f609c0c3e0fa97fce670d92cd0c37a1ed6", | ||
"libraries/data-model/src/index.ts": "49fc2befb673b800db4cdba4235ab4ddb6736788", | ||
"libraries/data-model/src/interfaces.ts": "c22b10f56b508fcfc50ef507a707ebec5ce2ed96", | ||
"libraries/data-model/src/interfaces.ts": "e4d4cc45d495aca3f667cb72b16f0058a686633e", | ||
"libraries/data-model/src/utils.test.ts": "734ecde19582f04e5a973c796307b6a70c03bc2c", | ||
"libraries/data-model/src/utils.ts": "6b889bc61337012dcfe5b0a99d36bc56c7c342ca", | ||
"libraries/data-model/src/utils.ts": "10c656a0b73e64640e025faf7e7e85474db97d85", | ||
"libraries/data-model/tsconfig.json": "22f94ca28b507f8ddcc21b9053158eefd3f726a9", | ||
@@ -16,0 +16,0 @@ "libraries/data-model/.rush/temp/shrinkwrap-deps.json": "fcb3fca669b68350f864742e0343d7dabb11d9a5", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
314621
6258