Dex

class bitshares.dex.Dex(bitshares_instance=None)

This class simplifies interactions with the decentralized exchange.

Parameters:bitshares_instance (bitshares.bitshares.BitShares) – BitShares instance

Note

The methods of this class only deal with a single asset (at most). If you are looking to deal with orders for trading, please use bitshares.market.Market.

adjust_collateral_ratio(symbol, target_collateral_ratio, account=None)

Adjust the collataral ratio of a debt position

Parameters:
  • amount (Asset) – Amount to borrow (denoted in ‘asset’)
  • target_collateral_ratio (float) – desired collateral ratio
Raises:
  • ValueError – if symbol is not a bitasset
  • ValueError – if collateral ratio is smaller than maintenance collateral ratio
  • ValueError – if required amounts of collateral are not available
adjust_debt(delta, new_collateral_ratio=None, account=None)

Adjust the amount of debt for an asset

Parameters:
  • delta (Amount) – Delta amount of the debt (-10 means reduce debt by 10, +10 means borrow another 10)
  • new_collateral_ratio (float) – collateral ratio to maintain (optional, by default tries to maintain old ratio)
Raises:
  • ValueError – if symbol is not a bitasset
  • ValueError – if collateral ratio is smaller than maintenance collateral ratio
  • ValueError – if required amounts of collateral are not available
borrow(amount, collateral_ratio=None, account=None)

Borrow bitassets/smartcoins from the network by putting up collateral in a CFD at a given collateral ratio.

Parameters:
  • amount (float) – Amount to borrow (denoted in ‘asset’)
  • collateral_ratio (float) – Collateral ratio to borrow at
Raises:
  • ValueError – if symbol is not a bitasset
  • ValueError – if collateral ratio is smaller than maintenance collateral ratio
  • ValueError – if required amounts of collateral are not available
close_debt_position(symbol, account=None)

Close a debt position and reclaim the collateral

Parameters:symbol (str) – Symbol to close debt position for
Raises:ValueError – if symbol has no open call position
list_debt_positions(account=None)

List Call Positions (borrowed assets and amounts)

Returns:Struct of assets with amounts and call price
Return type:json

Example:

returnFees()

Returns a dictionary of all fees that apply through the network

Example output:

{'proposal_create': {'fee': 400000.0},
'asset_publish_feed': {'fee': 1000.0}, 'account_create':
{'basic_fee': 950000.0, 'price_per_kbyte': 20000.0,
'premium_fee': 40000000.0}, 'custom': {'fee': 20000.0},
'asset_fund_fee_pool': {'fee': 20000.0},
'override_transfer': {'fee': 400000.0}, 'fill_order':
{}, 'asset_update': {'price_per_kbyte': 20000.0, 'fee':
200000.0}, 'asset_update_feed_producers': {'fee':
10000000.0}, 'assert': {'fee': 20000.0},
'committee_member_create': {'fee': 100000000.0}}