You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+13-40Lines changed: 13 additions & 40 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,6 +7,7 @@
7
7
[](https://github.com/SeaQL/sea-orm/stargazers/) If you like what we do, consider starring, sharing and contributing!
# Investing Algorithm Framework App Deployment to Azure Functions
2
+
3
+
This article demonstrates how to deploy your trading bot to Azure Functions.
4
+
We will deploy an example bot that uses the investing algorithm framework to
5
+
azure functions. In order to do that we will do the following:
6
+
7
+
1. Create a new app using the framework with the azure blob storage state handler.
8
+
2. Use the framework provided ci tools to create a azure functions ready application.
9
+
3. Use the framework provided ci tools to deploy the application to azure functions.
10
+
11
+
## Prerequisites
12
+
13
+
For this example, you need to have the following:
14
+
15
+
- An Azure account with an active subscription. [Create an account](https://azure.microsoft.com/en-us/free/)
16
+
- The Azure CLI installed. [Install the Azure CLI](https://docs.microsoft.com/en-us/cli/azure/install-azure-cli)
17
+
- The Azure Functions Core Tools installed. [Install the Azure Functions Core Tools](https://docs.microsoft.com/en-us/azure/azure-functions/functions-run-local)
18
+
- The investing algorithm framework installed. [Install the framework]() or simply run `pip install investing_algorithm_framework`
19
+
20
+
### Creating a new app
21
+
22
+
First run the following command to create a new app azure functions ready app:
23
+
24
+
```bash
25
+
create_azure_function_trading_bot_app
26
+
```
27
+
28
+
This command will create a new app with the following structure:
29
+
30
+
```yaml
31
+
.
32
+
├── function_app.py
33
+
├── host.json
34
+
├── local.settings.json
35
+
└── requirements.txt
36
+
```
37
+
38
+
The function_app.py while import the app from the app.py file in the root of the project and run it as an azure function. It is therefore important that you have a file named `app.py` in the root of your project that defines the application in a variable named `app`.
39
+
40
+
Additionaly, because Azure Functions are stateless, you need to use a state storage solution. In this example, we will use Azure Blob Storage state handler provided by the framework. This state handler is specifically designed to work with Azure Functions and Azure Blob Storage.
41
+
42
+
The reason why we need a state storage solution is that Azure Functions are stateless. This means that each function execution is independent of the previous one. This is a problem for trading bots because they need to keep track of their state between executions (portfolios, order, positions and trades). In order to solve this problem, we need to use a state storage solution that can store the bot's databases between executions.
43
+
44
+
Combining all of this, the `app.py` file should look like this:
45
+
46
+
> When you are using the cli command 'deploy_trading_bot_to_azure_function' (which we will use later) you don't need to provide any connection strings. The command will take care of provisioning all
47
+
> resourses and configuration of all required parameters for the state handler.
48
+
49
+
```python
50
+
from investing_algorithm_framework import AzureBlobStorageStateHandler, create_app
# Write here your code where your register your portfolio configurations, strategies and data providers
55
+
....
56
+
```
57
+
58
+
## Deployment to Azure
59
+
60
+
To deploy your trading bot to Azure Functions, you need to run the following command:
61
+
62
+
```bash
63
+
deploy_trading_bot_to_azure_function
64
+
```
65
+
66
+
This command will do the following:
67
+
68
+
- Create a new resource group in your Azure account.
69
+
- Create a new storage account in the resource group.
70
+
- Create a new blob container in the storage account.
71
+
- Create a new function app in the resource group.
72
+
- Deploy the trading bot to the function app.
73
+
- Configure the function app to use the blob container as the state handler.
74
+
- Print the URL of the function app.
75
+
76
+
After running the command, you will see the URL of the function app. You can use this URL to access your trading bot. Now your trading bot is running on Azure Functions!
0 commit comments