kraken: parse: define 'Order' type
Use strong typing for the various components of the order.
This commit is contained in:
parent
b7182826ab
commit
9550598a87
|
@ -2,10 +2,12 @@ add_executable(kraken kraken.cc)
|
||||||
target_link_libraries(kraken PRIVATE common_options)
|
target_link_libraries(kraken PRIVATE common_options)
|
||||||
|
|
||||||
add_subdirectory(csv)
|
add_subdirectory(csv)
|
||||||
|
add_subdirectory(parse)
|
||||||
add_subdirectory(utils)
|
add_subdirectory(utils)
|
||||||
|
|
||||||
target_link_libraries(kraken PRIVATE
|
target_link_libraries(kraken PRIVATE
|
||||||
csv
|
csv
|
||||||
|
parse
|
||||||
)
|
)
|
||||||
|
|
||||||
install(TARGETS kraken)
|
install(TARGETS kraken)
|
||||||
|
|
10
src/parse/CMakeLists.txt
Normal file
10
src/parse/CMakeLists.txt
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
add_library(parse STATIC
|
||||||
|
order.cc
|
||||||
|
order.hh
|
||||||
|
)
|
||||||
|
|
||||||
|
target_link_libraries(parse PRIVATE
|
||||||
|
utils
|
||||||
|
)
|
||||||
|
|
||||||
|
target_link_libraries(parse PRIVATE common_options)
|
1
src/parse/order.cc
Normal file
1
src/parse/order.cc
Normal file
|
@ -0,0 +1 @@
|
||||||
|
#include "order.hh"
|
65
src/parse/order.hh
Normal file
65
src/parse/order.hh
Normal file
|
@ -0,0 +1,65 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <variant>
|
||||||
|
|
||||||
|
#include "utils/strong-type.hh"
|
||||||
|
|
||||||
|
namespace kraken::parse {
|
||||||
|
|
||||||
|
/// Which side the order is on.
|
||||||
|
enum class Side {
|
||||||
|
/// An offer to sell.
|
||||||
|
BID,
|
||||||
|
/// An offer to buy.
|
||||||
|
ASK,
|
||||||
|
};
|
||||||
|
|
||||||
|
struct PriceTag;
|
||||||
|
/// A strongly-typed price value.
|
||||||
|
using Price = utils::StrongType<int, PriceTag>;
|
||||||
|
|
||||||
|
struct QuantityTag;
|
||||||
|
/// A strongly-typed quantity value.
|
||||||
|
using Quantity = utils::StrongType<int, PriceTag>;
|
||||||
|
|
||||||
|
struct SymbolTag;
|
||||||
|
/// A strongly-typed symbol value.
|
||||||
|
using Symbol = utils::StrongType<std::string, SymbolTag>;
|
||||||
|
|
||||||
|
struct UserTag;
|
||||||
|
/// A strongly-typed user id value.
|
||||||
|
using User = utils::StrongType<int, UserTag>;
|
||||||
|
|
||||||
|
struct UserOrderIdTag;
|
||||||
|
/// A strongly-typed user/order id value.
|
||||||
|
using UserOrderId = utils::StrongType<int, UserOrderIdTag>;
|
||||||
|
|
||||||
|
/// DTO to represent an order
|
||||||
|
struct TradeOrder {
|
||||||
|
/// User of the order.
|
||||||
|
User user;
|
||||||
|
/// Symbol of the order.
|
||||||
|
Symbol symbol;
|
||||||
|
/// Price of the order.
|
||||||
|
Price price;
|
||||||
|
/// Quantity of the order.
|
||||||
|
Quantity quantity;
|
||||||
|
/// Side of the order.
|
||||||
|
Side side;
|
||||||
|
/// User/order id.
|
||||||
|
UserOrderId id;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct CancelOrder {
|
||||||
|
/// User of the order.
|
||||||
|
User user;
|
||||||
|
/// User/order id to cancel.
|
||||||
|
UserOrderId id;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct FlushOrder {};
|
||||||
|
|
||||||
|
using Order = std::variant<TradeOrder, CancelOrder, FlushOrder>;
|
||||||
|
|
||||||
|
} // namespace kraken::parse
|
Loading…
Reference in a new issue