Suppose we already have a python package/function created on a local machine. This article will guide you through the steps to plug into ALGOGENE for backtest, live-test or real-trading.
For example, we created a simple package called "my_model" on a desktop machine.
Figure 1 - local python package
The whole package just has an empty "__init__.py" file, with a module file "func1.py". The module file contains 3 simple functions as follows.
Figure 2 - source code in "func1"
Then, we can upload the package to ALGOGENE as follows.
- after login the platform, go to [My History] > [Custom File Viewer]
- select "/lib" in the cloud directory, then drag our local packge on it
Figure 3 - upload files to ALGOGENE cloud
Upon successful upload, the cloud directory should look something like.
Figure 4 - cloud file tree
Suppose we want to use "my_diff" function in "func1.py" to calculate the market spread and print the result to console. It can be done as follows:
- after "self.evt" is initialized (at line 8)
- use "self.evt._include(...)" to include our package in python runtime environment (at line 11)
- import our desired module, and declare the module as global variable (at line 12-13)
- we can then call the module functions anywhere in the backtest script (at line 19)
We can find the calculated results from console.
Figure 5 - console log