43 lines
1.2 KiB
C++
43 lines
1.2 KiB
C++
#pragma once
|
|
|
|
#include "lib/api/services/PositionService.server.pb.h"
|
|
#include "lib/utils/bts_no_copy.h"
|
|
#include <vector>
|
|
|
|
namespace bts {
|
|
namespace md {
|
|
class MDClient;
|
|
}
|
|
|
|
namespace position {
|
|
|
|
class MDClient;
|
|
|
|
class PositionServicePNLHelper {
|
|
private:
|
|
struct PImpl;
|
|
std::unique_ptr<PImpl> me;
|
|
|
|
private:
|
|
double _compute_day_pnl(const bts::api::position::PNLUnit &);
|
|
// double _get_cpp (uint32_t);
|
|
// aggregates [sec, account]->pnl tp [account]->pnl
|
|
void _aggregate_account_pnl(
|
|
const std::vector<api::position::PNLUnit> &in_pnl,
|
|
const std::map<std::string, uint32_t> &account_map,
|
|
std::vector<api::position::AccountPNL> &out_account_pnl);
|
|
void _log_missing_data(const bts::api::position::PNLUnit &);
|
|
|
|
public:
|
|
PositionServicePNLHelper(md::MDClient &client);
|
|
~PositionServicePNLHelper();
|
|
void compute_pnl(
|
|
const std::map<int, bts::api::position::PositionUnit const *> &in_pos,
|
|
const std::map<std::string, uint32_t> &account_map,
|
|
const std::map<uint32_t, double> &cpp_override_map,
|
|
std::vector<bts::api::position::PNLUnit> &out_pnl,
|
|
std::vector<bts::api::position::AccountPNL> &out_account_pnl);
|
|
};
|
|
} // namespace position
|
|
} // namespace bts
|