beem.amount¶
-
class
beem.amount.
Amount
(amount, asset=None, fixed_point_arithmetic=False, new_appbase_format=True, blockchain_instance=None, **kwargs)¶ Bases:
dict
This class deals with Amounts of any asset to simplify dealing with the tuple:
(amount, asset)
Parameters: - args (list) – Allows to deal with different representations of an amount
- amount (float) – Let’s create an instance with a specific amount
- asset (str) – Let’s you create an instance with a specific asset (symbol)
- fixed_point_arithmetic (boolean) – when set to True, all operation are fixed point operations and the amount is always be rounded down to the precision
- steem_instance (Steem) – Steem instance
Returns: All data required to represent an Amount/Asset
Return type: dict
Raises: ValueError – if the data provided is not recognized
Way to obtain a proper instance:
args
can be a string, e.g.: “1 SBD”args
can be a dictionary containingamount
andasset_id
args
can be a dictionary containingamount
andasset
args
can be a list of afloat
andstr
(symbol)args
can be a list of afloat
and abeem.asset.Asset
amount
andasset
are defined manually
An instance is a dictionary and comes with the following keys:
amount
(float)symbol
(str)asset
(instance ofbeem.asset.Asset
)
Instances of this class can be used in regular mathematical expressions (
+-*/%
) such as:from beem.amount import Amount from beem.asset import Asset a = Amount("1 STEEM") b = Amount(1, "STEEM") c = Amount("20", Asset("STEEM")) a + b a * 2 a += b a /= 2.0
2.000 STEEM 2.000 STEEM
-
amount
¶ Returns the amount as float
-
amount_decimal
¶ Returns the amount as decimal
-
asset
¶ Returns the asset as instance of
steem.asset.Asset
-
copy
()¶ Copy the instance and make sure not to use a reference
-
json
()¶
-
symbol
¶ Returns the symbol of the asset
-
tuple
()¶
-
beem.amount.
check_asset
(other, self, stm)¶
-
beem.amount.
quantize
(amount, precision)¶