@barfinex/types
Version:
Core TypeScript type definitions and shared interfaces for the Barfinex ecosystem. Provides strongly-typed contracts for modules, services, and plugins.
154 lines • 4.01 kB
TypeScript
import { OrderSide, OrderType } from './common.interface';
import { ConnectorType, MarketType } from './connector.interface';
import { Instrument } from '.';
/**
* Interface representing a trading order.
*/
export interface Order {
closeTime?: number | null;
/**
* Instrument of the trading pair (e.g., BTC/USD).
*/
instrument?: Instrument | null;
/**
* Internal ID of the order.
*/
id?: string | null;
/**
* External ID of the order from the trading platform or connector.
*/
externalId?: string | null;
/**
* Side of the order (e.g., buy or sell).
*/
side?: OrderSide | null;
/**
* Type of the order (e.g., market, limit).
*/
type?: OrderType | null;
/**
* Price of the order, if applicable.
*/
price?: number | null;
/**
* Time when the order was created (Unix timestamp).
*/
time?: number;
/**
* Time when the order was last updated (Unix timestamp).
*/
updateTime?: number | null;
/**
* Total quantity for the order.
*/
quantity?: number | null;
/**
* Quantity of the order that has been executed.
*/
quantityExecuted?: number | null;
/**
* Indicates whether the order is placed in a sandbox (test) environment.
*/
useSandbox: boolean;
/**
* Price at which the order will be closed (e.g., for stop-loss or take-profit orders).
*/
priceClose?: number | null;
/**
* Type of connector used for the order (e.g., Binance, Tinkoff).
*/
connectorType: ConnectorType;
/**
* Type of market for the order (e.g., spot, futures).
*/
marketType: MarketType;
/**
* Source of the order, detailing its origin.
*/
source: OrderSource;
/**
* Leverage used for the order, if applicable.
*/
leverage?: number | null;
/**
* Optional idempotency key used to deduplicate retries on order creation.
*/
idempotencyKey?: string;
}
/**
* Interface representing the source of an order.
*/
export interface OrderSource {
/**
* Type of the source (e.g., detector, inspector, exchange).
*/
type: OrderSourceType;
/**
* Unique key identifying the source.
*/
key: string;
/**
* Base API URL of the source system.
*/
restApiUrl?: string | null;
}
/**
* Enum representing the types of order sources.
*/
export declare enum OrderSourceType {
/** Orders originating from a detector system. */
detector = "detector",
/** Orders originating from an inspector system. */
inspector = "inspector",
/** Orders originating directly from an provider. */
provider = "provider",
/** Orders originating from an advisor system. */
advisor = "advisor"
}
/**
* Interface representing orders for risk management.
*/
export interface RiskManagementOrders {
/**
* Take-profit order to secure profits at a specific price.
*/
takeProfit: Order;
/**
* Stop-loss order to limit potential losses.
*/
stopLoss: Order;
}
/**
* Interface representing permissible quantities for orders.
*/
export interface OrderPermissibleQuantity {
/**
* Indicates whether the quantity is acceptable.
*/
acceptable: boolean;
/**
* Minimum acceptable quantity for the order.
*/
acceptableQuantityMin: number;
/**
* Maximum acceptable quantity for the order.
*/
acceptableQuantityMax: number;
/**
* Default percentage of the total balance to use for entry quantity.
*/
entryQuantityDefaultPercent: number;
/**
* Default balance to use for entry quantity.
*/
entryBalanceDefault: number;
/**
* Maximum balance allowed for entry quantity.
*/
entryBalanceMax: number;
/**
* Default percentage of permissible quantity for the order.
*/
permissibleQuantityDefaultPercent: number;
}
//# sourceMappingURL=order.interface.d.ts.map