More refactoring of orderman.
This commit is contained in:
1 parent
551ac20aaf
commit
560e54075c
50 files changed
+144
-220
No files matched your search
@@ -2,7 +2,7 @@
|
||||
|
||||
#include "Position.h"
|
||||
#include "IPositionObserver.h"
|
||||
#include "server/sparkd/orderman/utils/orderman_utils.h"
|
||||
#include "server/sparkd/orderman2/orderman2_utils/orderman2_common.h"
|
||||
#include "server/sparkd/securities/SecurityDB.h"
|
||||
|
||||
#include "lib/utils/bts_assert.h"
|
||||
@@ -23,12 +23,12 @@ template <typename T> int sgn(T val) {
|
||||
class BookEntry
|
||||
{
|
||||
public:
|
||||
orderman::AccountName account;
|
||||
orderman2::AccountName account;
|
||||
SecurityKey security_key;
|
||||
double position;
|
||||
double avg_price;
|
||||
public:
|
||||
BookEntry(const orderman::AccountName& acc, SecurityKey k) :
|
||||
BookEntry(const orderman2::AccountName& acc, SecurityKey k) :
|
||||
account(acc), security_key(k), position(0.0), avg_price(0.0)
|
||||
{
|
||||
}
|
||||
@@ -49,14 +49,14 @@ public:
|
||||
|
||||
struct PositionServiceCore::PImpl
|
||||
{
|
||||
typedef std::pair<orderman::AccountName, SecurityKey> KeyType;
|
||||
typedef std::pair<orderman2::AccountName, SecurityKey> KeyType;
|
||||
boost::container::flat_map<KeyType, std::shared_ptr<BookEntry>> book;
|
||||
IPositionObserver* observer;
|
||||
PImpl(IPositionObserver* obs) : book(), observer(obs)
|
||||
{
|
||||
}
|
||||
|
||||
BookEntry& find_entry(const orderman::AccountName& account, SecurityKey skey)
|
||||
BookEntry& find_entry(const orderman2::AccountName& account, SecurityKey skey)
|
||||
{
|
||||
KeyType key(account, skey);
|
||||
auto& entry = book[key];
|
||||
@@ -65,7 +65,7 @@ struct PositionServiceCore::PImpl
|
||||
return *entry;
|
||||
}
|
||||
|
||||
void book_raw_fill(const orderman::AccountName& account, SecurityKey sec,
|
||||
void book_raw_fill(const orderman2::AccountName& account, SecurityKey sec,
|
||||
double last_size, double last_price, api::Side side)
|
||||
{
|
||||
auto& entry = find_entry(account, sec);
|
||||
@@ -82,7 +82,7 @@ PositionServiceCore::PositionServiceCore(securities::SecurityDB& db, IPositionOb
|
||||
|
||||
PositionServiceCore::~PositionServiceCore() {}
|
||||
|
||||
bool PositionServiceCore::query_position(const orderman::AccountName& account, SecurityKey seckey, Position& result)
|
||||
bool PositionServiceCore::query_position(const orderman2::AccountName& account, SecurityKey seckey, Position& result)
|
||||
{
|
||||
auto& entry = me->find_entry(account, seckey);
|
||||
auto sec = _db.resolve(entry.security_key);
|
||||
@@ -99,7 +99,7 @@ bool PositionServiceCore::query_position(const orderman::AccountName& account, S
|
||||
return false;
|
||||
}
|
||||
|
||||
void PositionServiceCore::query_all_positions(const orderman::AccountName& account, std::vector<Position>& result)
|
||||
void PositionServiceCore::query_all_positions(const orderman2::AccountName& account, std::vector<Position>& result)
|
||||
{
|
||||
result.reserve(me->book.size());
|
||||
for(auto& entry : me->book)
|
||||
@@ -123,7 +123,7 @@ void PositionServiceCore::query_all_positions(const orderman::AccountName& accou
|
||||
void PositionServiceCore::consume_raw_fill(const std::string& account, uint32_t security_key,
|
||||
double last_size, double last_price, api::Side side)
|
||||
{
|
||||
orderman::AccountName acc = orderman::to<orderman::AccountName>(account);
|
||||
orderman2::AccountName acc = orderman2::to<orderman2::AccountName>(account);
|
||||
SecurityKey skey(security_key);
|
||||
auto sec = _db.resolve(skey);
|
||||
if(sec->Contract_case() == api::Security::ContractCase::kSpread)
|
||||
|
||||
Reference in new issue
Block a user