ADD: Support for Spreads on Bybit. Gateio fixes.
This commit is contained in:
1 parent
1b5f1bfb27
commit
ca27903f63
7 files changed
+1192
-191
No files matched your search
@@ -4,6 +4,7 @@
|
||||
#include "python_interop/py_future.h"
|
||||
#include "python_interop/py_option.h"
|
||||
#include "python_interop/py_spot.h"
|
||||
#include "python_interop/py_spread.h"
|
||||
#include "spark/io/json_formatter.h"
|
||||
|
||||
#include <cstdint>
|
||||
@@ -50,6 +51,10 @@ class PySecurity {
|
||||
void set_option(PyOption);
|
||||
constexpr bool is_option() const;
|
||||
|
||||
const PySpread &spread() const;
|
||||
void set_spread(PySpread);
|
||||
constexpr bool is_spread() const;
|
||||
|
||||
const PyContractSpecification &contract_spec() const;
|
||||
void set_contract_spec(PyContractSpecification value);
|
||||
|
||||
@@ -65,7 +70,7 @@ class PySecurity {
|
||||
std::string name_;
|
||||
std::string currency_;
|
||||
PyContractSpecification contract_spec_;
|
||||
std::variant<PySpot, PyFuture, PyOption> sec_;
|
||||
std::variant<PySpot, PyFuture, PyOption, PySpread> sec_;
|
||||
|
||||
friend struct fmt::formatter<PySecurity>;
|
||||
friend void to_json(nlohmann::json &j, const PySecurity &sec);
|
||||
@@ -180,6 +185,18 @@ constexpr bool PySecurity::is_option() const {
|
||||
return std::holds_alternative<PyOption>(sec_);
|
||||
}
|
||||
|
||||
inline const PySpread &PySecurity::spread() const {
|
||||
if (std::holds_alternative<PySpread>(sec_)) {
|
||||
return std::get<PySpread>(sec_);
|
||||
}
|
||||
throw std::runtime_error{"PySecurity is not a spread"};
|
||||
}
|
||||
inline void PySecurity::set_spread(PySpread value) { sec_ = std::move(value); }
|
||||
constexpr bool PySecurity::is_spread() const {
|
||||
return std::holds_alternative<PySpread>(sec_);
|
||||
}
|
||||
|
||||
|
||||
inline const PyContractSpecification &PySecurity::contract_spec() const {
|
||||
return contract_spec_;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user