UNPKG

ccxt

Version:

A JavaScript / TypeScript / Python / C# / PHP cryptocurrency trading library with support for 100+ exchanges

442 lines (441 loc) • 26.7 kB
import Exchange from './abstract/poloniex.js'; import type { TransferEntry, Int, Leverage, OrderSide, OrderType, OHLCV, Trade, OrderBook, Order, Balances, Str, MarginModification, Transaction, Ticker, Tickers, Market, Strings, Currency, Num, Currencies, TradingFees, Dict, int, DepositAddress, Position } from './base/types.js'; /** * @class poloniex * @augments Exchange */ export default class poloniex extends Exchange { describe(): any; parseOHLCV(ohlcv: any, market?: Market): OHLCV; /** * @method * @name poloniex#fetchOHLCV * @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market * @see https://api-docs.poloniex.com/spot/api/public/market-data#candles * @see https://api-docs.poloniex.com/v3/futures/api/market/get-kline-data * @param {string} symbol unified symbol of the market to fetch OHLCV data for * @param {string} timeframe the length of time each candle represents * @param {int} [since] timestamp in ms of the earliest candle to fetch * @param {int} [limit] the maximum amount of candles to fetch * @param {object} [params] extra parameters specific to the exchange API endpoint * @param {int} [params.until] timestamp in ms * @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params) * @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume */ fetchOHLCV(symbol: string, timeframe?: string, since?: Int, limit?: Int, params?: {}): Promise<OHLCV[]>; loadMarkets(reload?: boolean, params?: {}): Promise<import("./base/types.js").Dictionary<import("./base/types.js").MarketInterface>>; /** * @method * @name poloniex#fetchMarkets * @description retrieves data on all markets for poloniex * @see https://api-docs.poloniex.com/spot/api/public/reference-data#symbol-information * @see https://api-docs.poloniex.com/v3/futures/api/market/get-all-product-info * @param {object} [params] extra parameters specific to the exchange API endpoint * @returns {object[]} an array of objects representing market data */ fetchMarkets(params?: {}): Promise<Market[]>; fetchSpotMarkets(params?: {}): Promise<Market[]>; fetchSwapMarkets(params?: {}): Promise<Market[]>; parseMarket(market: Dict): Market; parseSpotMarket(market: Dict): Market; parseSwapMarket(market: Dict): Market; /** * @method * @name poloniex#fetchTime * @description fetches the current integer timestamp in milliseconds from the exchange server * @see https://api-docs.poloniex.com/spot/api/public/reference-data#system-timestamp * @param {object} [params] extra parameters specific to the exchange API endpoint * @returns {int} the current integer timestamp in milliseconds from the exchange server */ fetchTime(params?: {}): Promise<Int>; parseTicker(ticker: Dict, market?: Market): Ticker; /** * @method * @name poloniex#fetchTickers * @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market * @see https://api-docs.poloniex.com/spot/api/public/market-data#ticker * @see https://api-docs.poloniex.com/v3/futures/api/market/get-market-info * @param {string[]|undefined} symbols unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned * @param {object} [params] extra parameters specific to the exchange API endpoint * @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure} */ fetchTickers(symbols?: Strings, params?: {}): Promise<Tickers>; /** * @method * @name poloniex#fetchCurrencies * @description fetches all available currencies on an exchange * @see https://api-docs.poloniex.com/spot/api/public/reference-data#currency-information * @param {object} [params] extra parameters specific to the exchange API endpoint * @returns {object} an associative dictionary of currencies */ fetchCurrencies(params?: {}): Promise<Currencies>; /** * @method * @name poloniex#fetchTicker * @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market * @see https://api-docs.poloniex.com/spot/api/public/market-data#ticker * @see https://api-docs.poloniex.com/v3/futures/api/market/get-market-info * @param {string} symbol unified symbol of the market to fetch the ticker for * @param {object} [params] extra parameters specific to the exchange API endpoint * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure} */ fetchTicker(symbol: string, params?: {}): Promise<Ticker>; parseTrade(trade: Dict, market?: Market): Trade; /** * @method * @name poloniex#fetchTrades * @description get the list of most recent trades for a particular symbol * @see https://api-docs.poloniex.com/spot/api/public/market-data#trades * @see https://api-docs.poloniex.com/v3/futures/api/market/get-execution-info * @param {string} symbol unified symbol of the market to fetch trades for * @param {int} [since] timestamp in ms of the earliest trade to fetch * @param {int} [limit] the maximum amount of trades to fetch * @param {object} [params] extra parameters specific to the exchange API endpoint * @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=public-trades} */ fetchTrades(symbol: string, since?: Int, limit?: Int, params?: {}): Promise<Trade[]>; /** * @method * @name poloniex#fetchMyTrades * @description fetch all trades made by the user * @see https://api-docs.poloniex.com/spot/api/private/trade#trade-history * @see https://api-docs.poloniex.com/v3/futures/api/trade/get-execution-details * @param {string} symbol unified market symbol * @param {int} [since] the earliest time in ms to fetch trades for * @param {int} [limit] the maximum number of trades structures to retrieve * @param {object} [params] extra parameters specific to the exchange API endpoint * @param {int} [params.until] the latest time in ms to fetch entries for * @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params) * @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure} */ fetchMyTrades(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Trade[]>; parseOrderStatus(status: Str): string; parseOrder(order: Dict, market?: Market): Order; parseOrderType(status: any): string; parseOpenOrders(orders: any, market: any, result: any): any; /** * @method * @name poloniex#fetchOpenOrders * @description fetch all unfilled currently open orders * @see https://api-docs.poloniex.com/spot/api/private/order#open-orders * @see https://api-docs.poloniex.com/spot/api/private/smart-order#open-orders // trigger orders * @see https://api-docs.poloniex.com/v3/futures/api/trade/get-current-orders * @param {string} symbol unified market symbol * @param {int} [since] the earliest time in ms to fetch open orders for * @param {int} [limit] the maximum number of open orders structures to retrieve * @param {object} [params] extra parameters specific to the exchange API endpoint * @param {boolean} [params.trigger] set true to fetch trigger orders instead of regular orders * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure} */ fetchOpenOrders(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Order[]>; /** * @method * @name poloniex#fetchClosedOrders * @see https://api-docs.poloniex.com/v3/futures/api/trade/get-order-history * @description fetches information on multiple closed orders made by the user * @param {string} symbol unified market symbol of the market orders were made in * @param {int} [since] the earliest time in ms to fetch orders for * @param {int} [limit] the maximum number of order structures to retrieve * @param {object} [params] extra parameters specific to the exchange API endpoint * @param {int} [params.until] timestamp in ms of the latest entry * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure} */ fetchClosedOrders(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Order[]>; /** * @method * @name poloniex#createOrder * @description create a trade order * @see https://api-docs.poloniex.com/spot/api/private/order#create-order * @see https://api-docs.poloniex.com/spot/api/private/smart-order#create-order // trigger orders * @param {string} symbol unified symbol of the market to create an order in * @param {string} type 'market' or 'limit' * @param {string} side 'buy' or 'sell' * @param {float} amount how much of currency you want to trade in units of base currency * @param {float} [price] the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders * @param {object} [params] extra parameters specific to the exchange API endpoint * @param {float} [params.triggerPrice] the price at which a trigger order is triggered at * @param {float} [params.cost] *spot market buy only* the quote quantity that can be used as an alternative for the amount * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure} */ createOrder(symbol: string, type: OrderType, side: OrderSide, amount: number, price?: Num, params?: {}): Promise<Order>; orderRequest(symbol: any, type: any, side: any, amount: any, request: any, price?: any, params?: {}): any[]; /** * @method * @name poloniex#editOrder * @description edit a trade order * @see https://api-docs.poloniex.com/spot/api/private/order#cancel-replace-order * @see https://api-docs.poloniex.com/spot/api/private/smart-order#cancel-replace-order * @param {string} id order id * @param {string} symbol unified symbol of the market to create an order in * @param {string} type 'market' or 'limit' * @param {string} side 'buy' or 'sell' * @param {float} [amount] how much of the currency you want to trade in units of the base currency * @param {float} [price] the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders * @param {object} [params] extra parameters specific to the exchange API endpoint * @param {float} [params.triggerPrice] The price at which a trigger order is triggered at * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure} */ editOrder(id: string, symbol: string, type: OrderType, side: OrderSide, amount?: Num, price?: Num, params?: {}): Promise<Order>; cancelOrder(id: string, symbol?: Str, params?: {}): Promise<Order>; /** * @method * @name poloniex#cancelAllOrders * @description cancel all open orders * @see https://api-docs.poloniex.com/spot/api/private/order#cancel-all-orders * @see https://api-docs.poloniex.com/spot/api/private/smart-order#cancel-all-orders // trigger orders * @see https://api-docs.poloniex.com/v3/futures/api/trade/cancel-all-orders - contract markets * @param {string} symbol unified market symbol, only orders in the market of this symbol are cancelled when symbol is not undefined * @param {object} [params] extra parameters specific to the exchange API endpoint * @param {boolean} [params.trigger] true if canceling trigger orders * @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure} */ cancelAllOrders(symbol?: Str, params?: {}): Promise<Order[]>; /** * @method * @name poloniex#fetchOrder * @description fetch an order by it's id * @see https://api-docs.poloniex.com/spot/api/private/order#order-details * @see https://api-docs.poloniex.com/spot/api/private/smart-order#open-orders // trigger orders * @param {string} id order id * @param {string} symbol unified market symbol, default is undefined * @param {object} [params] extra parameters specific to the exchange API endpoint * @param {boolean} [params.trigger] true if fetching a trigger order * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure} */ fetchOrder(id: string, symbol?: Str, params?: {}): Promise<Order>; fetchOrderStatus(id: string, symbol?: Str, params?: {}): Promise<"open" | "closed">; /** * @method * @name poloniex#fetchOrderTrades * @description fetch all the trades made from a single order * @see https://api-docs.poloniex.com/spot/api/private/trade#trades-by-order-id * @param {string} id order id * @param {string} symbol unified market symbol * @param {int} [since] the earliest time in ms to fetch trades for * @param {int} [limit] the maximum number of trades to retrieve * @param {object} [params] extra parameters specific to the exchange API endpoint * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure} */ fetchOrderTrades(id: string, symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Trade[]>; parseBalance(response: any): Balances; /** * @method * @name poloniex#fetchBalance * @description query for balance and get the amount of funds available for trading or funds locked in orders * @see https://api-docs.poloniex.com/spot/api/private/account#all-account-balances * @see https://api-docs.poloniex.com/v3/futures/api/account/balance * @param {object} [params] extra parameters specific to the exchange API endpoint * @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure} */ fetchBalance(params?: {}): Promise<Balances>; /** * @method * @name poloniex#fetchTradingFees * @description fetch the trading fees for multiple markets * @see https://api-docs.poloniex.com/spot/api/private/account#fee-info * @param {object} [params] extra parameters specific to the exchange API endpoint * @returns {object} a dictionary of [fee structures]{@link https://docs.ccxt.com/#/?id=fee-structure} indexed by market symbols */ fetchTradingFees(params?: {}): Promise<TradingFees>; /** * @method * @name poloniex#fetchOrderBook * @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data * @see https://api-docs.poloniex.com/spot/api/public/market-data#order-book * @see https://api-docs.poloniex.com/v3/futures/api/market/get-order-book * @param {string} symbol unified symbol of the market to fetch the order book for * @param {int} [limit] the maximum amount of order book entries to return * @param {object} [params] extra parameters specific to the exchange API endpoint * @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbols */ fetchOrderBook(symbol: string, limit?: Int, params?: {}): Promise<OrderBook>; /** * @method * @name poloniex#createDepositAddress * @description create a currency deposit address * @see https://api-docs.poloniex.com/spot/api/private/wallet#deposit-addresses * @param {string} code unified currency code of the currency for the deposit address * @param {object} [params] extra parameters specific to the exchange API endpoint * @returns {object} an [address structure]{@link https://docs.ccxt.com/#/?id=address-structure} */ createDepositAddress(code: string, params?: {}): Promise<DepositAddress>; /** * @method * @name poloniex#fetchDepositAddress * @description fetch the deposit address for a currency associated with this account * @see https://api-docs.poloniex.com/spot/api/private/wallet#deposit-addresses * @param {string} code unified currency code * @param {object} [params] extra parameters specific to the exchange API endpoint * @returns {object} an [address structure]{@link https://docs.ccxt.com/#/?id=address-structure} */ fetchDepositAddress(code: string, params?: {}): Promise<DepositAddress>; prepareRequestForDepositAddress(code: string, params?: Dict): any; parseDepositAddressSpecial(response: any, currency: any, networkEntry: any): DepositAddress; /** * @method * @name poloniex#transfer * @description transfer currency internally between wallets on the same account * @see https://api-docs.poloniex.com/spot/api/private/account#accounts-transfer * @param {string} code unified currency code * @param {float} amount amount to transfer * @param {string} fromAccount account to transfer from * @param {string} toAccount account to transfer to * @param {object} [params] extra parameters specific to the exchange API endpoint * @returns {object} a [transfer structure]{@link https://docs.ccxt.com/#/?id=transfer-structure} */ transfer(code: string, amount: number, fromAccount: string, toAccount: string, params?: {}): Promise<TransferEntry>; parseTransfer(transfer: Dict, currency?: Currency): TransferEntry; /** * @method * @name poloniex#withdraw * @description make a withdrawal * @see https://api-docs.poloniex.com/spot/api/private/wallet#withdraw-currency * @param {string} code unified currency code * @param {float} amount the amount to withdraw * @param {string} address the address to withdraw to * @param {string} tag * @param {object} [params] extra parameters specific to the exchange API endpoint * @returns {object} a [transaction structure]{@link https://docs.ccxt.com/#/?id=transaction-structure} */ withdraw(code: string, amount: number, address: string, tag?: any, params?: {}): Promise<Transaction>; fetchTransactionsHelper(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<any>; /** * @method * @name poloniex#fetchDepositsWithdrawals * @description fetch history of deposits and withdrawals * @see https://api-docs.poloniex.com/spot/api/private/wallet#wallets-activity-records * @param {string} [code] unified currency code for the currency of the deposit/withdrawals, default is undefined * @param {int} [since] timestamp in ms of the earliest deposit/withdrawal, default is undefined * @param {int} [limit] max number of deposit/withdrawals to return, default is undefined * @param {object} [params] extra parameters specific to the exchange API endpoint * @returns {object} a list of [transaction structure]{@link https://docs.ccxt.com/#/?id=transaction-structure} */ fetchDepositsWithdrawals(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<Transaction[]>; /** * @method * @name poloniex#fetchWithdrawals * @description fetch all withdrawals made from an account * @see https://api-docs.poloniex.com/spot/api/private/wallet#wallets-activity-records * @param {string} code unified currency code * @param {int} [since] the earliest time in ms to fetch withdrawals for * @param {int} [limit] the maximum number of withdrawals structures to retrieve * @param {object} [params] extra parameters specific to the exchange API endpoint * @returns {object[]} a list of [transaction structures]{@link https://docs.ccxt.com/#/?id=transaction-structure} */ fetchWithdrawals(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<Transaction[]>; /** * @method * @name poloniex#fetchDepositWithdrawFees * @description fetch deposit and withdraw fees * @see https://api-docs.poloniex.com/spot/api/public/reference-data#currency-information * @param {string[]|undefined} codes list of unified currency codes * @param {object} [params] extra parameters specific to the exchange API endpoint * @returns {object[]} a list of [fees structures]{@link https://docs.ccxt.com/#/?id=fee-structure} */ fetchDepositWithdrawFees(codes?: Strings, params?: {}): Promise<Dict>; parseDepositWithdrawFees(response: any, codes?: any, currencyIdKey?: any): Dict; parseDepositWithdrawFee(fee: any, currency?: Currency): any; /** * @method * @name poloniex#fetchDeposits * @description fetch all deposits made to an account * @see https://api-docs.poloniex.com/spot/api/private/wallet#wallets-activity-records * @param {string} code unified currency code * @param {int} [since] the earliest time in ms to fetch deposits for * @param {int} [limit] the maximum number of deposits structures to retrieve * @param {object} [params] extra parameters specific to the exchange API endpoint * @returns {object[]} a list of [transaction structures]{@link https://docs.ccxt.com/#/?id=transaction-structure} */ fetchDeposits(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<Transaction[]>; parseTransactionStatus(status: Str): string; parseTransaction(transaction: Dict, currency?: Currency): Transaction; /** * @method * @name poloniex#setLeverage * @description set the level of leverage for a market * @see https://api-docs.poloniex.com/v3/futures/api/positions/set-leverage * @param {int} leverage the rate of leverage * @param {string} symbol unified market symbol * @param {object} [params] extra parameters specific to the exchange API endpoint * @param {string} [params.marginMode] 'cross' or 'isolated' * @returns {object} response from the exchange */ setLeverage(leverage: Int, symbol?: Str, params?: {}): Promise<any>; /** * @method * @name poloniex#fetchLeverage * @description fetch the set leverage for a market * @see https://api-docs.poloniex.com/v3/futures/api/positions/get-leverages * @param {string} symbol unified market symbol * @param {object} [params] extra parameters specific to the exchange API endpoint * @returns {object} a [leverage structure]{@link https://docs.ccxt.com/#/?id=leverage-structure} */ fetchLeverage(symbol: string, params?: {}): Promise<Leverage>; parseLeverage(leverage: Dict, market?: Market): Leverage; /** * @method * @name poloniex#fetchPositionMode * @description fetchs the position mode, hedged or one way, hedged for binance is set identically for all linear markets or all inverse markets * @see https://api-docs.poloniex.com/v3/futures/api/positions/position-mode-switch * @param {string} symbol unified symbol of the market to fetch the order book for * @param {object} [params] extra parameters specific to the exchange API endpoint * @returns {object} an object detailing whether the market is in hedged or one-way mode */ fetchPositionMode(symbol?: Str, params?: {}): Promise<{ info: any; hedged: boolean; }>; /** * @method * @name poloniex#setPositionMode * @description set hedged to true or false for a market * @see https://api-docs.poloniex.com/v3/futures/api/positions/position-mode-switch * @param {bool} hedged set to true to use dualSidePosition * @param {string} symbol not used by binance setPositionMode () * @param {object} [params] extra parameters specific to the exchange API endpoint * @returns {object} response from the exchange */ setPositionMode(hedged: boolean, symbol?: Str, params?: {}): Promise<any>; /** * @method * @name poloniex#fetchPositions * @description fetch all open positions * @see https://api-docs.poloniex.com/v3/futures/api/positions/get-current-position * @param {string[]|undefined} symbols list of unified market symbols * @param {object} [params] extra parameters specific to the exchange API endpoint * @param {boolean} [params.standard] whether to fetch standard contract positions * @returns {object[]} a list of [position structures]{@link https://docs.ccxt.com/#/?id=position-structure} */ fetchPositions(symbols?: Strings, params?: {}): Promise<Position[]>; parsePosition(position: Dict, market?: Market): Position; modifyMarginHelper(symbol: string, amount: any, type: any, params?: {}): Promise<MarginModification>; parseMarginModification(data: Dict, market?: Market): MarginModification; /** * @method * @name poloniex#reduceMargin * @description remove margin from a position * @param {string} symbol unified market symbol * @param {float} amount the amount of margin to remove * @param {object} [params] extra parameters specific to the exchange API endpoint * @returns {object} a [margin structure]{@link https://docs.ccxt.com/#/?id=reduce-margin-structure} */ reduceMargin(symbol: string, amount: number, params?: {}): Promise<MarginModification>; /** * @method * @name poloniex#addMargin * @description add margin * @param {string} symbol unified market symbol * @param {float} amount amount of margin to add * @param {object} [params] extra parameters specific to the exchange API endpoint * @returns {object} a [margin structure]{@link https://docs.ccxt.com/#/?id=add-margin-structure} */ addMargin(symbol: string, amount: number, params?: {}): Promise<MarginModification>; nonce(): number; sign(path: any, api?: string, method?: string, params?: {}, headers?: any, body?: any): { url: any; method: string; body: any; headers: any; }; handleErrors(code: int, reason: string, url: string, method: string, headers: Dict, body: string, response: any, requestHeaders: any, requestBody: any): any; }