Base Strategy

All strategies should inherit stakemachine.basestrategy.BaseStrategy which simplifies and unifies the development of new strategies.

API

class stakemachine.basestrategy.BaseStrategy(config, name, onAccount=None, onOrderMatched=None, onOrderPlaced=None, onMarketUpdate=None, onUpdateCallOrder=None, ontick=None, bitshares_instance=None, *args, **kwargs)

Base Strategy and methods available in all Sub Classes that inherit this BaseStrategy.

BaseStrategy inherits:

Available attributes:

  • basestrategy.bitshares: instance of ´`bitshares.BitShares()``
  • basestrategy.add_state: Add a specific state
  • basestrategy.set_state: Set finite state machine
  • basestrategy.get_state: Change state of state machine
  • basestrategy.account: The Account object of this bot
  • basestrategy.market: The market used by this bot
  • basestrategy.orders: List of open orders of the bot’s account in the bot’s market
  • basestrategy.balance: List of assets and amounts available in the bot’s account

Also, Base Strategy inherits stakemachine.storage.Storage which allows to permanently store data in a sqlite database using:

basestrategy["key"] = "value"

Note

This applies a json.loads(json.dumps(value))!

account

Return the full account as bitshares.account.Account object!

Can be refreshed by using x.refresh()

balance(asset)

Return the balance of your bot’s account for a specific asset

balances

Return the balances of your bot’s account

cancelall()

Cancel all orders of this bot

disable()

This method can be called to disable a bot

enable()

This method can be called to re-enable a bot

execute()

Execute a bundle of operations

market

Return the market object as bitshares.market.Market

orders

Return the bot’s open accounts in the current market