Update ccapi to 7.9.3 (compatible w/ new boost)
This commit is contained in:
1 parent
bd7ccb5f44
commit
9fa7a9898e
117 files changed
+9016
-11255
No files matched your search
@@ -6,17 +6,18 @@
|
||||
#include "ccapi_cpp/ccapi_logger.h"
|
||||
#include "ccapi_cpp/ccapi_macro.h"
|
||||
#include "ccapi_cpp/ccapi_util_private.h"
|
||||
|
||||
namespace ccapi {
|
||||
|
||||
/**
|
||||
* A single subscription. A 'Subscription' is used when calling 'Session::subscribe()' or 'Session::subscribeByFix'. Subscription objects are created using
|
||||
* A single subscription. A 'Subscription' is used when calling 'Session::subscribe()' or 'Session::subscribe'. Subscription objects are created using
|
||||
* Subscription constructors. A correlation id can be used as the unique identifier to tag all data associated with this subscription.
|
||||
*/
|
||||
class Subscription CCAPI_FINAL {
|
||||
class Subscription {
|
||||
public:
|
||||
Subscription() {}
|
||||
Subscription(std::string exchange, std::string instrument, std::string field, std::string options = "", std::string correlationId = "",
|
||||
std::map<std::string, std::string> credential = {})
|
||||
: exchange(exchange), instrument(instrument), field(field), correlationId(correlationId), credential(credential) {
|
||||
explicit Subscription(const std::string& exchange = "", const std::string& instrument = "", const std::string& field = "", const std::string& options = "",
|
||||
const std::string& correlationId = "", const std::map<std::string, std::string>& credential = {}, const std::string& proxyUrl = "")
|
||||
: exchange(exchange), instrument(instrument), field(field), correlationId(correlationId), credential(credential), proxyUrl(proxyUrl) {
|
||||
auto originalInstrumentSet = UtilString::splitToSet(instrument, ",");
|
||||
std::copy_if(originalInstrumentSet.begin(), originalInstrumentSet.end(), std::inserter(this->instrumentSet, this->instrumentSet.end()),
|
||||
[](const std::string& value) { return !value.empty(); });
|
||||
@@ -41,11 +42,12 @@ class Subscription CCAPI_FINAL {
|
||||
this->optionMap[optionKeyValue.at(0)] = optionKeyValue.at(1);
|
||||
}
|
||||
}
|
||||
std::set<std::string> executionManagementSubscriptionFieldSet = {std::string(CCAPI_EM_ORDER_UPDATE), std::string(CCAPI_EM_PRIVATE_TRADE),
|
||||
std::string(CCAPI_EM_BALANCE_UPDATE), std::string(CCAPI_EM_POSITION_UPDATE)};
|
||||
std::set<std::string> executionManagementSubscriptionFieldSet = {std::string(CCAPI_EM_ORDER_UPDATE), std::string(CCAPI_EM_PRIVATE_TRADE),
|
||||
std::string(CCAPI_EM_PRIVATE_TRADE_LITE), std::string(CCAPI_EM_BALANCE_UPDATE),
|
||||
std::string(CCAPI_EM_POSITION_UPDATE), std::string(CCAPI_EM_WEBSOCKET_ORDER_ENTRY)};
|
||||
if (field == CCAPI_GENERIC_PUBLIC_SUBSCRIPTION) {
|
||||
this->serviceName = CCAPI_MARKET_DATA;
|
||||
} else if (field == CCAPI_FIX || field == CCAPI_FIX_MARKET_DATA || field == CCAPI_FIX_EXECUTION_MANAGEMENT) {
|
||||
} else if (field == CCAPI_FIX || field == CCAPI_FIX_MARKET_DATA) {
|
||||
this->serviceName = CCAPI_FIX;
|
||||
} else if (std::includes(executionManagementSubscriptionFieldSet.begin(), executionManagementSubscriptionFieldSet.end(), this->fieldSet.begin(),
|
||||
this->fieldSet.end())) {
|
||||
@@ -58,6 +60,7 @@ class Subscription CCAPI_FINAL {
|
||||
this->correlationId = UtilString::generateRandomString(CCAPI_CORRELATION_ID_GENERATED_LENGTH);
|
||||
}
|
||||
}
|
||||
|
||||
std::string toString() const {
|
||||
std::map<std::string, std::string> shortCredential;
|
||||
for (const auto& x : credential) {
|
||||
@@ -65,21 +68,35 @@ class Subscription CCAPI_FINAL {
|
||||
}
|
||||
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) + "]";
|
||||
", correlationId = " + correlationId + ", credential = " + ccapi::toString(shortCredential) + ", proxyUrl = " + proxyUrl +
|
||||
", serviceName = " + serviceName + ", timeSent = " + UtilTime::getISOTimestamp(timeSent) + "]";
|
||||
return output;
|
||||
}
|
||||
|
||||
const std::string& getCorrelationId() const { return correlationId; }
|
||||
|
||||
const std::string& getExchange() const { return exchange; }
|
||||
|
||||
const std::string& getInstrument() const { return instrument; }
|
||||
|
||||
const std::string& getInstrumentType() const { return instrumentType; }
|
||||
|
||||
const std::string& getField() const { return field; }
|
||||
|
||||
const std::string& getRawOptions() const { return rawOptions; }
|
||||
|
||||
const std::map<std::string, std::string>& getOptionMap() const { return optionMap; }
|
||||
|
||||
const std::map<std::string, std::string>& getCredential() const { return credential; }
|
||||
|
||||
const std::string& getProxyUrl() const { return proxyUrl; }
|
||||
|
||||
const std::string& getServiceName() const { return serviceName; }
|
||||
|
||||
const std::set<std::string>& getInstrumentSet() const { return instrumentSet; }
|
||||
|
||||
const std::set<std::string>& getFieldSet() const { return fieldSet; }
|
||||
|
||||
const std::string getSerializedOptions() const {
|
||||
std::string output;
|
||||
if (this->rawOptions.empty()) {
|
||||
@@ -98,15 +115,32 @@ class Subscription CCAPI_FINAL {
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
const std::string getSerializedCredential() const { return ccapi::toString(this->credential); }
|
||||
|
||||
// 'getTimeSent' only works in C++. For other languages, please use 'getTimeSentISO'.
|
||||
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& getMarginType() const { return marginType; }
|
||||
|
||||
void setExchange(const std::string& exchange) { this->exchange = exchange; }
|
||||
|
||||
void setInstrument(const std::string& instrument) { this->instrument = instrument; }
|
||||
|
||||
void setField(const std::string& field) { this->field = field; }
|
||||
|
||||
void setProxyUrl(const std::string& proxyUrl) { this->proxyUrl = proxyUrl; }
|
||||
|
||||
void setTimeSent(TimePoint timeSent) { this->timeSent = timeSent; }
|
||||
|
||||
void setInstrumentType(const std::string& instrumentType) { this->instrumentType = instrumentType; }
|
||||
|
||||
void setMarginType(const std::string& marginType) { this->marginType = marginType; }
|
||||
|
||||
enum class Status {
|
||||
UNKNOWN,
|
||||
SUBSCRIBING,
|
||||
@@ -114,6 +148,7 @@ class Subscription CCAPI_FINAL {
|
||||
UNSUBSCRIBING,
|
||||
UNSUBSCRIBED,
|
||||
};
|
||||
|
||||
static std::string statusToString(Status status) {
|
||||
std::string output;
|
||||
switch (status) {
|
||||
@@ -133,7 +168,7 @@ class Subscription CCAPI_FINAL {
|
||||
output = "UNSUBSCRIBED";
|
||||
break;
|
||||
default:
|
||||
CCAPI_LOGGER_FATAL(CCAPI_UNSUPPORTED_VALUE);
|
||||
CCAPI_LOGGER_FATAL(std::string(CCAPI_UNSUPPORTED_VALUE) + " " + std::to_string(static_cast<int>(status)));
|
||||
}
|
||||
return output;
|
||||
}
|
||||
@@ -150,10 +185,12 @@ class Subscription CCAPI_FINAL {
|
||||
std::map<std::string, std::string> optionMap;
|
||||
std::string correlationId;
|
||||
std::map<std::string, std::string> credential;
|
||||
std::string proxyUrl;
|
||||
std::string serviceName;
|
||||
std::set<std::string> instrumentSet;
|
||||
std::set<std::string> fieldSet;
|
||||
TimePoint timeSent{std::chrono::seconds{0}};
|
||||
};
|
||||
|
||||
} /* namespace ccapi */
|
||||
#endif // INCLUDE_CCAPI_CPP_CCAPI_SUBSCRIPTION_H_
|
||||
Reference in new issue
Block a user