Skip to content

Commit

Permalink
Merge pull request #342 from crypto-chassis/develop
Browse files Browse the repository at this point in the history
Release
  • Loading branch information
cryptochassis authored Dec 14, 2022
2 parents 8708719 + 321b794 commit afb6198
Show file tree
Hide file tree
Showing 11 changed files with 581 additions and 50 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@
* Code closely follows Bloomberg's API: https://www.bloomberg.com/professional/support/api-library/.
* It is ultra fast thanks to very careful optimizations: move semantics, regex optimization, locality of reference, lock contention minimization, etc.
* Supported exchanges:
* Market data: coinbase, gemini, kraken, kraken-futures, bitstamp, bitfinex, bitmex, binance-us, binance, binance-usds-futures, binance-coin-futures, huobi, huobi-usdt-swap, huobi-coin-swap, okx, erisx, kucoin, kucoin-futures, ftx, ftx-us, deribit, gateio, gateio-perpetual-futures, cryptocom, bybit, bybit-derivatives, ascendex, bitget, bitget-futures, bitmart, mexc, mexc-futures.
* Execution Management: coinbase, gemini, kraken, kraken-futures, bitstamp, bitfinex, bitmex, binance-us, binance, binance-usds-futures, binance-coin-futures, huobi, huobi-usdt-swap, huobi-coin-swap, okx, erisx, kucoin, ftx, ftx-us, deribit, gateio, gateio-perpetual-futures, cryptocom, bybit, bybit-derivatives, ascendex, bitget, bitget-futures, bitmart.
* FIX: coinbase, gemini, ftx, ftx-us.
* Market data: coinbase, gemini, kraken, kraken-futures, bitstamp, bitfinex, bitmex, binance-us, binance, binance-usds-futures, binance-coin-futures, huobi, huobi-usdt-swap, huobi-coin-swap, okx, erisx, kucoin, kucoin-futures, deribit, gateio, gateio-perpetual-futures, cryptocom, bybit, bybit-derivatives, ascendex, bitget, bitget-futures, bitmart, mexc, mexc-futures.
* Execution Management: coinbase, gemini, kraken, kraken-futures, bitstamp, bitfinex, bitmex, binance-us, binance, binance-usds-futures, binance-coin-futures, huobi, huobi-usdt-swap, huobi-coin-swap, okx, erisx, kucoin, deribit, gateio, gateio-perpetual-futures, cryptocom, bybit, bybit-derivatives, ascendex, bitget, bitget-futures, bitmart, mexc.
* FIX: coinbase, gemini.
* A spot market making application is provided as an end-to-end solution for liquidity providers.
* A single order execution application is provided as an end-to-end solution for executing large orders.
* To spur innovation and industry collaboration, this library is open for use by the public without cost.
Expand Down
2 changes: 2 additions & 0 deletions app/user_specified_cmake_include.cmake.example
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ endif()
#
# add_compile_definitions(CCAPI_ENABLE_EXCHANGE_BITMART)
#
# add_compile_definitions(CCAPI_ENABLE_EXCHANGE_MEXC)
#
# find_package(ZLIB REQUIRED)
# link_libraries(ZLIB::ZLIB)

