golosscripts.bitshares_helper

Module Contents

log[source]
class BitSharesHelper(node: Union[str, list] = None, loop: asyncio.BaseEventLoop = None)[source]

A helper class to interact with BitShares network.

Note

This class sets shared bitshares instance, see bitshares.aio.instance.set_shared_bitshares_instance().

Parameters
  • node (str,list) – bitshares node(s)

  • loopasyncio event loop instance

static split_pair(market: str)[source]

Split market pair into QUOTE, BASE symbols.

Parameters

market (str) – market pair in format ‘QUOTE/BASE’. Supported separators are: “/”, “:”, “-“.

Returns

list with QUOTE and BASE as separate symbols

Return type

list

async connect(self)[source]

Connect to BitShares network.

async get_market_buy_price_pct_depth(self, market: str, depth_pct: float)[source]

Measure QUOTE volume and BASE/QUOTE price for [depth] percent deep starting from highest bid.

Parameters
  • market (str) – market in format ‘QUOTE/BASE’

  • depth_pct (float) – depth percent (1-100) to measure volume and average price

Returns

tuple with (“price as float”, volume) where volume is actual quote volume

async get_market_sell_price_pct_depth(self, market: str, depth_pct: float)[source]

Measure QUOTE volume and BASE/QUOTE price for [depth] percent deep starting from lowest ask.

Parameters
  • market (str) – market in format ‘QUOTE/BASE’

  • depth_pct (float) – depth percent (1-100) to measure volume and average price

Returns

tuple with (“price as float”, volume) where volume is actual quote volume

async get_market_buy_price(self, market: str, quote_amount: float = 0, base_amount: float = 0)[source]

Returns the BASE/QUOTE price for which [depth] worth of QUOTE could be sold.

Parameters
  • market (str) – market in format ‘QUOTE/BASE’

  • quote_amount (float) –

  • base_amount (float) –

Returns

tuple with (“price as float”, volume) where volume is actual base or quote volume

async get_market_sell_price(self, market: str, quote_amount: float = 0, base_amount: float = 0)[source]

Returns the BASE/QUOTE price for which [depth] worth of QUOTE could be bought.

Parameters
  • market (str) – market in format ‘QUOTE/BASE’

  • quote_amount (float) –

  • base_amount (float) –

Returns

tuple with (“price as float”, volume) where volume is actual base or quote volume

async get_market_center_price(self, market: str, base_amount: float = 0, quote_amount: float = 0, depth_pct: float = 0)[source]

Returns the center price of market.

Parameters
  • market (str) – market in format ‘QUOTE/BASE’

  • base_amount (float) –

  • quote_amount (float) –

  • depth_pct (float) – depth percent (1-100) to measure volume and average price

Returns

Tuple with market center price as float, volume in buy or sell side which is lower

async get_price_across_2_markets(self, market: str, via: str, depth_pct: float = 20)[source]

Derive cross-price for A/C from A/B, B/C markets.

Parameters
  • market (str) – target market in format A/C

  • via (str) – intermediate asset

  • depth_pct (float) – depth percent (1-100) to measure volume and average price

Returns

tuple with price and volume

async get_feed_price(self, asset: str, invert: bool = False)[source]

Get price data from feed.

By default, price is MPA/BACKING, e.g. for USD asset price is how many USD per BTS. To get BACKING per MPA price, use invert=True

Parameters
  • asset (str) – name of the asset

  • invert (bool) – return inverted price

Returns

price as float

Return type

float

async _get_market(self, market)[source]