Skip to content

Setup

The functions behind pyhood setup. See Setup for the command-line walkthrough.

None of the status functions return a secret value, and none of them make network calls.

pyhood.onboarding.print_status(out=print)

Report what is configured. Reads nothing over the network.

Returns:

Type Description
int

0 if both credential kinds are usable, 1 otherwise.

pyhood.onboarding.session_status()

Describe the stored session without revealing any token.

pyhood.onboarding.crypto_status()

Describe the stored crypto credentials without revealing them.

Returns:

Name Type Description
Keys dict[str, Any]

source ('environment', 'file' or 'none'), path,

dict[str, Any]

exists, mode, owner_only, api_key_chars,

dict[str, Any]

private_key_bytes and private_key_valid.

pyhood.onboarding.setup_login(prompt=input, secret_prompt=getpass.getpass, out=print)

Obtain session tokens, reusing an existing session where possible.

A stored session that is still valid, or that can be refreshed, needs no password at all — so that is tried first.

Parameters:

Name Type Description Default
prompt Prompt

Reads the username and any MFA code. Injected for testing.

input
secret_prompt Prompt

Reads the password. Injected for testing.

getpass
out Printer

Receives progress output. Injected for testing.

print

Returns:

Type Description
int

Process exit code — 0 on success.

pyhood.onboarding.setup_crypto(force=False, verify=True, secret_prompt=getpass.getpass, out=print)

Generate a Crypto API key pair and store it.

The private key is generated on this machine and written directly to the credentials file — it is never displayed. Only the public key is shown, which is the half Robinhood needs.

Parameters:

Name Type Description Default
force bool

Replace an existing credentials file. Without this, an existing file is left alone, since overwriting it would revoke working keys.

False
verify bool

Make one signed read-only call afterwards to confirm the pair is accepted.

True
secret_prompt Prompt

Reads the API key. Injected for testing.

getpass
out Printer

Receives progress output. Injected for testing.

print

Returns:

Type Description
int

Process exit code — 0 on success.