feat: Support python md plugins
This commit is contained in:
1 parent
82b8224416
commit
0a3b8ca793
48 files changed
+3411
No files matched your search
@@ -0,0 +1,126 @@
|
||||
#pragma once
|
||||
|
||||
#include "python_md/py_contract_price_info_list.h"
|
||||
#include "python_md/py_contract_quantity_info_list.h"
|
||||
#include "spark/core/FMT_IMPL.h"
|
||||
|
||||
#include <fmt/format.h>
|
||||
#include <string>
|
||||
|
||||
namespace bts::md::py_interop {
|
||||
|
||||
/**
|
||||
* Quantity and price metadata for a particular contract.
|
||||
*/
|
||||
class PyContractSpecification {
|
||||
public:
|
||||
constexpr PyContractSpecification() = default;
|
||||
|
||||
const PyContractPriceInfoList &price_infos() const;
|
||||
PyContractPriceInfoList &mutable_price_infos();
|
||||
void set_price_infos(PyContractPriceInfoList value);
|
||||
|
||||
const PyContractQuantityInfoList &quantity_infos() const;
|
||||
PyContractQuantityInfoList &mutable_quantity_infos();
|
||||
void set_quantity_infos(PyContractQuantityInfoList value);
|
||||
|
||||
const PyContractQuantityInfoList ¬ional_quantity_infos() const;
|
||||
PyContractQuantityInfoList &mutable_notional_quantity_infos();
|
||||
void set_notional_quantity_infos(PyContractQuantityInfoList value);
|
||||
|
||||
std::string to_string() const;
|
||||
|
||||
private:
|
||||
PyContractPriceInfoList price_infos_;
|
||||
PyContractQuantityInfoList quantity_infos_;
|
||||
PyContractQuantityInfoList notional_quantity_infos_;
|
||||
};
|
||||
|
||||
std::ostream &operator<<(
|
||||
std::ostream &out, const PyContractSpecification &opt) noexcept;
|
||||
|
||||
//////////////////////////////////////////////////
|
||||
// Definition
|
||||
//////////////////////////////////////////////////
|
||||
|
||||
} // namespace bts::md::py_interop
|
||||
|
||||
FMT_IMPL(
|
||||
bts::md::py_interop::PyContractSpecification,
|
||||
s,
|
||||
R"({{ "price_infos": {}, "quantity_infos": {}, "notional_quantity_infos": {} }})",
|
||||
s.price_infos(),
|
||||
s.quantity_infos(),
|
||||
s.notional_quantity_infos());
|
||||
|
||||
// template <>
|
||||
// struct fmt::formatter<bts::md::py_interop::PyContractSpecification> {
|
||||
// constexpr auto parse(fmt ::format_parse_context &ctx)
|
||||
// -> decltype(ctx.end()) {
|
||||
// return ctx.end();
|
||||
// }
|
||||
// template <typename FormatContext>
|
||||
// auto format(
|
||||
// const bts::md::py_interop::PyContractSpecification &spec,
|
||||
// FormatContext &ctx) const -> decltype(ctx.out()) {
|
||||
// return fmt::format_to(
|
||||
// ctx.out(),
|
||||
// R"({{ "price_infos": [{}], "quantity_infos": [{}], "notional_quantity_infos": [{}] }})",
|
||||
// fmt::format("{}", fmt::join(spec.price_infos().items(), ", ")),
|
||||
// fmt::format("{}", fmt::join(spec.quantity_infos().items(), ", ")),
|
||||
// fmt::format(
|
||||
// "{}", fmt::join(spec.notional_quantity_infos().items(), ", ")));
|
||||
// }
|
||||
// };
|
||||
|
||||
namespace bts::md::py_interop {
|
||||
|
||||
inline const PyContractPriceInfoList &
|
||||
PyContractSpecification::price_infos() const {
|
||||
return price_infos_;
|
||||
}
|
||||
inline PyContractPriceInfoList &PyContractSpecification::mutable_price_infos() {
|
||||
return price_infos_;
|
||||
}
|
||||
inline void PyContractSpecification::set_price_infos(
|
||||
PyContractPriceInfoList value) {
|
||||
price_infos_ = std::move(value);
|
||||
}
|
||||
|
||||
inline const PyContractQuantityInfoList &
|
||||
PyContractSpecification::quantity_infos() const {
|
||||
return quantity_infos_;
|
||||
}
|
||||
inline PyContractQuantityInfoList &
|
||||
PyContractSpecification::mutable_quantity_infos() {
|
||||
return quantity_infos_;
|
||||
}
|
||||
inline void PyContractSpecification::set_quantity_infos(
|
||||
PyContractQuantityInfoList value) {
|
||||
quantity_infos_ = std::move(value);
|
||||
}
|
||||
|
||||
inline const PyContractQuantityInfoList &
|
||||
PyContractSpecification::notional_quantity_infos() const {
|
||||
return notional_quantity_infos_;
|
||||
}
|
||||
inline PyContractQuantityInfoList &
|
||||
PyContractSpecification::mutable_notional_quantity_infos() {
|
||||
return notional_quantity_infos_;
|
||||
}
|
||||
inline void PyContractSpecification::set_notional_quantity_infos(
|
||||
PyContractQuantityInfoList value) {
|
||||
notional_quantity_infos_ = std::move(value);
|
||||
}
|
||||
|
||||
inline std::string PyContractSpecification::to_string() const {
|
||||
return fmt::format("{}", *this);
|
||||
}
|
||||
|
||||
inline std::ostream &operator<<(
|
||||
std::ostream &out, const PyContractSpecification &spec) noexcept {
|
||||
out << fmt::format("{}", spec);
|
||||
return out;
|
||||
}
|
||||
|
||||
} // namespace bts::md::py_interop
|
||||
Reference in new issue
Block a user