Ejemplo n.º 1
0
    def command_buy(self):
        if not isinstance(self.amount, float) or self.amount < 0:
            return logging.error("Please add a positive amount to buy.")

        vault = Vault()
        try:
            wallet = vault.find_wallet(name=self.wallet)
        except ValueError:
            return logging.error(
                'The wallet is not recognized. Add a wallet with the wallet command.'
            )

        c_org_manager = ContinuousOrganisationManager(self.name)
        if not c_org_manager.is_built():
            return logging.error(
                'The continuous organisation is not deployed.  Run first `c-org deploy --help`.'
            )

        logging.debug('Buying an amount of {:.3f} to {}'.format(
            self.amount, self.name))
        c_org_manager.buy(self.amount, wallet)

        balance = c_org_manager.get_balance(wallet)
        logging.info(
            "Great! Your buy tokens! Your balance is now {:d}".format(balance))
Ejemplo n.º 2
0
    def command_stats(self):
        vault = Vault()
        try:
            wallet = vault.find_wallet(name=self.wallet)
        except ValueError:
            return logging.error(
                'The wallet is not recognized. Add a wallet with the wallet command.'
            )

        c_org_manager = ContinuousOrganisationManager(self.name)
        if not c_org_manager.is_built():
            return logging.error(
                'The continuous organisation is not deployed.  Run first `c-org deploy --help`.'
            )

        logging.debug('Retrieving the statistics')
        balance = c_org_manager.get_balance(wallet)
        logging.info("Balance: {:.3f} tokens".format(balance))
        tokens = c_org_manager.get_n_tokens()
        logging.info("Total tokens: {:.3f} tokens".format(tokens))
        reserve = c_org_manager.get_sell_reserve()
        logging.info("Reserve: {:.3f}".format(reserve))