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.

Feeds

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

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.

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 as new trades are received from Bitstamp. To subscribe to this event you need to pass in a callable object that receives one parameter:

  1. A pyalgotrade.bitstamp.wsclient.OrderBookUpdate instance.

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