HSend / TSend - Signal Sender Plugins (HTTP & TCP)

Hi all,
Happy holidays and new years.
Sharing a couple of plugin dll(s)

What it does:
Sends signals/data from AmiBroker to external applications on localhost:5000.

  • HSend - HTTP POST (JSON) - good for Flask, Node.js, REST APIs
  • TSend - Raw TCP - lightweight, low latency

AFL usage:
result = HSend("BUY,AAPL,100"); // HTTP
result = TSend("BUY,AAPL,100"); // TCP

Returns 1 on success, 0 on failure.

Link:
https://github.com/Sggin1/ami_dll

Pre-compiled 64-bit DLLs included using g++. Source code available if you want to modify or build.
Use at your own risk, minimal testing on a windows 10 w/ amibroker 7 w/o issues
Any problems, questions or ideas please share.
Thanks to the community for all the help over the years. Hope this is useful to someone.

1 Like

Hi,

#pragma pack(push, 2)

without a closing pop, is this intentional? at the top.
And what are you actually packing in 2Byte?

compiler may end up changing everything that follows risking memory corruption. std 64bit dll alignment is 8Byte

Hi,

removed #pragma pack(push, 2) from both HSend.cpp and TSend.cpp.
When I first started on the dll, it initially took a while to get a working version and that was left over from some initial testing. I haven't tested this version in action , but both compiled and the github, has been updated.

thank you for pointing it out nsm51 !

1 Like

I've spent over a year &a_half now only socket/websocket/json/ADK etc and the wild c++ demon in me which I was able to tame.

One reason you get performance in C++ is because it does only what its told.
For example, AFL does tons of checks and makes the users life easy. C++ is unforgiving.

for example you cant do this

char jsonPayload[2048];
sprintf(jsonPayload,
    "{\"timestamp\":\"%s\",\"chartID\":%d,\"payload\":\"%s\"}",
    timeStr, chartId, payload);

payload comes from user:

  1. you need guard code to make sure everything fits in 2048
  2. guard code to ensure no double quote, closing braces, back slash, new line etc is there to corrupt json. I use RapidJson for conformance.

Your WinHttp* func is blocking,and doesn't seem to handle if local server is not reachable.

Its good to see AB users go in this direction but we also have to adhere to c++ strictness.

1 Like