// Generated by dts-bundle v0.7.3
// Dependencies for this module:
//   ../pushbullet
//   ../stream
//   ../ws
//   ../events
//   ../bignumber.js
//   ../bintrees
//   ../superagent

import * as PushBullet from 'pushbullet';
import { Duplex } from 'stream';
import { Writable } from 'stream';
import { Transform } from 'stream';
import { Readable } from 'stream';
import WebSocket = require('ws');
import { EventEmitter } from 'events';
import { BigNumber as BigJS } from 'bignumber.js';
import stream = require('stream');
import { RBTree } from 'bintrees';
import * as BigNumber from 'bignumber.js';
import { NumberLike } from 'bignumber.js';
import { Readable, Writable } from 'stream';
import request = require('superagent');
import superAgent = require('superagent');

/***************************************************************************************************************************
  * @license                                                                                                                *
  * Copyright 2017 Coinbase, Inc.                                                                                           *
  *                                                                                                                         *
  * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance          *
  * with the License. You may obtain a copy of the License at                                                               *
  *                                                                                                                         *
  * http://www.apache.org/licenses/LICENSE-2.0                                                                              *
  *                                                                                                                         *
  * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on     *
  * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the                      *
  * License for the specific language governing permissions and limitations under the License.                              *
  ***************************************************************************************************************************/
export { Core, Exchanges, Factories, FXService, utils, lib };

/**
    * Loggers
    */
/**
    * FXService
    */
/**
    * GDAX factories
    */
export { GDAX };
/**
    * Bitfinex factories
    */
export { Bitfinex };
/**
    * Poloniex factories
    */
export { Poloniex };
/**
    * Bittrex factories
    */
export { Bittrex };
export { Binance };
export { Gemini };

export const Providers: {
    CoinMarketCapProvider: typeof CoinMarketCapProvider;
    OpenExchangeProvider: typeof OpenExchangeProvider;
    YahooFXProvider: typeof YahooFXProvider;
};
export const Calculators: {
    SimpleRateCalculator: typeof SimpleRateCalculator;
};

export { PushBullet };

/***************************************************************************************************************************
    * @license                                                                                                                *
    * Copyright 2017 Coinbase, Inc.                                                                                           *
    *                                                                                                                         *
    * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance          *
    * with the License. You may obtain a copy of the License at                                                               *
    *                                                                                                                         *
    * http://www.apache.org/licenses/LICENSE-2.0                                                                              *
    *                                                                                                                         *
    * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on     *
    * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the                      *
    * License for the specific language governing permissions and limitations under the License.                              *
    ***************************************************************************************************************************/
export interface ExchangeRateFilterConfig extends MessageTransformConfig {
        pair: CurrencyPair;
        fxService: FXService;
        precision: number;
}
/**
    * Implements a stream filter that applies an exchange rate to a stream of GDAX messages.
    *
    *
    * If the FXService has any problems and enters an ErrorState, the  filter will continue to convert prices, but you
    * can watch for FXRateMayBeInvalid events and respond accordingly
    */
export class ExchangeRateFilter extends AbstractMessageTransform {
        constructor(config: ExchangeRateFilterConfig);
        readonly rate: FXObject;
        transformMessage(msg: StreamMessage): StreamMessage;
}

export interface HFTFilterConfig extends MessageTransformConfig {
        targetQueueLength: number;
}
export interface HFTFilterStats {
        backlog: number;
        skippedMessages: number;
        tradesSkipped: number;
}
/**
    * Filters the raw WS message stream by batching messages and auto-cancelling zero-effect trades.
    *
    * If you read from this stream in 'push' mode, i.e. by attaching a `data` listener to it, then each message will
    * be emitted more/less  instantaneously, and so the filtering mechanism won't have time to catch HFTs. The
    * way you probably want to use this stream is to always have it paused and call `read` when you want the
    * next message (perhaps every n ms). This way, there's maximum opportunity to pre-filter zero-effect trades; and
    * re-order any messages that may have arrived out of order
    */
export class HFTFilter extends Duplex {
        constructor(config: HFTFilterConfig);
        getStats(): HFTFilterStats;
        readonly queueLength: number;
        readonly numSkippedMessages: number;
        read(size?: number): StreamMessage;
        /**
            * Add the message to the queue
            */
        addMessage(message: StreamMessage): boolean;
        processDoneMessage(done: BaseOrderMessage): boolean;
        processChangeMessage(change: ChangedOrderMessage): boolean;
        pop(): StreamMessage;
        clearQueue(): void;
        protected _read(): void;
        /**
            * If this stream has another stream piped into it, we just pass the data into the READABLE stream's filter
            */
        protected _write(chunk: any, encoding: string, callback: (err: Error) => void): void;
        /**
            * Returns true if the message Queue has lengthened
            */
        protected filterMessage(message: StreamMessage): boolean;
        /**
            * Simply passes the message onto the output stream
            */
        protected passThrough(message: StreamMessage): boolean;
}

/***************************************************************************************************************************
    * @license                                                                                                                *
    * Copyright 2017 Coinbase, Inc.                                                                                           *
    *                                                                                                                         *
    * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance          *
    * with the License. You may obtain a copy of the License at                                                               *
    *                                                                                                                         *
    * http://www.apache.org/licenses/LICENSE-2.0                                                                              *
    *                                                                                                                         *
    * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on     *
    * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the                      *
    * License for the specific language governing permissions and limitations under the License.                              *
    ***************************************************************************************************************************/
export class LiveBookConfig {
        product: string;
        strictMode?: boolean;
        logger?: Logger;
}
export enum SequenceStatus {
        OK = 0,
        ALREADY_PROCESSED = 1,
        SKIP_DETECTED = 2,
}
export interface SkippedMessageEvent {
        sequence: number;
        expected_sequence: number;
}
/**
    * A live orderbook. This class maintains the state of an orderbook (using BookBuilder) in realtime by responding to
    * messages from attached feeds.
    */
export class LiveOrderbook extends Writable implements Orderbook {
        readonly product: string;
        readonly baseCurrency: string;
        readonly quoteCurrency: string;
        protected snapshotReceived: boolean;
        protected strictMode: boolean;
        protected lastBookUpdate: Date;
        protected _book: BookBuilder;
        protected liveTicker: Ticker;
        protected _sourceSequence: number;
        constructor(config: LiveBookConfig);
        log(level: string, message: string, meta?: any): void;
        readonly sourceSequence: number;
        readonly numAsks: number;
        readonly numBids: number;
        readonly bidsTotal: BigJS;
        readonly asksTotal: BigJS;
        state(): OrderbookState;
        readonly book: BookBuilder;
        readonly ticker: Ticker;
        readonly sequence: number;
        /**
            */
        readonly timeSinceTickerUpdate: number;
        /**
            * The time (in seconds) since the last orderbook update
            */
        readonly timeSinceOrderbookUpdate: number;
        /**
            * Return an array of (aggregated) orders whose sum is equal to or greater than `value`. The side parameter is from
            * the perspective of the purchaser, so 'buy' returns asks and 'sell' bids.
            */
        ordersForValue(side: string, value: Biglike, useQuote: boolean, startPrice?: StartPoint): CumulativePriceLevel[];
        protected _read(): void;
        _write(msg: any, encoding: string, callback: () => void): void;
        protected processTradeMessage(msg: TradeMessage): void;
}

/***************************************************************************************************************************
    * @license                                                                                                                *
    * Copyright 2017 Coinbase, Inc.                                                                                           *
    *                                                                                                                         *
    * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance          *
    * with the License. You may obtain a copy of the License at                                                               *
    *                                                                                                                         *
    * http://www.apache.org/licenses/LICENSE-2.0                                                                              *
    *                                                                                                                         *
    * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on     *
    * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the                      *
    * License for the specific language governing permissions and limitations under the License.                              *
    ***************************************************************************************************************************/
/**
    * Configuration interface for A MessageQueue
    *
    * @param logger {Logger} An optional logging interface
    *
    * @param product {string} A product to filter for. A single feed might be producing messages form multiple products (each with their own
    * sequence numbers). This selects for the product so that all messages can be emitted in strictly increasing sequence number.
    *
    * @param targetQueueLength {number} Tries to maintain the queue length at this value. Default is zero, but you can increase to
    * small number like 2 or 3 if messages frequently arrive out of order. This will impose small lag on your feed, but will
    * reduce the risk of messages arriving out of order
    *
    * @param waitForSnapshot If true, messages are queued up until a snapshot message is received. If false, messages are
    * emitted in the order they are received without waiting for a snapshot.
    */
export interface MessageQueueConfig {
        product: string;
        logger?: Logger;
        targetQueueLength?: number;
        waitForSnapshot: boolean;
}
/**
    * The MessageQueue does two things:
    * i) Filters input messages for a specific product
    * ii) Queues messages, sorts them and emits them in a strictly increasing order.
    *
    * The source feed can contain multiple product streams. This class will filter out any products that don't match the configured
    * product feed. This means you can create a single websocket feed that subscribes to all of, say GDAX's products and then
    * create multiple `MessageStreams` without much overhead.
    *
    * There are three different ways of using the stream:
    *
    * 1. Push mode: You attach a `data` listener to this stream and each each message will be emitted more/less instantaneously,
    * as it is received from the feed. In this case one might still get messages arriving out of order, since the queue is usually
    * going to be empty.
    * 2. Create the stream in 'paused' mode (the default when you create it) and call `read` when you want the
    * next message (perhaps every n ms).
    * 3. Pipe the stream to another stream that performs some other function (like filter out HFT trades, or apply an exchange rate)
    *
    * You can always track out-of-order messages by subscribing to the `messageOutOfSequence` event.
    *
    * ## Events
    *
    * ### data(msg)
    * Emitted for each message that gets sent out
    *
    * ### messageOutOfSequence (msg, expectedSequence)
    * Emitted if a message is about to be sent out, out of sequence and waiting would violate the `targetQueueLength` constraint
    */
export class MessageQueue extends Duplex {
        constructor(options: MessageQueueConfig);
        readonly product: string;
        readonly queueLength: number;
        readonly sequence: number;
        read(size?: number): OrderbookMessage;
        /**
            * Close the stream. No more reads will be possible after calling this method
            */
        end(): void;
        /**
            * Add the message to the queue
            * @param message
            */
        addMessage(message: OrderbookMessage): void;
        clearQueue(): void;
        /**
            * Will provide the next message, in the correct order
            * @private
            */
        protected _read(): void;
        /**
            * Returns the next message off the queue, and removes it from the queue. pop() tries to keep the queue at
            * `targetQueueLength` if releasing a message would result in messages being out of order, so its possible for
            * pop() to return null
            * @returns {OrderbookMessage || null}
            */
        protected pop(): OrderbookMessage;
        protected _write(inputMessage: any, encoding: string, callback: (err: Error) => void): void;
}

/***************************************************************************************************************************
    * @license                                                                                                                *
    * Copyright 2017 Coinbase, Inc.                                                                                           *
    *                                                                                                                         *
    * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance          *
    * with the License. You may obtain a copy of the License at                                                               *
    *                                                                                                                         *
    * http://www.apache.org/licenses/LICENSE-2.0                                                                              *
    *                                                                                                                         *
    * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on     *
    * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the                      *
    * License for the specific language governing permissions and limitations under the License.                              *
    ***************************************************************************************************************************/
/**
    * Interfaces for the GTT Stream message types. These messages are generated and passed on my the GTT streaming
    * infrastructure. The `type` field is conventionally named after the interface, first letter lowercased,  with the word Message
    * stripped out, so e.g. HeartbeatMessage => heartbeat and NewOrderMessage => newOrder
    */
export interface StreamMessage {
        type: string;
        time: Date;
}
export function isStreamMessage(msg: any): boolean;
export interface ErrorMessage {
        message: string;
}
export interface UnknownMessage extends StreamMessage {
        sequence?: number;
        productId?: string;
        message: any;
}
/**
    * Root definition for messages that stem from a websocket feed
    */
export interface OrderbookMessage extends StreamMessage {
        sequence: number;
        sourceSequence?: number;
        productId: string;
        side: string;
}
export function isOrderbookMessage(msg: any): boolean;
/**
    * Message representing the common state for a resting order (for an order request, see PlaceOrderRequest)
    */
export interface BaseOrderMessage extends OrderbookMessage {
        orderId: string;
        price: string;
}
export function isOrderMessage(msg: any): boolean;
/**
    * In order-level books, represents a new order.
    *
    * `orderType` is market, limit, stop
    */
