Deribit's option position request hooked up
This commit is contained in:
1 parent
4769f66eea
commit
6d95a645e3
8 files changed
+295
-23
No files matched your search
@@ -1,4 +1,5 @@
|
||||
#include "CCAPIOrderCallbackMsgs.h"
|
||||
#include "lib/io/JsonReader.h"
|
||||
#include "lib/utils/bts_assert.h"
|
||||
|
||||
namespace bts::orderman {
|
||||
@@ -18,4 +19,42 @@ bts::api::orderman::OrderStatus convert_ccapi_status(
|
||||
return bts::api::orderman::OrderStatus::ORDER_STATUS_COMPLETED;
|
||||
}
|
||||
|
||||
void DeribitOpenPosition::parse(
|
||||
const nlohmann::json &j, DeribitOpenPosition &op) {
|
||||
bts::io::JsonReader jr{&j};
|
||||
jr.read("total_profit_loss", op.total_profit_loss);
|
||||
jr.read("size_currency", op.size_currency);
|
||||
jr.read("size", op.size);
|
||||
jr.read("settlement_price", op.settlement_price);
|
||||
jr.read("realized_profit_loss", op.realized_profit_loss);
|
||||
jr.read("instrument_name", op.instrument_name);
|
||||
jr.read("kind", op.kind);
|
||||
jr.read("direction", op.direction);
|
||||
jr.read("average_price", op.average_price);
|
||||
}
|
||||
|
||||
void from_json(const nlohmann::json &j, DeribitOpenPosition &dop) {
|
||||
bts::io::JsonReader jr{&j};
|
||||
jr.read("instrument_name", dop.instrument_name);
|
||||
jr.read("direction", dop.direction);
|
||||
jr.read("size", dop.size);
|
||||
jr.read("average_price", dop.average_price);
|
||||
}
|
||||
void to_json(nlohmann::json &j, const DeribitOpenPosition &dop) {
|
||||
j = nlohmann::json{
|
||||
{"instrument_name", dop.instrument_name},
|
||||
{"direction", dop.direction},
|
||||
{"size", dop.size},
|
||||
{"average_price", dop.average_price}};
|
||||
}
|
||||
|
||||
std::ostream &operator<<(
|
||||
std::ostream &out, const DeribitOpenPosition &dop) noexcept {
|
||||
std::string sep = " ";
|
||||
out << "instrument_name: " << dop.instrument_name << sep
|
||||
<< "direction: " << dop.direction << sep << "size: " << dop.size << sep
|
||||
<< "average_price: " << dop.average_price;
|
||||
return out;
|
||||
}
|
||||
|
||||
} // namespace bts::orderman
|
||||
Reference in new issue
Block a user