-
Notifications
You must be signed in to change notification settings - Fork 187
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8bd2082
commit d32f42b
Showing
29 changed files
with
199 additions
and
65 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,4 @@ docs/_build/ | |
# Other | ||
.project | ||
.venv/ | ||
target/ |
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,47 @@ | ||
set(NAME binding_java) | ||
project(${NAME}) | ||
set(SWIG_TARGET_NAME ccapi_${NAME}) | ||
|
||
# Find Java and JNI | ||
find_package(Java COMPONENTS Development REQUIRED) | ||
message(STATUS "Java_VERSION: ${Java_VERSION}") | ||
message(STATUS "Java_JAVA_EXECUTABLE: ${Java_JAVA_EXECUTABLE}") | ||
find_package(JNI REQUIRED) | ||
message(STATUS "JNI_FOUND: ${JNI_FOUND}") | ||
|
||
set(JAVA_DOMAIN_NAME "cryptochassis") | ||
set(JAVA_DOMAIN_EXTENSION "com") | ||
|
||
set(JAVA_GROUP "${JAVA_DOMAIN_EXTENSION}.${JAVA_DOMAIN_NAME}") | ||
set(JAVA_ARTIFACT "ccapi") | ||
|
||
set(JAVA_PACKAGE "${JAVA_GROUP}.${JAVA_ARTIFACT}") | ||
|
||
set_property(SOURCE ${SWIG_INTERFACE} PROPERTY CPLUSPLUS ON) | ||
set_property(SOURCE ${SWIG_INTERFACE} PROPERTY COMPILE_OPTIONS "-package;${JAVA_PACKAGE};-doxygen") | ||
|
||
swig_add_library(${SWIG_TARGET_NAME} | ||
LANGUAGE java | ||
OUTPUT_DIR ${CMAKE_BINARY_DIR}/java/${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(JAVA_PACKAGING_TARGET_NAME java_${PACKAGING_DIR}) | ||
add_custom_target(${JAVA_PACKAGING_TARGET_NAME} ALL | ||
COMMAND ${Java_JAVAC_EXECUTABLE} -d ${PACKAGING_DIR_FULL} ${CMAKE_CURRENT_BINARY_DIR}/${SWIG_TARGET_NAME}/*.java | ||
COMMAND ${Java_JAR_EXECUTABLE} cf ${JAVA_ARTIFACT}-${BUILD_VERSION}.jar ${JAVA_DOMAIN_EXTENSION}/${JAVA_DOMAIN_NAME}/${JAVA_ARTIFACT}/** | ||
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:${SWIG_TARGET_NAME}> ${PACKAGING_DIR_FULL} | ||
WORKING_DIRECTORY ${PACKAGING_DIR_FULL} | ||
) | ||
add_dependencies(${JAVA_PACKAGING_TARGET_NAME} ${SWIG_TARGET_NAME}) |
46 changes: 46 additions & 0 deletions
46
binding/java/example/execution_management_simple_request/Main.java
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,46 @@ | ||
import com.cryptochassis.ccapi.EventHandler; | ||
import com.cryptochassis.ccapi.SessionOptions; | ||
import com.cryptochassis.ccapi.SessionConfigs; | ||
import com.cryptochassis.ccapi.Session; | ||
import com.cryptochassis.ccapi.Request; | ||
import com.cryptochassis.ccapi.Event; | ||
import com.cryptochassis.ccapi.map_string_string; | ||
|
||
public class Main { | ||
static class MyEventHandler extends EventHandler { | ||
@Override | ||
public boolean processEvent(Event event, Session session) { | ||
System.out.println(String.format("Received an event:\n%s", event.toStringPretty(2, 2))); | ||
return true; | ||
} | ||
} | ||
public static void main(String[] args) { | ||
if(System.getenv("BINANCE_API_KEY") == null) { | ||
System.err.println("Please set environment variable BINANCE_API_KEY"); | ||
} | ||
if(System.getenv("BINANCE_API_SECRET") == null) { | ||
System.err.println("Please set environment variable BINANCE_API_SECRET"); | ||
} | ||
System.loadLibrary("ccapi_binding_java"); | ||
var eventHandler = new MyEventHandler(); | ||
var option = new SessionOptions(); | ||
var config = new SessionConfigs(); | ||
var session = new Session(option, config, eventHandler); | ||
var request = new Request(Request.Operation.CREATE_ORDER, "binance", "BTCUSDT"); | ||
var param = new map_string_string(); | ||
param.put("SIDE","BUY"); | ||
param.put("QUANTITY","0.0005"); | ||
param.put("LIMIT_PRICE","20000"); | ||
request.appendParam(param); | ||
session.sendRequest(request); | ||
try | ||
{ | ||
Thread.sleep(10000); | ||
} | ||
catch(InterruptedException e) | ||
{ | ||
} | ||
session.stop(); | ||
System.out.println("Bye"); | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
binding/java/example/market_data_simple_subscription/Main.java
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,48 @@ | ||
import com.cryptochassis.ccapi.EventHandler; | ||
import com.cryptochassis.ccapi.SessionOptions; | ||
import com.cryptochassis.ccapi.SessionConfigs; | ||
import com.cryptochassis.ccapi.Session; | ||
import com.cryptochassis.ccapi.Subscription; | ||
import com.cryptochassis.ccapi.SubscriptionList; | ||
import com.cryptochassis.ccapi.Event; | ||
|
||
public class Main { | ||
static class MyEventHandler extends EventHandler { | ||
@Override | ||
public boolean processEvent(Event event, Session session) { | ||
if (event.getType() == Event.Type.SUBSCRIPTION_DATA) { | ||
for (var message : event.getMessageList()) { | ||
System.out.println(String.format("Best bid and ask at %s are:", message.getTimeISO())); | ||
for (var element : message.getElementList()){ | ||
var elementNameValueMap = element.getNameValueMap(); | ||
for (var entry : elementNameValueMap.entrySet()){ | ||
var name = entry.getKey(); | ||
var value = entry.getValue(); | ||
System.out.println(String.format(" %s = %s", name, value)); | ||
} | ||
} | ||
} | ||
} | ||
return true; | ||
} | ||
} | ||
public static void main(String[] args) { | ||
System.loadLibrary("ccapi_binding_java"); | ||
var eventHandler = new MyEventHandler(); | ||
var option = new SessionOptions(); | ||
var config = new SessionConfigs(); | ||
var session = new Session(option, config, eventHandler); | ||
var subscriptionList = new SubscriptionList(); | ||
subscriptionList.add(new Subscription("coinbase", "BTC-USD", "MARKET_DEPTH")); | ||
session.subscribe(subscriptionList); | ||
try | ||
{ | ||
Thread.sleep(10000); | ||
} | ||
catch(InterruptedException e) | ||
{ | ||
} | ||
session.stop(); | ||
System.out.println("Bye"); | ||
} | ||
} |
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
Empty file.
Empty file.
Empty file.
Empty file removed
0
binding/python/example/src/execution_management_simple_subscription/__init__.py
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
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
Oops, something went wrong.