export interface NewOrderMessage extends BaseOrderMessage {
        size: string;
}
/**
    * In order-level books, means an order has been filled, or cancelled. RemainingSize indicated how much of the order
    * was left unfilled if it was cancelled
    */
export interface OrderDoneMessage extends BaseOrderMessage {
        reason: string;
        remainingSize: string;
}
/**
    * In order-level books, means the size of an existing order has changed. Either `newSize` (which replaces the old value)
    * or changedAmount (which adds to the old value) must be specified.
    */
export interface ChangedOrderMessage extends BaseOrderMessage {
        newSize?: string;
        changedAmount?: string;
}
/**
    * Represents a price-level change in an orderbook. The `size` parameter represents the new size of the level and should
    * replace the old one.
    */
export interface LevelMessage extends OrderbookMessage {
        price: string;
        size: string;
        count: number;
}
/**
    * Reflects a trade that has taken place. This message does not impact the orderbook, and as such does not carry a
    * sequence field. A corresponding `level`, `done`, or 'change` message will also be sent.
    */
export interface TradeMessage extends StreamMessage {
        productId: string;
        side: string;
        tradeId: string;
        price: string;
        size: string;
}
export interface SnapshotMessage extends StreamMessage, OrderbookState {
        productId: string;
}
export interface TickerMessage extends StreamMessage, Ticker {
        productId: string;
}
/**
    * A new order request message. Only the most common fields are specified here. Additional options can be specified
    * in the extra field, which can be handled by the target trade engine.
    */
export interface PlaceOrderMessage extends StreamMessage {
        productId: string;
        clientId?: string;
        side: string;
        orderType: string;
        price?: string;
        postOnly?: boolean;
        size?: string;
        funds?: string;
        extra?: any;
}
export interface CancelOrderRequestMessage extends StreamMessage {
        type: string;
        orderId: string;
}
/**
    * Emitted from a feed when one of my orders has been matched. (An authenticated feed is required)
    */
export interface TradeExecutedMessage extends StreamMessage {
        productId: string;
        orderId: string;
        side: string;
        price: string;
        orderType: string;
        tradeSize: string;
        remainingSize: string;
}
export interface TradeFinalizedMessage extends StreamMessage {
        productId: string;
        orderId: string;
        side: string;
        remainingSize: string;
        reason: string;
}
export interface MyOrderPlacedMessage extends StreamMessage {
        productId: string;
        orderId: string;
        side: string;
        price: string;
        orderType: string;
        size: string;
        sequence: number;
}

/***************************************************************************************************************************
    * @license                                                                                                                *
    * Copyright 2017 Coinbase, Inc.                                                                                           *
    *                                                                                                                         *
    * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance          *
    * with the License. You may obtain a copy of the License at                                                               *
    *                                                                                                                         *
    * http://www.apache.org/licenses/LICENSE-2.0                                                                              *
    *                                                                                                                         *
    * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on     *
    * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the                      *
    * License for the specific language governing permissions and limitations under the License.                              *
    ***************************************************************************************************************************/
export interface ProductFilterConfig extends MessageTransformConfig {
        productId: string;
}
/**
    * Filters out any messages that don't have the configured product_id
    */
export class ProductFilter extends AbstractMessageTransform {
        productId: string;
        constructor(config: ProductFilterConfig);
        transformMessage(msg: any): any;
}

/***************************************************************************************************************************
    * @license                                                                                                                *
    * Copyright 2017 Coinbase, Inc.                                                                                           *
    *                                                                                                                         *
    * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance          *
    * with the License. You may obtain a copy of the License at                                                               *
    *                                                                                                                         *
    * http://www.apache.org/licenses/LICENSE-2.0                                                                              *
    *                                                                                                                         *
    * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on     *
    * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the                      *
    * License for the specific language governing permissions and limitations under the License.                              *
    ***************************************************************************************************************************/
/**
    * A simple transform stream that passes messages through at a specified rate. The timestamp is updated to reflect when
    * the message was actually sent
    */
export default class RateLimiter extends Transform {
        /**
            * Limit outgoing message to `limit` per `interval`
            * @param limit The number of messages released per interval
            * @param interval The length of an interval in ms
            */
        constructor(limit: number, interval: number);
        protected _transform(msg: StreamMessage, encoding: string, callback: (err?: Error, data?: any) => void): void;
}

/***************************************************************************************************************************
    * @license                                                                                                                *
    * Copyright 2017 Coinbase, Inc.                                                                                           *
    *                                                                                                                         *
    * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance          *
    * with the License. You may obtain a copy of the License at                                                               *
    *                                                                                                                         *
    * http://www.apache.org/licenses/LICENSE-2.0                                                                              *
    *                                                                                                                         *
    * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on     *
    * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the                      *
    * License for the specific language governing permissions and limitations under the License.                              *
    ***************************************************************************************************************************/
export interface TraderConfig {
        logger: Logger;
        exchangeAPI: AuthenticatedExchangeAPI;
        productId: string;
        fitOrders: boolean;
        sizePrecision?: number;
        pricePrecision?: number;
}
/**
    * The Trader class places orders on your behalf. The commands for placing the trades can either come from an attached
    * stream, or directly via the API.
    *
    * One should have an *authenticated* feed piped into Trader so that it can keep track of the state of its own orderbook.
    * Failing this, it is trading 'blind' and will have to rely on REST requests to update the state of the book.
    *
    * Emitted messages:
    *   Trader.outOfSyncWarning - The internal order pool and what's actually on the exchange may be out of sync
    *   Trader.trade-finalized - An order is complete (done)
    *   Trader.my-orders-cancelled - A call to cancel all orders in this orderbook has completed
    *   Trader.all-orders-cancelled - A call to cancel ALL of the user's orders (including those placed elsewhere) has been completed
    *   Trader.order-placed - Emitted after an order has been successfully placed
    *   Trader.order-cancelled - Emitted after an order has been cancelled
    *   Trader.trade-executed - emitted after a trade has been executed against my limit order
    *   Trader.place-order-failed - A REST order request returned with an error
    *   Trader.cancel-order-failed - A Cancel request returned with an error status
    */
export class Trader extends Writable {
        constructor(config: TraderConfig);
        readonly productId: string;
        fitOrders: boolean;
        placeOrder(req: PlaceOrderMessage): Promise<LiveOrder>;
        cancelOrder(orderId: string): Promise<string>;
        cancelMyOrders(): Promise<string[]>;
        /**
            * Cancel all, and we mean ALL orders (even those not placed by this Trader). To cancel only the messages
            * listed in the in-memory orderbook, use `cancelMyOrders`
            */
        cancelAllOrders(): Promise<string[]>;
        state(): OrderbookState;
        /**
            * Compare the state of the in-memory orderbook with the one returned from a REST query of all my orders. The
            * result is an `OrderbookState` object that represents the diff between the two states. Negative sizes represent
            * orders in-memory that don't exist on the book and positive ones are vice versa
            */
        checkState(): Promise<OrderbookState>;
        executeMessage(msg: StreamMessage): void;
        protected _write(msg: any, encoding: string, callback: (err?: Error) => any): void;
}

/***************************************************************************************************************************
    * @license                                                                                                                *
    * Copyright 2017 Coinbase, Inc.                                                                                           *
    *                                                                                                                         *
    * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance          *
    * with the License. You may obtain a copy of the License at                                                               *
    *                                                                                                                         *
    * http://www.apache.org/licenses/LICENSE-2.0                                                                              *
    *                                                                                                                         *
    * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on     *
    * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the                      *
    * License for the specific language governing permissions and limitations under the License.                              *
    ***************************************************************************************************************************/
export type Action<T extends StreamMessage> = (event: T) => void;
export type TriggerFilter = (message: StreamMessage) => void;
/**
    * A trigger is a small utility class that associates an action with an event. You should seldom use this class
    * directly, but will rather use a factory function, such as [[createPriceTrigger]] to generate an appropriate trigger
    * for you.
    */
export class Trigger<T extends StreamMessage> {
        constructor(feed: ExchangeFeed);
        setAction(action: Action<T>): Trigger<T>;
        setFilter(filter: TriggerFilter): Trigger<T>;
        execute(event: T): Trigger<T>;
        cancel(): void;
}
/**
    * Creates a new price trigger. The feed and product specify which Ticker messages to watch for. priceThreshold is
    * the price which triggers the action when it is crossed. The first price tick after this trigger is created determines
    * whether it is a low- or high- price trigger.
    */
export function createPriceTrigger(feed: ExchangeFeed, product: string, priceThreshold: Biglike): Trigger<TickerMessage>;
export function createTickerTrigger(feed: ExchangeFeed, product: string, onlyOnce?: boolean): Trigger<TickerMessage>;

/***************************************************************************************************************************
  * @license                                                                                                                *
  * Copyright 2017 Coinbase, Inc.                                                                                           *
  *                                                                                                                         *
  * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance          *
  * with the License. You may obtain a copy of the License at                                                               *
  *                                                                                                                         *
  * http://www.apache.org/licenses/LICENSE-2.0                                                                              *
  *                                                                                                                         *
  * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on     *
  * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the                      *
  * License for the specific language governing permissions and limitations under the License.                              *
  ***************************************************************************************************************************/
export class ProductSplitter extends StreamCopier {
    constructor(feed: ExchangeFeed, productIds: string[]);
}

/***************************************************************************************************************************
  * @license                                                                                                                *
  * Copyright 2017 Coinbase, Inc.                                                                                           *
  *                                                                                                                         *
  * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance          *
  * with the License. You may obtain a copy of the License at                                                               *
  *                                                                                                                         *
  * http://www.apache.org/licenses/LICENSE-2.0                                                                              *
  *                                                                                                                         *
  * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on     *
  * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the                      *
  * License for the specific language governing permissions and limitations under the License.                              *
  ***************************************************************************************************************************/
export class RedisBookConfig extends LiveBookConfig {
    exchange: string;
}
export class RedisBook extends LiveOrderbook implements Orderbook {
    protected _book: RedisBookBuilder;
    constructor(config: RedisBookConfig);
    processTradeMessage(msg: TradeMessage): void;
}

export function getClient(): any;
export function getRedisct(): any;
export function getPubSubClient(): any;
export function getEmitter(): any;

/***************************************************************************************************************************
    * @license                                                                                                                *
    * Copyright 2017 Coinbase, Inc.                                                                                           *
    *                                                                                                                         *
    * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance          *
    * with the License. You may obtain a copy of the License at                                                               *
    *                                                                                                                         *
    * http://www.apache.org/licenses/LICENSE-2.0                                                                              *
    *                                                                                                                         *
    * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on     *
    * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the                      *
    * License for the specific language governing permissions and limitations under the License.                              *
    ***************************************************************************************************************************/
export class ExchangeFeedConfig {
        wsUrl: string;
        logger: Logger;
        auth: ExchangeAuthConfig;
}
export const hooks: {
        WebSocket: typeof WebSocket;
};
export abstract class ExchangeFeed extends Readable {
        protected auth: ExchangeAuthConfig;
        protected url: string;
        protected isConnecting: boolean;
        protected lastHeartBeat: number;
        protected multiSocket: boolean;
        protected sockets: WebSocket[];
        constructor(config: ExchangeFeedConfig);
        readonly logger: Logger;
        log(level: string, message: string, meta?: any): void;
        isConnected(): boolean;
        reconnect(delay: number): void;
        disconnect(): void;
        protected connect(products?: string[]): void;
        protected getWebsocketUrlForProduct(product: string): string;
        protected killProcess(msg: any): void;
        protected readonly abstract owner: string;
        protected abstract handleMessage(msg: string, product?: string): void;
        protected abstract onOpen(): void;
        protected onClose(code: number, reason: string): void;
        protected onError(err: Error): void;
        /**
            * Called by sub-classes to confirm that the connection is still alive
            */
        protected confirmAlive(): void;
        protected close(): void;
        protected onNewConnection(): void;
        /**
            * Check that we have received a heartbeat message within the last period ms
            */
        protected checkConnection(period: number): void;
        /**
            * Checks that the auth object provided is fully populated and is valid. Subclasses can override this to provide
            * additional validation steps.
            *
            * This function should return the auth object or `undefined` if it isn't valid.
            */
        protected validateAuth(auth: ExchangeAuthConfig): ExchangeAuthConfig;
        protected send(msg: any, cb?: (err: Error) => void): void;
        protected _read(size: number): void;
}
export interface ExchangeFeedConstructor<T extends ExchangeFeed, U extends ExchangeFeedConfig> {
        new (config: U): T;
}
/**
    * Get or create a Websocket feed to a GDAX product. A single connection is maintained per URL + auth combination.
    * Usually you'll connect to the  main GDAX feed by passing in `GDAX_WS_FEED` as the first parameter, but you can create
    * additional feeds to the public sandbox, for example by providing the relevant URL; or creating an authenticated and
    * public feed (although the authenticated feed also carries public messages)
    */
export function getFeed<T extends ExchangeFeed, U extends ExchangeFeedConfig>(type: ExchangeFeedConstructor<T, U>, config: U): T;
/**
    * Create a unique key hash based on URL and credentials
    */
export function getKey(wsUrl: string, config: any): string;

export interface BitfinexFeedConfig extends ExchangeFeedConfig {
        standardMessages: boolean;
        snapshotDepth?: number;
}
/**
    * A client class exposing the Bitfinex public websocket feed
    *
    * The possible channels to subscribe to are: ticker, book, trades
    *
    * The raw feed is re-interpreted and emitted as POJOs rather than Bitfinex's array structures.
    * If StandardMessages is true, the following standard messages are emitted
    *   ticker, snapshot, open, done, match
    *
    * The following events are emitted if standardMessages is false:
    *   bitfinex-ticker: BitfinexTickerMessage
    *   bitfinex-orderbook-snapshot: BitfinexOrderbookSnapshot
    *   bitfinex-orderbook-update: BitfinexOrderMessage
    *   bitfinex-trade-snapshot: BitfinexTradeSnapshot
    *   bitfinex-trade-update: BitfinexTradeMessage
    *
    * The following operational messages are also emitted
    *   close, error, open, connection
    *
    */
export class BitfinexFeed extends ExchangeFeed {
        constructor(config: BitfinexFeedConfig);
        readonly owner: string;
        clearChannels(): void;
        /**
            * Resubscribe to channels using fire-and-forget.
            */
        resubscribeAll(): void;
        subscribe(channelType: string, product: string): void;
        unsubscribe(chanId: string): void;
        onOpen(): void;
        protected onClose(code: number, reason: string): void;
        protected handleMessage(data: any): void;
}

export const GEMINI_API_URL = "https://api.gemini.com/v1";
export const GEMINI_WS_FEED = "wss://api.gemini.com/v1/marketdata/";
export class GeminiMarketFeed extends ExchangeFeed {
    readonly owner: string;
    readonly feedUrl: string;
    static product(genericProduct: string): string;
    static genericProduct(exchangeProduct: string): string;
    static getMarket(genericProduct: string): any;
    static getMarketForExchangeProduct(exchangeProduct: string): any;
    constructor(config: GI.GeminiMarketFeedConfig);
    protected getWebsocketUrlForProduct(product: string): string;
    protected handleMessage(msg: string, productId?: string): void;
    protected onOpen(): void;
}

export const BINANCE_WS_FEED: string;
export class BinanceFeed extends ExchangeFeed {
    readonly owner: string;
    readonly feedUrl: string;
    protected lastHeartBeat: number;
    protected initialMessagesQueue: {
        [product: string]: BinanceMessage[];
    };
    protected depthsockets: {
        [product: string]: WebSocket;
    };
    protected tradesockets: {
        [product: string]: WebSocket;
    };
    constructor(config: GI.BinanceFeedConfig);
    protected getWebsocketUrlForProduct(product: string): string;
    protected connect(products?: string[]): Promise<void>;
    subscribeProduct(product: string): Promise<void>;
    protected handleMessage(): void;
    protected handleSnapshotMessage(msg: BinanceSnapshotMessage, productId?: string): void;
    protected handleTradeMessages(msg: string, productId?: string): void;
    protected handleDepthMessages(msg: string, productId?: string): void;
    nextSequence(prodcutId: string): number;
    processLevelMessage(depthMessage: BinanceDepthMessage): void;
    protected onOpen(): void;
}

/***************************************************************************************************************************
    * @license                                                                                                                *
    * Copyright 2017 Coinbase, Inc.                                                                                           *
    *                                                                                                                         *
    * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance          *
    * with the License. You may obtain a copy of the License at                                                               *
    *                                                                                                                         *
    * http://www.apache.org/licenses/LICENSE-2.0                                                                              *
    *                                                                                                                         *
    * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on     *
    * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the                      *
    * License for the specific language governing permissions and limitations under the License.                              *
    ***************************************************************************************************************************/
export const GDAX_WS_FEED = "wss://ws-feed.gdax.com";
/**
    * Configuration interface for a GDAX websocket feed stream. `wsUrl` is used to override the default websocket URL.
    * Usually, you don't need this, but you may want to obtain a feed from the sandbox for testing, or an historical
    * message source, for example.
    *
    * The channels array determines which types of messages are sent back down the feed. Leave this as null to receive
    * all messages, or specify any of
    *   - `level2` - The orderbook messages
    *   - `matches` - aLl trades
    *   - `ticker` - Ticker updates (these come after every trade, so specifying both `matches` and `ticker` may be redundant)
    *   - `user` - If you provided auth credentials, private messages will also be sent
    */
export interface GDAXFeedConfig extends ExchangeFeedConfig {
        auth: GDAXAuthConfig;
        wsUrl: string;
        channels: string[];
        apiUrl: string;
}
/**
    * The GDAX message feed. Messages are created via a combination of WS and REST calls, which are then sent down the pipe.
    * It handles automatically reconnects on errors and tracks the connection by monitoring a heartbeat.
    * You can create the feeds from here, but it's preferable to use the `getFeed` or `FeedFactory` functions to get a
    * connection from the pool
    */
export class GDAXFeed extends ExchangeFeed {
        constructor(config: GDAXFeedConfig);
        readonly owner: string;
        /**
            * Returns the Authenticated API instance if auth credentials were supplied in the constructor; null otherwise
            */
        readonly authenticatedAPI: AuthenticatedExchangeAPI;
        /**
            * Subscribe to the products given in the `products` array.
            *
            * `subscribe` returns a Promise that resolves to true if the subscription was successful.
            */
        subscribe(products: string[]): Promise<boolean>;
        protected onClose(code: number, reason: string): void;
        protected validateAuth(auth: ExchangeAuthConfig): ExchangeAuthConfig;
        /**
            * Converts a GDAX feed message into a GTT [[StreamMessage]] instance
            */
        protected handleMessage(msg: string): void;
        protected onOpen(): void;
}

/***************************************************************************************************************************
  * @license                                                                                                                *
  * Copyright 2017 Coinbase, Inc.                                                                                           *
  *                                                                                                                         *
  * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance          *
  * with the License. You may obtain a copy of the License at                                                               *
  *                                                                                                                         *
  * http://www.apache.org/licenses/LICENSE-2.0                                                                              *
  *                                                                                                                         *
  * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on     *
  * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the                      *
  * License for the specific language governing permissions and limitations under the License.                              *
  ***************************************************************************************************************************/
export interface PoloniexFeedConfig extends ExchangeFeedConfig {
    tickerChannel: boolean;
}
export class PoloniexFeed extends ExchangeFeed {
    constructor(config: PoloniexFeedConfig);
    subscribe(channel: number): void;
    unsubscribe(channel: number): void;
    resubscribe(channel: number): void;
    getSubscriptions(): ChannelSubscription[];
    protected readonly owner: string;
    protected handleMessage(message: string): void;
    protected clear_pinger(): void;
    protected onOpen(): void;
    protected onClose(code: number, reason: string): void;
}

/***************************************************************************************************************************
  * @license                                                                                                                *
  * Copyright 2017 Coinbase, Inc.                                                                                           *
  *                                                                                                                         *
  * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance          *
  * with the License. You may obtain a copy of the License at                                                               *
  *                                                                                                                         *
  * http://www.apache.org/licenses/LICENSE-2.0                                                                              *
  *                                                                                                                         *
  * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on     *
  * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the                      *
  * License for the specific language governing permissions and limitations under the License.                              *
  ***************************************************************************************************************************/
export class BittrexFeed extends ExchangeFeed {
    constructor(config: ExchangeFeedConfig);
    readonly owner: string;
    subscribe(products: string[]): Promise<boolean>;
    protected connect(): Promise<void>;
    protected handleMessage(msg: any): void;
    protected onOpen(): void;
    protected onClose(code: number, reason: string): void;
    protected close(): void;
}

export class CCXTProductMap {
    getExchange(): any;
    getMarket(genericProduct: string): any;
    getExchangeProduct(genericProduct: string): string;
    getAvailableProducts(): string[];
    getGenericProduct(exchangeProduct: string): string;
    configureProductMap(exchangeToConfigure: string): Promise<void>;
}
export class ProductMap {
    static ExchangeMap: Map<string, CCXTProductMap>;
    static configureExchange(exchange: string): Promise<void>;
}

export interface Logger {
    log(level: string, message: string, meta?: any): void;
    error(err: Error): void;
}
export function ConsoleLoggerFactory(options?: any): Logger;
export const NullLogger: {
    log(level: string, message: string, meta?: any): void;
    error(err: Error): void;
};

/**
    * Create and return a new FXProvider.
    * @param provider {string} Allowed values are 'yahoo' and 'openexhangerates'. OpenExchangeRates requires the API key to
    * be specifies in the OPENEXCHANGERATE_KEY environment variable.
    * @param logger {Logger} An existing logger object.
    * @constructor
    */
export function FXProviderFactory(provider: string, logger: Logger): YahooFinanceFXProvider | OpenExchangeProvider | CoinMarketCapProvider;
/**
    * Generate an return an FXService provider with sane defaults. If no arguments are specified, Yahoo Finance is used
    * as the sole provider using a SimpleRateCalculator instance.
    *
    * The returned FXService has a default refresh interval of 10 minutes. By default, no currency pairs are set, so a
    * recommended pattern is to set them directly after receiving the FXService, i.e.
    *
    * ```
    *   const service = SimpleFXServiceFactory().addCurrencyePair({ from: 'USD', to: 'EUR'});
    * ```
    *
    * @param provider {string} Either 'yahoo', 'openexchangerates' or 'coinmarketcap'. For OER, the OPENEXCHANGE_KEY envar must be set
    * @param logger {Logger} If not specified a new ConsoleLogger will be created
    * @param refreshInterval {number} the period (in ms) to poll the underlying API for new prices
    */
export function SimpleFXServiceFactory(provider?: string, logger?: Logger, refreshInterval?: number): FXService;

/***************************************************************************************************************************
    * @license                                                                                                                *
    * Copyright 2017 Coinbase, Inc.                                                                                           *
    *                                                                                                                         *
    * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance          *
    * with the License. You may obtain a copy of the License at                                                               *
    *                                                                                                                         *
    * http://www.apache.org/licenses/LICENSE-2.0                                                                              *
    *                                                                                                                         *
    * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on     *
    * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the                      *
    * License for the specific language governing permissions and limitations under the License.                              *
    ***************************************************************************************************************************/
/**
    * A convenience function that returns a GDAXExchangeAPI instance for accessing REST methods conveniently. If API
    * key details are found in the GDAX_KEY etc. envars, they will be used
    */
export function DefaultAPI(logger: Logger): GDAXExchangeAPI;
/**
    * Convenience function to connect to and subscribe to the given channels
    * @param options {object} Any options from GDAXConfig will be accepted
    * @param products {string[]} An array of products to subscribe to
    */
export function getSubscribedFeeds(options: any, products: string[]): Promise<GDAXFeed>;
/**
    * This is a straightforward wrapper around getSubscribedFeeds using the Factory pattern with the most commonly used
    * defaults. For customised feeds, use getSubscribedFeeds instead.
    *
    * It is assumed that your API keys are stored in the GDAX_KEY, GDAX_SECRET and GDAX_PASSPHRASE envars
    */
export function FeedFactory(logger: Logger, productIDs?: string[], auth?: GDAXAuthConfig): Promise<GDAXFeed>;

/***************************************************************************************************************************
    * @license                                                                                                                *
    * Copyright 2017 Coinbase, Inc.                                                                                           *
    *                                                                                                                         *
    * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance          *
    * with the License. You may obtain a copy of the License at                                                               *
    *                                                                                                                         *
    * http://www.apache.org/licenses/LICENSE-2.0                                                                              *
    *                                                                                                                         *
    * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on     *
    * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the                      *
    * License for the specific language governing permissions and limitations under the License.                              *
    ***************************************************************************************************************************/
/**
    * A convenience function that returns a BitfinexExchangeAPI instance for accessing REST methods conveniently. If API
    * key details are found in the BITFINEX_KEY etc. envars, they will be used
    * @returns {PublicExchangeAPI}
    */
export function DefaultAPI(logger: Logger): BitfinexExchangeAPI;
/**
    * Convenience function to connect to and subscribe to the given channels
    * @param wsUrl {string} the WS feed to connect to
    * @param products {string[]} An array of products to subscribe to
    * @param auth
    * @param logger
    */
export function getSubscribedFeeds(wsUrl: string, products: string[], auth?: ExchangeAuthConfig, logger?: Logger, bookDepth?: number): Promise<BitfinexFeed>;
/**
    * This is a straightforward wrapper around getSubscribedFeeds using the Factory pattern with the most commonly used
    * defaults. For customised feeds, use getSubscribedFeeds instead.
    *
    * It is assumed that your API keys are stored in the BITFINEX_KEY and BITFINEX_SECRET envars
    */
export function FeedFactory(logger: Logger, productIDs?: string[]): Promise<BitfinexFeed>;

/***************************************************************************************************************************
    * @license                                                                                                                *
    * Copyright 2017 Coinbase, Inc.                                                                                           *
    *                                                                                                                         *
    * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance          *
    * with the License. You may obtain a copy of the License at                                                               *
    *                                                                                                                         *
    * http://www.apache.org/licenses/LICENSE-2.0                                                                              *
    *                                                                                                                         *
    * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on     *
    * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the                      *
    * License for the specific language governing permissions and limitations under the License.                              *
    ***************************************************************************************************************************/
/**
    * A convenience function that returns a GDAXExchangeAPI instance for accessing REST methods conveniently. If API
    * key details are found in the GDAX_KEY etc. envars, they will be used
    */
export function DefaultAPI(logger: Logger): PoloniexExchangeAPI;
/**
    * Convenience function to connect to and subscribe to the given channels
    * @param options {object} Any options from GDAXConfig will be accepted
    * @param products {string[]} An array of products to subscribe to
    */
export function getSubscribedFeeds(options: any, products: string[]): Promise<PoloniexFeed>;
/**
    * This is a straightforward wrapper around getSubscribedFeeds using the Factory pattern with the most commonly used
    * defaults. For customised feeds, use getSubscribedFeeds instead.
    *
    * It is assumed that your API keys are stored in the GDAX_KEY, GDAX_SECRET and GDAX_PASSPHRASE envars
    */
export function FeedFactory(logger: Logger, products: string[], auth?: ExchangeAuthConfig): Promise<PoloniexFeed>;

/***************************************************************************************************************************
    * @license                                                                                                                *
    * Copyright 2017 Coinbase, Inc.                                                                                           *
    *                                                                                                                         *
    * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance          *
    * with the License. You may obtain a copy of the License at                                                               *
    *                                                                                                                         *
    * http://www.apache.org/licenses/LICENSE-2.0                                                                              *
    *                                                                                                                         *
    * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on     *
    * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the                      *
    * License for the specific language governing permissions and limitations under the License.                              *
    ***************************************************************************************************************************/
/**
    * A convenience function that returns a GDAXExchangeAPI instance for accessing REST methods conveniently. If API
    * key details are found in the GDAX_KEY etc. envars, they will be used
    */
export function DefaultAPI(logger: Logger): BittrexAPI;
/**
    * Convenience function to connect to and subscribe to the given channels. Bittrex uses SignalR, which handles reconnects for us,
    * so this is a much simpler function than some of the other exchanges' methods.
    */
export function getSubscribedFeeds(options: ExchangeFeedConfig, products: string[]): Promise<BittrexFeed>;
/**
    * This is a straightforward wrapper around getSubscribedFeeds using the Factory pattern with the most commonly used
    * defaults. For customised feeds, use getSubscribedFeeds instead. It's really not adding much, but we keep it here
    * to maintain a consistent method naming strategy amongst all the exchanges
    *
    * It is assumed that your API keys are stored in the BITTREX_KEY and BITTREX_SECRET envars
    */
export function FeedFactory(logger: Logger, productIds: string[], auth?: ExchangeAuthConfig): Promise<BittrexFeed>;

/***************************************************************************************************************************
    * @license                                                                                                                *
    * Copyright 2017 Coinbase, Inc.                                                                                           *
    *                                                                                                                         *
    * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance          *
    * with the License. You may obtain a copy of the License at                                                               *
    *                                                                                                                         *
    * http://www.apache.org/licenses/LICENSE-2.0                                                                              *
    *                                                                                                                         *
    * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on     *
    * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the                      *
    * License for the specific language governing permissions and limitations under the License.                              *
    ***************************************************************************************************************************/
/**
    * Convenience function to connect to and subscribe to the given channels. Binance uses SignalR, which handles reconnects for us,
    * so this is a much simpler function than some of the other exchanges' methods.
    */
export function getSubscribedFeeds(options: any, products: string[]): Promise<BinanceFeed>;
/**
    * This is a straightforward wrapper around getSubscribedFeeds using the Factory pattern with the most commonly used
    * defaults. For customised feeds, use getSubscribedFeeds instead. It's really not adding much, but we keep it here
    * to maintain a consistent method naming strategy amongst all the exchanges
    *
    * It is assumed that your API keys are stored in the BINANCE_KEY and BINANCE_SECRET envars
    */
export function FeedFactory(logger: Logger, productIds: string[], auth?: ExchangeAuthConfig): Promise<BinanceFeed>;

export const GEMINI_API_URL = "https://api.gemini.com/v1";
export const GEMINI_WS_FEED = "wss://api.gemini.com/v1/marketdata/";
export function getSubscribedFeeds(options: any, symbol: string[]): Promise<GeminiMarketFeed>;
export function FeedFactory(logger: Logger, productIDs: string[], auth?: ExchangeAuthConfig): Promise<GeminiMarketFeed>;

/***************************************************************************************************************************
    * @license                                                                                                                *
    * Copyright 2017 Coinbase, Inc.                                                                                           *
    *                                                                                                                         *
    * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance          *
    * with the License. You may obtain a copy of the License at                                                               *
    *                                                                                                                         *
    * http://www.apache.org/licenses/LICENSE-2.0                                                                              *
    *                                                                                                                         *
    * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on     *
    * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the                      *
    * License for the specific language governing permissions and limitations under the License.                              *
    ***************************************************************************************************************************/
/**
    * The FX Rate Service provides near-realtime delivery of foreign exchange rates, including crypto-fiat and crypto-crypto.
    * This class is the client-facing part of the service. The real work gets done by two helper classes:
    *
    * [FXProvider] subclasses, that actually go and fetch the data from the online sources. A few of the more common
    * (and free) providers are already supplied in the providers directory.
    * [FXRateCalculator] subclasses, that carry out the FX calculation based on your preferences or specific needs. For
    * example, you may want to get rates from multiple providers and calculate a weighted average; or you may have a preference
    * for a given provider for crypto pairs and another provider for fiat pairs.
    *
    * FXService is not opinionated on how the rates are calculated, it just serves them up when asked for them.
    *
    * Since we are sensitive to the fact that the FX rate data provider might go offline, or suddenly give crazy results,
    * is a rate update fails, the errorState flag is set, which clients can inspect and respond to accordingly.
    */
export interface FXServiceConfig {
        logger?: Logger;
        calculator: FXRateCalculator;
        refreshInterval?: number;
        activePairs?: CurrencyPair[];
}
export interface FXRates {
        [index: string]: FXObject;
}
export class FXService extends EventEmitter {
        constructor(config: FXServiceConfig);
        /**
            * Returns the [[FXRateCalculator]] instance that is currently used by this service.
            */
        readonly calculator: FXRateCalculator;
        /**
            * Replaces the [[FXRateCalculator]] instance and returns `this` so that you can chain setter calls.
            */
        setCalculator(value: FXRateCalculator): this;
        /**
            * Returns the currently attached logger
            */
        readonly logger: Logger;
        /**
            * Sets a logger for the service  and returns `this` so that you can chain setter calls.
            */
        setLogger(value: Logger): this;
        /**
            * Returns the polling interval (in ms) for which [[FXService.calculateRates]] is called.
            */
        readonly refreshInterval: number;
        /**
            * Assigns a new polling interval for calculating exchange rates (in ms). Returns `this` so that you can chain setter calls.
            */
        setRefreshInterval(value: number): this;
        /**
            * Returns the current set of currency pairs that exchange rates are being provided for.
            */
        readonly currencyPairs: CurrencyPair[];
        /**
            * Replace all current pairs with the array of pairs provided. Returns `this` so that you can chain setter calls.
            */
        setActivePairs(pairs: CurrencyPair[]): this;
        /**
            * Adds a single currency pair to the service without removing any that are already being queried. If the pair is already
            * in the list, this function has no effect. Returns `this` so that you can chain setter calls.
            */
        addCurrencyPair(pair: CurrencyPair): this;
        /**
            * Removes a currency pair from the active list.  Returns `this` so that you can chain setter calls.
            */
        removePair(pair: CurrencyPair): boolean;
        /**
            * Returns the index of a given currency pair in the active pair list, or else -1 if it is not in the list
            */
        indexOf(pair: CurrencyPair): number;
        /**
            * If an error occurs while calculating a rate, isInErrorState will return true. Clients can use this to make
            * decisions (e.g. whether to suspend trading)  based on their needs.
            */
        isInErrorState(): boolean;
        /**
            * Sets the internal error state to false. No other action is taken.
            */
        clearErrorState(): void;
        /**
            * Returns the last set of exchange rate data that was returned by the RateCalculator
            */
        readonly rates: FXRates;
}

/***************************************************************************************************************************
  * @license                                                                                                                *
  * Copyright 2017 Coinbase, Inc.                                                                                           *
  *                                                                                                                         *
  * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance          *
  * with the License. You may obtain a copy of the License at                                                               *
  *                                                                                                                         *
  * http://www.apache.org/licenses/LICENSE-2.0                                                                              *
  *                                                                                                                         *
  * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on     *
  * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the                      *
  * License for the specific language governing permissions and limitations under the License.                              *
  ***************************************************************************************************************************/
export abstract class FXRateCalculator {
    abstract calculateRatesFor(pairs: CurrencyPair[]): Promise<FXObject[]>;
}

export interface CurrencyPair {
        from: string;
        to: string;
}
export function pairAsString(pair: CurrencyPair): string;
export interface FXObject extends CurrencyPair {
        time: Date;
        rate: BigJS;
        change?: BigJS;
}
export class EFXRateUnavailable extends Error {
        readonly provider: string;
        constructor(msg: string, provider: string);
}
export interface FXProviderConfig {
        logger?: Logger;
}
export abstract class FXProvider {
        constructor(config: FXProviderConfig);
        readonly abstract name: string;
        fetchCurrentRate(pair: CurrencyPair): Promise<FXObject>;
        /**
            * Returns a promise for the current rate. IsSupported must be true, and is not checked here. The method returns a
            * promise for the current network request, or generates a new one.
            * @param pair
            * @returns {Promise<FXObject>}
            */
        protected getPromiseForRate(pair: CurrencyPair): Promise<FXObject>;
        /**
            * Fetch the latest FX exchange rate from the service provider and return a promise for an FXObject.
            * If the service is down, or the latest value is unavailable, reject the promise with an EFXRateUnavailable error
            * @param pair
            */
        protected abstract downloadCurrentRate(pair: CurrencyPair): Promise<FXObject>;
        protected abstract supportsPair(pair: CurrencyPair): Promise<boolean>;
}

export default class CoinMarketCapProvider extends FXProvider {
    constructor(config: FXProviderConfig);
    readonly name: string;
    protected downloadCurrentRate(pair: CurrencyPair): Promise<FXObject>;
    /**
      * Valid quote currencies are USD, BTC, or one of the valid fiat currencies given in [[SUPPORTED_QUOTE_CURRENCIES]]
      * The list of currently supported base currencies will be constructed when this is first called.
      */
    protected supportsPair(pair: CurrencyPair): Promise<boolean>;
}

export interface OpenExchangeConfig extends FXProviderConfig {
    apiKey: string;
}
export default class OpenExchangeProvider extends FXProvider {
    constructor(config: OpenExchangeConfig);
    readonly name: string;
    protected downloadCurrentRate(pair: CurrencyPair): Promise<FXObject>;
    protected supportsPair(pair: CurrencyPair): Promise<boolean>;
}

export default class YahooFinanceFXProvider extends FXProvider {
    readonly name: string;
    protected downloadCurrentRate(pair: CurrencyPair): Promise<FXObject>;
    protected supportsPair(pair: CurrencyPair): Promise<boolean>;
}

/***************************************************************************************************************************
    * @license                                                                                                                *
    * Copyright 2017 Coinbase, Inc.                                                                                           *
    *                                                                                                                         *
    * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance          *
    * with the License. You may obtain a copy of the License at                                                               *
    *                                                                                                                         *
    * http://www.apache.org/licenses/LICENSE-2.0                                                                              *
    *                                                                                                                         *
    * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on     *
    * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the                      *
    * License for the specific language governing permissions and limitations under the License.                              *
    ***************************************************************************************************************************/
/**
    * A simple FX rate calculator that uses a single FXProvider and return the current exchange rate from it directly.
    * If the pair is unavailable, or some other error occurs, the calculator returns null for that pair
    */
export default class SimpleRateCalculator extends FXRateCalculator {
        logger: Logger;
        provider: FXProvider;
        constructor(provider: FXProvider, logger?: Logger);
        calculateRatesFor(pairs: CurrencyPair[]): Promise<FXObject[]>;
}

/***************************************************************************************************************************
  * @license                                                                                                                *
  * Copyright 2017 Coinbase, Inc.                                                                                           *
  *                                                                                                                         *
  * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance          *
  * with the License. You may obtain a copy of the License at                                                               *
  *                                                                                                                         *
  * http://www.apache.org/licenses/LICENSE-2.0                                                                              *
  *                                                                                                                         *
  * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on     *
  * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the                      *
  * License for the specific language governing permissions and limitations under the License.                              *
  ***************************************************************************************************************************/
export function printOrderbook(book: Orderbook, numOrders?: number, basePrec?: number, quotePrec?: number): string;
export function printSeparator(): string;
export function printTicker(ticker: Ticker, quotePrec?: number): string;
export function padfloat(val: BigJS | number, total: number, decimals: number): string;

/***************************************************************************************************************************
    * @license                                                                                                                *
    * Copyright 2017 Coinbase, Inc.                                                                                           *
    *                                                                                                                         *
    * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance          *
    * with the License. You may obtain a copy of the License at                                                               *
    *                                                                                                                         *
    * http://www.apache.org/licenses/LICENSE-2.0                                                                              *
    *                                                                                                                         *
    * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on     *
    * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the                      *
    * License for the specific language governing permissions and limitations under the License.                              *
    ***************************************************************************************************************************/
export interface MessageTransformConfig {
        logger?: Logger;
}
/**
    * A base class for providing message transform streams and filters. All this class does is implement some common logic,
    * making sure that the streamed messages are GDAXMessages before calling the `transformMessage` method that subclasses
    * will implement.
    */
export abstract class AbstractMessageTransform extends stream.Transform {
        protected logger: Logger;
        constructor(config: MessageTransformConfig);
        log(level: string, message: string, meta?: any): void;
        read(size?: number): StreamMessage;
        _transform(chunk: any, encoding: string, callback: (err: Error, chunk?: any) => void): void;
        abstract transformMessage(msg: StreamMessage): StreamMessage;
}

/***************************************************************************************************************************
    * @license                                                                                                                *
    * Copyright 2017 Coinbase, Inc.                                                                                           *
    *                                                                                                                         *
    * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance          *
    * with the License. You may obtain a copy of the License at                                                               *
    *                                                                                                                         *
    * http://www.apache.org/licenses/LICENSE-2.0                                                                              *
    *                                                                                                                         *
    * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on     *
    * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the                      *
    * License for the specific language governing permissions and limitations under the License.                              *
    ***************************************************************************************************************************/
export function AggregatedLevelFactory(totalSize: Biglike, price: Biglike, side: string): AggregatedLevelWithOrders;
export function AggregatedLevelFromPriceLevel(priceLevel: PriceLevelWithOrders): AggregatedLevelWithOrders;
/**
    * For cumulative order calculations, indicates at which price to start counting at and from which order size to start
    * within that level
    */
export interface StartPoint {
        price: BigJS;
        size: BigJS;
}
export interface OrderPool {
        [id: string]: Level3Order;
}
export class AggregatedLevel implements PriceLevel {
        totalSize: BigJS;
        totalValue: BigJS;
        price: BigJS;
        constructor(price: BigJS);
        readonly numOrders: number;
        isEmpty(): boolean;
        equivalent(level: AggregatedLevel): boolean;
        protected add(amount: BigJS): void;
        protected subtract(amount: BigJS): void;
}
export class AggregatedLevelWithOrders extends AggregatedLevel implements PriceLevelWithOrders {
        constructor(price: BigJS);
        readonly orders: Level3Order[];
        readonly numOrders: number;
        findOrder(id: string): Level3Order;
        addOrder(order: Level3Order): boolean;
        removeOrder(id: string): boolean;
}
/**
    * BookBuilder is a convenience class for maintaining an in-memory Level 3 order book. Each
    * side of the book is represented internally by a binary tree and a global order hash map
    *
    * The individual orders can be tracked globally via the orderPool set, or per level. The orderpool and the aggregated
    * levels point to the same order objects, and not copies.
    *
    * Call #state to get a hierarchical object representation of the orderbook
    */
export class BookBuilder extends EventEmitter implements Orderbook {
        sequence: number;
        protected bids: RBTree<AggregatedLevelWithOrders>;
        protected asks: RBTree<AggregatedLevelWithOrders>;
        protected _bidsTotal: BigJS;
        protected _bidsValueTotal: BigJS;
        protected _asksTotal: BigJS;
        protected _asksValueTotal: BigJS;
        protected _orderPool: OrderPool;
        constructor(logger: Logger);
        clear(): void;
        readonly bidsTotal: BigJS;
        readonly bidsValueTotal: BigJS;
        readonly asksTotal: BigJS;
        readonly asksValueTotal: BigJS;
        readonly numAsks: number;
        readonly numBids: number;
        orderPool: OrderPool;
        readonly highestBid: AggregatedLevelWithOrders;
        readonly lowestAsk: AggregatedLevelWithOrders;
        getOrder(id: string): Level3Order;
        hasOrder(orderId: string): boolean;
        getLevel(side: string, price: BigJS): AggregatedLevelWithOrders;
        /**
            * Add an order's information to the book
            * @param order
            */
        add(order: Level3Order): boolean;
        /**
            * Changes the size of an existing order to newSize. If the order doesn't exist, returns false.
            * If the newSize is zero, the order is removed.
            * If newSize is negative, an error is thrown.
            * It is possible for an order to switch sides, in which case the newSide parameter determines the new side.
            */
        modify(id: string, newSize: BigJS, newSide?: string): boolean;
        addLevel(side: string, level: AggregatedLevelWithOrders): void;
        /**
            * Remove a complete level and links to orders in the order pool. If the price level doesn't exist, it returns
            * false
            */
        removeLevel(side: string, priceLevel: PriceComparable): boolean;
        /**
            * Shortcut method for replacing a level. First removeLevel is called, and then addLevel
            */
        setLevel(side: string, level: AggregatedLevelWithOrders): boolean;
        /**
            * Remove the order from the orderbook If numOrders drops to zero, remove the level
            */
        remove(orderId: string): Level3Order;
        getTree(side: string): RBTree<AggregatedLevelWithOrders>;
        /**
            * Returns a book object that has all the bids and asks at this current moment. For performance reasons, this method
            * returns a shallow copy of the underlying orders, so modifying the state object may break the orderbook generally.
            * For deep copies, call #stateCopy instead
            */
        state(): OrderbookState;
        /**
            * Returns a deep copy of the orderbook state.
            */
        stateCopy(): OrderbookState;
        fromState(state: OrderbookState): void;
        /**
            * Return an array of (aggregated) orders whose sum is equal to or greater than `value`.
            * The side parameter is from the perspective of the purchaser, so 'buy' returns asks and 'sell' bids.
            * If useQuote is true, value is assumed to represent price * size, otherwise just size is used
            * startPrice sets the first price to start counting from (inclusive). The default is undefined, which starts at the best bid/by
            */
        ordersForValue(side: string, value: BigJS, useQuote: boolean, start?: StartPoint): CumulativePriceLevel[];
        protected removeFromPool(orderId: string): boolean;
        protected subtractFromTotal(amount: BigJS, side: string, price: BigJS): void;
        protected addToTotal(amount: BigJS, side: string, price: BigJS): void;
}

/***************************************************************************************************************************
    * @license                                                                                                                *
    * Copyright 2017 Coinbase, Inc.                                                                                           *
    *                                                                                                                         *
    * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance          *
    * with the License. You may obtain a copy of the License at                                                               *
    *                                                                                                                         *
    * http://www.apache.org/licenses/LICENSE-2.0                                                                              *
    *                                                                                                                         *
    * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on     *
    * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the                      *
    * License for the specific language governing permissions and limitations under the License.                              *
    ***************************************************************************************************************************/
export interface Orderbook {
        readonly numAsks: number;
        readonly numBids: number;
        readonly bidsTotal: BigJS;
        readonly asksTotal: BigJS;
        sequence: number;
        state(): OrderbookState;
}
export interface PriceComparable {
        price: BigJS;
}
export interface PriceLevel extends PriceComparable {
        totalSize: BigJS;
}
export interface PriceLevelWithOrders extends PriceLevel {
        orders: Level3Order[];
}
export function PriceLevelFactory(price: number, size: number, side: string): PriceLevelWithOrders;
export function PriceTreeFactory<T extends PriceComparable>(): RBTree<T>;
/**
    * BasicOrder only contains aggregated information about an order: price, side and size
    */
export interface BasicOrder {
        price: BigJS;
        size: BigJS;
        side: string;
}
export interface Level3Order extends BasicOrder {
        id: string;
}
export interface LiveOrder extends Level3Order {
        time: Date;
        productId: string;
        status: string;
        extra: any;
}
/**
    * Useful only as part of an array, the cumulative sum of the size and value of this level are included
    */
export interface CumulativePriceLevel extends PriceLevelWithOrders {
        value: BigJS;
        cumSize: BigJS;
        cumValue: BigJS;
}
export interface OrderbookState {
        sequence: number;
        sourceSequence?: number;
        asks: PriceLevelWithOrders[];
        bids: PriceLevelWithOrders[];
        orderPool: OrderPool;
}

/***************************************************************************************************************************
    * @license                                                                                                                *
    * Copyright 2017 Coinbase, Inc.                                                                                           *
    *                                                                                                                         *
    * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance          *
    * with the License. You may obtain a copy of the License at                                                               *
    *                                                                                                                         *
    * http://www.apache.org/licenses/LICENSE-2.0                                                                              *
    *                                                                                                                         *
    * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on     *
    * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the                      *
    * License for the specific language governing permissions and limitations under the License.                              *
    ***************************************************************************************************************************/
/**
    * Represents a sequence of trading commands that would bring the state of one book to another. Do not create instances
    * of this class directly. Use createOrderbookDiff instead.
    */
export class OrderbookDiff {
        /**
            * Compare order books by level only. Only the price and total size are relevant for determining the diff. However,
            * the individual orders are kept according to these rules:
            *  - If the level exists on initial only, then the orders from initial are copied over (sizes are negated).
            *  - If the level exists on final only, then the orders from final are copies over.
            *  - If the level exists on both and the sizes are different, the orders from initial are kept if `keepInitial` is true. Otherwise the final orders
            *    are copied. As usual, if inital orders are copied, the sizes are negated
            *  - If the levels are equivalent, then no orders are copied over at all, even if the sets are different.
            */
        static compareByLevel(initial: BookBuilder, final: BookBuilder, absolute: boolean, keepInitial?: boolean): OrderbookState;
        /**
            * Compares the order pools of the two books and returns an orderbook state comprising the intersection complement
            * of the two sets of orders. However, orders that are in initial, but not in final have negative sizes to indicate
            * that they should be canceled to make the initial book look like final.
            */
        static compareByOrder(initial: BookBuilder, final: BookBuilder): OrderbookState;
        productId: string;
        commands: StreamMessage[];
        initial: BookBuilder;
        final: BookBuilder;
        constructor(productId: string, initial: BookBuilder, final: BookBuilder);
        /**
            * Cancel all orders then place a single order for each level on final book. No diff calculation is required to
            * generate this set. If set, defaultOrderFields will be used to provide default values for any missing fields
            * on the order
            */
        generateSimpleCommandSet(defaultOrderFields?: any): StreamMessage[];
        /**
            * Compares price levels and issues order commands to produce a _single order_ for each desired price level.
            * If set, defaultOrderFields will be used to provide default values for any missing fields
            * on the order.
            */
        generateDiffCommands(diff?: OrderbookState, defaultOrderFields?: any): StreamMessage[];
}

