bhive.price module¶
-
class
bhive.price.
FilledOrder
(order, hive_instance=None, **kwargs)¶ Bases:
bhive.price.Price
This class inherits
bhive.price.Price
but has thebase
andquote
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
hive_instance (Hive) – Hive instance
Note
Instances of this class come with an additional
date
key that shows when the order has been filled!-
json
()¶
-
class
bhive.price.
Order
(base, quote=None, hive_instance=None, **kwargs)¶ Bases:
bhive.price.Price
This class inherits
bhive.price.Price
but has thebase
andquote
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
hive_instance (Hive) – Hive instance
Note
If an order is marked as deleted, it will carry the ‘deleted’ key which is set to
True
and all other data beNone
.
-
class
bhive.price.
Price
(price=None, base=None, quote=None, base_asset=None, hive_instance=None)¶ 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
bhive.amount.Amount
. The amount themselves define the price.Note
The price (floating) is derived as
base/quote
- Parameters
- 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 assetsargs
can be a floating number andbase
andquote
being instances ofbhive.asset.Asset
args
can be a floating number andbase
andquote
being instances ofstr
args
can be dict with keysprice
,base
, andquote
(graphene balances)args
can be dict with keysbase
andquote
args
can be dict with keyreceives
(filled orders)args
being a list of[quote, base]
both being instances ofbhive.amount.Amount
args
being a list of[quote, base]
both being instances ofstr
(amount symbol
)base
andquote
being instances ofbhive.asset.Amount
This allows instanciations like:
Price("0.315 HBD/HIVE")
Price(0.315, base="HBD", quote="HIVE")
Price(0.315, base=Asset("HBD"), quote=Asset("HIVE"))
Price({"base": {"amount": 1, "asset_id": "HBD"}, "quote": {"amount": 10, "asset_id": "HBD"}})
Price(quote="10 HIVE", base="1 HBD")
Price("10 HIVE", "1 HBD")
Price(Amount("10 HIVE"), Amount("1 HBD"))
Price(1.0, "HBD/HIVE")
Instances of this class can be used in regular mathematical expressions (
+-*/%
) such as:>>> from bhive.price import Price >>> Price("0.3314 HBD/HIVE") * 2 0.662804 HBD/HIVE >>> Price(0.3314, "HBD", "HIVE") 0.331402 HBD/HIVE
-
as_base
(base)¶ Returns the price instance so that the base asset is
base
.Note
This makes a copy of the object!
>>> from bhive.price import Price >>> Price("0.3314 HBD/HIVE").as_base("HIVE") 3.017483 HIVE/HBD
-
as_quote
(quote)¶ Returns the price instance so that the quote asset is
quote
.Note
This makes a copy of the object!
>>> from bhive.price import Price >>> Price("0.3314 HBD/HIVE").as_quote("HBD") 3.017483 HIVE/HBD
-
copy
() → a shallow copy of D¶
-
invert
()¶ Invert the price (e.g. go from
HBD/HIVE
intoHIVE/HBD
)>>> from bhive.price import Price >>> Price("0.3314 HBD/HIVE").invert() 3.017483 HIVE/HBD
-
json
()¶
-
property
market
¶ Open the corresponding market
- Returns
Instance of
bhive.market.Market
for the corresponding pair of assets.
-
symbols
()¶