Plugin upload
The Algorithms page for your own plugins: upload a built package, link a project on this computer, build, load, unload, reload and remove, with the states and refusals explained.
You have built an algorithm plugin, or you have its project folder, and you want Neurotrader to load it so you can use it in a simulation. You do that on the Algorithms page. This guide covers adding a plugin in both ways and managing it afterwards.
To write a plugin in the first place, see First plugin.
Trusted code
A plugin runs inside the engine with the engine's permissions. It is not sandboxed. Add only plugins you wrote or whose source you trust.
Algorithms page
The Algorithms page lists every algorithm the engine knows, in two groups:
- Your algorithms: the ones that come from plugins you added. This group is shown even when it is empty, with the Add algorithm button.
- Built-in: the algorithms that come with Neurotrader.
Each row carries a coloured dot for its state. Select a row to open the detail pane, which shows the description, every parameter with its default and range, and, for a plugin, the library it came from and the buttons that manage it. The same actions are in the menu behind the row's ellipsis.
One library can publish several algorithms. They appear as separate rows and are managed together: loading, unloading or removing the library affects all of them.
Package upload
Use this when you have a built library file. The engine keeps a copy and loads it straight away.
- Open Algorithms and choose Add algorithm.
- On How, choose Upload a package, then Next.
- On Where, choose the file. In the desktop app, choose Choose a package… and pick it in the file dialog. In a browser, drop it on the dialog or browse for it.
- Choose Next, check the Review step, and choose Add algorithm.
The file must be a native library built for the platform the engine runs on:
.dll on Windows, .so on Linux, .dylib on macOS. The largest accepted
size is 50 MiB.
When it succeeds, a message names the algorithms that were added, and the
first of them is selected in the list. The engine files the library under its
package name, the name in the plugin's Cargo.toml.
If the library was added but could not be loaded, the message says so with the reason, and the row shows Failed to load.
Replacement of an uploaded plugin
To install a new build of a plugin you already added, upload it the same way. The engine recognises the package name and the dialog says the name is taken:
- Replace it installs the new file in place of the old one. The plugin keeps its place in the catalog, and simulations set up with its algorithms keep working as long as the new build still publishes them.
- Keep the existing one closes the dialog and changes nothing.
No restart is needed. A replacement is refused while a run is using the plugin.
Project link
Use this while you are developing. You point the engine at the project folder, and the engine builds it and loads the result. To rebuild after a change, you choose Build instead of uploading a file.
-
Open Algorithms and choose Add algorithm.
-
On How, choose Link a project, then Next.
-
Fill in the Where step:
Field What to enter Project directory The full path of the project folder, the one with Cargo.tomlat its rootBuild command The command that builds it. The default is cargo build --release.Artifact Where the build leaves the library, relative to the project directory. Leave it empty and the engine works it out from the project's manifest. -
Choose Next, check the Review step, and choose Add algorithm.
The dialog closes at once and the plugin's row shows Building. When the build ends, a message reports the outcome and the row becomes Available or Failed to load.
Three things to know about a linked project:
- The path is on the engine's computer. The engine reads the folder itself.
- The build runs as the engine's own user, exactly as typed. The Rust toolchain must be on that user's path. An engine installed as a system service runs under an account of its own, which usually has no toolchain and cannot read your home folder. If the build fails for that reason, build the project yourself and use Package upload.
- The engine keeps a copy of what the build produced. It does not load
the file from your
targetfolder, so you can keep building while a simulation runs.
A build is stopped after fifteen minutes.
Rebuild of a linked project
After you change the code, select one of the plugin's algorithms and choose Build in the detail pane, or Build again in the row's menu.
The build that is loaded stays loaded and usable while the new one compiles. When the build succeeds, the new one replaces it. Rebuilds happen only when you ask for one.
A second link to a project whose package name is already in the catalog is refused. Build the existing one from its menu, or remove it first.
Load, unload and reload
Every plugin you added is loaded when the engine starts. You can also change that while it runs, from the detail pane or the row's menu:
| Action | Offered when | Effect |
|---|---|---|
| Load (Load library in the menu) | The plugin is Not loaded or Failed to load | Loads the library. Its algorithms become available. |
| Unload (Unload library) | The plugin is Available | Lets go of the library. Its algorithms stay listed and cannot run. |
| Reload (Reload library) | Always, except while it is Building | Unloads and loads again |
A simulation that uses an algorithm of an unloaded plugin does not start. It says which algorithm is not loaded. Load the plugin and start it again.
A run that is in progress keeps the code it started with. That is why the engine refuses to unload, reload, replace, rebuild into or remove a plugin while a run is using it. Stop the run, or wait for it to finish, and ask again. There is no way to force it. A paused run does not hold a plugin.
Plugin removal
- Select one of the plugin's algorithms.
- Choose Remove library… in the detail pane or the row's menu.
- Check the list of algorithms it will remove, and choose Remove.
The engine unloads the library, forgets its algorithms and deletes the copy it keeps. Your own project folder and the file you uploaded from are not touched.
A simulation set up with one of the removed algorithms does not start until the plugin is added again. Because an algorithm keeps the id its author gave it, adding the same plugin back makes those simulations work again.
Plugin states
| State | Dot | Meaning | Action |
|---|---|---|---|
| Available | Green | Loaded and ready to run | Nothing |
| Not loaded | Amber | The engine holds the plugin but has not loaded it | Choose Load |
| Failed to load | Red | The last load did not succeed. The detail pane shows the reason. | Fix the cause, then upload a new build, Build, or Load |
| Building | Grey, pulsing | The engine is building a linked project | Wait for the build to end |
A plugin that fails to load never stops the engine from starting. Its algorithms stay listed by name, so a simulation that uses one can tell you what is missing.
Refusals
When the engine refuses an action, the message says why. Over the API the
same refusal carries a reason.
| Message | reason | Meaning and remedy |
|---|---|---|
| A plugin with this name is already in the catalog. | plugin_exists | The package name is taken. On an upload, choose Replace it. On a link, build the existing plugin or remove it first. |
| A run in flight is using this plugin. | plugin_in_use | Stop the run or wait for it, then ask again. |
| The engine is building this plugin. | plugin_building | Wait for the build to end. |
| The package publishes an algorithm id another library already provides. | algorithm_id_clash | Two different plugins use the same algorithm id. Give your algorithm a fresh UUID. Nothing of the package is installed. |
| The engine loads native libraries built for its own platform and nothing else. | unsupported_package | The file is not a native library for this platform, for example a .so sent to an engine on Windows. Build for the engine's platform. |
| The package is larger than the engine accepts. | package_too_large | The file is over the size limit. |
| The engine could not load the package. | not_loadable | The library crashed or hung while loading, is missing a required function, or was built against a version of the SDK the engine does not accept. Rebuild against the current SDK. |
| The library's package name cannot be used as a plugin name. | invalid_name | Use only letters, digits, - and _ in the package name, at most 64 characters. |
| The upload did not reach the engine whole. | bad_upload | Try again. |
| The plugin is already loaded. / The plugin is not loaded. | already_loaded, not_loaded | The plugin is already in the state you asked for. |
| Only a linked project can be built. | not_linked | Build applies to linked projects. Upload a new package instead. |
| The engine no longer has this plugin. | no_such_plugin | It was removed, perhaps from another window. |
Over the API, a link can also be refused with invalid_project_dir (the
path is not an absolute path to a folder) or not_a_rust_project (there is
no Cargo.toml at its root).
API operations
Everything on this page is available over the HTTP API.
| Task | Operation |
|---|---|
| List plugins | list_plugins |
| Read one plugin | get_plugin |
| Upload a package | upload_plugin |
| Link a project | link_plugin |
| Build a linked project | build_plugin |
| Load, unload, reload | load_plugin, unload_plugin, reload_plugin |
| Reload every plugin | reload_plugins |
| Remove a plugin | remove_plugin |
An upload is multipart/form-data with the file in a part named package.
Add ?override=true to replace a plugin of the same name:
curl -X POST "http://127.0.0.1:8080/v1/plugin/upload?override=true" \
-H "Authorization: Bearer $TOKEN" \
-F "package=@target/release/libmy_trend.so"A link names the project folder:
curl -X POST "http://127.0.0.1:8080/v1/plugin/link" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{"project_dir": "/home/you/my-trend", "build_command": "cargo build --release", "rebuild": "manual"}'Related
- First plugin
- Plugin authoring: versions and compatibility
- Algorithm setup: adding an algorithm to a simulation
- Algorithm Assistant use: a plugin written from a description
- Algorithm confirmation
Real-funds runs
Set up, start, watch and stop a Real Trade run in a venue's production environment, and check the venue's own record afterwards.
Algorithm Assistant use
The Assistant pages in the app, step by step: toolchain setup, a new algorithm from a description, a change to an existing one, following the writing, and a first simulation of the result.