Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .cmake-format.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# CMake format settings
indent_width: 2 # Number of spaces for indentation
continuation_indent_width: 4 # Indentation for continued lines
line_width: 160 # Maximum line width
tab_size: 2 # Tab size (number of spaces per tab)
use_tabs: false # Whether to use tabs instead of spaces
18 changes: 0 additions & 18 deletions .github/workflows/check_cpp_code_style.yml.d

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ jobs:
COMMAND ${{ steps.cmake_and_ninja.outputs.cmake_dir }}/cmake
-DBUILD_PYTHON=ON
-DBUILD_JAVA=ON
-DBUILD_CSHARP=ON
# -DBUILD_CSHARP=ON
# -DBUILD_GO=ON
# -DBUILD_JAVASCRIPT=ON
-DBUILD_TEST=ON
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
* Macros in the compiler command line:
* Define service enablement macro such as `CCAPI_ENABLE_SERVICE_MARKET_DATA`, `CCAPI_ENABLE_SERVICE_EXECUTION_MANAGEMENT`, `CCAPI_ENABLE_SERVICE_FIX`, etc. and exchange enablement macros such as `CCAPI_ENABLE_EXCHANGE_COINBASE`, etc. These macros can be found at the top of [`include/ccapi_cpp/ccapi_session.h`](include/ccapi_cpp/ccapi_session.h).
* Dependencies:
* boost https://boostorg.jfrog.io/artifactory/main/release/1.80.0/source/boost_1_80_0.tar.gz (notice that its include directory is boost).
* boost https://archives.boost.io/release/1.80.0/source/boost_1_80_0.tar.gz (notice that its include directory is boost).
* rapidjson https://github.com/Tencent/rapidjson/archive/refs/tags/v1.1.0.tar.gz (notice that its include directory is rapidjson/include).
* If you use FIX API, also need hffix https://github.com/jamesdbrock/hffix/archive/refs/tags/v1.3.0.tar.gz (notice that its include directory is hffix/include).
* Include directory for this library:
Expand Down Expand Up @@ -277,7 +277,7 @@ Received an event:
]
Bye
```
* Request operation types: `GET_INSTRUMENT`, `GET_INSTRUMENTS`, `GET_RECENT_TRADES`, `GET_HISTORICAL_TRADES`, `GET_RECENT_CANDLESTICKS`, `GET_HISTORICAL_CANDLESTICKS`, `GET_RECENT_AGG_TRADES`, `GET_HISTORICAL_AGG_TRADES`(only applicable to binance family: https://binance-docs.github.io/apidocs/spot/en/#compressed-aggregate-trades-list), ``.
* Request operation types: `GET_SERVER_TIME`, `GET_INSTRUMENT`, `GET_INSTRUMENTS`, `GET_BBOS`, `GET_RECENT_TRADES`, `GET_HISTORICAL_TRADES`, `GET_RECENT_CANDLESTICKS`, `GET_HISTORICAL_CANDLESTICKS`, `GET_RECENT_AGG_TRADES`, `GET_HISTORICAL_AGG_TRADES`(only applicable to binance family: https://binance-docs.github.io/apidocs/spot/en/#compressed-aggregate-trades-list), ``.
* Request parameter names: `LIMIT`, `INSTRUMENT_TYPE`, `CANDLESTICK_INTERVAL_SECONDS`, `START_TIME_SECONDS`, `END_TIME_SECONDS`, `START_TRADE_ID`, `END_TRADE_ID`, `START_AGG_TRADE_ID`, `END_AGG_TRADE_ID`. Instead of these convenient names you can also choose to use arbitrary parameter names and they will be passed to the exchange's native API. See [this example](example/src/market_data_advanced_request/main.cpp).
* Message's `time` represents the exchange's reported timestamp. Its `timeReceived` represents the library's receiving timestamp. `time` can be retrieved by `getTime` method and `timeReceived` can be retrieved by `getTimeReceived` method. (For non-C++, please use `getTimeUnix` and `getTimeReceivedUnix` methods or `getTimeISO` and `getTimeReceivedISO` methods).

Expand Down
73 changes: 41 additions & 32 deletions app/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ if(NOT APPLE AND NOT MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread")
endif()
set(OPENSSL_USE_STATIC_LIBS TRUE)
if (WIN32)
if(WIN32)
set(CMAKE_BUILD_TYPE "Release")
endif()
if(NOT CMAKE_BUILD_TYPE)
Expand All @@ -21,54 +21,58 @@ message(STATUS "CCAPI_PROJECT_DIR: ${CCAPI_PROJECT_DIR}")
if(NOT CCAPI_LEGACY_USE_WEBSOCKETPP)
message(STATUS "use boost beast websocket")
if(NOT BOOST_INCLUDE_DIR)
include(ExternalProject)
ExternalProject_Add(boost
URL https://boostorg.jfrog.io/artifactory/main/release/1.80.0/source/boost_1_80_0.tar.gz
SOURCE_DIR "${CMAKE_BINARY_DIR}/boost"
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ""
TEST_COMMAND ""
)
set(BOOST_INCLUDE_DIR "${CMAKE_BINARY_DIR}/boost")
include(ExternalProject)
ExternalProject_Add(
boost
URL https://archives.boost.io/release/1.80.0/source/boost_1_80_0.tar.gz
SOURCE_DIR "${CMAKE_BINARY_DIR}/boost"
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ""
TEST_COMMAND "")
set(BOOST_INCLUDE_DIR "${CMAKE_BINARY_DIR}/boost")
else()
add_library(boost INTERFACE)
add_library(boost INTERFACE)
endif()
if(NOT RAPIDJSON_INCLUDE_DIR)
include(ExternalProject)
ExternalProject_Add(rapidjson
URL https://github.com/Tencent/rapidjson/archive/refs/tags/v1.1.0.tar.gz
SOURCE_DIR "${CMAKE_BINARY_DIR}/rapidjson"
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ""
TEST_COMMAND ""
)
set(RAPIDJSON_INCLUDE_DIR "${CMAKE_BINARY_DIR}/rapidjson/include")
include(ExternalProject)
ExternalProject_Add(
rapidjson
URL https://github.com/Tencent/rapidjson/archive/refs/tags/v1.1.0.tar.gz
SOURCE_DIR "${CMAKE_BINARY_DIR}/rapidjson"
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ""
TEST_COMMAND "")
set(RAPIDJSON_INCLUDE_DIR "${CMAKE_BINARY_DIR}/rapidjson/include")
else()
add_library(rapidjson INTERFACE)
add_library(rapidjson INTERFACE)
endif()
include_directories(${CCAPI_PROJECT_DIR}/include ${BOOST_INCLUDE_DIR} ${RAPIDJSON_INCLUDE_DIR} ${OPENSSL_INCLUDE_DIR})
include_directories(${CCAPI_PROJECT_DIR}/include ${BOOST_INCLUDE_DIR}
${RAPIDJSON_INCLUDE_DIR} ${OPENSSL_INCLUDE_DIR})
else()
message(STATUS "use websocketpp")
add_compile_definitions(CCAPI_LEGACY_USE_WEBSOCKETPP)
set(RAPIDJSON_INCLUDE_DIR ${CCAPI_PROJECT_DIR}/dependency/rapidjson/include)
set(WEBSOCKETPP_INCLUDE_DIR ${CCAPI_PROJECT_DIR}/dependency/websocketpp)
set(BOOST_INCLUDE_DIR ${CCAPI_PROJECT_DIR}/dependency/boost)
include_directories(${CCAPI_PROJECT_DIR}/include ${WEBSOCKETPP_INCLUDE_DIR} ${BOOST_INCLUDE_DIR} ${RAPIDJSON_INCLUDE_DIR} ${OPENSSL_INCLUDE_DIR})
include_directories(
${CCAPI_PROJECT_DIR}/include ${WEBSOCKETPP_INCLUDE_DIR}
${BOOST_INCLUDE_DIR} ${RAPIDJSON_INCLUDE_DIR} ${OPENSSL_INCLUDE_DIR})
endif()
set(APP_INCLUDE_DIR ${CCAPI_PROJECT_DIR}/app/include)
find_package(OpenSSL REQUIRED)
include_directories(${APP_INCLUDE_DIR})
set(ADDITIONAL_LINK_LIBRARIES "")
if (WIN32)
if(WIN32)
set(ADDITIONAL_LINK_LIBRARIES ws2_32)
endif()
link_libraries(OpenSSL::Crypto OpenSSL::SSL ${ADDITIONAL_LINK_LIBRARIES})
add_compile_options(-Wno-deprecated -Wno-nonnull -Wno-deprecated-declarations)

# If you encountered segmentation fault at run-time, comment out the following line.
if (CMAKE_BUILD_TYPE STREQUAL "Release")
# If you encountered segmentation fault at run-time, comment out the following
# line.
if(CMAKE_BUILD_TYPE STREQUAL "Release")
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
endif()

Expand Down Expand Up @@ -106,19 +110,24 @@ add_compile_definitions(CCAPI_ENABLE_EXCHANGE_MEXC)
find_package(ZLIB REQUIRED)
link_libraries(ZLIB::ZLIB)

# If backtesting, you may want to comment out the following line to improve run-time speed.
# If backtesting, you may want to comment out the following line to improve
# run-time speed.
add_compile_definitions(CCAPI_APP_ENABLE_LOG_INFO)

# If uncommented, the program will print out more information.
# add_compile_definitions(CCAPI_APP_ENABLE_LOG_DEBUG)

# If you have custom logics and want to reuse part of class EventHandlerBase.
# add_compile_definitions(CCAPI_APP_USE_CUSTOM_EVENT_HANDLER)
# get_filename_component(CUSTOM_EVENT_HANDLER_DIRECTORY ${CUSTOM_EVENT_HANDLER_PATH} DIRECTORY)
# get_filename_component(CUSTOM_EVENT_HANDLER_DIRECTORY
# ${CUSTOM_EVENT_HANDLER_PATH} DIRECTORY)
# include_directories(${CUSTOM_EVENT_HANDLER_DIRECTORY})

# If you have custom logics and need to repeatedly rebuild for backtesting, you may want to comment out the following line to improve build-time speed. If so, make sure to
# provide additional environment variables BASE_ASSET_OVERRIDE, QUOTE_ASSET_OVERRIDE, ORDER_PRICE_INCREMENT_OVERRIDE, and ORDER_QUANTITY_INCREMENT_OVERRIDE at run time.
# If you have custom logics and need to repeatedly rebuild for backtesting, you
# may want to comment out the following line to improve build-time speed. If so,
# make sure to provide additional environment variables BASE_ASSET_OVERRIDE,
# QUOTE_ASSET_OVERRIDE, ORDER_PRICE_INCREMENT_OVERRIDE, and
# ORDER_QUANTITY_INCREMENT_OVERRIDE at run time.
# add_compile_definitions(CCAPI_APP_IS_BACKTEST)

add_subdirectory(src/spot_market_making)
Expand Down
Loading
Loading