nectarengine.market module

class nectarengine.market.Market(api: Api | None = None, blockchain_instance: Any | None = None)

Bases: list

Access the hive-engine market

Parameters:

blockchain_instance (Hive) – Hive instance

buy(account: str, amount: float, symbol: str, price: float) Dict[str, Any]

Buy token for given price.

Parameters:
  • account (str) – account name

  • amount (float) – Amount to withdraw

  • symbol (str) – symbol

  • price (float) – price

Buy example:

from nectarengine.market import Market
from nectar import Hive
active_wif = "5xxxx"
hv = Hive(keys=[active_wif])
market = Market(blockchain_instance=hv)
market.buy("test", 1, "BEE", 0.95)
cancel(account: str, order_type: str, order_id: int) Dict[str, Any]

Cancel buy/sell order.

Parameters:
  • account (str) – account name

  • order_type (str) – sell or buy

  • order_id (int) – order id

Cancel example:

from nectarengine.market import Market
from nectar import Hive
active_wif = "5xxxx"
hv = Hive(keys=[active_wif])
market = Market(blockchain_instance=hv)
market.sell("test", "sell", 12)
deposit(account: str, amount: float) Dict[str, Any]

Deposit HIVE to market in exchange for SWAP.HIVE.

Parameters:
  • account (str) – account name

  • amount (float) – Amount to deposit

Deposit example:

from nectarengine.market import Market
from nectar import Hive
active_wif = "5xxxx"
hv = Hive(keys=[active_wif])
market = Market(blockchain_instance=hv)
market.deposit("test", 1)
get_buy_book(symbol: str, account: str | None = None, limit: int = 100, offset: int = 0) List[Dict[str, Any]]

Returns the buy book for a given symbol. When account is set, the order book from the given account is shown.

get_metrics() List[Dict[str, Any]]

Returns all token within the wallet as list

get_sell_book(symbol: str, account: str | None = None, limit: int = 100, offset: int = 0) List[Dict[str, Any]]

Returns the sell book for a given symbol. When account is set, the order book from the given account is shown.

get_trades_history(symbol: str, account: str | None = None, limit: int = 30, offset: int = 0) List[Dict[str, Any]]

Returns the trade history for a given symbol. When account is set, the trade history from the given account is shown.

refresh() None
sell(account: str, amount: float, symbol: str, price: float) Dict[str, Any]

Sell token for given price.

Parameters:
  • account (str) – account name

  • amount (float) – Amount to withdraw

  • symbol (str) – symbol

  • price (float) – price

Sell example:

from nectarengine.market import Market
from nectar import Hive
active_wif = "5xxxx"
hv = Hive(keys=[active_wif])
market = Market(blockchain_instance=hv)
market.sell("test", 1, "BEE", 0.95)
set_id(ssc_id: str) None

Sets the ssc id (default is ssc-mainnet-hive)

withdraw(account: str, amount: float) Dict[str, Any]

Widthdraw SWAP.HIVE to account as HIVE.

Parameters:
  • account (str) – account name

  • amount (float) – Amount to withdraw

Withdraw example:

from nectarengine.market import Market
from nectar import Hive
active_wif = "5xxxx"
hv = Hive(keys=[active_wif])
market = Market(blockchain_instance=hv)
market.withdraw("test", 1)