Skip to Content
NeurotraderDocs
How-to guides

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.

Screenshot
The Algorithms page with the Your algorithms group holding two plugin algorithms, one Available and one Not loaded, the Built-in group below, and the detail pane open on the selected plugin algorithm with its Load, Reload and Remove library buttons

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.

  1. Open Algorithms and choose Add algorithm.
  2. On How, choose Upload a package, then Next.
  3. 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.
  4. Choose Next, check the Review step, and choose Add algorithm.
Screenshot
The Add algorithm dialog on its first step, How, with the two choices side by side: Upload a package, selected, and Link a project

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.

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.

  1. Open Algorithms and choose Add algorithm.

  2. On How, choose Link a project, then Next.

  3. Fill in the Where step:

    FieldWhat to enter
    Project directoryThe full path of the project folder, the one with Cargo.toml at its root
    Build commandThe command that builds it. The default is cargo build --release.
    ArtifactWhere the build leaves the library, relative to the project directory. Leave it empty and the engine works it out from the project's manifest.
  4. Choose Next, check the Review step, and choose Add algorithm.

Screenshot
The Add algorithm dialog on the Where step for Link a project, with the Project directory, Build command and Artifact fields filled in and the note that the build runs as the engine's own user

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 target folder, 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:

ActionOffered whenEffect
Load (Load library in the menu)The plugin is Not loaded or Failed to loadLoads the library. Its algorithms become available.
Unload (Unload library)The plugin is AvailableLets go of the library. Its algorithms stay listed and cannot run.
Reload (Reload library)Always, except while it is BuildingUnloads 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

  1. Select one of the plugin's algorithms.
  2. Choose Remove library… in the detail pane or the row's menu.
  3. 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

StateDotMeaningAction
AvailableGreenLoaded and ready to runNothing
Not loadedAmberThe engine holds the plugin but has not loaded itChoose Load
Failed to loadRedThe last load did not succeed. The detail pane shows the reason.Fix the cause, then upload a new build, Build, or Load
BuildingGrey, pulsingThe engine is building a linked projectWait 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.

MessagereasonMeaning and remedy
A plugin with this name is already in the catalog.plugin_existsThe 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_useStop the run or wait for it, then ask again.
The engine is building this plugin.plugin_buildingWait for the build to end.
The package publishes an algorithm id another library already provides.algorithm_id_clashTwo 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_packageThe 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_largeThe file is over the size limit.
The engine could not load the package.not_loadableThe 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_nameUse only letters, digits, - and _ in the package name, at most 64 characters.
The upload did not reach the engine whole.bad_uploadTry again.
The plugin is already loaded. / The plugin is not loaded.already_loaded, not_loadedThe plugin is already in the state you asked for.
Only a linked project can be built.not_linkedBuild applies to linked projects. Upload a new package instead.
The engine no longer has this plugin.no_such_pluginIt 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.

TaskOperation
List pluginslist_plugins
Read one pluginget_plugin
Upload a packageupload_plugin
Link a projectlink_plugin
Build a linked projectbuild_plugin
Load, unload, reloadload_plugin, unload_plugin, reload_plugin
Reload every pluginreload_plugins
Remove a pluginremove_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"}'

On this page