trivionomicon: ibkr-tws-api: initial commit
This commit is contained in:
parent
652871f78f
commit
64721389f6
3 changed files with 194 additions and 0 deletions
|
|
@ -1,12 +1,15 @@
|
|||
final: prev:
|
||||
with prev.lib; let
|
||||
inherit (final) callPackage;
|
||||
intel-decimalfp = callPackage ./intel-decimalfp {};
|
||||
in {
|
||||
override = {};
|
||||
|
||||
athena-bccr = callPackage ./athena-bccr {vendor = "athena";};
|
||||
ibkr-tws = callPackage ./ibkr-tws {};
|
||||
ibkr-tws-api = callPackage ./ibkr-tws-api {inherit intel-decimalfp;};
|
||||
idopte-bccr = callPackage ./athena-bccr {vendor = "idopte";};
|
||||
inherit intel-decimalfp;
|
||||
snapborg = final.python3Packages.callPackage ./snapborg {};
|
||||
socialpredict = callPackage ./socialpredict {};
|
||||
spliit = callPackage ./spliit {};
|
||||
|
|
|
|||
150
pkgs/ibkr-tws-api/default.nix
Normal file
150
pkgs/ibkr-tws-api/default.nix
Normal file
|
|
@ -0,0 +1,150 @@
|
|||
{
|
||||
cmake,
|
||||
lib,
|
||||
fetchzip,
|
||||
intel-decimalfp,
|
||||
pkg-config,
|
||||
protobuf,
|
||||
python3Packages,
|
||||
stdenv,
|
||||
}: let
|
||||
version = "1044.01";
|
||||
|
||||
src-with-protobuf = stdenv.mkDerivation {
|
||||
pname = "ibkr-tws-api-src";
|
||||
inherit version;
|
||||
|
||||
src = fetchzip {
|
||||
url = "https://interactivebrokers.github.io/downloads/twsapi_macunix.${version}.zip";
|
||||
hash = "sha256-9bi2Mgp3qDHz8R2lrXEOYIeBffRKOWqKxDYecybR8Eo=";
|
||||
stripRoot = false;
|
||||
};
|
||||
|
||||
nativeBuildInputs = [
|
||||
protobuf
|
||||
];
|
||||
|
||||
configurePhase = ''
|
||||
runHook preConfigure
|
||||
|
||||
rm IBJts/source/{cppclient/client/protobufUnix/*,pythonclient/ibapi/protobuf/*}
|
||||
protoc \
|
||||
-IIBJts/source/proto \
|
||||
--cpp_out=IBJts/source/cppclient/client/protobufUnix \
|
||||
--python_out=IBJts/source/pythonclient/ibapi/protobuf \
|
||||
IBJts/source/proto/*.proto
|
||||
|
||||
sed -i '/^import / { s/\(\<[A-Za-z0-9_]*[A-Za-z0-9]_pb2\)/ibapi.protobuf.\1/g }' IBJts/source/pythonclient/ibapi/protobuf/*.py
|
||||
touch IBJts/source/pythonclient/ibapi/protobuf/__init__.py
|
||||
|
||||
runHook postConfigure
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
|
||||
cp -r . $out
|
||||
|
||||
runHook postInstall
|
||||
'';
|
||||
};
|
||||
|
||||
native-lib = stdenv.mkDerivation {
|
||||
pname = "ibkr-tws-api-native";
|
||||
inherit version;
|
||||
|
||||
src = src-with-protobuf;
|
||||
sourceRoot = "ibkr-tws-api-src-${version}/IBJts/source/cppclient/client";
|
||||
|
||||
buildInputs = [
|
||||
intel-decimalfp
|
||||
protobuf
|
||||
];
|
||||
|
||||
postPatch = ''
|
||||
sed -i 's/-std=c++11/-std=c++17/' makefile
|
||||
'';
|
||||
|
||||
makeFlags = [
|
||||
"LIB_DIR=${intel-decimalfp}/lib"
|
||||
"LIB_NAME=libbid.a"
|
||||
];
|
||||
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
|
||||
mkdir -p $out/lib
|
||||
cp -v lib*.so $out/lib
|
||||
|
||||
runHook postInstall
|
||||
'';
|
||||
};
|
||||
|
||||
test-client = stdenv.mkDerivation {
|
||||
pname = "ibkr-tws-api-test-client";
|
||||
inherit version;
|
||||
|
||||
src = src-with-protobuf;
|
||||
sourceRoot = "ibkr-tws-api-src-${version}/IBJts/samples/Cpp/TestCppClient";
|
||||
|
||||
nativeBuildInputs = [
|
||||
pkg-config
|
||||
];
|
||||
|
||||
buildInputs = [
|
||||
intel-decimalfp
|
||||
native-lib
|
||||
protobuf
|
||||
];
|
||||
|
||||
postPatch = ''
|
||||
sed -i "s/-std=c++11/-std=c++17/; s@-lprotobuf@$(pkg-config --libs protobuf)@" makefile
|
||||
'';
|
||||
|
||||
makeFlags = [
|
||||
"TestCppClientDynamic"
|
||||
"LIB_DIR=${intel-decimalfp}/lib"
|
||||
"LIB_NAME_SO=libbid.a"
|
||||
"SOURCE_DIR=${native-lib}/lib"
|
||||
];
|
||||
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
|
||||
mkdir -p $out/bin
|
||||
install -m755 TestCppClientDynamic $out/bin/TestCppClient
|
||||
|
||||
runHook postInstall
|
||||
'';
|
||||
|
||||
postFixup = ''
|
||||
patchelf --add-rpath ${native-lib}/lib $out/bin/TestCppClient
|
||||
'';
|
||||
|
||||
meta = {
|
||||
mainProgram = "TestCppClient";
|
||||
};
|
||||
};
|
||||
|
||||
py-client = {
|
||||
buildPythonPackage,
|
||||
protobuf,
|
||||
}:
|
||||
buildPythonPackage {
|
||||
pname = "ibapi-python";
|
||||
inherit version;
|
||||
|
||||
src = src-with-protobuf;
|
||||
sourceRoot = "ibkr-tws-api-src-${version}/IBJts/source/pythonclient";
|
||||
|
||||
format = "setuptools";
|
||||
|
||||
propagatedBuildInputs = [
|
||||
protobuf
|
||||
];
|
||||
};
|
||||
in {
|
||||
inherit test-client;
|
||||
native = native-lib;
|
||||
ibapi-python = python3Packages.callPackage py-client {};
|
||||
}
|
||||
41
pkgs/intel-decimalfp/default.nix
Normal file
41
pkgs/intel-decimalfp/default.nix
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
{
|
||||
fetchzip,
|
||||
lib,
|
||||
stdenv,
|
||||
}: let
|
||||
version = "20U3";
|
||||
in
|
||||
stdenv.mkDerivation {
|
||||
pname = "intel-decimalfp";
|
||||
inherit version;
|
||||
|
||||
src = fetchzip {
|
||||
url = "https://www.netlib.org/misc/intel/IntelRDFPMathLib${version}.tar.gz";
|
||||
hash = "sha256-m+Yp1IwVEEZIz+cMQXHhkQrrWeRDfIk9ey7nWvV+u44=";
|
||||
stripRoot = false;
|
||||
};
|
||||
|
||||
sourceRoot = "source/LIBRARY";
|
||||
|
||||
makeFlags = [
|
||||
"OBJ_DIR=$(out)/lib"
|
||||
"LIB_DIR=$(out)/lib"
|
||||
];
|
||||
|
||||
preBuild = ''
|
||||
mkdir -p $out/lib
|
||||
touch $out/lib/.directory_exists
|
||||
'';
|
||||
|
||||
postBuild = ''
|
||||
rm $out/lib/.directory_exists
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
|
||||
rm -f $out/lib/*.o
|
||||
|
||||
runHook postInstall
|
||||
'';
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue