Ejemplo n.º 1
0
void Strategy::printExecutionReport( const FIX42::ExecutionReport ereport ) {

	FIX::OrderID orderID;
	FIX::ExecID execID;
	FIX::ExecTransType execTransType;
	FIX::ExecType execType;
	FIX::OrdStatus ordStatus;
	FIX::Symbol symbol;
	FIX::Side side;
	FIX::LeavesQty leavesQty;
	FIX::CumQty cumQty;
	FIX::AvgPx avgPx;

	ereport.get(orderID);
	ereport.get(execID);
	ereport.get(execTransType);
	ereport.get(execType);
	ereport.get(ordStatus);
	ereport.get(symbol);
	ereport.get(side);
	ereport.get(leavesQty);
	ereport.get(cumQty);
	ereport.get(avgPx);

	std::cout<<  "[EXECUTION REPORT] symbol:" << symbol
			<< "\tSide:" << ( side == FIX::Side_SELL ? "SELL" : "BUY" )
			<< "\tLeavesQty:" << leavesQty
			<< "\tCumQty:" << cumQty
			<< "\tAvgPx:"<< std::fixed << std::setprecision(2) << (double)avgPx
			<< std::endl;
}
Ejemplo n.º 2
0
void Application::onMessage
( const FIX42::ExecutionReport& message, const FIX::SessionID& ) {

    FIX::OrdStatus status;
    message.get(status);

    switch(status){
    case (FIX::OrdStatus_NEW):
		getConfirmationTrade=true;
    	break;
    case (FIX::OrdStatus_PARTIALLY_FILLED):
		getConfirmationPartialExecutionTrade =true;
		this->strategy.postTrade(message);
    	break;
    case (FIX::OrdStatus_FILLED):
		getConfirmationExecutionTrade =true;
		this->strategy.postTrade(message);
    	break;
    case (FIX::OrdStatus_CANCELED):
		getConfirmationCanceledTrade=true;
    	break;
    default:
    	break;

    }
}
Ejemplo n.º 3
0
void Strategy::postTrade(FIX42::ExecutionReport ereport){
	std::cout << "Strategy::PostTrade"<<std::endl;
	//this->printExecutionReport(ereport);

	FIX::LastShares lastShares;
	FIX::LastPx lastPx;
	FIX::Side side;

	ereport.get(lastShares);
	ereport.get(lastPx);
	ereport.get(side);

	this->numberStock += ( side == FIX::Side_SELL ? -lastShares : +lastShares );
	this->cash += ( side == FIX::Side_SELL ? +lastShares*lastPx : -lastShares*lastPx );


    FIX::TransactTime now;

	this->agentControl.setPortfolio(now.getString(),this->cash, this->numberStock, 0.0);

	//if(this->cash <= 0.0 && this->numberStock <= 0.0)
	//	exit(1);

}