quantpylib.utilities.general
backup_folder(s3, local, bucket, ignore=['.*', '*.parquet.*'])
async
Backup a local folder to an S3 bucket.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
s3
|
object
|
The async S3 client. |
required |
local
|
str
|
The local folder path. |
required |
bucket
|
str
|
The S3 bucket name. |
required |
ignore
|
list
|
List of patterns to ignore. Defaults to ['.','.parquet.*']. |
['.*', '*.parquet.*']
|
get_boto_client(endpoint_url, aws_access_key_id, aws_secret_access_key)
async
Get an async boto3 client.
list_s3_files(s3, bucket)
async
List all files in an S3 bucket.
load_pickle(path)
Loads a Python object from a pickle file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path
|
str
|
The path to the pickle file. |
required |
next_hr(utc=True, timestamp=True)
Get the next hour timestamp.
pdf_snapshot(save, code_file=None, include_comments=True, report_data=[])
Generates a PDF report with high-resolution images and a snapshot of code_file
if given.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
save
|
str
|
Path to save the PDF report. |
required |
code_file
|
str
|
Path to the script file for code snapshot inclusion. Defaults to None. |
None
|
include_comments
|
bool
|
Whether to include comments in the code snapshot. Defaults to |
True
|
report_data
|
list
|
List of tuples containing the data to include in the report. Defaults to |
[]
|
resolve_path(path, make_dir=False, *args, **kwargs)
Resolves a path and returns the directory and file path.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path
|
str
|
The path to resolve. |
required |
make_dir
|
bool
|
Whether to create the directory if it does not exist. Defaults to False. |
False
|
restore_folder(s3, local, bucket, remote_subpaths=[''], match_files=[])
async
Restore a folder from an S3 bucket.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
s3
|
object
|
The async S3 client. |
required |
local
|
str
|
The local folder path. |
required |
bucket
|
str
|
The S3 bucket name. |
required |
remote_subpaths
|
list
|
List of remote subpaths to restore. Defaults to [''] (all). |
['']
|
match_files
|
list
|
List of files to restore. Defaults to |
[]
|
save_pickle(path, obj)
Saves a Python object to a pickle.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path
|
str
|
The path to save the pickle file. |
required |
obj
|
object
|
The Python object to save. |
required |
stopwatch(_func=None, *, units='ms', return_time=False)
A decorator that measures the time taken for a function to execute.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
_func
|
Callable
|
The function/coroutine to decorate. Defaults to None. |
None
|
units
|
str
|
The units to return the time in. Options are 's', 'ms', and 'ns'. Defaults to 'ms'. |
'ms'
|
return_time
|
bool
|
Whether to return the time taken or result of function execution. Defaults to False. |
False
|