working cpp implementation here: https://github.com/milsanore/trader.cpp/blob/master/src/MyApplication.cpp#L55