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