@barfinex/types
Version:
Core TypeScript type definitions and shared interfaces for the Barfinex ecosystem. Provides strongly-typed contracts for modules, services, and plugins.
71 lines • 3.19 kB
TypeScript
import { Asset, Position, Order, Instrument, Account, TimeFrame } from '.';
import { ConnectorType, MarketType } from './connector.interface';
/**
* Unified adapter interface that every exchange connector library must implement.
* Provider uses this interface to interact with any exchange without knowing internals.
*/
export interface ExchangeAdapter {
readonly connectorType: ConnectorType;
init(credentials: Record<string, string>): Promise<void>;
destroy(): Promise<void>;
isReady(): boolean;
getAssetsInfo(marketType: MarketType): Promise<{
assets: Asset[];
positions: Position[];
}>;
getAccountInfo(marketType: MarketType): Promise<Account>;
changeLeverage?(instrument: Instrument, leverage: number): Promise<Instrument>;
getInstrumentsInfo(connectorType: ConnectorType, marketType: MarketType): Promise<Instrument[]>;
validateInstruments?(marketType: MarketType, symbols: string[]): {
validInstruments: string[];
removedInstruments: string[];
};
openOrder(order: Order): Promise<Order>;
closeOrder(options: {
id: string;
instrument: Instrument;
marketType: MarketType;
}): Promise<Order>;
closeAllOrders(options: {
instrument: Instrument;
marketType: MarketType;
}): Promise<void>;
getOpenOrders(options: {
instrument?: Instrument;
marketType: MarketType;
}): Promise<Order[]>;
getPrices?(marketType: MarketType, instruments: Instrument[]): Promise<Record<string, {
value: number;
moment: number;
}>>;
subscribeToAccount(options: {
marketType: MarketType;
}, handler: (event: any) => void): Promise<() => void>;
subscribeToTrade(options: {
marketType: MarketType;
instruments: Instrument[];
}, handler: (trade: any) => void): Promise<() => void>;
subscribeToOrderBook(options: {
marketType: MarketType;
instruments: Instrument[];
}, handler: (ob: any) => void): Promise<() => void>;
subscribeToCandles(options: {
marketType: MarketType;
instruments: Instrument[];
interval: TimeFrame;
}, handler: (candle: any) => void): Promise<() => void>;
subscribeToInstruments?(options: {
marketType: MarketType;
}, handler: (instruments: any) => void): Promise<() => void>;
subscribeToInstrumentPrices?(options: {
marketType: MarketType;
symbols: string[];
}, handler: (prices: any) => void): Promise<() => void>;
createTradeAdapter(handler: (...args: any[]) => void): (marketType: MarketType) => (msg: any) => void;
createOrderBookAdapter(handler: (...args: any[]) => void): (marketType: MarketType) => (msg: any) => void;
createCandleAdapter(options: any): (msg: any) => void;
createAccountAdapter(options: any, handler: (...args: any[]) => void): (marketType: MarketType) => (msg: any) => void;
createInstrumentsAdapter?(options: any): (msg: any) => void;
createInstrumentPricesAdapter?(logger: any, handler: (...args: any[]) => void): (marketType: MarketType) => (msg: any) => void;
}
//# sourceMappingURL=exchange-adapter.interface.d.ts.map