More DB work.
This commit is contained in:
1 parent
440a68cb9b
commit
b423872e66
3 files changed
+42
-7
No files matched your search
@@ -291,7 +291,7 @@ from
|
||||
where
|
||||
polygon_opportunities.begin_eid=events_begin.eid and
|
||||
polygon_opportunities.end_eid+1=events_end.eid;
|
||||
|
||||
|
||||
|
||||
drop view if exists total_opportunity;
|
||||
create view total_opportunity as
|
||||
@@ -334,5 +334,20 @@ select
|
||||
from
|
||||
opportunities_detail
|
||||
group by opid;
|
||||
|
||||
with entry_exit as (
|
||||
select
|
||||
opportunities.*,
|
||||
entry_books.symbol entry_symbol,
|
||||
exit_books.symbol exit_symbol
|
||||
from
|
||||
opportunities,
|
||||
top_of_books entry_books,
|
||||
top_of_books exit_books
|
||||
where
|
||||
opportunities.begin_eid = entry_books.eid and
|
||||
opportunities.end_eid = exit_books.eid)
|
||||
select count(*) c, avg(observable_duration) d, entry_symbol, exit_symbol from entry_exit group by entry_symbol, exit_symbol order by c;
|
||||
|
||||
|
||||
|
||||
@@ -94,23 +94,32 @@ select
|
||||
param_latency.param_value latency,
|
||||
param_date.param_value date,
|
||||
param_min_depth.param_value min_depth,
|
||||
param_min_orders.param_value min_orders,
|
||||
param_min_value.param_value min_value,
|
||||
param_min_orders.param_value min_orders
|
||||
param_qty.param_value qty,
|
||||
param_max_transaction_latency.param_value max_t_latency,
|
||||
param_double_dip.param_value double_dip
|
||||
from
|
||||
session,
|
||||
run,
|
||||
(select * from param where param_name='base_algo_latency_ns') param_latency,
|
||||
(select * from param where param_name='market_date') param_date,
|
||||
(select * from param where param_name='MinDepth') param_min_depth,
|
||||
(select * from param where param_name='MinOrdersAtTop') param_min_orders,
|
||||
(select * from param where param_name='MinValue') param_min_value,
|
||||
(select * from param where param_name='MinOrdersAtTop') param_min_orders
|
||||
(select * from param where param_name='Qty') param_qty,
|
||||
(select * from param where param_name='MaxTransactionLatency') param_max_transaction_latency,
|
||||
(select * from param where param_name='DoubleDip') param_double_dip
|
||||
WHERE
|
||||
session.session_id = run.session_id and
|
||||
run.run_id = param_latency.run_id and
|
||||
run.run_id = param_date.run_id and
|
||||
run.run_id = param_min_depth.run_id and
|
||||
run.run_id = param_min_orders.run_id and
|
||||
run.run_id = param_min_value.run_id and
|
||||
run.run_id = param_min_orders.run_id
|
||||
run.run_id = param_qty.run_id and
|
||||
run.run_id = param_max_transaction_latency.run_id and
|
||||
run.run_id = param_double_dip.run_id
|
||||
order by
|
||||
cast(realized_pandl as real) desc;
|
||||
|
||||
|
||||
@@ -57,6 +57,7 @@ struct Sniper::PImpl {
|
||||
size_t max_events;
|
||||
double min_value;
|
||||
size_t max_transaction_latency;
|
||||
bool double_dip;
|
||||
|
||||
State state = State::WAIT_OPPORTUNITY;
|
||||
std::unordered_map<MDP3SecurityID, DependentTargets> books;
|
||||
@@ -83,8 +84,10 @@ void Sniper::init(ISimServices &s, protos::SimRunOptions const &options) {
|
||||
param_or_default(options, "MaxEvents", std::numeric_limits<int>::max());
|
||||
me->min_value = param_or_default(options, "MinValue", 2);
|
||||
me->max_transaction_latency =
|
||||
param_or_default(options, "MaxTransactionLatency", 100000);
|
||||
|
||||
1000 * param_or_default(options, "MaxTransactionLatency", 100000);
|
||||
me->double_dip =
|
||||
param_or_default(options,"DoubleDip",false);
|
||||
|
||||
me->state = State::WAIT_OPPORTUNITY;
|
||||
me->books.clear();
|
||||
me->targets.clear();
|
||||
@@ -308,7 +311,15 @@ void Sniper::operator()(const OrderUpdate &update) {
|
||||
me->current_event.second, in_flight.value_at_observation_ts,
|
||||
pandl.net_cash(all_fills));
|
||||
me->sim->log_pandl();
|
||||
transition(State::WAIT_CLEAR);
|
||||
if (!me->double_dip)
|
||||
transition(State::WAIT_CLEAR);
|
||||
else {
|
||||
auto best_shot = pick();
|
||||
if (best_shot)
|
||||
fire(best_shot.value());
|
||||
else
|
||||
transition(State::WAIT_OPPORTUNITY);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user