dxFeed Graal CXX API v7.0.0
Loading...
Searching...
No Matches
OptionChain.hpp
1// Copyright (c) 2025 Devexperts LLC.
2// SPDX-License-Identifier: MPL-2.0
3
4#pragma once
5
6#include "../../internal/Conf.hpp"
7
9
10#include "../../internal/Common.hpp"
11#include "./OptionSeries.hpp"
12
13#include <set>
14#include <string>
15
16/**
17 * \addtogroup dxfcpp_ipf
18 * @{
19 */
20
22
23/**
24 * Set of option series for a single product or underlying symbol.
25 *
26 * <h3>Threads and locks</h3>
27 *
28 * This class is <b>NOT</b> thread-safe and cannot be used from multiple threads without external synchronization.
29 *
30 * @tparam T The type of option instrument instances
31 */
32template <typename T> class OptionChain final {
33 friend class OptionChainsBuilder<T>;
34
35 std::string symbol_{};
36 std::set<OptionSeries<T>> series_{};
37
38 explicit OptionChain(const StringLike& symbol) : symbol_(symbol) {
39 }
40
41 void addOption(const OptionSeries<T> &series, bool isCall, double strike, std::shared_ptr<T> option) {
42 auto it = series_.find(series);
43
44 if (it == series_.end()) {
45 OptionSeries<T> os(series);
46 os.addOption(isCall, strike, option);
47 series_.insert(os);
48 } else {
49 OptionSeries<T> modifiedSeries = *it;
50 series_.erase(it);
51 modifiedSeries.addOption(isCall, strike, option);
52 series_.insert(modifiedSeries);
53 }
54 }
55
56 public:
57 /**
58 * Returns symbol (product or underlying) of this option chain.
59 *
60 * @return symbol (product or underlying) of this option chain.
61 */
62 const std::string &getSymbol() const & {
63 return symbol_;
64 }
65
66 /**
67 * Returns a sorted set of option series of this option chain.
68 *
69 * @return sorted set of option series of this option chain.
70 */
72 return series_;
73 }
74};
75
77
78/// @}
79
#define DXFCXX_DISABLE_MSC_WARNINGS_POP()
Definition Conf.hpp:31
#define DXFCPP_END_NAMESPACE
Definition Conf.hpp:97
#define DXFCPP_BEGIN_NAMESPACE
Definition Conf.hpp:94
#define DXFCXX_DISABLE_MSC_WARNINGS_PUSH(warnings)
Definition Conf.hpp:30
const std::string & getSymbol() const &
Returns symbol (product or underlying) of this option chain.
Definition OptionChain.hpp:62
std::set< OptionSeries< T > > getSeries()
Returns a sorted set of option series of this option chain.
Definition OptionChain.hpp:71
Builder class for a set of option chains grouped by product or underlying symbol.
Definition OptionChainsBuilder.hpp:32
A lightweight wrapper around strings or string-like inputs.
Definition StringUtils.hpp:27