dexbot.pricefeeds.bitshares_feed module

class dexbot.pricefeeds.bitshares_feed.BitsharesPriceFeed(market, bitshares_instance=None)

Bases: object

This Price Feed class enables usage of Bitshares DEX for market center and order book pricing, without requiring a registered account. It may be used for both strategy and indicator analysis tools.

All prices are passed and returned as BASE/QUOTE. (In the BREAD/USD market that would be USD/BREAD, 2.5 USD / 1 BREAD).

  • Buy orders reserve BASE
  • Sell orders reserve QUOTE
filter_buy_orders(orders, sort=None)

Return own buy orders from list of orders. Can be used to pick buy orders from a list that is not up to date with the blockchain data.

Parameters:
  • | orders (list) – List of orders
  • | sort (string) – DESC or ASC will sort the orders accordingly, default None
Return list | buy_orders:
 

List of buy orders only

filter_sell_orders(orders, sort=None, invert=True)

Return sell orders from list of orders. Can be used to pick sell orders from a list that is not up to date with the blockchain data.

Parameters:
  • | orders (list) – List of orders
  • | sort (string) – DESC or ASC will sort the orders accordingly, default None
  • | invert (bool) – return inverted orders or not
Return list | sell_orders:
 

List of sell orders only

get_highest_market_buy_order(orders=None)

Returns the highest buy order that is not own, regardless of order size.

Parameters:| orders (list) – Optional list of orders, if none given fetch newest from market
Returns:Highest market buy order or None
get_limit_orders(depth=1)

Returns orders from the current market. Orders are sorted by price. Does not require account info.

get_limit_orders() call does not have any depth limit.

Parameters:depth (int) – Amount of orders per side will be fetched, default=1
Returns:Returns a list of orders or None
get_lowest_market_sell_order(orders=None)

Returns the lowest sell order that is not own, regardless of order size.

Parameters:| orders (list) – Optional list of orders, if none given fetch newest from market
Returns:Lowest market sell order or None
get_market_buy_orders(depth=10)

Fetches most recent data and returns list of buy orders.

Parameters:| depth (int) – Amount of buy orders returned, Default=10
Returns:List of market sell orders
get_market_buy_price(quote_amount=0, base_amount=0, **kwargs)

Returns the BASE/QUOTE price for which [depth] worth of QUOTE could be bought, enhanced with moving average or weighted moving average.

Parameters:
  • | quote_amount (float) –
  • | base_amount (float) –
  • | kwargs (dict) –
Returns:

price as float

get_market_center_price(base_amount=0, quote_amount=0, suppress_errors=False)

Returns the center price of market including own orders.

Parameters:
  • base_amount (float) –
  • quote_amount (float) –
  • suppress_errors (bool) – True = return None on errors, False = disable worker
Returns:

Market center price as float

get_market_sell_orders(depth=10)

Fetches most recent data and returns list of sell orders.

Parameters:| depth (int) – Amount of sell orders returned, Default=10
Returns:List of market sell orders
get_market_sell_price(quote_amount=0, base_amount=0, **kwargs)

Returns the BASE/QUOTE price for which [quote_amount] worth of QUOTE could be bought, enhanced with moving average or weighted moving average.

[quote/base]_amount = 0 means lowest regardless of size

Parameters:
  • | quote_amount (float) –
  • | base_amount (float) –
  • | kwargs (dict) –
Returns:

get_market_spread(quote_amount=0, base_amount=0)

Returns the market spread %, including own orders, from specified depth.

Parameters:
  • | quote_amount (float) –
  • | base_amount (float) –
Returns:

Market spread as float or None

get_orderbook_orders(depth=1)

Returns orders from the current market split in bids and asks. Orders are sorted by price.

Market.orderbook() call has hard-limit of depth=50 enforced by bitshares node.

bids = buy orders asks = sell orders

Parameters:| depth (int) – Amount of orders per side will be fetched, default=1
Returns:Returns a dictionary of orders or None
static sort_orders_by_price(orders, sort='DESC')

Return list of orders sorted ascending or descending by price.

Parameters:
  • | orders (list) – list of orders to be sorted
  • | sort (string) – ASC or DESC. Default DESC
Return list:

Sorted list of orders