Login Page - Create Account

DTC Protocol Discussion Forum


Date/Time: Fri, 29 Nov 2024 14:36:38 +0000



Post From: Python interface for DTC protocol library

[2017-04-09 16:29:17]
Queeq - Posts: 42
I finally managed to make it importable. Had to add some ignores to DTCProtocol.i:

%module DTCProtocol

%{
#define SWIG_FILE_WITH_INIT
#include "DTCProtocol.h"
%}

%ignore s_MarketDepthFullUpdate20;
%ignore s_MarketDepthFullUpdate10;

%include "DTCProtocol.h"

And also add -lstdc++ when creating .so. Thus, the complete list of commands is as follows:

swig -c++ -python DTCProtocol.i
gcc -O2 -fPIC -std=c++11 -c DTCProtocol.cpp DTCProtocol_wrap.cxx -I/usr/include/python3.5
gcc -shared DTCProtocol.o DTCProtocol_wrap.o -o _DTCProtocol.so -lstdc++

Seems to work now:

>>> import DTCProtocol
>>> print(DTCProtocol.cvar.CURRENT_VERSION)
<Swig Object of type 'int32_t *' at 0x7fc50173fa20>

Not sure how to use it from a Python script yet, but I think I'll figure it out.
Date Time Of Last Edit: 2017-04-09 16:31:40