types.ts•5.31 kB
// Bybit API Types
export interface BybitConfig {
accessKey: string;
secretKey: string;
demo: boolean;
testnet: boolean;
}
export interface BybitResponse<T = any> {
retCode: number;
retMsg: string;
result: T;
retExtInfo?: any;
time: number;
}
export interface TickerData {
symbol: string;
lastPrice: string;
prevPrice24h: string;
price24hPcnt: string;
highPrice24h: string;
lowPrice24h: string;
volume24h: string;
turnover24h: string;
fundingRate: string;
openInterest: string;
}
export interface OrderbookData {
symbol: string;
bids: [string, string][];
asks: [string, string][];
ts: number;
u: number;
}
export interface KlineData {
symbol: string;
category: string;
list: [string, string, string, string, string, string, string][];
}
export interface WalletBalance {
accountType: string;
totalEquity: string;
totalWalletBalance: string;
totalMarginBalance: string;
totalAvailableBalance: string;
totalPerpUPL: string;
totalInitialMargin: string;
totalMaintenanceMargin: string;
coin: CoinBalance[];
}
export interface CoinBalance {
coin: string;
equity: string;
usdValue: string;
walletBalance: string;
availableToWithdraw: string;
availableToBorrow: string;
borrowAmount: string;
accruedInterest: string;
totalOrderIM: string;
totalPositionIM: string;
totalPositionMM: string;
unrealisedPnl: string;
cumRealisedPnl: string;
}
export interface Position {
symbol: string;
side: string;
size: string;
avgPrice: string;
positionValue: string;
tradeMode: number;
positionIdx: number;
riskId: number;
riskLimitValue: string;
entryPrice: string;
markPrice: string;
liqPrice: string;
bustPrice: string;
positionMM: string;
positionIM: string;
tpslMode: string;
takeProfit: string;
stopLoss: string;
trailingStop: string;
unrealisedPnl: string;
cumRealisedPnl: string;
sessionAvgPrice: string;
sessionUPL: string;
leverage: string;
autoAddMargin: number;
positionStatus: string;
adlRankIndicator: number;
isReduceOnly: boolean;
mmrSysUpdatedTime: string;
leverageSysUpdatedTime: string;
createdTime: string;
updatedTime: string;
seq: number;
}
export interface OrderRequest {
category: string;
symbol: string;
side: 'Buy' | 'Sell';
orderType: 'Market' | 'Limit';
qty: string;
price?: string;
timeInForce?: 'GTC' | 'IOC' | 'FOK' | 'PostOnly';
orderLinkId?: string;
isLeverage?: number;
orderFilter?: 'Order' | 'tpslOrder' | 'StopOrder';
triggerPrice?: string;
triggerBy?: string;
orderIv?: string;
positionIdx?: string;
takeProfit?: string;
stopLoss?: string;
tpTriggerBy?: string;
slTriggerBy?: string;
tpLimitPrice?: string;
slLimitPrice?: string;
tpOrderType?: 'Market' | 'Limit';
slOrderType?: 'Market' | 'Limit';
}
export interface OrderResponse {
orderId: string;
orderLinkId: string;
}
export interface Order {
orderId: string;
orderLinkId: string;
blockTradeId: string;
symbol: string;
price: string;
qty: string;
side: 'Buy' | 'Sell';
isLeverage: string;
positionIdx: number;
orderStatus: string;
cancelType: string;
rejectReason: string;
avgPrice: string;
leavesQty: string;
leavesValue: string;
cumExecQty: string;
cumExecValue: string;
cumExecFee: string;
timeInForce: string;
orderType: string;
stopOrderType: string;
orderIv: string;
triggerPrice: string;
takeProfit: string;
stopLoss: string;
tpTriggerBy: string;
slTriggerBy: string;
triggerDirection: number;
triggerBy: string;
lastPriceOnCreated: string;
reduceOnly: boolean;
closeOnTrigger: boolean;
smpType: string;
smpGroup: number;
smpOrderId: string;
tpslMode: string;
tpLimitPrice: string;
slLimitPrice: string;
placeType: string;
createdTime: string;
updatedTime: string;
}
export interface ApiKeyInfo {
id: string;
note: string;
apiKey: string;
readOnly: number;
secret: string;
permissions: {
ContractTrade: string[];
Spot: string[];
Wallet: string[];
Options: string[];
Derivatives: string[];
CopyTrading: string[];
BlockTrade: string[];
Exchange: string[];
NFT: string[];
Affiliate: string[];
};
ips: string[];
type: number;
deadlineDay: number;
expiredAt: string;
createdAt: string;
unified: number;
uta: number;
userID: number;
inviterID: number;
vipLevel: string;
mktMakerLevel: string;
affiliateID: number;
rsaPublicKey: string;
isMaster: boolean;
parentUid: string;
kycLevel: string;
kycRegion: string;
}
export interface InstrumentInfo {
symbol: string;
contractType: string;
status: string;
baseCoin: string;
quoteCoin: string;
launchTime: string;
deliveryTime: string;
deliveryFeeRate: string;
priceScale: string;
leverageFilter: {
minLeverage: string;
maxLeverage: string;
leverageStep: string;
};
priceFilter: {
minPrice: string;
maxPrice: string;
tickSize: string;
};
lotSizeFilter: {
maxOrderQty: string;
maxMktOrderQty: string;
minOrderQty: string;
qtyStep: string;
postOnlyMaxOrderQty: string;
};
unifiedMarginTrade: boolean;
fundingInterval: number;
settleCoin: string;
copyTrading: string;
upperFundingRate: string;
lowerFundingRate: string;
}