Better logging for sniper model.
This commit is contained in:
1 parent
ffcebdf94a
commit
43f4fe2011
2 files changed
+35
-22
No files matched your search
@@ -71,6 +71,7 @@ drop view if exists sniper_shots;
|
||||
create view sniper_shots as
|
||||
select
|
||||
run_id,
|
||||
sim_seq,
|
||||
t_time,
|
||||
h_t_time,
|
||||
val3 begin_eid,
|
||||
@@ -79,38 +80,49 @@ select
|
||||
cast(val6 as real) outcome,
|
||||
cast(val5 as real) / cast(val8 as numeric) target_edge,
|
||||
cast(val8 as numeric) target_quantity,
|
||||
cast(val9 as bool) clean
|
||||
cast(val9 as bool) clean,
|
||||
cast(val10 as bool) forced
|
||||
from
|
||||
log
|
||||
where
|
||||
entry_type='shot_outcome';
|
||||
|
||||
drop view if exists sniper_run_stats;
|
||||
create view sniper_run_stats as
|
||||
select
|
||||
run_id,
|
||||
sum(outcome) pandl,
|
||||
count(*) n,
|
||||
sum(clean) c,
|
||||
sum(forced) f,
|
||||
(count(*) - sum(clean) - sum(forced)) s,
|
||||
(100 * sum(clean) / count(*)) hr,
|
||||
sum (case when outcome > 0 then 1 else 0 end) w,
|
||||
sum (case when outcome <= 0 then 1 else 0 end) l,
|
||||
sum (case when outcome >0 then outcome else 0 end) wcash,
|
||||
sum (case when outcome <= 0 then outcome else 0 end) lcash
|
||||
from
|
||||
sniper_shots
|
||||
group
|
||||
by run_id ;
|
||||
|
||||
drop view if exists sniper_run;
|
||||
create view sniper_run as
|
||||
select
|
||||
run_id,
|
||||
market_date mkt_date,
|
||||
base_algo_latency_ns s_latency,
|
||||
transaction_latency_ns e_latency,
|
||||
use_first_packet_st fp,
|
||||
realized_pandl pandl,
|
||||
position_pandl pos,
|
||||
param1 p1,
|
||||
sniper_run_stats.*,
|
||||
param2 p2,
|
||||
param3 p3,
|
||||
param4 p4,
|
||||
param5 p5,
|
||||
param6 p6,
|
||||
param7 p7,
|
||||
param8 p8,
|
||||
param9 p9,
|
||||
param10 p10,
|
||||
param11 p11,
|
||||
param12 p12
|
||||
param10 p10
|
||||
from
|
||||
run;
|
||||
run, sniper_run_stats
|
||||
where
|
||||
run.run_id = sniper_run_stats.run_id
|
||||
order by
|
||||
mkt_date,
|
||||
pandl;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -191,12 +191,11 @@ void SniperModel::on_order_update(EventHeader const &h,
|
||||
in_flight.working[update.key].fills.push_back(update);
|
||||
|
||||
auto pending_orders = in_flight.working.size();
|
||||
bool all_aggressors = true;
|
||||
bool clean_fills = true;
|
||||
for (auto const &p : in_flight.working) {
|
||||
auto &these_fills = p.second.fills;
|
||||
for (auto &f : these_fills) {
|
||||
all_aggressors =
|
||||
all_aggressors && (f.fill_type == OrderUpdate::AGGRESSIVE);
|
||||
clean_fills = clean_fills && (f.fill_type == OrderUpdate::AGGRESSIVE);
|
||||
if (f.status == OrderUpdate::CANCELED ||
|
||||
f.status == OrderUpdate::FILLED) {
|
||||
pending_orders--;
|
||||
@@ -223,7 +222,9 @@ void SniperModel::on_order_update(EventHeader const &h,
|
||||
api::Side_Name(in_flight.target.side),
|
||||
in_flight.observed.event_id.first, in_flight.observed.event_id.second,
|
||||
in_flight.value_at_observation_ts * in_flight.quantity.value(), net,
|
||||
commission, in_flight.quantity.value(), all_aggressors);
|
||||
commission, in_flight.quantity.value(),
|
||||
clean_fills && !me->current_shot->forced_completion,
|
||||
me->current_shot->forced_completion);
|
||||
me->sim->log_pandl();
|
||||
if (!me->double_dip)
|
||||
transition(State::PAUSED);
|
||||
|
||||
Reference in new issue
Block a user