Skip to content

Commit

Permalink
Merge branch 'main' into gh-pages
Browse files Browse the repository at this point in the history
  • Loading branch information
ttldtor committed Dec 5, 2023
2 parents 39c546d + 290d8c6 commit 40e9f1c
Show file tree
Hide file tree
Showing 16 changed files with 717 additions and 53 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ set(CMAKE_POLICY_DEFAULT_CMP0077 NEW)

project(dxFeedGraalCxxApi)

set(DXFCXX_VERSION "v1.1.0-beta" CACHE STRING "The dxFeed Graal CXX API package version")
set(DXFCXX_VERSION "v1.1.1-beta" CACHE STRING "The dxFeed Graal CXX API package version")

set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -284,8 +284,10 @@ Quote{AAPL, eventTime=0, time=20221219-223312.000, timeNanoPart=0, sequence=0, b
int main() {
using namespace dxfcpp;

// The experimental property must be enabled.
System::setProperty("dxfeed.experimental.dxlink.enable", "true");
// Enable experimental feature.
System::SetProperty("dxfeed.experimental.dxlink.enable", "true");
// Set scheme for dxLink.
System::SetProperty("scheme", "ext:resource:dxlink.xml");

// For token-based authorization, use the following address format:
// "demo.dxfeed.com:7300[login=entitle:token]"
Expand Down
4 changes: 2 additions & 2 deletions include/dxfeed_graal_cpp_api/event/candle/Candle.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -378,8 +378,8 @@ class DXFCPP_EXPORT Candle final : public EventTypeWithSymbol<CandleSymbol>,
* @see Candle::getTime()
*/
void setTime(std::int64_t time) noexcept {
data_.index = orOp(orOp(sal(time_util::getSecondsFromTime(time), SECONDS_SHIFT),
sal(time_util::getMillisFromTime(time), MILLISECONDS_SHIFT)),
data_.index = orOp(orOp(sal(static_cast<std::int64_t>(time_util::getSecondsFromTime(time)), SECONDS_SHIFT),
sal(static_cast<std::int64_t>(time_util::getMillisFromTime(time)), MILLISECONDS_SHIFT)),
getSequence());
}

Expand Down
12 changes: 8 additions & 4 deletions include/dxfeed_graal_cpp_api/event/market/MarketEventSymbols.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

#include "../../internal/Conf.hpp"

#include <string>
#include <optional>
#include <string>

namespace dxfcpp {

Expand Down Expand Up @@ -52,7 +52,7 @@ struct DXFCPP_EXPORT MarketEventSymbols {
* @return exchange code of the specified symbol or `'\0'` if none is defined.
*/
static char getExchangeCode(const std::string &symbol) noexcept {
return hasExchangeCode(symbol) ? symbol[getLengthWithoutAttributesInternal(symbol) - 1] : 0;
return hasExchangeCode(symbol) ? symbol[getLengthWithoutAttributesInternal(symbol) - 1] : '\0';
}

/**
Expand All @@ -65,8 +65,8 @@ struct DXFCPP_EXPORT MarketEventSymbols {
static DXFCPP_CXX20_CONSTEXPR_STRING std::string changeExchangeCode(const std::string &symbol,
char exchangeCode) noexcept {
auto i = getLengthWithoutAttributesInternal(symbol);
auto result = exchangeCode == 0 ? getBaseSymbolInternal(symbol, i)
: getBaseSymbolInternal(symbol, i) + EXCHANGE_SEPARATOR + exchangeCode;
auto result = exchangeCode == '\0' ? getBaseSymbolInternal(symbol, i)
: getBaseSymbolInternal(symbol, i) + EXCHANGE_SEPARATOR + exchangeCode;
return i == symbol.length() ? result : result + symbol.substr(i);
}

Expand Down Expand Up @@ -180,6 +180,8 @@ struct DXFCPP_EXPORT MarketEventSymbols {

return std::nullopt;
} catch (...) {
// TODO: error handling: [EN-8232]

return std::nullopt;
}
}
Expand Down Expand Up @@ -212,6 +214,8 @@ struct DXFCPP_EXPORT MarketEventSymbols {

return symbol.substr(0, i) + symbol.substr(j);
} catch (...) {
// TODO: error handling: [EN-8232]

return symbol;
}
}
Expand Down
16 changes: 9 additions & 7 deletions include/dxfeed_graal_cpp_api/event/market/OptionSale.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
#include <cassert>
#include <cstdint>
#include <memory>
#include <string>
#include <optional>
#include <string>

#include "../../internal/Common.hpp"
#include "../EventTypeEnum.hpp"
Expand Down Expand Up @@ -219,9 +219,10 @@ class DXFCPP_EXPORT OptionSale final : public MarketEvent, public IndexedEvent {
* @param time time of this event.
*/
void setTime(std::int64_t time) noexcept {
data_.timeSequence = orOp(
sal(static_cast<std::int64_t>(time_util::getSecondsFromTime(time)), SECONDS_SHIFT),
orOp(sal(static_cast<std::int64_t>(time_util::getMillisFromTime(time)), MILLISECONDS_MASK), getSequence()));
data_.timeSequence =
orOp(orOp(sal(static_cast<std::int64_t>(time_util::getSecondsFromTime(time)), SECONDS_SHIFT),
sal(static_cast<std::int64_t>(time_util::getMillisFromTime(time)), MILLISECONDS_SHIFT)),
getSequence());
}

/**
Expand Down Expand Up @@ -271,7 +272,7 @@ class DXFCPP_EXPORT OptionSale final : public MarketEvent, public IndexedEvent {
* @return The sequence number of this event
*/
std::int32_t getSequence() const noexcept {
return static_cast<std::int32_t>(andOp(data_.index, MAX_SEQUENCE));
return static_cast<std::int32_t>(andOp(data_.timeSequence, MAX_SEQUENCE));
}

/**
Expand All @@ -284,7 +285,7 @@ class DXFCPP_EXPORT OptionSale final : public MarketEvent, public IndexedEvent {
// TODO: Improve error handling [EN-8232]
assert(sequence >= 0 && sequence <= MAX_SEQUENCE);

data_.index = orOp(andOp(data_.index, ~MAX_SEQUENCE), sequence);
data_.timeSequence = orOp(andOp(data_.timeSequence, ~MAX_SEQUENCE), sequence);
}

/**
Expand Down Expand Up @@ -445,7 +446,8 @@ class DXFCPP_EXPORT OptionSale final : public MarketEvent, public IndexedEvent {
* @param tradeThroughExempt TradeThroughExempt flag of this option sale event.
*/
void setTradeThroughExempt(char tradeThroughExempt) noexcept {
// TODO: error handling [EN-8232] //util::checkChar(tradeThroughExempt, TimeAndSale::TTE_MASK, "tradeThroughExempt");
// TODO: error handling [EN-8232] //util::checkChar(tradeThroughExempt, TimeAndSale::TTE_MASK,
// "tradeThroughExempt");

data_.flags = setBits(data_.flags, TimeAndSale::TTE_MASK, TimeAndSale::TTE_SHIFT, tradeThroughExempt);
}
Expand Down
18 changes: 10 additions & 8 deletions include/dxfeed_graal_cpp_api/event/market/OrderBase.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -280,8 +280,8 @@ class DXFCPP_EXPORT OrderBase : public MarketEvent, public IndexedEvent {
* @return time of this order.
*/
std::int64_t getTime() const noexcept {
return sar(orderBaseData_.index, SECONDS_SHIFT) * 1000 +
andOp(sar(orderBaseData_.index, MILLISECONDS_SHIFT), MILLISECONDS_MASK);
return sar(orderBaseData_.timeSequence, SECONDS_SHIFT) * 1000 +
andOp(sar(orderBaseData_.timeSequence, MILLISECONDS_SHIFT), MILLISECONDS_MASK);
}

/**
Expand All @@ -291,9 +291,10 @@ class DXFCPP_EXPORT OrderBase : public MarketEvent, public IndexedEvent {
* @param time time of this order.
*/
void setTime(std::int64_t time) noexcept {
orderBaseData_.index = orOp(orOp(sal(time_util::getSecondsFromTime(time), SECONDS_SHIFT),
sal(time_util::getMillisFromTime(time), MILLISECONDS_SHIFT)),
getSequence());
orderBaseData_.timeSequence =
orOp(orOp(sal(static_cast<std::int64_t>(time_util::getSecondsFromTime(time)), SECONDS_SHIFT),
sal(static_cast<std::int64_t>(time_util::getMillisFromTime(time)), MILLISECONDS_SHIFT)),
getSequence());
}

/**
Expand Down Expand Up @@ -600,10 +601,11 @@ class DXFCPP_EXPORT OrderBase : public MarketEvent, public IndexedEvent {
* @return exchange code of this order as UTF8 string.
*/
std::string getExchangeCodeString() const noexcept {
//TODO: cache [EN-8231]
// TODO: cache [EN-8231]

return std::string(1ULL, static_cast<char>(
static_cast<unsigned char>(getBits(orderBaseData_.flags, EXCHANGE_MASK, EXCHANGE_SHIFT))));
return std::string(
1ULL, static_cast<char>( // NOLINT(*-return-braced-init-list)
static_cast<unsigned char>(getBits(orderBaseData_.flags, EXCHANGE_MASK, EXCHANGE_SHIFT))));
}

/**
Expand Down
6 changes: 3 additions & 3 deletions include/dxfeed_graal_cpp_api/event/market/TimeAndSale.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
#include <cassert>
#include <cstdint>
#include <memory>
#include <string>
#include <optional>
#include <string>

#include "../../internal/Common.hpp"
#include "../EventTypeEnum.hpp"
Expand Down Expand Up @@ -224,8 +224,8 @@ class DXFCPP_EXPORT TimeAndSale final : public MarketEvent, public TimeSeriesEve
* @see ::getTime()
*/
void setTime(std::int64_t time) noexcept {
data_.index = orOp(orOp(sal(time_util::getSecondsFromTime(time), SECONDS_SHIFT),
sal(time_util::getMillisFromTime(time), MILLISECONDS_SHIFT)),
data_.index = orOp(orOp(sal(static_cast<std::int64_t>(time_util::getSecondsFromTime(time)), SECONDS_SHIFT),
sal(static_cast<std::int64_t>(time_util::getMillisFromTime(time)), MILLISECONDS_SHIFT)),
getSequence());
}

Expand Down
9 changes: 5 additions & 4 deletions include/dxfeed_graal_cpp_api/event/market/TradeBase.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,10 @@ class DXFCPP_EXPORT TradeBase : public MarketEvent, public LastingEvent {
* @param time time of the last trade.
*/
void setTime(std::int64_t time) noexcept {
tradeBaseData_.timeSequence = orOp(
sal(static_cast<std::int64_t>(time_util::getSecondsFromTime(time)), SECONDS_SHIFT),
orOp(sal(static_cast<std::int64_t>(time_util::getMillisFromTime(time)), MILLISECONDS_MASK), getSequence()));
tradeBaseData_.timeSequence =
orOp(orOp(sal(static_cast<std::int64_t>(time_util::getSecondsFromTime(time)), SECONDS_SHIFT),
sal(static_cast<std::int64_t>(time_util::getMillisFromTime(time)), MILLISECONDS_SHIFT)),
getSequence());
}

/**
Expand Down Expand Up @@ -212,7 +213,7 @@ class DXFCPP_EXPORT TradeBase : public MarketEvent, public LastingEvent {
* @return exchange code of last trade as UTF8 string.
*/
std::string getExchangeCodeString() const noexcept {
//TODO: cache [EN-8231]
// TODO: cache [EN-8231]

return dxfcpp::utf16toUtf8String(tradeBaseData_.exchangeCode);
}
Expand Down
4 changes: 2 additions & 2 deletions include/dxfeed_graal_cpp_api/event/option/Greeks.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,8 @@ class DXFCPP_EXPORT Greeks final : public MarketEvent, public TimeSeriesEvent, p
* @see ::getTime()
*/
void setTime(std::int64_t time) noexcept {
data_.index = orOp(orOp(sal(time_util::getSecondsFromTime(time), SECONDS_SHIFT),
sal(time_util::getMillisFromTime(time), MILLISECONDS_SHIFT)),
data_.index = orOp(orOp(sal(static_cast<std::int64_t>(time_util::getSecondsFromTime(time)), SECONDS_SHIFT),
sal(static_cast<std::int64_t>(time_util::getMillisFromTime(time)), MILLISECONDS_SHIFT)),
getSequence());
}

Expand Down
Loading

0 comments on commit 40e9f1c

Please sign in to comment.