本文整理汇总了C++中MamdaOrderBook::bidBegin方法的典型用法代码示例。如果您正苦于以下问题:C++ MamdaOrderBook::bidBegin方法的具体用法?C++ MamdaOrderBook::bidBegin怎么用?C++ MamdaOrderBook::bidBegin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MamdaOrderBook
的用法示例。
在下文中一共展示了MamdaOrderBook::bidBegin方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: displayEntries
void BookViewer::displayEntries (const MamdaOrderBook& book)
{
const char* symbol = book.getSymbol ();
int symbolCol = sMidColumn - (strlen (symbol)/2);
attron (A_BOLD);
mvprintw (0, symbolCol, "%s", symbol);
attroff (A_BOLD);
/* Bid entries */
attron (A_BOLD);
mvprintw (1, 0, "%s", sBidHeading);
attroff (A_BOLD);
MamdaOrderBook::constBidIterator bidIter = book.bidBegin ();
MamdaOrderBook::constBidIterator bidEnd = book.bidEnd ();
int colorId = 1;
for (int i = 2; i < LINES-1;)
{
if (bidIter != bidEnd)
{
const MamdaOrderBookPriceLevel* bidLevel = *bidIter;
displayBidEntriesInLevel (bidLevel, i, colorId);
++bidIter;
++colorId;
}
else
{
mvprintw (i, 0, " |");
i++;
}
}
/* Ask entries */
attron (A_BOLD);
mvprintw (1, sMidColumn+1, "%s", sAskHeading);
attroff (A_BOLD);
MamdaOrderBook::constAskIterator askIter = book.askBegin ();
MamdaOrderBook::constAskIterator askEnd = book.askEnd ();
colorId = 1;
for (int i = 2; i < LINES-1;)
{
if (askIter!= askEnd)
{
const MamdaOrderBookPriceLevel* askLevel = *askIter;
displayAskEntriesInLevel (askLevel, i, colorId);
++askIter;
++colorId;
}
else
{
mvprintw (i, sMidColumn+1,
" ");
i++;
}
}
refresh (); // refresh the screen
}
示例2: displayLevels
void BookViewer::displayLevels (const MamdaOrderBook& book)
{
const char* symbol = book.getSymbol ();
int symbolCol = sMidColumn - (strlen (symbol)/2);
attron (A_BOLD);
mvprintw (0, symbolCol, "%s", symbol);
mvprintw (1, 0, "%s | %s",
" Time Num Size Price",
"Price Size Num Time ");
attroff (A_BOLD);
MamdaOrderBook::constBidIterator bidIter = book.bidBegin ();
MamdaOrderBook::constBidIterator bidEnd = book.bidEnd ();
MamdaOrderBook::constAskIterator askIter = book.askBegin ();
MamdaOrderBook::constAskIterator askEnd = book.askEnd ();
for (int i = 2; i < LINES-1; i++)
{
move (i, 0);
if (i < 7)
attron (COLOR_PAIR (i-1));
if (bidIter != bidEnd)
{
const MamdaOrderBookPriceLevel* bidLevel = *bidIter;
printw (" %12s %4d %7d %7.4f ",
bidLevel->getTime ().getTimeAsString (),
bidLevel->getNumEntries (),
(long)bidLevel->getSize (),
bidLevel->getPrice ());
++bidIter;
}
else
{
printw (" ");
}
printw ("|");
if (askIter!= askEnd)
{
const MamdaOrderBookPriceLevel* askLevel = *askIter;
printw (" %-7.4f %-7d %-6d %-12s ",
askLevel->getPrice (),
(long)askLevel->getSize (),
askLevel->getNumEntries (),
askLevel->getTime ().getTimeAsString ());
++askIter;
}
else
{
printw (" ");
}
if (i < 7)
attroff (COLOR_PAIR (i-1));
}
refresh (); // refresh the screen
}
示例3: handleQuote
void MamdaQuoteToBookListenerImpl::handleQuote (MamdaSubscription* subscription,
const MamaMsg& msg)
{
checkQuoteCount (subscription, msg);
MamdaOrderBookPriceLevel* level = NULL;
if (mQuoteCache.mGotBidSize || mQuoteCache.mGotBidPrice)
{
// get current level
MamdaOrderBook::bidIterator bidIter = mFullBook->bidBegin();
if (bidIter == mFullBook->bidEnd())
level = NULL;
else
level = *bidIter;
if (level == NULL)
{
if (mQuoteCache.mBidSize == (mama_quantity_t)0 || mQuoteCache.mBidPrice.isZero())
{
if (mQuoteCache.mBidSize == (mama_quantity_t)0 && mQuoteCache.mBidPrice.isZero())
{
mama_log (MAMA_LOG_LEVEL_WARN,
"MamdaQuoteToBookListener: Got bid update, but price and size are 0\n");
}
}
else
{
addLevel (level,
mQuoteCache.mBidPrice.getValue(),
mQuoteCache.mBidSize,
MamdaOrderBookPriceLevel::MAMDA_BOOK_SIDE_BID,
mQuoteCache.mQuoteTime);
}
}
else
{
if ((mQuoteCache.mBidSize == 0) || (mQuoteCache.mBidPrice.isZero()))
{
deleteLevel (level, MamdaOrderBookPriceLevel::MAMDA_BOOK_SIDE_BID, mQuoteCache.mQuoteTime);
}
else if (mQuoteCache.mBidPrice == level->getPrice())
{
updateLevel (level,
mQuoteCache.mBidSize,
mQuoteCache.mBidSize - level->getSize(),
MamdaOrderBookPriceLevel::MAMDA_BOOK_SIDE_BID,
mQuoteCache.mQuoteTime);
}
else
{
deleteLevel (level,
MamdaOrderBookPriceLevel::MAMDA_BOOK_SIDE_BID,
mQuoteCache.mQuoteTime);
addLevel (level,
mQuoteCache.mBidPrice.getValue(),
mQuoteCache.mBidSize,
MamdaOrderBookPriceLevel::MAMDA_BOOK_SIDE_BID,
mQuoteCache.mQuoteTime);
}
}
}
if (mQuoteCache.mGotAskSize || mQuoteCache.mGotAskPrice)
{
// get current level
MamdaOrderBook::askIterator askIter = mFullBook->askBegin();
if (askIter == mFullBook->askEnd())
level = NULL;
else
level = *askIter;
if (level == NULL)
{
if (mQuoteCache.mAskSize == (mama_quantity_t)0 || mQuoteCache.mAskPrice.isZero())
{
if (mQuoteCache.mAskSize == (mama_quantity_t)0 && mQuoteCache.mAskPrice.isZero())
{
mama_log (MAMA_LOG_LEVEL_WARN,
"MamdaQuoteToBookListener: Got ask update, but price and size are 0\n");
}
}
else
{
addLevel (level,
mQuoteCache.mAskPrice.getValue(),
mQuoteCache.mAskSize,
MamdaOrderBookPriceLevel::MAMDA_BOOK_SIDE_ASK,
mQuoteCache.mQuoteTime);
}
}
else
{
if ((mQuoteCache.mAskSize == 0) || (mQuoteCache.mAskPrice.isZero()))
{
deleteLevel (level, MamdaOrderBookPriceLevel::MAMDA_BOOK_SIDE_ASK, mQuoteCache.mQuoteTime);
}
else if (mQuoteCache.mAskPrice == level->getPrice())
{
updateLevel (level,
mQuoteCache.mAskSize,
mQuoteCache.mAskSize - level->getSize(),
MamdaOrderBookPriceLevel::MAMDA_BOOK_SIDE_ASK,
//.........这里部分代码省略.........
示例4: prettyPrintLevels
void prettyPrintLevels (const MamdaOrderBook& book)
{
printf ("%s | %s\n",
" Time Num Size Price Act",
"Act Price Size Num Time ");
MamdaOrderBook::constBidIterator bidIter = book.bidBegin ();
MamdaOrderBook::constBidIterator bidEnd = book.bidEnd ();
MamdaOrderBook::constAskIterator askIter = book.askBegin ();
MamdaOrderBook::constAskIterator askEnd = book.askEnd ();
char timeStr[32];
if (mShowMarketOrders)
{
printf (" MARKET ORDERS ---------------------------------------------------------------\n");
const MamdaOrderBookPriceLevel* marketOrders = NULL;
if (marketOrders = book.getBidMarketOrders())
{
marketOrders->getTime().getAsFormattedString (timeStr, 32, "%T%;");
printf (" %12s %4d %7g MARKET %c ",
timeStr,
marketOrders->getNumEntries (),
marketOrders->getSize (),
marketOrders->getAction ());
}
else
{
printf (" ");
}
printf ("|");
if (marketOrders = book.getAskMarketOrders())
{
marketOrders->getTime().getAsFormattedString (timeStr, 32, "%T%;");
printf (" %c MARKET %-7g %-6d %-12s ",
marketOrders->getAction (),
marketOrders->getSize (),
marketOrders->getNumEntries (),
timeStr);
}
else
{
printf (" ");
}
printf ("\n");
printf (" LIMIT ORDERS ---------------------------------------------------------------\n");
}
while ((bidIter != bidEnd) || (askIter != askEnd))
{
if (bidIter != bidEnd)
{
const MamdaOrderBookPriceLevel* bidLevel = *bidIter;
bidLevel->getTime().getAsFormattedString (timeStr, 32, "%T%;");
printf (" %12s %4d %7g %7.*f %c ",
timeStr,
bidLevel->getNumEntries (),
bidLevel->getSize (),
mPrecision,
bidLevel->getPrice (),
bidLevel->getAction ());
++bidIter;
}
else
{
printf (" ");
}
printf ("|");
if (askIter != askEnd)
{
const MamdaOrderBookPriceLevel* askLevel = *askIter;
askLevel->getTime().getAsFormattedString (timeStr, 32, "%T%;");
printf (" %c %-7.*f %-7g %-6d %-12s ",
askLevel->getAction (),
mPrecision,
askLevel->getPrice (),
askLevel->getSize (),
askLevel->getNumEntries (),
timeStr);
++askIter;
}
printf ("\n");
}
printf ("\n");
}
示例5: prettyPrintEntries
void prettyPrintEntries (const MamdaOrderBook& book)
{
printf ("%s\n",
" ID/Num Time Size Price");
MamdaOrderBook::constBidIterator bidIter = book.bidBegin ();
MamdaOrderBook::constBidIterator bidEnd = book.bidEnd ();
MamdaOrderBook::constAskIterator askIter = book.askBegin ();
MamdaOrderBook::constAskIterator askEnd = book.askEnd ();
char timeStr[32];
if (mShowMarketOrders)
{
const MamdaOrderBookPriceLevel* marketBidLevel =
book.getBidMarketOrders ();
if (marketBidLevel)
{
marketBidLevel->getTime().getAsFormattedString (timeStr, 32, "%T%;");
printf (" Bid %4d %12s %7g MARKET\n",
marketBidLevel->getNumEntries (),
timeStr,
marketBidLevel->getSize ());
MamdaOrderBookPriceLevel::const_iterator end = marketBidLevel->end ();
MamdaOrderBookPriceLevel::const_iterator i = marketBidLevel->begin ();
while (i != end)
{
const MamdaOrderBookEntry* entry = *i;
const char* id = entry->getId ();
mama_quantity_t size = entry->getSize ();
entry->getTime().getAsFormattedString (timeStr, 32, "%T%;");
printf (" %14s %12s %7g MARKET\n",
id, timeStr, size);
++i;
}
}
}
if (mShowMarketOrders)
{
const MamdaOrderBookPriceLevel* marketAskLevel =
book.getAskMarketOrders ();
if (marketAskLevel)
{
marketAskLevel->getTime().getAsFormattedString (timeStr, 32, "%T%;");
printf (" Ask %4d %12s %7g MARKET\n",
marketAskLevel->getNumEntries (),
timeStr,
marketAskLevel->getSize ());
MamdaOrderBookPriceLevel::const_iterator end = marketAskLevel->end ();
MamdaOrderBookPriceLevel::const_iterator i = marketAskLevel->begin ();
while (i != end)
{
const MamdaOrderBookEntry* entry = *i;
const char* id = entry->getId ();
mama_quantity_t size = entry->getSize ();
entry->getTime().getAsFormattedString (timeStr, 32, "%T%;");
printf (" %14s %12s %7g MARKET\n",
id, timeStr, size);
++i;
}
}
}
while (bidIter != bidEnd)
{
const MamdaOrderBookPriceLevel* bidLevel = *bidIter;
bidLevel->getTime().getAsFormattedString (timeStr, 32, "%T%;");
printf (" Bid %4d %12s %7g %7.*f\n",
bidLevel->getNumEntries (),
timeStr,
bidLevel->getSize (),
mPrecision,
bidLevel->getPrice ());
MamdaOrderBookPriceLevel::const_iterator end = bidLevel->end ();
MamdaOrderBookPriceLevel::const_iterator i = bidLevel->begin ();
while (i != end)
{
const MamdaOrderBookEntry* entry = *i;
const char* id = entry->getId ();
mama_quantity_t size = entry->getSize ();
double price = bidLevel->getPrice ();
entry->getTime().getAsFormattedString (timeStr, 32, "%T%;");
printf (" %14s %12s %7g %7.*f\n",
id, timeStr, size, mPrecision, price);
++i;
}
++bidIter;
}
while (askIter != askEnd)
{
const MamdaOrderBookPriceLevel* askLevel = *askIter;
askLevel->getTime().getAsFormattedString (timeStr, 32, "%T%;");
printf (" Ask %4d %12s %7g %7.*f\n",
askLevel->getNumEntries (),
timeStr,
askLevel->getSize (),
mPrecision,
askLevel->getPrice ());
MamdaOrderBookPriceLevel::const_iterator end = askLevel->end ();
MamdaOrderBookPriceLevel::const_iterator i = askLevel->begin ();
//.........这里部分代码省略.........