peerplays.price module

class peerplays.price.FilledOrder(order, **kwargs)

Bases: peerplays.price.Price

This class inherits peerplays.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 (peerplays.peerplays.PeerPlays) – PeerPlays instance

Note

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

as_base(base)

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

Note: This makes a copy of the object!

as_quote(quote)

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

Note: This makes a copy of the object!

blockchain
blockchain_instance_class

alias of peerplays.instance.BlockchainInstance

chain

Short form for blockchain (for the lazy)

clear() → None. Remove all items from D.
copy() → a shallow copy of D
define_classes()

Needs to define instance variables that provide classes

fromkeys()

Create a new dictionary with keys from iterable and values set to value.

get()

Return the value for key if key is in the dictionary, else default.

get_instance_class()

Should return the Chain instance class, e.g. peerplays.PeerPlays

classmethod inject(cls)
invert()

Invert the price (e.g. go from USD/BTS into BTS/USD)

items() → a set-like object providing a view on D's items
json()
return {
“base”: self[“base”].json(), “quote”: self[“quote”].json()

}

keys() → a set-like object providing a view on D's keys
market

Open the corresponding market.

Returns:Instance of peerplays.market.Market for the corresponding pair of assets.
peerplays

Alias for the specific blockchain

pop(k[, d]) → v, remove specified key and return the corresponding value.

If key is not found, d is returned if given, otherwise KeyError is raised

popitem() → (k, v), remove and return some (key, value) pair as a

2-tuple; but raise KeyError if D is empty.

classmethod set_shared_blockchain_instance(instance)

This method allows us to override default instance for all users of SharedInstance.instance.

Parameters:instance (chaininstance) – Chain instance
classmethod set_shared_config(config)

This allows to set a config that will be used when calling shared_blockchain_instance and allows to define the configuration without requiring to actually create an instance

set_shared_instance()

This method allows to set the current instance as default

setdefault()

Insert key with a value of default if key is not in the dictionary.

Return the value for key if key is in the dictionary, else default.

shared_blockchain_instance()

This method will initialize SharedInstance.instance and return it. The purpose of this method is to have offer single default instance that can be reused by multiple classes.

symbols()
update([E, ]**F) → None. Update D from dict/iterable E and F.

If E is present and has a .keys() method, then does: for k in E: D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]

values() → an object providing a view on D's values
class peerplays.price.Order(*args, **kwargs)

Bases: peerplays.price.Price

This class inherits peerplays.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 (peerplays.peerplays.PeerPlays) – PeerPlays 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.

as_base(base)

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

Note: This makes a copy of the object!

as_quote(quote)

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

Note: This makes a copy of the object!

blockchain
blockchain_instance_class

alias of peerplays.instance.BlockchainInstance

chain

Short form for blockchain (for the lazy)

clear() → None. Remove all items from D.
copy() → a shallow copy of D
define_classes()

Needs to define instance variables that provide classes

for_sale
fromkeys()

Create a new dictionary with keys from iterable and values set to value.

get()

Return the value for key if key is in the dictionary, else default.

get_instance_class()

Should return the Chain instance class, e.g. peerplays.PeerPlays

classmethod inject(cls)
invert()

Invert the price (e.g. go from USD/BTS into BTS/USD)

items() → a set-like object providing a view on D's items
json()
return {
“base”: self[“base”].json(), “quote”: self[“quote”].json()

}

keys() → a set-like object providing a view on D's keys
market

Open the corresponding market.

Returns:Instance of peerplays.market.Market for the corresponding pair of assets.
peerplays

Alias for the specific blockchain

pop(k[, d]) → v, remove specified key and return the corresponding value.

If key is not found, d is returned if given, otherwise KeyError is raised

popitem() → (k, v), remove and return some (key, value) pair as a

2-tuple; but raise KeyError if D is empty.

price
classmethod set_shared_blockchain_instance(instance)

This method allows us to override default instance for all users of SharedInstance.instance.

Parameters:instance (chaininstance) – Chain instance
classmethod set_shared_config(config)

This allows to set a config that will be used when calling shared_blockchain_instance and allows to define the configuration without requiring to actually create an instance

set_shared_instance()

This method allows to set the current instance as default

setdefault()

Insert key with a value of default if key is not in the dictionary.

Return the value for key if key is in the dictionary, else default.

shared_blockchain_instance()

This method will initialize SharedInstance.instance and return it. The purpose of this method is to have offer single default instance that can be reused by multiple classes.

symbols()
to_buy
update([E, ]**F) → None. Update D from dict/iterable E and F.

If E is present and has a .keys() method, then does: for k in E: D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]

values() → an object providing a view on D's values
class peerplays.price.Price(*args, **kwargs)

Bases: peerplays.instance.BlockchainInstance, peerplays.price.Price

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 :class:`peerplays.amount.Amount`. The
amount themselves define the price.

.. note::

    The price (floating) is derived as ``base/quote``

:param list args: Allows to deal with different representations of a price
:param peerplays.asset.Asset base: Base asset
:param peerplays.asset.Asset quote: Quote asset
:param peerplays.peerplays.PeerPlays blockchain_instance: PeerPlays instance
:returns: All data required to represent a price
:rtype: dict

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 :class:`peerplays.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 :class:`peerplays.amount.Amount`
    * ``args`` being a list of ``[quote, base]`` both being instances of ``str`` (``amount symbol``)
    * ``base`` and ``quote`` being instances of :class:`peerplays.asset.Amount`

This allows instanciations like:

* ``Price("0.315 BTC/PPY")``
* ``Price(0.315, base="BTC", quote="PPY")``
* ``Price(0.315, base=Asset("BTC"), quote=Asset("PPY"))``
* ``Price({"base": {"amount": 1, "asset_id": "1.3.0"}, "quote": {"amount": 10, "asset_id": "1.3.106"}})``
* ``Price({"receives": {"amount": 1, "asset_id": "1.3.0"}, "pays": {"amount": 10, "asset_id": "1.3.106"}}, base_asset=Asset("1.3.0"))``
* ``Price(quote="10 GOLD", base="1 BTC")``
* ``Price("10 GOLD", "1 BTC")``
* ``Price(Amount("10 GOLD"), Amount("1 BTC"))``
* ``Price(1.0, "BTC/GOLD")``

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

.. code-block:: python

    >>> from peerplays.price import Price
    >>> Price("0.3314 BTC/PPY") * 2
    0.662600000 BTC/PPY
as_base(base)

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

Note: This makes a copy of the object!

as_quote(quote)

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

Note: This makes a copy of the object!

blockchain
blockchain_instance_class

alias of peerplays.instance.BlockchainInstance

chain

Short form for blockchain (for the lazy)

clear() → None. Remove all items from D.
copy() → a shallow copy of D
define_classes()

Needs to define instance variables that provide classes

fromkeys()

Create a new dictionary with keys from iterable and values set to value.

get()

Return the value for key if key is in the dictionary, else default.

get_instance_class()

Should return the Chain instance class, e.g. peerplays.PeerPlays

classmethod inject(cls)
invert()

Invert the price (e.g. go from USD/BTS into BTS/USD)

items() → a set-like object providing a view on D's items
json()
return {
“base”: self[“base”].json(), “quote”: self[“quote”].json()

}

keys() → a set-like object providing a view on D's keys
market

Open the corresponding market.

Returns:Instance of peerplays.market.Market for the corresponding pair of assets.
peerplays

Alias for the specific blockchain

pop(k[, d]) → v, remove specified key and return the corresponding value.

If key is not found, d is returned if given, otherwise KeyError is raised

popitem() → (k, v), remove and return some (key, value) pair as a

2-tuple; but raise KeyError if D is empty.

classmethod set_shared_blockchain_instance(instance)

This method allows us to override default instance for all users of SharedInstance.instance.

Parameters:instance (chaininstance) – Chain instance
classmethod set_shared_config(config)

This allows to set a config that will be used when calling shared_blockchain_instance and allows to define the configuration without requiring to actually create an instance

set_shared_instance()

This method allows to set the current instance as default

setdefault()

Insert key with a value of default if key is not in the dictionary.

Return the value for key if key is in the dictionary, else default.

shared_blockchain_instance()

This method will initialize SharedInstance.instance and return it. The purpose of this method is to have offer single default instance that can be reused by multiple classes.

symbols()
update([E, ]**F) → None. Update D from dict/iterable E and F.

If E is present and has a .keys() method, then does: for k in E: D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]

values() → an object providing a view on D's values
class peerplays.price.PriceFeed(*args, **kwargs)

Bases: peerplays.instance.BlockchainInstance, peerplays.price.PriceFeed

This class is used to represent a price feed consisting of.

  • a witness,
  • a symbol,
  • a core exchange rate,
  • the maintenance collateral ratio,
  • the max short squeeze ratio,
  • a settlement price, and
  • a date
Parameters:blockchain_instance (peerplays.peerplays.PeerPlays) – PeerPlays instance
blockchain
blockchain_instance_class

alias of peerplays.instance.BlockchainInstance

chain

Short form for blockchain (for the lazy)

clear() → None. Remove all items from D.
copy() → a shallow copy of D
define_classes()

Needs to define instance variables that provide classes

fromkeys()

Create a new dictionary with keys from iterable and values set to value.

get()

Return the value for key if key is in the dictionary, else default.

get_instance_class()

Should return the Chain instance class, e.g. peerplays.PeerPlays

classmethod inject(cls)
items() → a set-like object providing a view on D's items
keys() → a set-like object providing a view on D's keys
peerplays

Alias for the specific blockchain

pop(k[, d]) → v, remove specified key and return the corresponding value.

If key is not found, d is returned if given, otherwise KeyError is raised

popitem() → (k, v), remove and return some (key, value) pair as a

2-tuple; but raise KeyError if D is empty.

classmethod set_shared_blockchain_instance(instance)

This method allows us to override default instance for all users of SharedInstance.instance.

Parameters:instance (chaininstance) – Chain instance
classmethod set_shared_config(config)

This allows to set a config that will be used when calling shared_blockchain_instance and allows to define the configuration without requiring to actually create an instance

set_shared_instance()

This method allows to set the current instance as default

setdefault()

Insert key with a value of default if key is not in the dictionary.

Return the value for key if key is in the dictionary, else default.

shared_blockchain_instance()

This method will initialize SharedInstance.instance and return it. The purpose of this method is to have offer single default instance that can be reused by multiple classes.

update([E, ]**F) → None. Update D from dict/iterable E and F.

If E is present and has a .keys() method, then does: for k in E: D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]

values() → an object providing a view on D's values
class peerplays.price.UpdateCallOrder(call, **kwargs)

Bases: peerplays.price.Price

This class inherits peerplays.price.Price but has the base and quote Amounts not only be used to represent the call price (as a ratio of base and quote).

Parameters:blockchain_instance (peerplays.peerplays.PeerPlays) – PeerPlays instance
as_base(base)

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

Note: This makes a copy of the object!

as_quote(quote)

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

Note: This makes a copy of the object!

blockchain
blockchain_instance_class

alias of peerplays.instance.BlockchainInstance

chain

Short form for blockchain (for the lazy)

clear() → None. Remove all items from D.
copy() → a shallow copy of D
define_classes()

Needs to define instance variables that provide classes

fromkeys()

Create a new dictionary with keys from iterable and values set to value.

get()

Return the value for key if key is in the dictionary, else default.

get_instance_class()

Should return the Chain instance class, e.g. peerplays.PeerPlays

classmethod inject(cls)
invert()

Invert the price (e.g. go from USD/BTS into BTS/USD)

items() → a set-like object providing a view on D's items
json()
return {
“base”: self[“base”].json(), “quote”: self[“quote”].json()

}

keys() → a set-like object providing a view on D's keys
market

Open the corresponding market.

Returns:Instance of peerplays.market.Market for the corresponding pair of assets.
peerplays

Alias for the specific blockchain

pop(k[, d]) → v, remove specified key and return the corresponding value.

If key is not found, d is returned if given, otherwise KeyError is raised

popitem() → (k, v), remove and return some (key, value) pair as a

2-tuple; but raise KeyError if D is empty.

classmethod set_shared_blockchain_instance(instance)

This method allows us to override default instance for all users of SharedInstance.instance.

Parameters:instance (chaininstance) – Chain instance
classmethod set_shared_config(config)

This allows to set a config that will be used when calling shared_blockchain_instance and allows to define the configuration without requiring to actually create an instance

set_shared_instance()

This method allows to set the current instance as default

setdefault()

Insert key with a value of default if key is not in the dictionary.

Return the value for key if key is in the dictionary, else default.

shared_blockchain_instance()

This method will initialize SharedInstance.instance and return it. The purpose of this method is to have offer single default instance that can be reused by multiple classes.

symbols()
update([E, ]**F) → None. Update D from dict/iterable E and F.

If E is present and has a .keys() method, then does: for k in E: D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]

values() → an object providing a view on D's values