コード例 #1
0
def run_bot(bot=bot):
    try:
        rpc = GrapheneAPI(config.wallet_host, config.wallet_port, "", "")
        rpc.unlock(config.wallet_password)  # unlock the wallet.
    except RPCError as e:
        print(e)

    print(str(datetime.datetime.now()) + ": Starting bot...")
    print(str(datetime.datetime.now()) + ": Cancelling orders...")
    bot.cancel_all()
    print(str(datetime.datetime.now()) + ": Sleeping")
    time.sleep(12)
    print(str(datetime.datetime.now()) + ": Running the bot")

    try:
        bot.execute()
    except RPCError as e:
        if "amount_to_sell.amount > 0" in str(e):
            print(
                "MANUAL ACTION NEEDED: Can't place order because the amount is too small"
            )
            print(
                "Getting more of the currency you are selling or buying with should fix this"
            )
            print(e)
        else:
            print(e)
コード例 #2
0
def run_bot(bot=bot):
    rpc = GrapheneAPI(config.wallet_host, config.wallet_port, "", "")
    if rpc.is_locked():
        rpc.unlock(config.wallet_password)

    print(str(datetime.now()) + "| Starting bot...")
    bot.init(config)
    time.sleep(6)
    print(str(datetime.now()) + "| Running the bot")
    bot.run()
コード例 #3
0
def run_bot(bot=bot):
    try:
        rpc = GrapheneAPI(config.wallet_host, config.wallet_port, "", "")
        rpc.unlock(config.wallet_password) # unlock the wallet.
    except RPCError as e:
        print(e)

    print(str(datetime.datetime.now()) + ": Starting bot...")
    print(str(datetime.datetime.now()) + ": Cancelling orders...")
    bot.cancel_all()
    print(str(datetime.datetime.now()) + ": Sleeping")
    time.sleep(12)
    print(str(datetime.datetime.now()) + ": Running the bot")
    
    try:
        bot.execute()
    except RPCError as e:
        if "amount_to_sell.amount > 0" in str(e):
            print("MANUAL ACTION NEEDED: Can't place order because the amount is too small")
            print("Getting more of the currency you are selling or buying with should fix this")
            print(e)
        else:
            print(e)
コード例 #4
0
            }
        }
    request = requests.post(faucet + '/api/v1/accounts', data=json.dumps(payload), headers=headers)
    return (request.status_code == 201, request.text)


if __name__ == '__main__':
    time.sleep(5) # sleep to give the cli_wallet time to start

    # rpc connection
    rpc = GrapheneAPI(config.wallet_host, config.wallet_port, "", "")
    try:
        rpc.set_password(config.wallet_password) # try to set password
    except RPCError: # if RCPError the password is already set
        pass
    rpc.unlock(config.wallet_password) # unlock the wallet.

    my_accounts = rpc.list_my_accounts()

    if len(my_accounts) is 0:
        brain_key = rpc.suggest_brain_key()
        account_registered, account_registration_response = register_account_faucet(config.account, brain_key['pub_key'])
        if account_registered:
            rpc.import_key(config.account, brain_key['wif_priv_key'])

            print("Account: %s succesfully registered" % config.account)
            print(rpc.list_my_accounts())

            print("Brain key: %s" % brain_key['brain_priv_key'])
            print("Write it down/back it up ^")
コード例 #5
0
        }
    }
    request = requests.post(faucet + '/api/v1/accounts',
                            data=json.dumps(payload),
                            headers=headers)
    return (request.status_code == 201, request.text)


if __name__ == '__main__':
    time.sleep(5)  # sleep to give the cli_wallet time to start
    rpc = GrapheneAPI(config.wallet_host, config.wallet_port, "", "")
    try:
        rpc.set_password(config.wallet_password)  # try to set password
    except RPCError:  # if RCPError the password is already set
        pass
    rpc.unlock(config.wallet_password)  # unlock the wallet.
    my_accounts = rpc.list_my_accounts()

    if len(my_accounts) == 0:
        brain_key = rpc.suggest_brain_key()
        account_registered, account_registration_response = register_account_faucet(
            config.account, brain_key['pub_key'])
        if account_registered:
            rpc.import_key(config.account, brain_key['wif_priv_key'])

            print("Account: %s successfully registered" % config.account)
            print(rpc.list_my_accounts())

            print("Brain key: %s" % brain_key['brain_priv_key'])
            print("Write it down/back it up ^")