bitraider package

Submodules

exchange module

class bitraider.exchange.CoinbaseExchangeAuth(api_key, secret_key, passphrase)[source]

Bases: requests.auth.AuthBase

class bitraider.exchange.cb_exchange(key=None, secret=None, password=None)[source]

Bases: bitraider.exchange.exchange

CoinbaseExchange API Wrapper

cancel_order(order_id)[source]

Cancel an order

get_24_hour_stats(product_id)[source]

Get 24 hour stats for the product

get_account(account_id)[source]

Get information for a single account

get_account_history(account_id)[source]

List account activity. Items are paginated and sorted latest first.

get_currencies()[source]

Get a list of known currencies

get_historic_rates(start_time, end_time, granularity, product_id='BTC-USD')[source]

Get a historic rates for a product. Rates are returned in grouped buckets based on requested granularity

get_holds(account_id)[source]

Holds are placed on an account for any active orders. As an order is filled, the hold amount is updated. If ad order is canceled, any remaining hold is removed.

get_last_trade(product_id)[source]

Get snapshot information about the last trade (tick)

get_order(order_id)[source]

Get a single order

get_order_book(product_id, level=1)[source]

Get a list of open orders for a product. Amount of detail shown can be customized with the level parameter.

get_products()[source]

Get a list of available currency pairs for trading

get_time()[source]

Get the API server time

get_trades(product_id)[source]

Get a paginated list of latest trades for a product

list_accounts()[source]

Get a list of trading accounts

list_fills()[source]

Get a list of recent fills

list_open_orders()[source]

List currently open orders

place_order(price, size, side, product_id)[source]

Place an order

transfer()[source]

Move funds to/from Coinbase Exchange and Coinbase account

class bitraider.exchange.cb_exchange_sim(start_btc, start_usd)[source]

Bases: bitraider.exchange.exchange

Class used for backtesting

get_historic_rates(start_time, end_time, granularity, product_id='BTC-USD')[source]

Get a historic rates for a product. Rates are returned in grouped buckets based on requested granularity

get_last_trade(product_id)[source]

Get snapshot information about the last trade (tick)

place_order(price, size, side, product_id, historic_timeslice=None)[source]

Place an order

For buy orders, we will hold price x size x (1 + fee-percent) USD. For sell orders, we will hold the number of Bitcoin you wish to sell. Actual fees are assessed at time of trade. If you cancel a partially filled or unfilled order, any remaining funds will be released from hold.

class bitraider.exchange.exchange[source]

Bases: object

place_order()[source]

example_strategy module

class bitraider.example_strategy.awesome_strategy(interval=3600, time_from_start=86400, buy_amt=0.001, pivot=0.5)[source]

Bases: bitraider.strategy.strategy

trade(timeslice)[source]

strategy module

class bitraider.strategy.strategy(name='default name', interval=5)[source]

Bases: object

strategy defines an abstract base strategy class. Minimum required to create a strategy is a file with a class which inherits from strategy containing a backtest_strategy function. As a bonus, strategy includes utility functions like calculate_historic_data.

backtest_strategy(historic_data)[source]

Returns performance of a strategy vs market performance.

static calculate_historic_data(data, pivot)[source]
Returns average price weighted according to volume, and the number of bitcoins traded
above and below a price point, called a pivot.

pivot: the price used for returning volume above and below

data: a list of lists formated as follows [time, low, high, open, close]

[

[“2014-11-07 22:19:28.578544+00”, “0.32”, “4.2”, “0.35”, “4.2”, “12.3”],

...

]

trade(timeslice)[source]

Perform operations on a timeslice.

timeslice: a section of trade data with time length equal to the strategy’s interval, formatted as follows:

[time, low, high, open, close, volume]

trader_template module

bitraider.trader_template.run()[source]
class bitraider.trader_template.runner[source]

Bases: cmd.Cmd

authenticate()[source]
do_backtest(option)[source]
do_config(option)[source]

usage: ‘config ‘ [option]

do_exit(line)[source]
do_list(line)[source]
do_load(option)[source]
do_optimize(line)[source]
do_price(line)[source]
do_run(line)[source]
load_strategy(module, cls)[source]

Load a user-defined strategy from a file.

module: the filename in the current directory containing the strategy class which
inherits from bitraider.strategy (does not include .py)

cls: the classname within the file to load

print_curr_price()[source]

Print the most recent price.

run()[source]
set_ticker_on()[source]
strategies = None

The currently loaded strategies

Module contents