-
Notifications
You must be signed in to change notification settings - Fork 86
Closed
Description
Azure Storage provides a simple, scalable, and cost-effective way to save state and could be used to allow users to run their algorithm stateless in an Azure function but still store their state in between runs in a azure blob container.
Initialisation should look like this:
from investing_algorithm_framework import AzureBlobStorageStateHandler
from azure.storage.blob import BlobServiceClient
connection_string = "<your_connection_string>"
container_name = "my-container"
state_handler = AzureBlobStorageStateHandler(connection_string, container_name=container_name)
app = create_app(config=config, state_handler=state_handler)
... Do all you algorithm initializationImplementation of the state handler should look something like below:
from azure.storage.blob import BlobServiceClient
connection_string = "<your_connection_string>"
blob_service_client = BlobServiceClient.from_connection_string(connection_string)
container_name = "my-container"
blob_name = "my-state.json"
# Write state
blob_client = blob_service_client.get_blob_client(container=container_name, blob=blob_name)
blob_client.upload_blob("My serialized state", overwrite=True)
# Read state
download_stream = blob_client.download_blob()
state = download_stream.readall()
Class AzureBlobStorageStateHandler(StateHandler):
.....
def store(algorithm):
def load_portfolio() -> Portfolio
def load_orders() -> List[Order]
def load_trades() -> List[Trade]
def load_position() -> List[Position]Metadata
Metadata
Assignees
Labels
No labels