Last active
November 8, 2020 04:31
-
-
Save AdvaithD/c9218c3059750a62a97110b1657f6af0 to your computer and use it in GitHub Desktop.
ccxt types
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
declare module 'ccxt' { | |
interface Dictionary<T> { | |
[key: string]: T; | |
} | |
export class BaseError extends Error { | |
constructor(message: string); | |
} | |
export class ExchangeError extends BaseError {} | |
export class AuthenticationError extends ExchangeError {} | |
export class PermissionDenied extends AuthenticationError {} | |
export class AccountSuspended extends AuthenticationError {} | |
export class ArgumentsRequired extends ExchangeError {} | |
export class BadRequest extends ExchangeError {} | |
export class BadSymbol extends BadRequest {} | |
export class BadResponse extends ExchangeError {} | |
export class NullResponse extends BadResponse {} | |
export class InsufficientFunds extends ExchangeError {} | |
export class InvalidAddress extends ExchangeError {} | |
export class AddressPending extends InvalidAddress {} | |
export class InvalidOrder extends ExchangeError {} | |
export class OrderNotFound extends InvalidOrder {} | |
export class OrderNotCached extends InvalidOrder {} | |
export class CancelPending extends InvalidOrder {} | |
export class OrderImmediatelyFillable extends InvalidOrder {} | |
export class OrderNotFillable extends InvalidOrder {} | |
export class DuplicateOrderId extends InvalidOrder {} | |
export class NotSupported extends ExchangeError {} | |
export class NetworkError extends BaseError {} | |
export class DDoSProtection extends NetworkError {} | |
export class RateLimitExceeded extends DDoSProtection {} | |
export class ExchangeNotAvailable extends NetworkError {} | |
export class OnMaintenance extends ExchangeNotAvailable {} | |
export class InvalidNonce extends NetworkError {} | |
export class RequestTimeout extends NetworkError {} | |
export interface MinMax { | |
min: number; | |
max: number | undefined; | |
} | |
export interface Market { | |
id: string; | |
symbol: string; | |
base: string; | |
quote: string; | |
baseId: string, | |
quoteId: string, | |
active: boolean; | |
precision: { base: number, quote: number, amount: number, price: number }; | |
limits: { amount: MinMax, price: MinMax, cost?: MinMax }; | |
tierBased: boolean, | |
percentage: boolean, | |
taker: number, | |
maker: number, | |
info: any, | |
} | |
export interface Order { | |
id: string; | |
datetime: string; | |
timestamp: number; | |
lastTradeTimestamp: number; | |
status: 'open' | 'closed' | 'canceled'; | |
symbol: string; | |
type: string; | |
side: 'buy' | 'sell'; | |
price: number; | |
average?: number; | |
amount: number; | |
filled: number; | |
remaining: number; | |
cost: number; | |
trades: Trade[]; | |
fee: Fee; | |
info: any; | |
} | |
export interface OrderBook { | |
asks: [number, number][]; | |
bids: [number, number][]; | |
datetime: string; | |
timestamp: number; | |
nonce: number; | |
} | |
export interface Trade { | |
amount: number; // amount of base currency | |
datetime: string; // ISO8601 datetime with milliseconds; | |
id: string; // string trade id | |
info: any; // the original decoded JSON as is | |
order?: string; // string order id or undefined/None/null | |
price: number; // float price in quote currency | |
timestamp: number; // Unix timestamp in milliseconds | |
type?: 'market' | 'limit'; // order type, 'market', 'limit' or undefined/None/null | |
side: 'buy' | 'sell'; // direction of the trade, 'buy' or 'sell' | |
symbol: string; // symbol in CCXT format | |
takerOrMaker: 'taker' | 'maker'; // string, 'taker' or 'maker' | |
cost: number; // total cost (including fees), `price * amount` | |
fee: Fee; | |
} | |
export interface Ticker { | |
symbol: string; | |
info: any; | |
timestamp: number; | |
datetime: string; | |
high: number; | |
low: number; | |
bid: number; | |
bidVolume?: number; | |
ask: number; | |
askVolume?: number; | |
vwap?: number; | |
open?: number; | |
close?: number; | |
last?: number; | |
previousClose?: number; | |
change?: number; | |
percentage?: number; | |
average?: number; | |
quoteVolume?: number; | |
baseVolume?: number; | |
} | |
export interface Transaction { | |
info: any; | |
id: string; | |
txid?: string; | |
timestamp: number; | |
datetime: string; | |
address: string; | |
type: "deposit" | "withdrawal"; | |
amount: number; | |
currency: string; | |
status: "pending" | "ok"; | |
updated: number; | |
fee: Fee; | |
} | |
export interface Tickers extends Dictionary<Ticker> { | |
info: any; | |
} | |
export interface Currency { | |
id: string; | |
code: string; | |
numericId?: number; | |
precision: number; | |
} | |
export interface Balance { | |
free: number; | |
used: number; | |
total: number; | |
} | |
export interface PartialBalances extends Dictionary<number> { | |
} | |
export interface Balances extends Dictionary<Balance> { | |
info: any; | |
} | |
export interface DepositAddress { | |
currency: string; | |
address: string; | |
status: string; | |
info: any; | |
} | |
export interface Fee { | |
type: 'taker' | 'maker'; | |
currency: string; | |
rate: number; | |
cost: number; | |
} | |
export interface WithdrawalResponse { | |
info: any; | |
id: string; | |
} | |
export interface DepositAddressResponse { | |
currency: string; | |
address: string; | |
info: any; | |
tag?: string; | |
} | |
/** [ timestamp, open, high, low, close, volume ] */ | |
export type OHLCV = [number, number, number, number, number, number]; | |
/** Request parameters */ | |
type Params = Dictionary<string | number>; | |
export class Exchange { | |
constructor(config?: {[key in keyof Exchange]?: Exchange[key]}); | |
// allow dynamic keys | |
[key: string]: any; | |
// properties | |
version: string; | |
apiKey: string; | |
secret: string; | |
password: string; | |
uid: string; | |
requiredCredentials: { | |
apiKey: boolean; | |
secret: boolean; | |
uid: boolean; | |
login: boolean; | |
password: boolean; | |
twofa: boolean; | |
privateKey: boolean; | |
walletAddress: boolean; | |
token: boolean; | |
}; | |
options: { | |
[key: string]: any; | |
fetchTradesMethod: 'publicGetAggTrades' | string; | |
fetchTickersMethod: 'publicGetTicker24hr' | string; | |
defaultTimeInForce: 'GTC' | string; | |
defaultLimitOrderType: 'limit' | 'market' | string; | |
hasAlreadyAuthenticatedSuccessfully: boolean; | |
warnOnFetchOpenOrdersWithoutSymbol: boolean; | |
recvWindow: number; | |
timeDifference: number; | |
adjustForTimeDifference: boolean; | |
parseOrderToPrecision: boolean; | |
newOrderRespType: { | |
market: 'FULL' | string; | |
limit: 'RESULT' | string; | |
}; | |
}; | |
urls: { | |
logo: string; | |
api: string | Dictionary<string>; | |
test: string | Dictionary<string>; | |
www: string; | |
doc: string[]; | |
api_management?: string; | |
fees: string; | |
referral: string; | |
}; | |
precisionMode: number; | |
hash: any; | |
hmac: any; | |
jwt: any; | |
binaryConcat: any; | |
stringToBinary: any; | |
stringToBase64: any; | |
base64ToBinary: any; | |
base64ToString: any; | |
binaryToString: any; | |
utf16ToBase64: any; | |
urlencode: any; | |
pluck: any; | |
unique: any; | |
extend: any; | |
deepExtend: any; | |
flatten: any; | |
groupBy: any; | |
indexBy: any; | |
sortBy: any; | |
keysort: any; | |
decimal: any; | |
safeFloat: any; | |
safeString: any; | |
safeInteger: any; | |
safeValue: any; | |
capitalize: any; | |
json: JSON["stringify"] | |
sum: any; | |
ordered: any; | |
aggregate: any; | |
truncate: any; | |
name: string; | |
// nodeVersion: string; | |
fees: object; | |
enableRateLimit: boolean; | |
countries: string[]; | |
// set by loadMarkets | |
markets: Dictionary<Market>; | |
marketsById: Dictionary<Market>; | |
currencies: Dictionary<Currency>; | |
ids: string[]; | |
symbols: string[]; | |
id: string; | |
proxy: string; | |
parse8601: typeof Date.parse | |
milliseconds: typeof Date.now; | |
rateLimit: number; // milliseconds = seconds * 1000 | |
timeout: number; // milliseconds | |
verbose: boolean; | |
twofa: boolean;// two-factor authentication | |
substituteCommonCurrencyCodes: boolean; | |
timeframes: Dictionary<number | string>; | |
has: Dictionary<boolean | 'emulated'>; // https://github.com/ccxt/ccxt/pull/1984 | |
balance: object; | |
orderbooks: object; | |
orders: object; | |
trades: object; | |
userAgent: { 'User-Agent': string } | false; | |
limits: { amount: MinMax, price: MinMax, cost: MinMax }; | |
hasCancelAllOrders: boolean; | |
hasCancelOrder: boolean; | |
hasCancelOrders: boolean; | |
hasCORS: boolean; | |
hasCreateDepositAddress: boolean; | |
hasCreateLimitOrder: boolean; | |
hasCreateMarketOrder: boolean; | |
hasCreateOrder: boolean; | |
hasDeposit: boolean; | |
hasEditOrder: boolean; | |
hasFetchBalance: boolean; | |
hasFetchBidsAsks: boolean; | |
hasFetchClosedOrders: boolean; | |
hasFetchCurrencies: boolean; | |
hasFetchDepositAddress: boolean; | |
hasFetchDeposits: boolean; | |
hasFetchFundingFees: boolean; | |
hasFetchL2OrderBook: boolean; | |
hasFetchLedger: boolean; | |
hasFetchMarkets: boolean; | |
hasFetchMyTrades: boolean; | |
hasFetchOHLCV: boolean; | |
hasFetchOpenOrders: boolean; | |
hasFetchOrder: boolean; | |
hasFetchOrderBook: boolean; | |
hasFetchOrderBooks: boolean; | |
hasFetchOrders: boolean; | |
hasFetchStatus: boolean; | |
hasFetchTicker: boolean; | |
hasFetchTickers: boolean; | |
hasFetchTime: boolean; | |
hasFetchTrades: boolean; | |
hasFetchTradingFee: boolean; | |
hasFetchTradingFees: boolean; | |
hasFetchTradingLimits: boolean; | |
hasFetchTransactions: boolean; | |
hasFetchWithdrawals: boolean; | |
hasPrivateAPI: boolean; | |
hasPublicAPI: boolean; | |
hasWithdraw: boolean; | |
// methods | |
account (): Balance; | |
cancelAllOrders (...args: any): Promise<any>; // TODO: add function signatures | |
cancelOrder (id: string, symbol?: string, params?: Params): Promise<Order>; | |
cancelOrders (...args: any): Promise<any>; // TODO: add function signatures | |
checkRequiredCredentials (): void; | |
commonCurrencyCode (currency: string): string; | |
createDepositAddress (currency: string, params?: Params): Promise<DepositAddressResponse>; | |
createLimitOrder (symbol: string, side: Order['side'], amount: number, price?: number, params?: Params): Promise<Order>; | |
createMarketOrder (symbol: string, side: Order['side'], amount: number, price?: number, params?: Params): Promise<Order>; | |
createOrder (symbol: string, type: Order['type'], side: Order['side'], amount: number, price?: number, params?: Params): Promise<Order>; | |
decode (str: string): string; | |
defaults (): any; | |
defineRestApi (api: any, methodName: any, options?: Dictionary<any>): void; | |
deposit (...args: any): Promise<any>; // TODO: add function signatures | |
describe (): any; | |
editOrder (id: string, symbol: string, type: Order['type'], side: Order['side'], amount: number, price?: number, params?: Params): Promise<Order>; | |
encode (str: string): string; | |
encodeURIComponent (...args: any[]): string; | |
extractParams (str: string): string[]; | |
fetch (url: string, method?: string, headers?: any, body?: any): Promise<any>; | |
fetch2 (path: any, api?: string, method?: string, params?: Params, headers?: any, body?: any): Promise<any>; | |
fetchBalance (params?: Params): Promise<Balances>; | |
fetchBidsAsks (symbols?: string[], params?: Params): Promise<any>; | |
fetchClosedOrders (symbol?: string, since?: number, limit?: number, params?: Params): Promise<Order[]>; | |
fetchCurrencies (params?: Params): Promise<Dictionary<Currency>>; | |
fetchDepositAddress (currency: string, params?: Params): Promise<DepositAddressResponse>; | |
fetchDeposits (currency?: string, since?: number, limit?: number, params?: Params): Promise<Transaction[]>; | |
fetchFreeBalance (params?: Params): Promise<PartialBalances>; | |
fetchFundingFees (...args: any): Promise<any>; // TODO: add function signatures | |
fetchL2OrderBook (...args: any): Promise<any>; // TODO: add function signatures | |
fetchLedger (...args: any): Promise<any>; // TODO: add function signatures | |
fetchMarkets (): Promise<Market[]>; | |
fetchMyTrades (symbol?: string, since?: any, limit?: any, params?: Params): Promise<Trade[]>; | |
fetchOHLCV (symbol: string, timeframe?: string, since?: number, limit?: number, params?: Params): Promise<OHLCV[]>; | |
fetchOpenOrders (symbol?: string, since?: number, limit?: number, params?: Params): Promise<Order[]>; | |
fetchOrder (id: string, symbol: string, params?: Params): Promise<Order>; | |
fetchOrderBook (symbol: string, limit?: number, params?: Params): Promise<OrderBook>; | |
fetchOrderBooks (...args: any): Promise<any>; // TODO: add function signatures | |
fetchOrders (symbol?: string, since?: number, limit?: number, params?: Params): Promise<Order[]>; | |
fetchOrderStatus (id: string, market: string): Promise<string>; | |
fetchStatus (...args: any): Promise<any>; // TODO: add function signatures | |
fetchTicker (symbol: string, params?: Params): Promise<Ticker>; | |
fetchTickers (symbols?: string[], params?: Params): Promise<Dictionary<Ticker>>; | |
fetchTime (params?: Params): Promise<number>; | |
fetchTotalBalance (params?: Params): Promise<PartialBalances>; | |
fetchTrades (symbol: string, since?: number, limit?: number, params?: Params): Promise<Trade[]>; | |
fetchTradingFee (...args: any): Promise<any>; // TODO: add function signatures | |
fetchTradingFees (...args: any): Promise<any>; // TODO: add function signatures | |
fetchTradingLimits (...args: any): Promise<any>; // TODO: add function signatures | |
fetchTransactions (currency?: string, since?: number, limit?: number, params?: Params): Promise<Transaction[]>; | |
fetchUsedBalance (params?: Params): Promise<PartialBalances>; | |
fetchWithdrawals (currency?: string, since?: number, limit?: number, params?: Params): Promise<Transaction[]>; | |
getMarket (symbol: string): Market; | |
initRestRateLimiter (): void; | |
iso8601 (timestamp: number | string): string; | |
loadMarkets (reload?: boolean): Promise<Dictionary<Market>>; | |
market (symbol: string): Market; | |
marketId (symbol: string): string; | |
marketIds (symbols: string[]): string[]; | |
microseconds (): number; | |
nonce (): number; | |
parseTimeframe (timeframe: string): number; | |
purgeCachedOrders (timestamp: number): void; | |
request (path: string, api?: string, method?: string, params?: Params, headers?: any, body?: any): Promise<any>; | |
seconds (): number; | |
setMarkets (markets: Market[], currencies?: Currency[]): Dictionary<Market>; | |
symbol (symbol: string): string; | |
withdraw (currency: string, amount: number, address: string, tag?: string, params?: Params): Promise<WithdrawalResponse>; | |
YmdHMS (timestamp: string, infix: string) : string; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment