bitstamp – Bitstamp reference

WebSocket

This package has classes for the events emitted by Bitstamp’s streaming service. Check https://www.bitstamp.net/websocket/ for more information.

class pyalgotrade.bitstamp.wsclient.OrderBookUpdate(dateTime, eventDict)

Bases: pyalgotrade.websocket.pusher.Event

An order book update event.

getAskPrices()

Returns a list with the top 20 ask prices.

getAskVolumes()

Returns a list with the top 20 ask volumes.

getBidPrices()

Returns a list with the top 20 bid prices.

getBidVolumes()

Returns a list with the top 20 bid volumes.

getDateTime()

Returns the datetime.datetime when this event was received.

class pyalgotrade.bitstamp.wsclient.Trade(dateTime, eventDict)

Bases: pyalgotrade.websocket.pusher.Event

A trade event.

getAmount()

Returns the trade amount.

getDateTime()

Returns the datetime.datetime when this event was received.

getId()

Returns the trade id.

getPrice()

Returns the trade price.

isBuy()

Returns True if the trade was a buy.

isSell()

Returns True if the trade was a sell.

class pyalgotrade.bitstamp.wsclient.WebSocketClient(queue)

Bases: pyalgotrade.websocket.pusher.WebSocketClient

This websocket client class is designed to be running in a separate thread and for that reason events are pushed into a queue.

class pyalgotrade.bitstamp.wsclient.WebSocketClientThread

Bases: pyalgotrade.websocket.client.WebSocketClientThreadBase

This thread class is responsible for running a WebSocketClient.

Feeds

class pyalgotrade.bitstamp.barfeed.LiveTradeFeed(maxLen=None)

Bases: pyalgotrade.barfeed.BaseBarFeed

A real-time BarFeed that builds bars from live trades.

Parameters:maxLen (int.) – The maximum number of values that the pyalgotrade.dataseries.bards.BarDataSeries will hold. Once a bounded length is full, when new items are added, a corresponding number of items are discarded from the opposite end. If None then dataseries.DEFAULT_MAX_LEN is used.

Note

Note that a Bar will be created for every trade, so open, high, low and close values will all be the same.

getOrderBookUpdateEvent()

Returns the event that will be emitted when the orderbook gets updated.

Eventh handlers should receive one parameter:
  1. A pyalgotrade.bitstamp.wsclient.OrderBookUpdate instance.
Return type:pyalgotrade.observer.Event.

Brokers

class pyalgotrade.bitstamp.broker.PaperTradingBroker(cash, barFeed, fee=0.0025)

Bases: pyalgotrade.bitstamp.broker.BacktestingBroker

A Bitstamp paper trading broker.

Parameters:
  • cash (int/float.) – The initial amount of cash.
  • barFeed (pyalgotrade.barfeed.BarFeed) – The bar feed that will provide the bars.
  • fee (float.) – The fee percentage for each order. Defaults to 0.5%.

Note

  • Only limit orders are supported.
  • Orders are automatically set as goodTillCanceled=True and allOrNone=False.
  • BUY_TO_COVER orders are mapped to BUY orders.
  • SELL_SHORT orders are mapped to SELL orders.
class pyalgotrade.bitstamp.broker.LiveBroker(clientId, key, secret)

Bases: pyalgotrade.broker.Broker

A Bitstamp live broker.

Parameters:
  • clientId (string.) – Client id.
  • key (string.) – API key.
  • secret (string.) – API secret.

Note

  • Only limit orders are supported.
  • Orders are automatically set as goodTillCanceled=True and allOrNone=False.
  • BUY_TO_COVER orders are mapped to BUY orders.
  • SELL_SHORT orders are mapped to SELL orders.
  • API access permissions should include:
    • Account balance
    • Open orders
    • Buy limit order
    • User transactions
    • Cancel order
    • Sell limit order
refreshAccountBalance()

Refreshes cash and BTC balance.

Table Of Contents

Previous topic

Bitstamp support

Next topic

Bitstamp Example

This Page