dxFeed Graal CXX API v4.2.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
17
18/**
19 * Set of option series for a single product or underlying symbol.
20 *
21 * <h3>Threads and clocks</h3>
22 *
23 * This class is <b>NOT</b> thread-safe and cannot be used from multiple threads without external synchronization.
24 *
25 * @tparam T The type of option instrument instances
26 */
27template <typename T> class OptionChain final {
28 friend class OptionChainsBuilder<T>;
29
30 std::string symbol_{};
31 std::set<OptionSeries<T>> series_{};
32
33 explicit OptionChain(std::string symbol) : symbol_(std::move(symbol)) {
34 }
35
36 void addOption(const OptionSeries<T> &series, bool isCall, double strike, std::shared_ptr<T> option) {
37 auto it = series_.find(series);
38
39 if (it == series_.end()) {
40 OptionSeries<T> os(series);
41 os.addOption(isCall, strike, option);
42 series_.insert(os);
43 } else {
44 OptionSeries<T> modifiedSeries = *it;
45 series_.erase(it);
46 modifiedSeries.addOption(isCall, strike, option);
47 series_.insert(modifiedSeries);
48 }
49 }
50
51 public:
52 /**
53 * Returns symbol (product or underlying) of this option chain.
54 *
55 * @return symbol (product or underlying) of this option chain.
56 */
57 const std::string &getSymbol() const & {
58 return symbol_;
59 }
60
61 /**
62 * Returns a sorted set of option series of this option chain.
63 *
64 * @return sorted set of option series of this option chain.
65 */
67 return series_;
68 }
69};
70
72
#define DXFCXX_DISABLE_MSC_WARNINGS_POP()
Definition Conf.hpp:22
#define DXFCPP_END_NAMESPACE
Definition Conf.hpp:70
#define DXFCPP_BEGIN_NAMESPACE
Definition Conf.hpp:67
#define DXFCXX_DISABLE_MSC_WARNINGS_PUSH(warnings)
Definition Conf.hpp:21
const std::string & getSymbol() const &
Returns symbol (product or underlying) of this option chain.
Definition OptionChain.hpp:57
std::set< OptionSeries< T > > getSeries()
Returns a sorted set of option series of this option chain.
Definition OptionChain.hpp:66
Builder class for a set of option chains grouped by product or underlying symbol.
Definition OptionChainsBuilder.hpp:27