/***************************************************************************************************************************
    * @license                                                                                                                *
    * Copyright 2017 Coinbase, Inc.                                                                                           *
    *                                                                                                                         *
    * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance          *
    * with the License. You may obtain a copy of the License at                                                               *
    *                                                                                                                         *
    * http://www.apache.org/licenses/LICENSE-2.0                                                                              *
    *                                                                                                                         *
    * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on     *
    * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the                      *
    * License for the specific language governing permissions and limitations under the License.                              *
    ***************************************************************************************************************************/
export interface MarketOrderStats {
        first_price: BigJS;
        last_price: BigJS;
        ave_price: BigJS;
        total_size: BigJS;
        total_cost: BigJS;
        slippage: BigJS;
        fees: BigJS;
        unfilled: BigJS;
        first_price_index?: number;
        last_price_index?: number;
}
/**
    * Calculate stats for trades given an order book. The orderbook is immutable.
    */
export default class OrderbookUtils {
        static calcFees(fees: BigJS, totalCost: BigJS): {
                fees_total: BigNumber.BigNumber;
                total_cost: BigNumber.BigNumber;
        };
        constructor(book: OrderbookState);
        readonly isCached: boolean;
        precache(): void;
        bustCache(): void;
        state(): OrderbookState;
        /**
            * Calculate stats for a market order. If a cached version is available, it will use that, which is much more
            * efficient if multiple calculations on the same book are required. Otherwise for small, once-off calculations
            * it's better to use the naive approach
            * @param side {string} Must be 'buy' or 'sell'
            * @param amount {string|number} The size of the trade
            * @param fees {string|number} [] Optional. The fee rate charged (as a fraction, NOT a percentage)
            * @returns {{ave_price: BigJS, total_size: BigJS, total_cost: BigJS, slippage: BigJS, fees: BigJS, unfilled: BigJS}}
            */
        calculateMarketOrderStats(side: string, amount: Biglike, fees?: BigJS): MarketOrderStats;
        /**
            * Return the index of the first order where the cumulative size is greater or equal to size
            * @param size {BigJS}
            * @param isBuy {boolean}
            * @returns {number}
            */
        getIndexOfTotalSize(size: BigJS, isBuy: boolean): number;
        /**
            * Return the index of the first order where the cumulative value is greater or equal to value
            * @param value {BigJS}
            * @param isBuy {boolean}
            * @returns {number}
            */
        getIndexOfTotalValue(value: BigJS, isBuy: boolean): number;
        /**
            * Calculate the marginal cost in buying from start_size to end_size, ie sum(price_i * size_i) i == start_size to end_size
            * @param startSize {BigJS} the lower bound of the order
            * @param endSize {BigJS} the upper bound of the order
            * @param isBuy
            * @param fees {BigJS}
            * @param useValue {boolean} integrate using the value (quote currency) rather than base
            */
        integrateBetween(startSize: BigJS, endSize: Biglike, isBuy: boolean, fees: BigJS, useValue?: boolean): MarketOrderStats;
        /**
            * Return the cumulative order size after filling until `index` orders
            * @param index {number}
            * @param isBuy {boolean}
            */
        getCumulativeSize(index: number, isBuy: boolean): BigNumber.BigNumber;
        /**
            * Return the cumulative order cost after filling until `index` orders
            * @param index {number}
            * @param isBuy {boolean}
            */
        getCumulativeCost(index: number, isBuy: boolean): BigNumber.BigNumber;
        /**
            * Calculate the base size that can be bought with total_cost, including fees
            * @param startValue {BigJS} The total value that has already been traded
            * @param totalFunds {BigJS} The quote amount to spend, including fees
            * @param isBuy {boolean}
            * @param fees {BigJS} fractional fee rate
            */
        getSizeFromCost(startValue: BigJS, totalFunds: BigJS, isBuy: boolean, fees?: BigJS): MarketOrderStats;
}

/***************************************************************************************************************************
    * @license                                                                                                                *
    * Copyright 2017 Coinbase, Inc.                                                                                           *
    *                                                                                                                         *
    * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance          *
    * with the License. You may obtain a copy of the License at                                                               *
    *                                                                                                                         *
    * http://www.apache.org/licenses/LICENSE-2.0                                                                              *
    *                                                                                                                         *
    * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on     *
    * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the                      *
    * License for the specific language governing permissions and limitations under the License.                              *
    ***************************************************************************************************************************/
/**
    * Simple stream that pipes through a supplied set of stream messages when the `send` method is called.
    */
export class StaticCommandSet extends Readable {
        messages: StreamMessage[];
        constructor(messages: StreamMessage[]);
        send(): void;
        sendOne(): void;
        protected _read(size: number): void;
}

/***************************************************************************************************************************
  * @license                                                                                                                *
  * Copyright 2017 Coinbase, Inc.                                                                                           *
  *                                                                                                                         *
  * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance          *
  * with the License. You may obtain a copy of the License at                                                               *
  *                                                                                                                         *
  * http://www.apache.org/licenses/LICENSE-2.0                                                                              *
  *                                                                                                                         *
  * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on     *
  * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the                      *
  * License for the specific language governing permissions and limitations under the License.                              *
  ***************************************************************************************************************************/
export const big: BigNumber.BigNumberStatic;
export const Big: (x: BigNumber.NumberLike) => BigNumber.BigNumber;
export const ZERO: BigNumber.BigNumber;
export const ONE: BigNumber.BigNumber;
export type Biglike = NumberLike;
export type BigJS = BigNumber.BigNumber;

/***************************************************************************************************************************
    * @license                                                                                                                *
    * Copyright 2017 Coinbase, Inc.                                                                                           *
    *                                                                                                                         *
    * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance          *
    * with the License. You may obtain a copy of the License at                                                               *
    *                                                                                                                         *
    * http://www.apache.org/licenses/LICENSE-2.0                                                                              *
    *                                                                                                                         *
    * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on     *
    * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the                      *
    * License for the specific language governing permissions and limitations under the License.                              *
    ***************************************************************************************************************************/
/**
    * A generic API interface that defines the standard REST features that any crypto exchange typically exposes
    *
    * This interface does not define any behaviour related to maintaining a live orderbook, typically synchronized with a
    * websocket feed. Look at #LiveBook for an interface that handles this behaviour.
    *
    * This interface should typically not require authentication credentials; information such as ticker price and the
    * orderbook snapshots are usually available over a public API.
    *
    */
export interface PublicExchangeAPI {
        readonly owner: string;
        /**
            * Load the list of supported products on this exchange
            */
        loadProducts(): Promise<Product[]>;
        /**
            * Load the mid-market price from the exchange's ticker
            */
        loadMidMarketPrice(gdaxProduct: string): Promise<BigJS>;
        /**
            * Load the order book from the REST API and return an aggregated book as a #{../core/BookBuilder} object
            */
        loadOrderbook(gdaxProduct: string): Promise<BookBuilder>;
        /**
            * Load the ticker for the configured product from the REST API
            */
        loadTicker(gdaxProduct: string): Promise<Ticker>;
}
/**
    * The interface for the book ticker. The standard GDAX api is employed. See (https://docs.gdax.com/#get-product-ticker)
    */
export interface Ticker {
        productId: string;
        price: BigJS;
        bid: BigJS;
        ask: BigJS;
        side?: string;
        volume?: BigJS;
        time: Date;
        trade_id?: string;
        size?: BigJS;
}
export interface Product {
        id: string;
        baseCurrency: string;
        quoteCurrency: string;
        baseMinSize: BigJS;
        baseMaxSize: BigJS;
        quoteIncrement: BigJS;
}

/***************************************************************************************************************************
    * @license                                                                                                                *
    * Copyright 2017 Coinbase, Inc.                                                                                           *
    *                                                                                                                         *
    * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance          *
    * with the License. You may obtain a copy of the License at                                                               *
    *                                                                                                                         *
    * http://www.apache.org/licenses/LICENSE-2.0                                                                              *
    *                                                                                                                         *
    * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on     *
    * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the                      *
    * License for the specific language governing permissions and limitations under the License.                              *
    ***************************************************************************************************************************/
/**
    * Exchange functionality that requires user authentication lives here, like querying balances, or making trades
    */
export interface AuthenticatedExchangeAPI {
        readonly owner: string;
        /**
            * Place a new order. Returns a promise for placing a new order on the exchange. It will resolve with the order id if successful,
            * or undefined if not. If any other error occurs, the promise will be rejected.
            */
        placeOrder(order: PlaceOrderMessage): Promise<LiveOrder>;
        /**
            * Cancel the order identified by id. The returned promise resolves with the result of the cancellation. This will be
            * the order id if the order was cancelled, or the promise will be rejected with an error
            *
            * @param id {string} The order ID to cancel
            */
        cancelOrder(id: string): Promise<string>;
        /**
            * Cancel all orders. If product is not null, only cancel orders from that book
            */
        cancelAllOrders(product: string): Promise<string[]>;
        /**
            * Load details for a user-placed order on the exchange
            */
        loadOrder(id: string): Promise<LiveOrder>;
        /**
            * Loads all currently active orders placed by the user (i.e. not the full orderbook). If product is null, load
            * all orders from all books
            */
        loadAllOrders(gdaxProduct: string): Promise<LiveOrder[]>;
        /**
            * Return the balances for all the accounts the user has associated with the current authentication credentials
            */
        loadBalances(): Promise<Balances>;
}
export interface AvailableBalance {
        balance: BigJS;
        available: BigJS;
}
export interface Balances {
        [profileId: string]: {
                [currency: string]: AvailableBalance;
        };
}

/***************************************************************************************************************************
    * @license                                                                                                                *
    * Copyright 2017 Coinbase, Inc.                                                                                           *
    *                                                                                                                         *
    * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance          *
    * with the License. You may obtain a copy of the License at                                                               *
    *                                                                                                                         *
    * http://www.apache.org/licenses/LICENSE-2.0                                                                              *
    *                                                                                                                         *
    * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on     *
    * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the                      *
    * License for the specific language governing permissions and limitations under the License.                              *
    ***************************************************************************************************************************/
/**
    * Clones a (readable) stream to multiple (writable) streams. Manages backpressure for each output stream, though if
    * one stream is much slower than the others you could get large memory consumption. There's no way around this, except
    * stopping the feed to all the other streams too.
    *
    * Accepts an optional filter function that determines whether a message goes to any particular output stream (aka a devil's
    * trapdoor).
    */
export class StreamCopier extends EventEmitter {
        /**
            * Create a new StreamCopier. `numOutputs` reserves that many outward conections for streams and will buffer messages
            * until a downstream consumer is attached.
            *
            * The `options` parameter is passed onto the Writable streams' constructor and defaults to `objectMode: true` if
            * omitted.
            */
        constructor(feed: Readable, numOutputs: number, options?: any);
        /**
            * Return the number of output streams conected to the feed
            */
        readonly numConnections: number;
        /**
            * Attachs new output stream to the feed and assign it the given id
            * Returns true if the attachement was a success, false otherwise
            */
        attach(id: string): boolean;
        pipe(id: string, stream: Writable): boolean;
        /**
            *
            * @param {string} id
            * @returns {"stream".internal.Writable}
            */
        unpipe(id: string): Writable;
        addFilter(id: string, filter: RelayFilter): boolean;
}
export type RelayFilter = (msg: any) => boolean;

/**
    * BookBuilder is a convenience class for maintaining an in-memory Level 3 order book. Each
    * side of the book is represented internally by a binary tree and a global order hash map
    *
    * The individual orders can be tracked globally via the orderPool set, or per level. The orderpool and the aggregated
    * levels point to the same order objects, and not copies.
    *
    * Call #state to get a hierarchical object representation of the orderbook
    */
