Order going out: (->OrderServiceServer -> ... EMNativeOrder -> ... -> EMExecutionGateway -> exchange)
----------------

OrderServiceServer::create_order (Create) ->
ServiceBridge::create_order(Create) ->
   publish(ActivateOrderEvent)
OrderManager::on_activate_order(const mercury::Update<ActivateOrderEvent> &) ->
OrderServices::activate ->
EMNativeOrder::on_activate (p, q, services) ->
OrderServices::queue_order_msg (CreateOrderMsg) ->
SessionServices::queue_order_msg(CreateOrderMsg) ->
   _session_data->buffered_order_msgs->emplace_back(OrderMsg{order_op}) ->

OrderManager has the handle to the same queue above (buffered_order_msgs)
In OrderManager::after_event it checks for messages and sends them to IExecutionGateway
(gw->send_msgs(queued_ops, osd->current_trace);)

EMExecutionGateway::send_msg(std::vector<OrderMsg> const &)
(this is where the order is actually sent out)

The above is a single chain (callstack maybe), but there are other components 
listening to events and acting


Callbacks coming in (exchange -> ... EMExecutionGateway ... -> EMNativeOrder .. -> OrderServiceServer)
--------------------

EMExecutionGateway::dispatch_incoming_fix_messages() ->
(EMExecutionGateway receives messages independently from the exchange and queues them,
in dispatch_incoming_fix_messages, it calls on_exe_report)

EMExecutionGateway::on_exe_report(ExecutionReport) ->
OrderManager::publish(mercury::Stream<NewExecutionReportEvent) ->

EMNativeOrder::_on_exe_report(const NewExecutionReportEvent &er) ->
EMNativeOrder::report_state() ->
OrderServices::report_state(OrderState) ->
OrderManager::publish(OrderStateUpdateEvent) ->
   through the event system
OrderStore::on_order_state_update(mercury::Update<OrderStateUpdateEvent> const &) ->
OrderStore::publish(StoredOrderEvent) ->
   through the event system
ServiceBridge::on(mercury::Update<StoredOrderEvent> const &) ->
OrderServiceServer::on_orders(OrderRecord)
(goes out to the client)

Persisting Orders:
-----------------
EMNativeOrder::report_state ->
OrderServices::report_state ->
OrderManager::publish(mercury::Stream<OrderStateUpdateEvent>) ->
   through the event system
OrderStore::on_order_state_update(mercury::Stream<OrderStateUpdateEvent>&)

Persisting Fills:
-----------------
FillStore::on_execution_report(const mercury::Update<NewExecutionReportEvent> &)

Order/ExecutionReport state:
---------------------------

IEMOrderMuxer::EMOrderState absorbs emumba::order_entry::order_state
ExecutionReport copies values directly from EMOrderState (no logic except to check trades)
EMNativeOrder::_absorb_fill checks for er.last_shares and copies fill values directly from ExecutionReport

RFQ:
----
OrderServiceServer::send_rfq ->
ServiceBridge::send_rfq ->
   publish(RFQEvent)
OrderManager::on_rfq_send (event callback) ->
IExecutionGateway::send_msgs  // iterates through all  of them
// for Deribit
EMExecutionGateway::send_msgs ->
EmMDListener::send_rfq

Misc:
-----
To search for a publisher for an event search for make_stream<Event_Name>, for 
example make_stream<OrderStateUpdateEvent>()

is_gateway_connected can be false in the NativeOrder class (GlbxNativeOrder) ->
OrderServices->is_gateway_connected->
SessionServices->is_gateway_connected
SessionServicesData->gw_connected
OrderManager sets SessionServicesData->gw_connected on void OrderManager::on_gateway_state(const mercury::Update<GatewayStatusChangeEvent> &m)


Exchange gateway is down (debugging):
-------------------------------------
This happens at times and if often a config issue.
GlbCNativeOrder::_on_activate ->
OrderServices::is_gateway_connected ->
SessionServices::is_gateway_connected ->
SessionServicesData::

IExecutionGateway::on_gw_status_change is what sends out the status


--------------------------------------------------------------------------
market data
--------------------------------------------------------------------------
adding exchanges:
the following places need to accommodate exchanges
managed:
- SecurityExtensions: public static string security_desc(this SecurityImmutable security) ..
- SecurityExtensions: public static Venue to_venue(this domain.Venue api_venue) ..
- SecurityExtensions: public static domain.Venue to_api_venue(this Venue venue) ..
C++
- AdminServiceUtils.cpp, 6 switch statements should compilation error
- Symbols.proto in Symbols
- Symbols.conf exchange section in SymbolLists and Symbols
- Security.proto, 3 places 
- FixedSecurity.cpp, exchange_id(..) and convert_security(..) both switch
- QueryServer set_mic, switch
- VenueOption name(..) switch
- DomainSecurityUtils switch, get_security, convert
- MarketDataSubscription.cpp Pimpl and create add
- MarketDataSubscription.h Pimpl and create add
-MarketDataConfig.proto add entry and create file

---------------------------------------------------------------------------
adding security type
---------------------------------------------------------------------------
 modified:   src/lib/api/service_helpers/AdminServiceUtils.cpp
        modified:   src/lib/domain_model/Security.cpp
        modified:   src/lib/domain_model/Security.proto
        modified:   src/lib/md/MDConsumer.cpp
        modified:   src/lib/md/SecurityMapper.cpp
        modified:   src/lib/md/Shm/FixedSecurity.cpp
        modified:   src/lib/md/Shm/FixedSecurity.h
        modified:   src/lib/md/ccApi/CCMain.cpp
        modified:   src/lib/md/ccApi/CCMarketDataListener.cpp
        modified:   src/lib/md/relay/RelayClient.cpp
        modified:   src/lib/orderman/limiter/Limiter.cpp

ALGO:
----
// last 3 steps before an algo gets a child order update

AlgoWrapperOrder::me->services->subscribe_to_child_updates
AlgoWrapperOrder::on_child_order_update
TaskingEyeAlgo::on_child_change

ORDER ROUTING (JetFix connections)
-------------
EMNativeOrder::SessionServices = OrderServices::get_session_services("deribit_1");
session services are tied to JetFIX::Connection::name
(so eventhough crypto exchanges dont use the JetFix connection, they are tied to them)
For non CME connections we just add these hard coded connection names to JetFix.conf
and then AdminServiceUtils::fill_connections_from_config (gets called at server boot)
and adds them to the DB
This is complicated and needless. For now, we will make the names not be hardcoded,
and deal with the rest later


MARKET DATA REPLAY:
------------------
main.cpp ->
Md::Md() ->
Record::Record ->
RelayClient::record_everything (not a class function) ->
RelayClient::RelayScheduler::run


--------------------------------------------------------------------------
market data
--------------------------------------------------------------------------
adding exchanges:
the following places need to accommodate exchanges
managed:
- SecurityExtensions: public static string security_desc(this SecurityImmutable security) ..
- SecurityExtensions: public static Venue to_venue(this domain.Venue api_venue) ..
- SecurityExtensions: public static domain.Venue to_api_venue(this Venue venue) ..
C++
- AdminServiceUtils.cpp, 6 switch statements should compilation error
- Symbols.proto in Symbols
- Symbols.conf exchange section in SymbolLists and Symbols
- Security.proto, 3 places 
- FixedSecurity.cpp, exchange_id(..) and convert_security(..) both switch
- QueryServer set_mic, switch
- VenueOption name(..) switch

---------------------------------------------------------------------------
adding security type
---------------------------------------------------------------------------
 modified:   src/lib/api/service_helpers/AdminServiceUtils.cpp
        modified:   src/lib/domain_model/Security.cpp
        modified:   src/lib/domain_model/Security.proto
        modified:   src/lib/md/MDConsumer.cpp
        modified:   src/lib/md/SecurityMapper.cpp
        modified:   src/lib/md/Shm/FixedSecurity.cpp
        modified:   src/lib/md/Shm/FixedSecurity.h
        modified:   src/lib/md/ccApi/CCMain.cpp
        modified:   src/lib/md/ccApi/CCMarketDataListener.cpp
        modified:   src/lib/md/relay/RelayClient.cpp
        modified:   src/lib/orderman/limiter/Limiter.cpp
