Zorro Plugin [iOS Pro]
To improve usability:
double PLUGIN_CALL(char* name, double* params, int nParams) if(strcmp(name, "sentiment") == 0 && nParams >= 1) // params[0] is a pointer to a string? Actually passed as double hack. // Better: pass ticker as string via a separate function. return get_sentiment((char*)(int)params[0]); // unsafe but illustrative
double get_sentiment(const char* ticker) char url[256]; snprintf(url, sizeof(url), "https://newsapi.org/v2/everything?q=%s", ticker); // Perform HTTP request -> jsonResponse double score = model->predict(jsonResponse); return score; zorro plugin
Zorro Plugin: Architecture, Implementation, and Application in Algorithmic Trading Systems
function run()
plugin("myplugin.dll"); print(plugin_call("add", 5, 3)); // prints 8.000000
gcc -shared -o myplugin.dll minimal_plugin.c Use in Zorro: // Perform HTTP request ->
__declspec(dllexport) double PLUGIN_CALL(char* name, double* params, int n) if(strcmp(name, "add") == 0 && n == 2) return params[0] + params[1]; if(strcmp(name, "mul") == 0 && n == 2) return params[0] * params[1]; return 0;