export class RedisBookBuilder extends BookBuilder implements Orderbook {
        sequence: number;
        protected bids: RBTree<AggregatedLevelWithOrders>;
        protected asks: RBTree<AggregatedLevelWithOrders>;
        protected _bidsTotal: BigJS;
        protected _bidsValueTotal: BigJS;
        protected _asksTotal: BigJS;
        protected _asksValueTotal: BigJS;
        constructor(exchange: string, product: string, logger: Logger);
        clear(): void;
        readonly bidsTotal: BigJS;
        readonly bidsValueTotal: BigJS;
        readonly asksTotal: BigJS;
        readonly asksValueTotal: BigJS;
        readonly numAsks: number;
        readonly numBids: number;
        readonly highestBid: AggregatedLevelWithOrders;
        readonly lowestAsk: AggregatedLevelWithOrders;
        getLevel(side: string, price: BigJS): AggregatedLevelWithOrders;
        /**
            * Add an order's information to the book
            * @param order
            */
        add(order: Level3Order): boolean;
        processTradeMessage(msg: TradeMessage): void;
        /**
            * Changes the size of an existing order to newSize. If the order doesn't exist, returns false.
            * If the newSize is zero, the order is removed.
            * If newSize is negative, an error is thrown.
            * It is possible for an order to switch sides, in which case the newSide parameter determines the new side.
            */
        modify(id: string, newSize: BigJS, newSide?: string): boolean;
        updateRedis(side: string, level: AggregatedLevelWithOrders): void;
        addLevel(side: string, level: AggregatedLevelWithOrders): void;
        /**
            * Remove a complete level and links to orders in the order pool. If the price level doesn't exist, it returns
            * false
            */
        removeLevel(side: string, priceLevel: PriceComparable): boolean;
        /**
            * Shortcut method for replacing a level. First removeLevel is called, and then addLevel
            */
        setLevel(side: string, level: AggregatedLevelWithOrders): boolean;
        /**
            * Remove the order from the orderbook If numOrders drops to zero, remove the level
            */
        remove(orderId: string): Level3Order;
}

/**
    * A common authentication credentials pattern for crypto exchanges
    */
export interface ExchangeAuthConfig {
        key: string;
        secret: string;
}

/***************************************************************************************************************************
  * @license                                                                                                                *
  * Copyright 2017 Coinbase, Inc.                                                                                           *
  *                                                                                                                         *
  * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance          *
  * with the License. You may obtain a copy of the License at                                                               *
  *                                                                                                                         *
  * http://www.apache.org/licenses/LICENSE-2.0                                                                              *
  *                                                                                                                         *
  * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on     *
  * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the                      *
  * License for the specific language governing permissions and limitations under the License.                              *
  ***************************************************************************************************************************/
export interface GeminiConfig {
    apiUrl?: string;
    auth?: ExchangeAuthConfig;
    logger: Logger;
}
export interface GeminiMarketFeedConfig extends ExchangeFeedConfig {
    products: string[];
}
export interface GeminiMessage {
    type: string;
    productId: string;
}
export interface GeminiOrderMessage extends GeminiMessage {
    socket_sequence: number;
    order_id: string;
    event_id: string;
    api_session: string;
    client_order_id: string;
    symbol: string;
    side: 'buy' | 'sell';
    behavior: string;
    order_type: string;
    timestamp: string;
    timestampms: string;
    is_live: boolean;
    is_cancelled: boolean;
    is_hidden: boolean;
    avg_execution_price: string;
    executed_amount: string;
    remaining_amount: string;
    original_amount: string;
    price: string;
    total_spend: string;
}
export interface GeminiAckMessage extends GeminiMessage {
    accountId: number;
    subscriptionId: string;
    symbolFilter: string[];
    apiSessionFilter: string[];
    eventTypeFilter: string[];
}
export interface GeminiHeartbeatMessage extends GeminiMessage {
    timestampms: number;
    sequence: number;
    socket_sequence: number;
    trace_id: string;
}
export interface GeminiUpdateMessage extends GeminiMessage {
    socket_sequence: number;
    eventId: string;
    events: GeminiEvent[];
    timestamp: string;
    timestampms: string;
}
export interface GeminiEvent {
    type: string;
    productId: string;
}
export interface GeminiChangeEvent extends GeminiEvent {
    price: string;
    side: 'bid' | 'ask';
    reason: string;
    remaining: string;
    delta: string;
}
export interface GeminiTradeEvent extends GeminiEvent {
    tid: number;
    price: string;
    amount: string;
    makerSide: 'bid' | 'ask' | 'auction';
}
export interface GeminiAuctionEvent extends GeminiEvent {
    type: string;
}
export interface GeminiAuctionOpenEvent extends GeminiAuctionEvent {
    auction_open_ms: string;
    auction_time_ms: string;
    first_indicative_ms: string;
    last_cancel_time_ms: string;
}
export interface GeminiAuctionIndicativeEvent extends GeminiAuctionEvent {
    result: string;
    event_time_ms: string;
    highest_bid_price: string;
    lowest_ask_price: string;
    eid: number;
    indicative_price: string;
    indicative_quantity: string;
}
export interface GeminiAuctionOutcomeEvent extends GeminiAuctionEvent {
    result: 'success' | 'failure';
    event_time_ms: string;
    highest_bid_price: string;
    eid: number;
    auction_price: string;
    auction_quantity: string;
}

/***************************************************************************************************************************
  * @license                                                                                                                *
  * Copyright 2017 Coinbase, Inc.                                                                                           *
  *                                                                                                                         *
  * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance          *
  * with the License. You may obtain a copy of the License at                                                               *
  *                                                                                                                         *
  * http://www.apache.org/licenses/LICENSE-2.0                                                                              *
  *                                                                                                                         *
  * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on     *
  * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the                      *
  * License for the specific language governing permissions and limitations under the License.                              *
  ***************************************************************************************************************************/
export interface BinanceConfig {
    apiUrl?: string;
    auth?: ExchangeAuthConfig;
    logger: Logger;
}
export interface BinanceFeedConfig extends ExchangeFeedConfig {
    products: string[];
}
export interface BinanceMessage {
    e: string;
    E: number;
    s: string;
}
export interface BinanceTradeMessage extends BinanceMessage {
    t: number;
    p: string;
    q: string;
    b: number;
    a: number;
    T: number;
    m: true;
    M: true;
}
export interface BinanceDepthMessage extends BinanceMessage {
    "U": number;
    "u": number;
    "b": any[];
    "a": any[];
}
export interface BinanceSnapshotMessage extends BinanceMessage {
    lastUpdateId: number;
    s: string;
    bids: any[];
    asks: any[];
}

/***************************************************************************************************************************
  * @license                                                                                                                *
  * Copyright 2017 Coinbase, Inc.                                                                                           *
  *                                                                                                                         *
  * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance          *
  * with the License. You may obtain a copy of the License at                                                               *
  *                                                                                                                         *
  * http://www.apache.org/licenses/LICENSE-2.0                                                                              *
  *                                                                                                                         *
  * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on     *
  * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the                      *
  * License for the specific language governing permissions and limitations under the License.                              *
  ***************************************************************************************************************************/
import Response = request.Response;
export const GDAX_API_URL = "https://api.gdax.com";
export interface GDAXConfig {
    apiUrl?: string;
    auth?: GDAXAuthConfig;
    logger: Logger;
}
export interface GDAXAuthConfig extends ExchangeAuthConfig {
    passphrase: string;
}
export interface AuthHeaders {
    'CB-ACCESS-KEY': string;
    'CB-ACCESS-SIGN': string;
    'CB-ACCESS-TIMESTAMP': string;
    'CB-ACCESS-PASSPHRASE': string;
}
export interface GDAXAccountResponse {
    id: string;
    currency: string;
    balance: string;
    available: string;
    hold: string;
    profile_id: string;
}
export interface AuthCallOptions {
    body?: any;
    qs?: any;
    headers?: any;
}
export interface OrderbookEndpointParams {
    product: string;
    level: number;
}
export interface GDAXAPIProduct {
    id: string;
    base_currency: string;
    quote_currency: string;
    base_min_size: string;
    base_max_size: string;
    quote_increment: string;
    display_name: string;
}
export class GDAXExchangeAPI implements PublicExchangeAPI, AuthenticatedExchangeAPI {
    owner: string;
    quoteCurrency: string;
    baseCurrency: string;
    constructor(options: GDAXConfig);
    readonly apiURL: string;
    static product(genericProduct: string): string;
    static genericProduct(exchangeProduct: string): string;
    static getMarket(genericProduct: string): any;
    static getMarketForExchangeProduct(exchangeProduct: string): any;
    loadProducts(): Promise<Product[]>;
    loadMidMarketPrice(genericProduct: string): Promise<BigJS>;
    loadOrderbook(genericProduct: string): Promise<BookBuilder>;
    loadFullOrderbook(genericProduct: string): Promise<BookBuilder>;
    loadGDAXOrderbook(options: OrderbookEndpointParams): Promise<any>;
    loadTicker(genericProduct: string): Promise<Ticker>;
    aggregateBook(body: any): BookBuilder;
    placeOrder(order: PlaceOrderMessage): Promise<LiveOrder>;
    cancelOrder(id: string): Promise<string>;
    cancelAllOrders(genericProduct: string): Promise<string[]>;
    loadOrder(id: string): Promise<LiveOrder>;
    loadAllOrders(genericProduct: string): Promise<LiveOrder[]>;
    loadBalances(): Promise<Balances>;
    authCall(method: string, path: string, opts: AuthCallOptions): Promise<Response>;
    getSignature(method: string, relativeURI: string, body: string): AuthHeaders;
    handleResponse<T>(req: Promise<Response>, meta: any): Promise<T>;
    checkAuth(): Promise<GDAXAuthConfig>;
}

/***************************************************************************************************************************
  * @license                                                                                                                *
  * Copyright 2017 Coinbase, Inc.                                                                                           *
  *                                                                                                                         *
  * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance          *
  * with the License. You may obtain a copy of the License at                                                               *
  *                                                                                                                         *
  * http://www.apache.org/licenses/LICENSE-2.0                                                                              *
  *                                                                                                                         *
  * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on     *
  * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the                      *
  * License for the specific language governing permissions and limitations under the License.                              *
  ***************************************************************************************************************************/
export interface PoloniexTicker {
    id: number;
    last: string;
    lowestAsk: string;
    highestBid: string;
    percentChange: string;
    baseVolume: string;
    quoteVolume: string;
    isFrozen: string;
    high24hr: string;
    low24hr: string;
}
export interface PoloniexTickers {
    [product: string]: PoloniexTicker;
}
export interface PoloniexBalance {
    available: string;
    onOrders: string;
    btcValue: string;
}
export interface PoloniexBalances {
    [currency: string]: PoloniexBalance;
}
export type PoloniexOrderbookLevel = [number, number];
export interface PoloniexOrderbook {
    asks: PoloniexOrderbookLevel[];
    bids: PoloniexOrderbookLevel[];
    isFrozen: number;
    seq: number;
}
export interface ChannelSubscription {
    id: number;
    connected: boolean;
    sequence: number;
}
export interface PoloniexTrollboxMessage {
    sequence: number;
    user: string;
    text: string;
    reputation: number;
}
export interface PoloniexVolumeMessage {
    timestamp: Date;
    sequence: number;
    volume: number;
}
export interface PoloniexSnapshotLevel {
    [price: number]: string;
}
export interface PoloniexSnapshotMessage {
    currencyPair: string;
    orderBook: [PoloniexSnapshotLevel, PoloniexSnapshotLevel];
}

/***************************************************************************************************************************
    * @license                                                                                                                *
    * Copyright 2017 Coinbase, Inc.                                                                                           *
    *                                                                                                                         *
    * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance          *
    * with the License. You may obtain a copy of the License at                                                               *
    *                                                                                                                         *
    * http://www.apache.org/licenses/LICENSE-2.0                                                                              *
    *                                                                                                                         *
    * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on     *
    * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the                      *
    * License for the specific language governing permissions and limitations under the License.                              *
    ***************************************************************************************************************************/
export interface BitfinexConfig {
        auth?: ExchangeAuthConfig;
        logger?: Logger;
}
export interface BitfinexRESTOrder {
        price: string;
        amount: string;
        timestamp: string;
}
export interface BitfinexOrderbook {
        bids: BitfinexRESTOrder[];
        asks: BitfinexRESTOrder[];
}
export interface BitfinexProduct {
        pair: string;
        price_precision: number;
        initial_margin: string;
        minimum_margin: string;
        maximum_order_size: string;
        minimum_order_size: string;
        expiration: string;
}
/**
    * An adapter class that maps the standardized API calls to Bitfinex's API interface
    */
