crypto-client
Version:
An unified client for all cryptocurrency exchanges.
133 lines (132 loc) • 4.5 kB
TypeScript
import { Market, MarketType } from 'crypto-markets';
import { UserConfig } from './config';
import { ActionExtended } from './pojo';
import { Currency } from './pojo/currency';
import { DepositAddress } from './pojo/deposit_address';
import { WithdrawalFee } from './pojo/withdrawal_fee';
export { UserConfig } from './config';
export * from './pojo';
export declare const SUPPORTED_EXCHANGES: string[];
/**
* Initialize.
*
*/
export declare function init({ eosAccount, eosPrivateKey, ethPrivateKey, BINANCE_API_KEY, BINANCE_API_SECRET, BITFINEX_API_KEY, BITFINEX_API_SECRET, BITSTAMP_USER_ID, BITSTAMP_API_KEY, BITSTAMP_API_SECRET, COINBASE_ACCESS_KEY, COINBASE_ACCESS_SECRET, COINBASE_ACCESS_PASSPHRASE, DFUSE_API_KEY, HUOBI_ACCESS_KEY, HUOBI_SECRET_KEY, HUOBI_ACCOUNT_ID, KRAKEN_API_KEY, KRAKEN_PRIVATE_KEY, MXC_ACCESS_KEY, MXC_SECRET_KEY, OKEX_SPOT_API_KEY, OKEX_SPOT_API_SECRET, OKEX_SPOT_API_PASSPHRASE, OKEX_SPOT_FUND_PASSWORD, WHALEEX_API_KEY, WHALEEX_USER_ID, }: UserConfig): Promise<void>;
/**
* Create an Order object but don't sent it.
*
* This API is only used in DEX exchanges.
*
* @param market The trading market
* @param price The price
* @param quantity The quantity
* @param sell true if sell, otherwise false
* @returns ActionExtended
*/
export declare function createOrder(market: {
exchange: string;
type: MarketType;
pair: string;
id?: string;
} | Market, price: number, quantity: number, sell: boolean): Promise<ActionExtended>;
/**
* Place an order.
*
* @param market The trading market
* @param price The price
* @param quantity The quantity
* @param sell true if sell, otherwise false
* @returns transaction_id for dex, or order_id for central
*/
export declare function placeOrder(market: {
exchange: string;
type: MarketType;
pair: string;
id?: string;
} | Market, price: number, quantity: number, sell: boolean, clientOrderId?: string): Promise<string>;
/**
* Cancel an order.
*
* @param market The trading market
* @param orderId Order ID
* @returns boolean if central, transaction_id if dex
*/
export declare function cancelOrder(market: {
exchange: string;
type: MarketType;
pair: string;
id?: string;
} | Market, orderId: string): Promise<boolean | string>;
/**
* Query an order.
*
* @param market The trading market
* @param orderId Order ID
* @returns The order information
*/
export declare function queryOrder(market: {
exchange: string;
type: MarketType;
pair: string;
id?: string;
} | Market, orderId: string): Promise<{
[key: string]: any;
} | undefined>;
/**
* Get all balances of an exchange.
*
* @param exchange The exchange name
* @param all Only used for debugging. False, get only available balances; True, get all including free and locked balances. Default to false.
*/
export declare function queryAllBalances(exchange: string, all?: boolean): Promise<{
[key: string]: number;
} | Error>;
export declare function queryBalance(exchange: string, symbol: string): Promise<number>;
/**
* Get deposit addresses.
*
* @param exchangeName The exchange name
* @params symbols Symbols to retreive
* @returns symbol->platform->DepositAddress
*/
export declare function getDepositAddresses(exchange: string, symbols: string[]): Promise<{
[key: string]: {
[key: string]: DepositAddress;
};
}>;
/**
*
* @param exchangeName The exchange name
* @params symbols Symbols to retreive
* @returns symbol->platform -> WithdrawalFee
*/
export declare function getWithdrawalFees(exchange: string, symbols?: string[]): Promise<{
[key: string]: {
[key: string]: WithdrawalFee;
};
}>;
/**
* Fetch deposit and withdrawal statuses.
*
* Similar to fetchCurrencies() of ccxt.
*
* @param exchange The exchange name
* @returns symbol -> chain -> SymbolStatus or symbol -> SymbolStatus
*/
export declare function fetchCurrencies(exchange: string): Promise<{
[key: string]: Currency;
}>;
/**
* Withdraw.
*
* @param exchange The exchange name
* @param symbol The currency symbol
* @param address Destination address
* @param amount Withdrawal amount
* @param memo Optional, some currencies like EOS require addtional memo
* @param params Additional parameters, each exchange is different
* @returns Withdrawal ID
*/
export declare function withdraw(exchange: string, symbol: string, address: string, amount: number, memo?: string, params?: {
[key: string]: string | number | boolean;
}): Promise<string>;