-
Notifications
You must be signed in to change notification settings - Fork 204
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #405 from crypto-chassis/develop
Release
Showing
42 changed files
with
477 additions
and
110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -148,3 +148,5 @@ docs/_build/ | |
# Other | ||
.project | ||
.venv/ | ||
target/ | ||
obj/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
set(NAME binding_csharp) | ||
project(${NAME}) | ||
set(SWIG_TARGET_NAME ccapi_${NAME}) | ||
|
||
# Find dotnet cli | ||
find_program(DOTNET_EXECUTABLE NAMES dotnet REQUIRED) | ||
if(NOT DOTNET_EXECUTABLE) | ||
message(FATAL_ERROR "Check for dotnet Program: not found") | ||
else() | ||
message(STATUS "Found dotnet Program: ${DOTNET_EXECUTABLE}") | ||
endif() | ||
|
||
execute_process( | ||
COMMAND ${DOTNET_EXECUTABLE} --version | ||
OUTPUT_VARIABLE DOTNET_EXECUTABLE_VERSION | ||
OUTPUT_STRIP_TRAILING_WHITESPACE | ||
) | ||
message(STATUS "Dotnet version: ${DOTNET_EXECUTABLE_VERSION}") | ||
|
||
# set(CSHARP_DOMAIN_NAME "cryptochassis") | ||
# set(CSHARP_DOMAIN_EXTENSION "com") | ||
|
||
# set(CSHARP_GROUP "${CSHARP_DOMAIN_EXTENSION}.${CSHARP_DOMAIN_NAME}") | ||
# set(CSHARP_ARTIFACT "ccapi") | ||
|
||
set(CSHARP_NAMESPACE "ccapi") | ||
|
||
set_property(SOURCE ${SWIG_INTERFACE} PROPERTY CPLUSPLUS ON) | ||
set_property(SOURCE ${SWIG_INTERFACE} PROPERTY COMPILE_OPTIONS "-namespace;${CSHARP_NAMESPACE};-dllimport;${SWIG_TARGET_NAME}.so") | ||
# set_property(SOURCE ${SWIG_INTERFACE} PROPERTY COMPILE_OPTIONS "-package;${CSHARP_PACKAGE};-doxygen") | ||
|
||
swig_add_library(${SWIG_TARGET_NAME} | ||
LANGUAGE csharp | ||
OUTPUT_DIR ${CMAKE_BINARY_DIR}/csharp/${SWIG_TARGET_NAME} | ||
SOURCES ${SWIG_INTERFACE} ${SOURCE_LOGGER}) | ||
|
||
if(NOT CCAPI_LEGACY_USE_WEBSOCKETPP) | ||
add_dependencies(${SWIG_TARGET_NAME} boost rapidjson hffix) | ||
endif() | ||
# set_property(TARGET ${SWIG_TARGET_NAME} PROPERTY SWIG_USE_TARGET_INCLUDE_DIRECTORIES ON) | ||
# target_include_directories(${SWIG_TARGET_NAME} | ||
# PRIVATE | ||
# ${JNI_INCLUDE_DIRS} | ||
# ) | ||
|
||
|
||
|
||
set(PACKAGING_DIR packaging) | ||
set(PACKAGING_DIR_FULL ${CMAKE_CURRENT_BINARY_DIR}/${PACKAGING_DIR}/${BUILD_VERSION}) | ||
file(MAKE_DIRECTORY ${PACKAGING_DIR_FULL}) | ||
|
||
set(SRC_DIR_FULL ${CMAKE_CURRENT_BINARY_DIR}/src) | ||
file(MAKE_DIRECTORY ${SRC_DIR_FULL}) | ||
|
||
configure_file( | ||
ccapi.csproj.in | ||
${SRC_DIR_FULL}/ccapi.csproj | ||
@ONLY) | ||
set(CSHARP_PACKAGING_TARGET_NAME csharp_${PACKAGING_DIR}) | ||
add_custom_target(${CSHARP_PACKAGING_TARGET_NAME} ALL | ||
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/${SWIG_TARGET_NAME}/*.cs ${SRC_DIR_FULL} | ||
# COMMAND ${DOTNET_EXECUTABLE} build -c ${CMAKE_BUILD_TYPE} ccapi.csproj | ||
COMMAND ${DOTNET_EXECUTABLE} build -c ${CMAKE_BUILD_TYPE} -o ${PACKAGING_DIR_FULL} ccapi.csproj | ||
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:${SWIG_TARGET_NAME}> ${PACKAGING_DIR_FULL} | ||
WORKING_DIRECTORY ${SRC_DIR_FULL} | ||
) | ||
add_dependencies(${CSHARP_PACKAGING_TARGET_NAME} ${SWIG_TARGET_NAME}) | ||
|
||
# COMMAND ${Java_JAVAC_EXECUTABLE} -d ${PACKAGING_DIR_FULL} ${CMAKE_CURRENT_BINARY_DIR}/${SWIG_TARGET_NAME}/*.java | ||
# COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:${SWIG_TARGET_NAME}> ${PACKAGING_DIR_FULL} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net6.0</TargetFramework> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
</Project> |
38 changes: 38 additions & 0 deletions
38
binding/csharp/example/execution_management_simple_request/MainProgram.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
class MainProgram | ||
{ | ||
class MyEventHandler : ccapi.EventHandler { | ||
public override bool ProcessEvent(ccapi.Event event_, ccapi.Session session) { | ||
System.Console.WriteLine(System.String.Format("Received an event:\n%s", event_.ToStringPretty(2, 2))); | ||
return true; | ||
} | ||
} | ||
static void Main(string[] args) | ||
{ | ||
if(System.Environment.GetEnvironmentVariable("OKX_API_KEY") is null) { | ||
System.Console.Error.WriteLine("Please set environment variable OKX_API_KEY"); | ||
return; | ||
} | ||
if(System.Environment.GetEnvironmentVariable("OKX_API_SECRET") is null) { | ||
System.Console.Error.WriteLine("Please set environment variable OKX_API_SECRET"); | ||
return; | ||
} | ||
if(System.Environment.GetEnvironmentVariable("OKX_API_PASSPHRASE") is null) { | ||
System.Console.Error.WriteLine("Please set environment variable OKX_API_PASSPHRASE"); | ||
return; | ||
} | ||
var eventHandler = new MyEventHandler(); | ||
var option = new ccapi.SessionOptions(); | ||
var config = new ccapi.SessionConfigs(); | ||
var session = new ccapi.Session(option, config, eventHandler); | ||
var request = new ccapi.Request(Request.Operation.CREATE_ORDER, "okx", "BTC-USDT"); | ||
var param = new ccapi.MapStringString(); | ||
param.Add("SIDE","BUY"); | ||
param.Add("QUANTITY","0.0005"); | ||
param.Add("LIMIT_PRICE","20000"); | ||
request.AppendParam(param); | ||
session.SendRequest(request); | ||
System.Threading.Thread.Sleep(10000); | ||
session.Stop(); | ||
System.Console.WriteLine("Bye"); | ||
} | ||
} |
Oops, something went wrong.