export class BitfinexExchangeAPI implements PublicExchangeAPI, AuthenticatedExchangeAPI, ExchangeTransferAPI {
        /**
            * Returns the Bitfinex product that's equivalent to the given Generic product. If it doesn't exist,
            * return the given product
            * @param genericProduct
            * @returns {string} Bitfinex product code
            */
        static product(genericProduct: string): string;
        static genericProduct(exchangeProduct: string): string;
        static getMarket(genericProduct: string): any;
        static getMarketForExchangeProduct(exchangeProduct: string): any;
        static convertBSOPToOrder(bfOrder: BitfinexSuccessfulOrderExecution): LiveOrder;
        owner: string;
        constructor(config: BitfinexConfig);
        loadProducts(): Promise<Product[]>;
        loadMidMarketPrice(genericProduct: string): Promise<BigJS>;
        loadOrderbook(genericProduct: string): Promise<BookBuilder>;
        loadTicker(genericProduct: string): Promise<Ticker>;
        checkAuth(): Promise<ExchangeAuthConfig>;
        placeOrder(order: PlaceOrderMessage): Promise<LiveOrder>;
        cancelOrder(id: string): Promise<string>;
        cancelAllOrders(): Promise<string[]>;
        loadOrder(id: string): Promise<LiveOrder>;
        loadAllOrders(): Promise<LiveOrder[]>;
        loadBalances(): Promise<Balances>;
        requestCryptoAddress(cur: string): Promise<CryptoAddress>;
        requestTransfer(req: TransferRequest): Promise<TransferResult>;
        requestWithdrawal(req: WithdrawalRequest): Promise<TransferResult>;
        transfer(cur: string, amount: BigJS, from: string, to: string, options: any): Promise<TransferResult>;
        convertBitfinexBookToGdaxBook(bfBook: BitfinexOrderbook): BookBuilder;
}

/***************************************************************************************************************************
    * @license                                                                                                                *
    * Copyright 2017 Coinbase, Inc.                                                                                           *
    *                                                                                                                         *
    * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance          *
    * with the License. You may obtain a copy of the License at                                                               *
    *                                                                                                                         *
    * http://www.apache.org/licenses/LICENSE-2.0                                                                              *
    *                                                                                                                         *
    * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on     *
    * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the                      *
    * License for the specific language governing permissions and limitations under the License.                              *
    ***************************************************************************************************************************/
export interface PoloniexConfig {
        auth?: ExchangeAuthConfig;
        logger?: Logger;
}
/**
    * An adapter class that maps the standardized API calls to Polinex's API interface
    */
export class PoloniexExchangeAPI implements PublicExchangeAPI, AuthenticatedExchangeAPI, ExchangeTransferAPI {
        owner: string;
        auth: ExchangeAuthConfig;
        logger: Logger;
        constructor(config: PoloniexConfig);
        static product(genericProduct: string): string;
        static genericProduct(exchangeProduct: string): string;
        static getMarket(genericProduct: string): any;
        static getMarketForExchangeProduct(exchangeProduct: string): any;
        loadProducts(): Promise<Product[]>;
        placeOrder(order: PlaceOrderMessage): Promise<LiveOrder>;
        cancelOrder(id: string): Promise<string>;
        cancelAllOrders(): Promise<string[]>;
        loadOrder(id: string): Promise<LiveOrder>;
        loadAllOrders(genericProduct: string): Promise<LiveOrder[]>;
        loadBalances(): Promise<Balances>;
        requestCryptoAddress(cur: string): Promise<CryptoAddress>;
        requestTransfer(request: TransferRequest): Promise<TransferResult>;
        requestWithdrawal(request: WithdrawalRequest): Promise<TransferResult>;
        transfer(cur: string, amount: BigJS, from: string, to: string, options: any): Promise<TransferResult>;
        loadMidMarketPrice(genericProduct: string): Promise<BigJS>;
        loadOrderbook(genericProduct: string): Promise<BookBuilder>;
        loadTicker(genericProduct: string): Promise<Ticker>;
        publicRequest(command: string, params?: object): Promise<superAgent.Response>;
        authRequest(command: string, params?: object): Promise<superAgent.Response>;
}

/***************************************************************************************************************************
  * @license                                                                                                                *
  * Copyright 2017 Coinbase, Inc.                                                                                           *
  *                                                                                                                         *
  * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance          *
  * with the License. You may obtain a copy of the License at                                                               *
  *                                                                                                                         *
  * http://www.apache.org/licenses/LICENSE-2.0                                                                              *
  *                                                                                                                         *
  * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on     *
  * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the                      *
  * License for the specific language governing permissions and limitations under the License.                              *
  ***************************************************************************************************************************/
export class BittrexAPI implements PublicExchangeAPI, AuthenticatedExchangeAPI {
    readonly owner: string;
    readonly logger: Logger;
    static product(genericProduct: string): string;
    static genericProduct(exchangeProduct: string): string;
    static getMarket(genericProduct: string): any;
    static getMarketForExchangeProduct(exchangeProduct: string): any;
    constructor(auth: ExchangeAuthConfig, logger: Logger);
    loadProducts(): Promise<Product[]>;
    loadMidMarketPrice(genericProduct: string): Promise<BigNumber.BigNumber>;
    loadOrderbook(genericProduct: string): Promise<BookBuilder>;
    loadTicker(genericProduct: string): Promise<Ticker>;
    placeOrder(order: PlaceOrderMessage): Promise<LiveOrder>;
    cancelOrder(id: string): Promise<string>;
    cancelAllOrders(product: string): Promise<string[]>;
    loadOrder(id: string): Promise<LiveOrder>;
    loadAllOrders(genericProduct: string): Promise<LiveOrder[]>;
    loadBalances(): Promise<Balances>;
}

/***************************************************************************************************************************
    * @license                                                                                                                *
    * Copyright 2017 Coinbase, Inc.                                                                                           *
    *                                                                                                                         *
    * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance          *
    * with the License. You may obtain a copy of the License at                                                               *
    *                                                                                                                         *
    * http://www.apache.org/licenses/LICENSE-2.0                                                                              *
    *                                                                                                                         *
    * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on     *
    * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the                      *
    * License for the specific language governing permissions and limitations under the License.                              *
    ***************************************************************************************************************************/
import Response = request.Response;
export type BitfinexWallet = 'deposit' | 'exchange' | 'trading';
export type BitfinexSupportedCurrency = 'bitcoin' | 'ethereum' | 'litecoin' | 'mastercoin' | 'ethereumc' | 'zcash' | 'monero';
export type BitfinexOrderType = 'exchange market' | 'exchange limit' | 'exchange stop' | 'exchange trailing-stop' | 'exchange fill-or-kill' | 'market' | 'limit' | 'stop' | 'trailing-stop' | 'fill-or-kill';
export interface BitfinexOrderRequest {
        product_id: string;
        size: string;
        price: string;
        side: string;
        type: BitfinexOrderType;
        post_only?: boolean;
        is_hidden?: boolean;
        ocoorder?: boolean;
        buy_price_oco?: string;
}
export interface BitfinexDepositRequest {
        method: BitfinexSupportedCurrency;
        wallet_name: BitfinexWallet;
        renew: number;
}
export interface BitfinexResult {
        result: string;
}
export interface BitfinexSuccessfulOrderExecution {
        id: number;
        symbol: string;
        exchange: string;
        price: string;
        avg_execution_price: string;
        side: 'buy' | 'sell';
        type: string;
        timestamp: string;
        is_live: boolean;
        is_cancelled: boolean;
        is_hidden: boolean;
        was_forced: boolean;
        original_amount: string;
        remaining_amount: string;
        executed_amount: string;
}
export interface BitfinexBalance {
        type: BitfinexWallet;
        currency: string;
        amount: string;
        available: string;
}
export function loadAccountInfo(auth: ExchangeAuthConfig): Promise<any>;
export function loadBalances(auth: ExchangeAuthConfig): Promise<BitfinexBalance[]>;
/**
    * Place a trade order on Bitfinex
    *
    * @param auth
    * @param order
    */
export function placeOrder(auth: ExchangeAuthConfig, order: BitfinexOrderRequest): Promise<BitfinexSuccessfulOrderExecution>;
export function cancelOrder(auth: ExchangeAuthConfig, orderId: number): Promise<BitfinexSuccessfulOrderExecution>;
export function orderStatus(auth: ExchangeAuthConfig, orderId: number): Promise<BitfinexSuccessfulOrderExecution>;
export function activeOrders(auth: ExchangeAuthConfig): Promise<BitfinexSuccessfulOrderExecution[]>;
export function cancelAllOrders(auth: ExchangeAuthConfig): Promise<BitfinexResult>;
/**
    * Gets a deposit address for the given wallet and currency
    * @param auth
    * @param details
    */
export function getAddress(auth: ExchangeAuthConfig, details: BitfinexDepositRequest): Promise<Response>;
export interface BitfinexWithdrawRequest {
        withdraw_type: BitfinexSupportedCurrency;
        amount: string;
        address: string;
        walletselected: BitfinexWallet;
}
/**
    * Request a cryptocurrency withdrawal to the given address
    * @param auth
    * @param details
    */
export function withdraw(auth: ExchangeAuthConfig, details: BitfinexWithdrawRequest): Promise<Response>;
export interface BitfinexTransferRequest {
        currency: string;
        amount: string;
        walletfrom: BitfinexWallet;
        walletto: BitfinexWallet;
}
export function transfer(auth: ExchangeAuthConfig, details: BitfinexTransferRequest): Promise<request.Response>;
export function isBFWallet(id: string): id is BitfinexWallet;

/***************************************************************************************************************************
    * @license                                                                                                                *
    * Copyright 2017 Coinbase, Inc.                                                                                           *
    *                                                                                                                         *
    * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance          *
    * with the License. You may obtain a copy of the License at                                                               *
    *                                                                                                                         *
    * http://www.apache.org/licenses/LICENSE-2.0                                                                              *
    *                                                                                                                         *
    * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on     *
    * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the                      *
    * License for the specific language governing permissions and limitations under the License.                              *
    ***************************************************************************************************************************/
/**
    * WalletAPI defines a general adapter interface for handling wallet transactions, such as deposits and withdrawals
    * on a crypto exchange
    */
export interface ExchangeTransferAPI {
        /**
            * Request a new crypto `cur` address for deposits
            * @param cur {string} the crypto-currency to request an address for
            */
        requestCryptoAddress(cur: string): Promise<CryptoAddress>;
        /**
            * Request a transfer to another wallet or account on the same exchange. This operation should resolve near-instantaeously.
            * If the exchange does not support this operation, the promise is rejected, but there are ways of implementing
            * pseudo-wallets so that this operation can be emulated on exchanges that don't formally support multiple wallets.
            * @param request
            */
        requestTransfer(request: TransferRequest): Promise<TransferResult>;
        /**
            * Request a crypto-currency transfer of [amount] cur to the given crypto address
            */
        requestWithdrawal(request: WithdrawalRequest): Promise<TransferResult>;
        /**
            * Transfer currency from one wallet *on the same exchange (or the dummy staging wallet)* to another. This should
            * be a near-instantaneous transaction
            * @param cur {string} The currency to transfer
            * @param amount {BigJS} The amount to transfer
            * @param from {string} the source wallet name
            * @param to {string} the destination wallet
            * @param options {*} Any additional options to pass onto the underlying API
            */
        transfer(cur: string, amount: BigJS, from: string, to: string, options: any): Promise<TransferResult>;
}
/**
    * @param currency {string} the Currency to transfer (BTC, ETH etc)
    * @param amount {BigJS} the amount to transfer
    * @param address {string} a valid destination address
    * @param options {object} any additional options the underlying exchange API may accept
    */
export interface WithdrawalRequest {
        currency: string;
        amount: BigJS;
        address: string;
        options?: any;
}
export interface TransferResult {
        success: boolean;
        details?: any;
}
export interface CryptoAddress {
        currency: string;
        address: string;
}
export interface TransferRequest {
        currency: string;
        amount: BigJS;
        walletIdFrom: string;
        walletIdTo: string;
        options?: any;
}

