80 lines
2.0 KiB
C++
80 lines
2.0 KiB
C++
#include "Application.h"
|
|
|
|
#include <quickfix/FileStore.h>
|
|
#include <quickfix/SocketAcceptor.h>
|
|
#include <quickfix/SessionSettings.h>
|
|
#include <boost/algorithm/string/replace.hpp>
|
|
|
|
#include <string>
|
|
#include <iostream>
|
|
#include <fstream>
|
|
|
|
#include "lib/os/os.h"
|
|
#include "lib/config/protos/Ports.pb.h"
|
|
#include "lib/config/config.h"
|
|
|
|
#include <quickfix/FileLog.h>
|
|
|
|
namespace bts {
|
|
namespace sim {
|
|
auto cfg =
|
|
"[DEFAULT]\n"
|
|
"ConnectionType=acceptor\n"
|
|
"SocketAcceptPort=$EXCHANGE_SIM_FIX_PORT\n"
|
|
"SocketReuseAddress=Y\n"
|
|
"StartTime=06:02:00\n"
|
|
"EndTime=05:55:00\n"
|
|
"FileLogPath=$BTS_DATA_PATH/exchange_sim/log\n"
|
|
"FileStorePath=$BTS_DATA_PATH/exchange_sim/store\n"
|
|
"HeartBtInt=30\n"
|
|
"[SESSION]\n"
|
|
"BeginString=FIX.4.2\n"
|
|
"SenderCompID=BTS\n"
|
|
"TargetCompID=SPARK\n"
|
|
"UseDataDictionary=N\n"
|
|
"ValidateFieldsOutOfOrder=N\n";
|
|
|
|
int start_exchange_sim()
|
|
{
|
|
try
|
|
{
|
|
auto str_settings = std::string(cfg);
|
|
boost::replace_all(str_settings,"$BTS_DATA_PATH", os::bts_data_path());
|
|
boost::replace_all(str_settings,"$EXCHANGE_SIM_FIX_PORT",
|
|
std::to_string(
|
|
config::get<config::Ports>().exchange_sim_fix_port()));
|
|
|
|
std::istringstream str{str_settings};
|
|
FIX::SessionSettings settings( str );
|
|
|
|
Application application;
|
|
FIX::FileStoreFactory storeFactory( settings );
|
|
FIX::FileLogFactory logFactory( settings );
|
|
FIX::SocketAcceptor acceptor( application, storeFactory, settings, logFactory );
|
|
|
|
acceptor.start();
|
|
while ( true )
|
|
{
|
|
std::string value;
|
|
std::cin >> value;
|
|
|
|
if ( value == "#symbols" )
|
|
application.orderMatcher().display();
|
|
else if( value == "#quit" )
|
|
break;
|
|
else
|
|
application.orderMatcher().display( value );
|
|
|
|
std::cout << std::endl;
|
|
}
|
|
acceptor.stop();
|
|
return 0;
|
|
}
|
|
catch ( std::exception & e )
|
|
{
|
|
std::cout << e.what() << std::endl;
|
|
return 1;
|
|
}
|
|
}
|
|
}}
|