cointrader package¶
Subpackages¶
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.chart module¶
cointrader.config module¶
cointrader.exchange module¶
-
class
cointrader.exchange.
BacktestMarket
(exchange, name)[source]¶ Bases:
cointrader.exchange.Market
Market to enable backtesting a strategy on the market.
-
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
-
markets
¶
-
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.
-
url
¶
-
-
class
cointrader.exchange.
Poloniex
(config)[source]¶ Bases:
cointrader.exchange.Exchange
-
url
¶
-
cointrader.helpers module¶
cointrader.strategy module¶
-
class
cointrader.strategy.
NullStrategy
[source]¶ Bases:
cointrader.strategy.Strategy