70 lines
2.4 KiB
C++
70 lines
2.4 KiB
C++
#pragma once
|
|
|
|
#include "lib/api/services/OrderService.pb.h"
|
|
#include "lib/orderman/orders/Order.h"
|
|
#include "lib/tracing/PerfLog.h"
|
|
#include <memory>
|
|
|
|
namespace bts {
|
|
namespace orderman {
|
|
struct RoutingRecord;
|
|
class NewExecutionReportEvent;
|
|
class CancelRejectEvent;
|
|
class GatewayStatusChangeEvent;
|
|
class ExecutionReport;
|
|
|
|
class NativeOrder : public Order {
|
|
public:
|
|
NativeOrder();
|
|
~NativeOrder() override;
|
|
|
|
api::orderman::OrderDefinition const &definition() const override;
|
|
void on_init_new(api::orderman::OrderDefinition const &,
|
|
const PreActivationOrderServices &) override;
|
|
void on_init_recovered(api::orderman::OrderRecord const &,
|
|
const PreActivationOrderServices &) override;
|
|
void on_activate(Price, Quantity, OrderServices &,
|
|
trace::CorID const &) override;
|
|
void on_update(Price, Quantity, trace::CorID const &) override;
|
|
void on_crack(trace::CorID const &) override;
|
|
void on_cancel(trace::CorID const &) override;
|
|
|
|
void on_init_from_exe_report(ExecutionReport const &,
|
|
const PreActivationOrderServices &);
|
|
|
|
protected:
|
|
void warm_up_activate(OrderServicesData &,OrderServices&) override;
|
|
|
|
private:
|
|
struct PImpl;
|
|
std::unique_ptr<PImpl> me;
|
|
|
|
bool _on_activate(Price, Quantity, bts::orderman::OrderServices &,
|
|
trace::CorID const &);
|
|
void on_exe_report(const NewExecutionReportEvent &);
|
|
void on_cancel_reject(const CancelRejectEvent &);
|
|
void on_gateway_status(const GatewayStatusChangeEvent &);
|
|
void report_state(trace::CorID const &trace = trace::CorID());
|
|
|
|
void init_fix();
|
|
void add_exchange_order_id_to_fix();
|
|
|
|
void transition(api::orderman::OrderStatus new_state,
|
|
std::string const &msg);
|
|
void transition(api::orderman::OrderStatus new_state);
|
|
void transition_to_error(api::orderman::NativeOrderState::SubError sub_error,
|
|
std::string const &msg);
|
|
|
|
void update_working_position();
|
|
bool has_exchange_order_id();
|
|
Quantity position_contribution();
|
|
bool is_old_exe_report(api::orderman::NativeOrderState &,
|
|
const NewExecutionReportEvent &) const;
|
|
bool terminal_state(api::orderman::OrderStatus status) const;
|
|
api::orderman::NativeOrderState &
|
|
get_native_state(api::orderman::OrderState &);
|
|
};
|
|
|
|
} // namespace orderman
|
|
} // namespace bts
|