Upgrade ccapi to v6.12.0
This commit is contained in:
1 parent
8069cc893f
commit
90492733fd
109 files changed
+4172
-8930
No files matched your search
@@ -7,6 +7,15 @@
|
||||
|
||||
#include "ccapi_cpp/ccapi_macro.h"
|
||||
#include "ccapi_cpp/ccapi_util_private.h"
|
||||
// We use macros instead of static constants in the Request class so that SWIG can properly generate C# bindings
|
||||
#define CCAPI_REQUEST_OPERATION_TYPE_CUSTOM 0x100
|
||||
#define CCAPI_REQUEST_OPERATION_TYPE_GENERIC_PUBLIC_REQUEST 0x200
|
||||
#define CCAPI_REQUEST_OPERATION_TYPE_GENERIC_PRIVATE_REQUEST 0x300
|
||||
#define CCAPI_REQUEST_OPERATION_TYPE_FIX 0x400
|
||||
#define CCAPI_REQUEST_OPERATION_TYPE_MARKET_DATA 0x500
|
||||
#define CCAPI_REQUEST_OPERATION_TYPE_EXECUTION_MANAGEMENT 0x600
|
||||
#define CCAPI_REQUEST_OPERATION_TYPE_EXECUTION_MANAGEMENT_ORDER CCAPI_REQUEST_OPERATION_TYPE_EXECUTION_MANAGEMENT
|
||||
#define CCAPI_REQUEST_OPERATION_TYPE_EXECUTION_MANAGEMENT_ACCOUNT 0x700
|
||||
namespace ccapi {
|
||||
/**
|
||||
* A single request. Request objects are created using Request constructors. They are used with Session::sendRequest() or Session::sendRequestByWebsocket() or
|
||||
@@ -16,29 +25,26 @@ namespace ccapi {
|
||||
*/
|
||||
class Request CCAPI_FINAL {
|
||||
public:
|
||||
static constexpr int operationTypeCustom = 0x100;
|
||||
static constexpr int operationTypeGenericPublicRequest = 0x200;
|
||||
static constexpr int operationTypeGenericPrivateRequest = 0x300;
|
||||
static constexpr int operationTypeFix = 0x400;
|
||||
static constexpr int operationTypeMarketData = 0x500;
|
||||
static constexpr int operationTypeExecutionManagement = 0x600;
|
||||
static constexpr int operationTypeExecutionManagementOrder = operationTypeExecutionManagement;
|
||||
static constexpr int operationTypeExecutionManagementAccount = 0x700;
|
||||
enum class Operation {
|
||||
CUSTOM = operationTypeCustom,
|
||||
GENERIC_PUBLIC_REQUEST = operationTypeGenericPublicRequest,
|
||||
GENERIC_PRIVATE_REQUEST = operationTypeGenericPrivateRequest,
|
||||
FIX = operationTypeFix,
|
||||
GET_RECENT_TRADES = operationTypeMarketData,
|
||||
CUSTOM = CCAPI_REQUEST_OPERATION_TYPE_CUSTOM,
|
||||
GENERIC_PUBLIC_REQUEST = CCAPI_REQUEST_OPERATION_TYPE_GENERIC_PUBLIC_REQUEST,
|
||||
GENERIC_PRIVATE_REQUEST = CCAPI_REQUEST_OPERATION_TYPE_GENERIC_PRIVATE_REQUEST,
|
||||
FIX = CCAPI_REQUEST_OPERATION_TYPE_FIX,
|
||||
GET_RECENT_TRADES = CCAPI_REQUEST_OPERATION_TYPE_MARKET_DATA,
|
||||
GET_HISTORICAL_TRADES,
|
||||
GET_RECENT_AGG_TRADES,
|
||||
GET_HISTORICAL_AGG_TRADES,
|
||||
GET_RECENT_CANDLESTICKS,
|
||||
GET_HISTORICAL_CANDLESTICKS,
|
||||
GET_MARKET_DEPTH,
|
||||
GET_INSTRUMENT,
|
||||
GET_INSTRUMENTS,
|
||||
CREATE_ORDER = operationTypeExecutionManagementOrder,
|
||||
CREATE_ORDER = CCAPI_REQUEST_OPERATION_TYPE_EXECUTION_MANAGEMENT_ORDER,
|
||||
CANCEL_ORDER,
|
||||
GET_ORDER,
|
||||
GET_OPEN_ORDERS,
|
||||
CANCEL_OPEN_ORDERS,
|
||||
GET_ACCOUNTS = operationTypeExecutionManagementAccount,
|
||||
GET_ACCOUNTS = CCAPI_REQUEST_OPERATION_TYPE_EXECUTION_MANAGEMENT_ACCOUNT,
|
||||
GET_ACCOUNT_BALANCES,
|
||||
GET_ACCOUNT_POSITIONS,
|
||||
};
|
||||
@@ -60,9 +66,24 @@ class Request CCAPI_FINAL {
|
||||
case Operation::GET_RECENT_TRADES:
|
||||
output = "GET_RECENT_TRADES";
|
||||
break;
|
||||
case Operation::GET_HISTORICAL_TRADES:
|
||||
output = "GET_HISTORICAL_TRADES";
|
||||
break;
|
||||
case Operation::GET_RECENT_AGG_TRADES:
|
||||
output = "GET_RECENT_AGG_TRADES";
|
||||
break;
|
||||
case Operation::GET_HISTORICAL_AGG_TRADES:
|
||||
output = "GET_HISTORICAL_AGG_TRADES";
|
||||
break;
|
||||
case Operation::GET_RECENT_CANDLESTICKS:
|
||||
output = "GET_RECENT_CANDLESTICKS";
|
||||
break;
|
||||
case Operation::GET_HISTORICAL_CANDLESTICKS:
|
||||
output = "GET_HISTORICAL_CANDLESTICKS";
|
||||
break;
|
||||
case Operation::GET_MARKET_DEPTH:
|
||||
output = "GET_MARKET_DEPTH";
|
||||
break;
|
||||
case Operation::GET_INSTRUMENT:
|
||||
output = "GET_INSTRUMENT";
|
||||
break;
|
||||
@@ -111,7 +132,7 @@ class Request CCAPI_FINAL {
|
||||
} else if (operation == Operation::FIX) {
|
||||
this->serviceName = CCAPI_FIX;
|
||||
} else {
|
||||
this->serviceName = static_cast<int>(operation) >= operationTypeExecutionManagement ? CCAPI_EXECUTION_MANAGEMENT : CCAPI_MARKET_DATA;
|
||||
this->serviceName = static_cast<int>(operation) >= CCAPI_REQUEST_OPERATION_TYPE_EXECUTION_MANAGEMENT ? CCAPI_EXECUTION_MANAGEMENT : CCAPI_MARKET_DATA;
|
||||
}
|
||||
if (this->correlationId.empty()) {
|
||||
this->correlationId = UtilString::generateRandomString(CCAPI_CORRELATION_ID_GENERATED_LENGTH);
|
||||
@@ -127,7 +148,8 @@ class Request CCAPI_FINAL {
|
||||
", correlationId = " + correlationId + ", secondaryCorrelationId = " + secondaryCorrelationId +
|
||||
(this->serviceName == CCAPI_FIX ? ", paramListFix = " + ccapi::toString(paramListFix) : ", paramList = " + ccapi::toString(paramList)) +
|
||||
", credential = " + ccapi::toString(shortCredential) + ", operation = " + operationToString(operation) +
|
||||
", timeSent = " + UtilTime::getISOTimestamp(timeSent) + "]";
|
||||
", timeSent = " + UtilTime::getISOTimestamp(timeSent) + ", index = " + ccapi::toString(index) + ", localIpAddress = " + localIpAddress +
|
||||
", baseUrl = " + baseUrl + "]";
|
||||
return output;
|
||||
}
|
||||
const std::string& getCorrelationId() const { return correlationId; }
|
||||
@@ -160,11 +182,36 @@ class Request CCAPI_FINAL {
|
||||
std::pair<long long, long long> getTimeSentPair() const { return UtilTime::divide(timeSent); }
|
||||
void setTimeSent(TimePoint timeSent) { this->timeSent = timeSent; }
|
||||
int getIndex() const { return index; }
|
||||
const std::string& getLocalIpAddress() const { return localIpAddress; }
|
||||
const std::string& getBaseUrl() const { return baseUrl; }
|
||||
const std::string& getHost() const { return host; }
|
||||
const std::string& getPort() const { return port; }
|
||||
void setIndex(int index) { this->index = index; }
|
||||
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 setMarginType(const std::string& marginType) { this->marginType = marginType; }
|
||||
void setLocalIpAddress(const std::string& localIpAddress) { this->localIpAddress = localIpAddress; }
|
||||
void setBaseUrl(const std::string& baseUrl) {
|
||||
this->baseUrl = baseUrl;
|
||||
this->setBaseUrlParts();
|
||||
}
|
||||
void setBaseUrlParts() {
|
||||
auto splitted1 = UtilString::split(this->baseUrl, "://");
|
||||
if (splitted1.size() >= 2) {
|
||||
auto splitted2 = UtilString::split(UtilString::split(splitted1.at(1), "/").at(0), ":");
|
||||
this->host = splitted2.at(0);
|
||||
if (splitted2.size() == 2) {
|
||||
this->port = splitted2.at(1);
|
||||
} else {
|
||||
if (splitted1.at(0) == "https" || splitted1.at(0) == "wss") {
|
||||
this->port = CCAPI_HTTPS_PORT_DEFAULT;
|
||||
} else {
|
||||
this->port = CCAPI_HTTP_PORT_DEFAULT;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#ifndef CCAPI_EXPOSE_INTERNAL
|
||||
|
||||
private:
|
||||
@@ -181,6 +228,10 @@ class Request CCAPI_FINAL {
|
||||
std::vector<std::vector<std::pair<int, std::string> > > paramListFix;
|
||||
TimePoint timeSent{std::chrono::seconds{0}};
|
||||
int index{};
|
||||
std::string localIpAddress;
|
||||
std::string baseUrl;
|
||||
std::string host;
|
||||
std::string port;
|
||||
};
|
||||
} /* namespace ccapi */
|
||||
#endif // INCLUDE_CCAPI_CPP_CCAPI_REQUEST_H_
|
||||
Reference in new issue
Block a user