bitshares.aio.dex module

class bitshares.aio.dex.Dex(*args, **kwargs)[source]

Bases: bitshares.aio.instance.BlockchainInstance

This class simplifies interactions with the decentralized exchange.

Parameters:blockchain_instance (bitshares.aio.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.aio.market.Market.

adjust_collateral_ratio(symbol, new_collateral_ratio, account=None, target_collateral_ratio=None)[source]

Adjust the collataral ratio of a debt position.

Parameters:
  • symbol (str) – Symbol to adjust collateral for
  • new_collateral_ratio (float) – desired collateral ratio
  • target_collateral_ratio (float) – Tag the call order so that in case of margin call, only enough debt is covered to get back to this 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, target_collateral_ratio=None)[source]

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)
  • target_collateral_ratio (float) – Tag the call order so that in case of margin call, only enough debt is covered to get back to this 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
bitshares

Alias for the specific blockchain.

blockchain
borrow(amount, collateral_ratio=None, account=None, target_collateral_ratio=None)[source]

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

Parameters:
  • amount (Amount) – Amount to borrow (denoted in ‘asset’)
  • collateral_ratio (float) – Collateral ratio to borrow at
  • target_collateral_ratio (float) – Tag the call order so that in case of margin call, only enough debt is covered to get back to this 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
chain

Short form for blockchain (for the lazy)

close_debt_position(symbol, account=None)[source]

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
define_classes()

Needs to define instance variables that provide classes

get_instance_class()

Should return the Chain instance class, e.g. bitshares.BitShares

classmethod inject(cls)
list_debt_positions(account=None)[source]

List Call Positions (borrowed assets and amounts)

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

Example:

returnFees()[source]

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}}
classmethod set_shared_blockchain_instance(instance)

This method allows us to override default instance for all users of SharedInstance.instance.

Parameters:instance (chaininstance) – Chain instance
classmethod set_shared_config(config)

This allows to set a config that will be used when calling shared_blockchain_instance and allows to define the configuration without requiring to actually create an instance

set_shared_instance()

This method allows to set the current instance as default

shared_blockchain_instance()

This method will initialize SharedInstance.instance and return it. The purpose of this method is to have offer single default instance that can be reused by multiple classes.