cleaned up risk limiter ambiguity
This commit is contained in:
1 parent
5b677125bb
commit
d6e10e1ffc
4 files changed
+19
-16
No files matched your search
@@ -23,6 +23,7 @@ namespace risklimits
|
||||
{
|
||||
|
||||
SharedLimiterData::SharedLimiterData(const AccountName& acct, const SymbolKey& sym) :
|
||||
account_name(acct),
|
||||
account_info(api::account::Account::default_instance()),
|
||||
position_info({ sym, 0u, 0u, 0u, 0u }),
|
||||
risk_limit(),
|
||||
@@ -84,21 +85,28 @@ void AccountRiskLimiter::allowed_operators(std::vector<orderman::OperatorID>& op
|
||||
}
|
||||
|
||||
void AccountRiskLimiter::on_account_update(const api::account::Account& acct)
|
||||
{
|
||||
//TODO This is a little strange-- we update the account, but not the limits,
|
||||
//we break those down above and call down below. Might want to rework this, but the reason is because the scope of this object
|
||||
//is Account,Symbolname
|
||||
{
|
||||
bts_assert(acct.tag1() == me->shared_data.account_info.tag1() || me->shared_data.account_info.tag1() == "");
|
||||
me->shared_data.account_info = acct;
|
||||
me->shared_data.risk_limit = api::account::RiskLimit::default_instance();
|
||||
if(me->shared_data.position_info.symbol.second == api::Security::ContractCase::kFuture)
|
||||
{
|
||||
auto iter = acct.future_limits().find(me->shared_data.position_info.symbol.first);
|
||||
if(iter != acct.future_limits().end())
|
||||
me->shared_data.risk_limit = iter->second;
|
||||
}
|
||||
else if(me->shared_data.position_info.symbol.second == api::Security::ContractCase::kSpread)
|
||||
{
|
||||
auto iter = acct.spread_limits().find(me->shared_data.position_info.symbol.first);
|
||||
if(iter != acct.spread_limits().end())
|
||||
me->shared_data.risk_limit = iter->second;
|
||||
}
|
||||
else
|
||||
bts_assert_msg(false, "got risk limit for unknown contract type");
|
||||
for(const auto& i : me->operator_map)
|
||||
i.second->on_account_update();
|
||||
}
|
||||
|
||||
void AccountRiskLimiter::on_risk_limit_update(const api::account::RiskLimit& risk)
|
||||
{
|
||||
me->shared_data.risk_limit = risk;
|
||||
}
|
||||
|
||||
void AccountRiskLimiter::on_operator_update(const api::user::Operator& oper)
|
||||
{
|
||||
auto& lim = me->find_limiter( to<OperatorID>(oper.operator_id().tag50() ));
|
||||
|
||||
@@ -21,7 +21,8 @@ class SharedLimiterData
|
||||
BTS_NO_COPY(SharedLimiterData);
|
||||
public:
|
||||
SharedLimiterData(const orderman::AccountName&, const SymbolKey&);
|
||||
api::account::Account account_info;
|
||||
orderman::AccountName account_name;
|
||||
api::account::Account account_info;
|
||||
struct PositionInfo { SymbolKey symbol;
|
||||
uint32_t long_position; uint32_t short_position;
|
||||
uint32_t long_working; uint32_t short_working; } position_info;
|
||||
@@ -45,7 +46,6 @@ public:
|
||||
protected:
|
||||
friend class RiskLimitManager;
|
||||
void on_account_update(const api::account::Account&);
|
||||
void on_risk_limit_update(const api::account::RiskLimit&);
|
||||
void on_operator_update(const api::user::Operator&);
|
||||
void on_margin_update(const position::MarginResult&);
|
||||
|
||||
|
||||
@@ -50,7 +50,6 @@ struct RiskLimitManager::PImpl
|
||||
{
|
||||
AccountRiskLimiter& lim = find_limiter(to_accountname(acct), to_symbolkey(j.first, contract_type));
|
||||
lim.on_account_update(acct);
|
||||
lim.on_risk_limit_update(j.second);
|
||||
lim.on_operator_update(allowed->second);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,10 +97,6 @@ public:
|
||||
{
|
||||
shared.on_operator_update(oper);
|
||||
}
|
||||
static void risk_limit_update(AccountRiskLimiter& shared, const api::account::RiskLimit& risk)
|
||||
{
|
||||
shared.on_risk_limit_update(risk);
|
||||
}
|
||||
static void order_state_update(RiskLimiter& lim,api::Side side, Quantity quantity, Quantity filled_quantity)
|
||||
{
|
||||
lim.on_order_state(side,quantity,filled_quantity);
|
||||
|
||||
Reference in new issue
Block a user