示例#1
0
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 ) );
    }
  }

}
示例#2
0
void CTraderApi::OnRtnQuote(CUstpFtdcRtnQuoteField *pQuote)
{
	OnQuote(pQuote);
}
示例#3
0
void CTraderApi::OnRtnQuote(CThostFtdcQuoteField *pQuote)
{
	OnQuote(pQuote);
}