Expand Down
23 changes: 19 additions & 4 deletions include/ccapi_cpp/ccapi_macro.h
Original file line number Diff line number Diff line change
Expand Up @@ -387,8 +387,11 @@
#ifndef CCAPI_EM_ACCOUNT_TYPE
#define CCAPI_EM_ACCOUNT_TYPE "ACCOUNT_TYPE"
#endif
#ifndef CCAPI_EM_ACCOUNT_TYPE_MARGIN
#define CCAPI_EM_ACCOUNT_TYPE_MARGIN "MARGIN"
#ifndef CCAPI_EM_MARGIN_TYPE_CROSS_MARGIN
#define CCAPI_EM_MARGIN_TYPE_CROSS_MARGIN "CROSS_MARGIN"
#endif
#ifndef CCAPI_EM_MARGIN_TYPE_ISOLATED_MARGIN
#define CCAPI_EM_MARGIN_TYPE_ISOLATED_MARGIN "ISOLATED_MARGIN"
#endif
#ifndef CCAPI_EM_ASSET
#define CCAPI_EM_ASSET "ASSET"
Expand All @@ -414,6 +417,9 @@
#ifndef CCAPI_EM_QUOTE_ASSET_QUANTITY_AVAILABLE_FOR_TRADING
#define CCAPI_EM_QUOTE_ASSET_QUANTITY_AVAILABLE_FOR_TRADING "QUOTE_ASSET_QUANTITY_AVAILABLE_FOR_TRADING"
#endif
#ifndef CCAPI_EM_INSTRUMENT
#define CCAPI_EM_INSTRUMENT "INSTRUMENT"
#endif
#ifndef CCAPI_EM_SYMBOL
#define CCAPI_EM_SYMBOL "SYMBOL"
#endif
Expand Down Expand Up @@ -561,8 +567,11 @@
#ifndef CCAPI_BINANCE_LISTEN_KEY_PATH
#define CCAPI_BINANCE_LISTEN_KEY_PATH "/api/v3/userDataStream"
#endif
#ifndef CCAPI_BINANCE_LISTEN_KEY_MARGIN_PATH
#define CCAPI_BINANCE_LISTEN_KEY_MARGIN_PATH "/sapi/v1/userDataStream"
#ifndef CCAPI_BINANCE_LISTEN_KEY_CROSS_MARGIN_PATH
#define CCAPI_BINANCE_LISTEN_KEY_CROSS_MARGIN_PATH "/sapi/v1/userDataStream"
#endif
#ifndef CCAPI_BINANCE_LISTEN_KEY_ISOLATED_MARGIN_PATH
#define CCAPI_BINANCE_LISTEN_KEY_ISOLATED_MARGIN_PATH "/sapi/v1/userDataStream/isolated"
#endif
#ifndef CCAPI_BINANCE_USDS_FUTURES_URL_REST_BASE
#define CCAPI_BINANCE_USDS_FUTURES_URL_REST_BASE "https://fapi.binance.com"
Expand Down Expand Up @@ -690,6 +699,12 @@
#ifndef CCAPI_MEXC_URL_REST_BASE
#define CCAPI_MEXC_URL_REST_BASE "https://api.mexc.com"
#endif
#ifndef CCAPI_MEXC_CREATE_ORDER_PATH
#define CCAPI_MEXC_CREATE_ORDER_PATH "/api/v3/order"
#endif
#ifndef CCAPI_MEXC_LISTEN_KEY_PATH
#define CCAPI_MEXC_LISTEN_KEY_PATH "/api/v3/userDataStream"
#endif
#ifndef CCAPI_MEXC_FUTURES_URL_REST_BASE
#define CCAPI_MEXC_FUTURES_URL_REST_BASE "https://contract.mexc.com"
#endif
Expand Down
8 changes: 4 additions & 4 deletions include/ccapi_cpp/ccapi_request.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ class Request CCAPI_FINAL {
shortCredential.insert(std::make_pair(x.first, UtilString::firstNCharacter(x.second, CCAPI_CREDENTIAL_DISPLAY_LENGTH)));
}
std::string output =
"Request [exchange = " + exchange + ", accountType = " + accountType + ", instrument = " + instrument + ", serviceName = " + serviceName +
"Request [exchange = " + exchange + ", marginType = " + marginType + ", instrument = " + instrument + ", serviceName = " + serviceName +
", correlationId = " + correlationId + ", secondaryCorrelationId = " + secondaryCorrelationId +
(this->serviceName == CCAPI_FIX ? ", paramListFix = " + ccapi::toString(paramListFix) : ", paramList = " + ccapi::toString(paramList)) +
", credential = " + ccapi::toString(shortCredential) + ", operation = " + operationToString(operation) +
Expand All @@ -133,7 +133,7 @@ class Request CCAPI_FINAL {
const std::string& getCorrelationId() const { return correlationId; }
const std::string& getSecondaryCorrelationId() const { return secondaryCorrelationId; }
const std::string& getExchange() const { return exchange; }
const std::string& getAccountType() const { return accountType; }
const std::string& getMarginType() const { return marginType; }
const std::string& getInstrument() const { return instrument; }
const std::map<std::string, std::string>& getCredential() const { return credential; }
const std::string& getServiceName() const { return serviceName; }
Expand Down Expand Up @@ -164,13 +164,13 @@ class Request CCAPI_FINAL {
void setCredential(const std::map<std::string, std::string>& credential) { this->credential = credential; }
void setCorrelationId(const std::string& correlationId) { this->correlationId = correlationId; }
void setSecondaryCorrelationId(const std::string& secondaryCorrelationId) { this->secondaryCorrelationId = secondaryCorrelationId; }
void setAccountType(const std::string& accountType) { this->accountType = accountType; }
void setMarginType(const std::string& marginType) { this->marginType = marginType; }
#ifndef CCAPI_EXPOSE_INTERNAL

private:
#endif
std::string exchange;
std::string accountType;
std::string marginType;
std::string instrument;
std::string serviceName;
std::string correlationId;
Expand Down
7 changes: 7 additions & 0 deletions include/ccapi_cpp/ccapi_session.h
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,9 @@
#ifdef CCAPI_ENABLE_EXCHANGE_BITMART
#include "ccapi_cpp/service/ccapi_execution_management_service_bitmart.h"
#endif
#ifdef CCAPI_ENABLE_EXCHANGE_MEXC
#include "ccapi_cpp/service/ccapi_execution_management_service_mexc.h"
#endif
#endif
// end: enable exchanges for execution management

Expand Down Expand Up @@ -541,6 +544,10 @@ class Session {
this->serviceByServiceNameExchangeMap[CCAPI_EXECUTION_MANAGEMENT][CCAPI_EXCHANGE_NAME_BITMART] =
std::make_shared<ExecutionManagementServiceBitmart>(this->internalEventHandler, sessionOptions, sessionConfigs, this->serviceContextPtr);
#endif
#ifdef CCAPI_ENABLE_EXCHANGE_MEXC
this->serviceByServiceNameExchangeMap[CCAPI_EXECUTION_MANAGEMENT][CCAPI_EXCHANGE_NAME_MEXC] =
std::make_shared<ExecutionManagementServiceMexc>(this->internalEventHandler, sessionOptions, sessionConfigs, this->serviceContextPtr);
#endif
#endif
#ifdef CCAPI_ENABLE_SERVICE_FIX
#ifdef CCAPI_ENABLE_EXCHANGE_COINBASE
Expand Down
8 changes: 4 additions & 4 deletions include/ccapi_cpp/ccapi_subscription.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class Subscription CCAPI_FINAL {
for (const auto& x : credential) {
shortCredential.insert(std::make_pair(x.first, UtilString::firstNCharacter(x.second, CCAPI_CREDENTIAL_DISPLAY_LENGTH)));
}
std::string output = "Subscription [exchange = " + exchange + ", accountType = " + accountType + ", instrumentType = " + instrumentType +
std::string output = "Subscription [exchange = " + exchange + ", marginType = " + marginType + ", instrumentType = " + instrumentType +
", instrument = " + instrument + ", field = " + field + ", optionMap = " + ccapi::toString(optionMap) +
", correlationId = " + correlationId + ", credential = " + ccapi::toString(shortCredential) + ", serviceName = " + serviceName +
", timeSent = " + UtilTime::getISOTimestamp(timeSent) + "]";
Expand Down Expand Up @@ -100,10 +100,10 @@ class Subscription CCAPI_FINAL {
TimePoint getTimeSent() const { return timeSent; }
std::string getTimeSentISO() const { return UtilTime::getISOTimestamp(timeSent); }
std::pair<long long, long long> getTimeSentPair() const { return UtilTime::divide(timeSent); }
const std::string& getAccountType() const { return accountType; }
const std::string& getMarginType() const { return marginType; }
void setTimeSent(TimePoint timeSent) { this->timeSent = timeSent; }
void setInstrumentType(const std::string& instrumentType) { this->instrumentType = instrumentType; }
void setAccountType(const std::string& accountType) { this->accountType = accountType; }
void setMarginType(const std::string& marginType) { this->marginType = marginType; }
enum class Status {
UNKNOWN,
SUBSCRIBING,
Expand Down Expand Up @@ -139,7 +139,7 @@ class Subscription CCAPI_FINAL {
private:
#endif
std::string exchange;
std::string accountType;
std::string marginType;
std::string instrumentType;
std::string instrument;
std::string field;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,10 @@ class ExecutionManagementServiceBinance : public ExecutionManagementServiceBinan
this->getOrderMarginTarget = "/sapi/v1/margin/order";
this->getOpenOrdersMarginTarget = "/sapi/v1/margin/openOrders";
this->cancelOpenOrdersMarginTarget = "/sapi/v1/margin/openOrders";
this->getAccountBalancesMarginTarget = "/sapi/v1/margin/account";
this->listenKeyMarginTarget = CCAPI_BINANCE_LISTEN_KEY_MARGIN_PATH;
this->getAccountBalancesCrossMarginTarget = "/sapi/v1/margin/account";
this->getAccountBalancesIsolatedMarginTarget = "/sapi/v1/margin/isolated/account";
this->listenKeyCrossMarginTarget = CCAPI_BINANCE_LISTEN_KEY_CROSS_MARGIN_PATH;
this->listenKeyIsolatedMarginTarget = CCAPI_BINANCE_LISTEN_KEY_ISOLATED_MARGIN_PATH;
}
virtual ~ExecutionManagementServiceBinance() {}
};
Expand Down
Loading

0 comments on commit afb6198

Please sign in to comment.