void Position::HandleQuote( quote_t quote ) { if ( ( 0 == quote.Ask() ) || ( 0 == quote.Bid() ) ) return; OnQuote( quote ); double dblPreviousUnRealizedPL = m_row.dblUnRealizedPL; bool bProcessed(false); double dblMarketValue; switch ( m_row.eOrderSideActive ) { case OrderSide::Buy: dblMarketValue = m_row.nPositionActive * quote.Bid() * m_dblMultiplier; m_row.dblUnRealizedPL = dblMarketValue - m_row.dblConstructedValue; bProcessed = true; break; case OrderSide::Sell: dblMarketValue = - ( m_row.nPositionActive * quote.Ask() ) * m_dblMultiplier; m_row.dblUnRealizedPL = dblMarketValue - m_row.dblConstructedValue; bProcessed = true; break; } if ( bProcessed ) { OnQuotePostProcess( quote_pair_t( *this, quote ) ); if ( dblPreviousUnRealizedPL != m_row.dblUnRealizedPL ) { OnUnRealizedPL( PositionDelta_delegate_t( *this, dblPreviousUnRealizedPL, m_row.dblUnRealizedPL ) ); } } }
void CTraderApi::OnRtnQuote(CUstpFtdcRtnQuoteField *pQuote) { OnQuote(pQuote); }
void CTraderApi::OnRtnQuote(CThostFtdcQuoteField *pQuote) { OnQuote(pQuote); }