-
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 #404 from crypto-chassis/java
docs: update README.md
- Loading branch information
Showing
19 changed files
with
360 additions
and
129 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 |
---|---|---|
|
@@ -149,3 +149,4 @@ docs/_build/ | |
.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"); | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
binding/csharp/example/execution_management_simple_request/main.csproj
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,13 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net6.0</TargetFramework> | ||
<Nullable>enable</Nullable> | ||
<CcapiLibraryPath>to be provided in command line</CcapiLibraryPath> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Reference Include="ccapi"> | ||
<HintPath>$(CcapiLibraryPath)</HintPath> | ||
</Reference> | ||
</ItemGroup> | ||
</Project> |
35 changes: 35 additions & 0 deletions
35
binding/csharp/example/market_data_simple_subscription/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,35 @@ | ||
class MainProgram | ||
{ | ||
class MyEventHandler : ccapi.EventHandler { | ||
public override bool ProcessEvent(ccapi.Event event_, ccapi.Session session) { | ||
if (event_.GetType_() == ccapi.Event.Type.SUBSCRIPTION_DATA) { | ||
foreach (var message in event_.GetMessageList()) { | ||
System.Console.WriteLine(System.String.Format("Best bid and ask at {0} are:", message.GetTimeISO())); | ||
foreach (var element in message.GetElementList()){ | ||
var elementNameValueMap = element.GetNameValueMap(); | ||
foreach(var entry in elementNameValueMap) | ||
{ | ||
var name = entry.Key; | ||
var value = entry.Value; | ||
System.Console.WriteLine(System.String.Format(" {0} = {1}", name, value)); | ||
} | ||
} | ||
} | ||
} | ||
return true; | ||
} | ||
} | ||
static void Main(string[] args) | ||
{ | ||
var eventHandler = new MyEventHandler(); | ||
var option = new ccapi.SessionOptions(); | ||
var config = new ccapi.SessionConfigs(); | ||
var session = new ccapi.Session(option, config, eventHandler); | ||
var subscriptionList = new ccapi.SubscriptionList(); | ||
subscriptionList.Add(new ccapi.Subscription("okx", "BTC-USDT", "MARKET_DEPTH")); | ||
session.Subscribe(subscriptionList); | ||
System.Threading.Thread.Sleep(10000); | ||
session.Stop(); | ||
System.Console.WriteLine("Bye"); | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
binding/csharp/example/market_data_simple_subscription/main.csproj
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,13 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net6.0</TargetFramework> | ||
<Nullable>enable</Nullable> | ||
<CcapiLibraryPath>to be provided in command line</CcapiLibraryPath> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Reference Include="ccapi"> | ||
<HintPath>$(CcapiLibraryPath)</HintPath> | ||
</Reference> | ||
</ItemGroup> | ||
</Project> |
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,2 @@ | ||
%rename("%(camelcase)s", %$isfunction, %$ismember, %$ispublic) ""; | ||
%rename("%(regex:/^(toString|getType|setType)$/\\u\\1_/)s") ""; |
Oops, something went wrong.