cointrader package

Submodules

cointrader.bot module

class cointrader.bot.Cointrader(market, strategy, resolution='30m', start=None, end=None)[source]

Bases: sqlalchemy.ext.declarative.api.Base

active
created
id
market
start(interval=None, backtest=False)[source]

Start the bot and begin trading with given amount of BTC.

The bot will trigger a analysis of the chart every N seconds. The default number of seconds is set on initialisation using the resolution option. You can overwrite this setting by using the interval option.

By setting the backtest option the trade will be simulated on real chart data. This is useful for testing to see how good your strategy performs.

Btc:Amount of BTC to start trading with
Interval:Number of seconds to wait until the bot again call
for a trading signal. This defaults to the resolution of the bot
which is provided on initialisation.
Backtest:Simulate trading on historic chart data on the given market.
Returns:None
stat(delete_trades=False)[source]

Returns a dictionary with some statistic of the performance of the bot. Performance means how good cointrader performs in comparison to the market movement. Market movement is measured by looking at the start- and end rate of the chart.

The performance of cointrader is measured by looking at the start and end value of the trade. These values are also multiplied with the start and end rate. So if cointrader does some good decisions and increases eater btc or amount of coins of the bot the performance should be better.

strategy
trades
class cointrader.bot.Trade(date, order_type, order_id, trade_id, market, rate, amount, amount_taxed, btc, btc_taxed)[source]

Bases: sqlalchemy.ext.declarative.api.Base

All trades of cointrader are saved in the database. A trade can either be a BUY or SELL.

amount
amount_taxed
bot_id
btc
btc_taxed
date
id
market
order_id
order_type
rate
trade_id
cointrader.bot.get_bot(market, strategy, resolution, start, end, btc, amount)[source]
cointrader.bot.init_db()[source]
cointrader.bot.replay_tradelog(trades)[source]

cointrader.chart module

class cointrader.chart.Chart(data, start, end)[source]

Bases: object

Docstring for Chart.

data
get_first_point()[source]
get_last_point()[source]
macdh()[source]
sma(window=10)[source]
values(which='close')[source]
cointrader.chart.chart2csv(chart)[source]
cointrader.chart.search_chartdata_by_date(data, dt, le=True)[source]

cointrader.cli module

class cointrader.cli.Context[source]

Bases: object

Docstring for Context.

cointrader.config module

class cointrader.config.Config(configfile=None)[source]

Bases: object

api
cointrader.config.get_path_to_config()[source]

cointrader.exchange module

class cointrader.exchange.BacktestMarket(exchange, name)[source]

Bases: cointrader.exchange.Market

Market to enable backtesting a strategy on the market.

buy(btc, price=None)[source]
continue_backtest()[source]
get_chart(resolution='30m', start=None, end=None)[source]
sell(amount, price=None)[source]
class cointrader.exchange.Coin(name, quantity, btc_value=None)[source]

Bases: object

Docstring for Coin.

value
class cointrader.exchange.Exchange(config, api=None)[source]

Bases: object

Baseclass for all exchanges

get_market(market, backtest=False, dry_run=False)[source]
get_top_markets(markets, limit=10)[source]
get_top_profit_markets(markets=None, limit=10)[source]
get_top_volume_markets(markets=None, limit=10)[source]
markets
resolution2seconds(resolution)[source]
resolutions = {'15m': 900, '24h': 86400, '5m': 300, '30m': 1800, '4h': 14400, '1h': 3600, '2h': 7200}
total_btc_value
total_euro_value
url
class cointrader.exchange.Market(exchange, name, dry_run=False)[source]

Bases: object

Docstring for Market.

buy(btc, price=None, option=None)[source]

Will buy coins on the market for the given amount of BTC. On default we will make a market order which means we will try to buy for the best price available. If price is given the order will be placed for at the given price. You can optionally provide some options. See cointrader.exchanges.poloniex.api for more details.

Btc:Amount of BTC
Price:Optionally price for which you want to buy
Option:Optionally some buy options
Returns:Dict witch details on the order.
currency
get_chart(resolution='30m', start=None, end=None)[source]

Will return a chart of the market. On default the chart will have a resolution of 30m. It will include the last recent data of the market on default. You can optionally define a different timeframe by providing a start and end point. On default the start and end of the chart will be the time of requesting the chart data.

The start and end date are used to get the start and end rate of the market for later profit calculations.

Resolution:Resolution of the chart (Default 30m)
Start:Start of the chart data (Default Now)
End:End of the chart data (Default Now)
Returns:Chart instance.
sell(amount, price=None, option=None)[source]
url
class cointrader.exchange.Poloniex(config)[source]

Bases: cointrader.exchange.Exchange

btc2dollar(amount)[source]
dollar2btc(amount)[source]
get_balance(currency=None)[source]
get_market(name, backtest=False, dry_run=False)[source]
url
cointrader.exchange.add_fee(btc, fee=0.025)[source]
cointrader.exchange.get_market_name(market)[source]

cointrader.helpers module

cointrader.helpers.colorize_value(value)[source]
cointrader.helpers.render_bot_statistic(stat)[source]
cointrader.helpers.render_bot_title(bot, market, resolution)[source]
cointrader.helpers.render_bot_tradelog(trades)[source]

cointrader.strategy module

class cointrader.strategy.InteractivStrategyWrapper(strategie)[source]

Bases: object

set_bot(bot)[source]
signal(market, resolution, start, end)[source]

Will return either a BUY, SELL or WAIT signal for the given market

class cointrader.strategy.NullStrategy[source]

Bases: cointrader.strategy.Strategy

details(market, resolution)[source]

Will return details on the reasong why the signal was emited.

signal(market, resolution, start, end)[source]

Will return either a BUY, SELL or WAIT signal for the given market

class cointrader.strategy.Signal(signal, date)[source]

Bases: object

class cointrader.strategy.Strategy[source]

Bases: object

Docstring for Strategy.

details(market, resolution)[source]

Will return details on the reasong why the signal was emited.

set_bot(bot)[source]
signal(market, resolution, start, end)[source]

Will return either a BUY, SELL or WAIT signal for the given market

Module contents