user_cache

Classes

UserCache

User Cache / Config for accessing and storing user-specific data.

Module Contents

class user_cache.UserCache(/, **data)

Bases: pydantic.BaseModel

User Cache / Config for accessing and storing user-specific data. The cache contains any secrets, as well as the paths t secrets. The user may specify the JSON file to use for the cache via the environment variable RR_TRADING_USER_CACHE_PATH. If this variable is not set, the default path is ~/.rr_trading/user_cache.json.

Parameters:

data (Any)

polygon_access_token_path: pathlib.Path = None
alpaca_api_key_live: pydantic.SecretStr = None
alpaca_api_secret_live: pydantic.SecretStr = None
alpaca_api_key: pydantic.SecretStr = None
alpaca_api_secret: pydantic.SecretStr = None
r2_access_key_id: pydantic.SecretStr = None
r2_secret_access_key: pydantic.SecretStr = None
r2_endpoint_url: str = None
out_dir: pathlib.Path = None
backtest_dir: pathlib.Path = None
classmethod user_cache_path()
Return type:

pathlib.Path

dump_secret(v)
__setattr__(name, value)

Override the __setattr__ method to save the cache whenever a new attribute is set.

__getattribute__(name)
property polygon_access_token: str | None

Get the Polygon.io access token from the specified path.

Return type:

Optional[str]

classmethod load()

Load the user cache from a JSON file. If the file does not exist, create it with default values.

Return type:

UserCache

save()

Save the user cache to a JSON file.

Return type:

None

delete()

Delete the user cache file.

Return type:

None