beem.price

class beem.price.FilledOrder(order, blockchain_instance=None, **kwargs)

Bases: beem.price.Price

This class inherits beem.price.Price but has the base and quote Amounts not only be used to represent the price (as a ratio of base and quote) but instead has those amounts represent the amounts of an actually filled order!

Parameters:blockchain_instance (Steem) – Steem instance

Note

Instances of this class come with an additional date key that shows when the order has been filled!

json()
class beem.price.Order(base, quote=None, blockchain_instance=None, **kwargs)

Bases: beem.price.Price

This class inherits beem.price.Price but has the base and quote Amounts not only be used to represent the price (as a ratio of base and quote) but instead has those amounts represent the amounts of an actual order!

Parameters:blockchain_instance (Steem) – Steem instance

Note

If an order is marked as deleted, it will carry the ‘deleted’ key which is set to True and all other data be None.

class beem.price.Price(price=None, base=None, quote=None, base_asset=None, blockchain_instance=None, **kwargs)

Bases: dict

This class deals with all sorts of prices of any pair of assets to simplify dealing with the tuple:

(quote, base)

each being an instance of beem.amount.Amount. The amount themselves define the price.

Note

The price (floating) is derived as base/quote

Parameters:
  • args (list) – Allows to deal with different representations of a price
  • base (Asset) – Base asset
  • quote (Asset) – Quote asset
  • blockchain_instance (Steem) – Steem instance
Returns:

All data required to represent a price

Return type:

dictionary

Way to obtain a proper instance:

  • args is a str with a price and two assets
  • args can be a floating number and base and quote being instances of beem.asset.Asset
  • args can be a floating number and base and quote being instances of str
  • args can be dict with keys price, base, and quote (graphene balances)
  • args can be dict with keys base and quote
  • args can be dict with key receives (filled orders)
  • args being a list of [quote, base] both being instances of beem.amount.Amount
  • args being a list of [quote, base] both being instances of str (amount symbol)
  • base and quote being instances of beem.asset.Amount

This allows instanciations like:

  • Price("0.315 SBD/STEEM")
  • Price(0.315, base="SBD", quote="STEEM")
  • Price(0.315, base=Asset("SBD"), quote=Asset("STEEM"))
  • Price({"base": {"amount": 1, "asset_id": "SBD"}, "quote": {"amount": 10, "asset_id": "SBD"}})
  • Price(quote="10 STEEM", base="1 SBD")
  • Price("10 STEEM", "1 SBD")
  • Price(Amount("10 STEEM"), Amount("1 SBD"))
  • Price(1.0, "SBD/STEEM")

Instances of this class can be used in regular mathematical expressions (+-*/%) such as:

>>> from beem.price import Price
>>> from beem import Steem
>>> stm = Steem("https://api.steemit.com")
>>> Price("0.3314 SBD/STEEM", blockchain_instance=stm) * 2
0.662804 SBD/STEEM
>>> Price(0.3314, "SBD", "STEEM", blockchain_instance=stm)
0.331402 SBD/STEEM
as_base(base)

Returns the price instance so that the base asset is base.

Note

This makes a copy of the object!

>>> from beem.price import Price
>>> from beem import Steem
>>> stm = Steem("https://api.steemit.com")
>>> Price("0.3314 SBD/STEEM", blockchain_instance=stm).as_base("STEEM")
3.017483 STEEM/SBD
as_quote(quote)

Returns the price instance so that the quote asset is quote.

Note

This makes a copy of the object!

>>> from beem.price import Price
>>> from beem import Steem
>>> stm = Steem("https://api.steemit.com")
>>> Price("0.3314 SBD/STEEM", blockchain_instance=stm).as_quote("SBD")
3.017483 STEEM/SBD
copy() → a shallow copy of D
invert()

Invert the price (e.g. go from SBD/STEEM into STEEM/SBD)

>>> from beem.price import Price
>>> from beem import Steem
>>> stm = Steem("https://api.steemit.com")
>>> Price("0.3314 SBD/STEEM", blockchain_instance=stm).invert()
3.017483 STEEM/SBD
json()
market

Open the corresponding market

Returns:Instance of beem.market.Market for the corresponding pair of assets.
symbols()
beem.price.check_asset(other, self, stm)