backtrader.commissions.dc_commission module

Digital Currency Commission Module - Crypto commission scheme.

This module provides the ComminfoDC class for calculating commissions for digital currency (cryptocurrency) trading.

Classes:

ComminfoDC: Commission info for digital currency trading.

Example

>>> comminfo = bt.commissions.ComminfoDC(
...     commission=0.001,
...     margin=0.5
... )
>>> cerebro.broker.setcommission(comminfo)
class backtrader.commissions.dc_commission.ComminfoDC[source]

Bases: CommInfoBase

Implement a digital currency commission class

params = (('stocklike', False), ('commtype', 0), ('percabs', True), ('interest', 3))
get_margin(price)[source]

Calculate margin required for a position at given price.

Parameters:

price – Price per unit of the asset.

Returns:

Margin amount required.

Return type:

float

get_credit_interest(data, pos, dt)[source]

For example, I hold 100U, want to buy 300U of BTC, leverage is 3x, at this time I only need to borrow 2*100U, so interest should be 200U * interest, similarly, for nx long, need to pay (n-1)*base interest

If I want to open short, I only have 100U, I must borrow BTC to sell first, even 1x short, need to borrow 100U worth of BTC, so for nx short, need to pay n*base interest