当前位置: 首页>>代码示例>>C++>>正文


C++ Stock类代码示例

本文整理汇总了C++中Stock的典型用法代码示例。如果您正苦于以下问题:C++ Stock类的具体用法?C++ Stock怎么用?C++ Stock使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Stock类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

int main()
{
    using std::cout;
    using std::ios_base;

// create an array of initialized objects
    Stock stocks[STKS] = {
        Stock("NanoSmart", 12, 20.0),
        Stock("Boffo Objects", 200, 2.0),
        Stock("Monolithic Obelisks", 130, 3.25),
        Stock("Fleep Enterprises", 60, 6.5)
        };

    cout.precision(2);                               // #.## format
    cout.setf(ios_base::fixed, ios_base::floatfield);// #.## format
    cout.setf(ios_base::showpoint);                  // #.## format

    cout << "Stock holdings:\n";
    int st;
    for (st = 0; st < STKS; st++)
        stocks[st].show();

    Stock top = stocks[0];
    for (st = 1; st < STKS; st++)
        top = top.topval(stocks[st]);
    cout << "\nMost valuable holding:\n";
    top.show();

    return 0; 
}
开发者ID:feiermi,项目名称:C-Primer-Plus-,代码行数:30,代码来源:usestok2.cpp

示例2: command

Stock PgsqlDataProvider::getStock(uint32_t id)
{
  nontransaction command(*conn);  
  string query = "SELECT id, price FROM get_stock(" + to_string(id) + ");";
  result queryResult(command.exec(query));
  
  if (verbose)
    cout << "Result of " << query << ": " << endl;

  if (queryResult.size() != 1)
  {
    cerr << "getStock: Incorrect number of results: " << queryResult.size() << endl;
    throw invalid_argument("getStock: Incorrect number of results.");
  }

  if (queryResult[0][0].is_null())
  {
    cerr << "getStock: Stock id = " << id << " does not exist." << endl;
    throw invalid_argument("getStock: Stock does not exist.");
  }

  Stock stock;
  stock.setId(queryResult[0][0].as<int>());
  stock.setPrice(Decimal(queryResult[0][1].as<string>()));
  if (verbose)
    cout << "Stock: id = " << stock.getId() << ", price = " << stock.getPrice() << endl;

  return stock;
}
开发者ID:junajan,项目名称:nodejs-stock,代码行数:29,代码来源:PgsqlDataProvider.cpp

示例3: return

template <class numericType> numericType calculatePERatio<numericType>::operator() (const Stock<numericType>& stock) {
  if ((stock.getTickerPrice() == 0) || (stock.getLastDividend() == 0)) {
    return (numericType)0;
  }
  
  return (numericType)(stock.getTickerPrice()/stock.getLastDividend());
}
开发者ID:qm-jpm-job,项目名称:interview,代码行数:7,代码来源:peRatioCalculator.cpp

示例4: Stock

Stock* Stock::create(int stockCode, String* stockName,int nowPrice,int makedealprice,float percent,int storeNumber )
{
	Stock* stock = new Stock(stockCode,stockName,nowPrice,makedealprice,percent,storeNumber);
	stock->init();
	stock->autorelease();
	return stock;
}
开发者ID:coolshou,项目名称:richer,代码行数:7,代码来源:Stock.cpp

示例5: moveTest

  static void moveTest(){
    ostringstream oss;
    Stock stock = Stock();
    Draw draw = Draw();

    int size;
    try {
      draw.move(stock, size = 26);
      assert(stock.getSize() == 26);
      
      draw.move(stock, size = 5);
    } catch(std::logic_error & e){
      oss << "Failure while trying to take " << size << " cards!";
    }
    assert(oss.str() == "Failure while trying to take 5 cards!");    
    oss.str("");
    oss.clear();
  
    Build build = Build();
    stock += 3;
    try {
      stock.move(build);
      assert(false);
    }
    catch(std::exception & e){
      oss << e.what();
    }
    assert(oss.str() == "Can't add card - not in sequence!\n");    
  }  
开发者ID:smsukardi,项目名称:skip-bo,代码行数:29,代码来源:DeckTest.cpp

示例6: market_code

HKU_API std::ostream & operator<<(std::ostream& os, const TradeRecord& record) {
    Stock stock = record.stock;
    string market_code(""), name("");
    if(!stock.isNull()){
        market_code = stock.market_code();
#if defined(BOOST_WINDOWS) && (PY_VERSION_HEX >= 0x03000000)
        name = utf8_to_gb(stock.name());
#else
        name = stock.name();
#endif
    }

    string strip(", ");
    os << std::fixed;
    os.precision(4);
    os << "Trade(" << record.datetime << strip << market_code
            << strip << name << strip << getBusinessName(record.business)
            << strip << record.planPrice << strip << record.realPrice;

    if (record.goalPrice == Null<price_t>()) {
        os << strip << "NULL";
    }  else {
        os << strip << record.goalPrice;
    }

    os << strip << record.number << strip << record.cost.commission
       << strip << record.cost.stamptax << strip << record.cost.transferfee
       << strip << record.cost.others << strip << record.cost.total
       << strip << record.stoploss << strip << record.cash
       << strip << getSystemPartName(record.from) << ")";

    os.unsetf(std::ostream::floatfield);
    os.precision();
    return os;
}
开发者ID:fasiondog,项目名称:hikyuu,代码行数:35,代码来源:TradeRecord.cpp

示例7: main

int main(void)
{
	using std::cout;
	using std::ios_base;

	Stock stocks[STKS] = {
		Stock("NanoSmart", 12, 20.0),
		Stock("Boffo Objects", 200, 2.0),
		Stock("Obelisk blue", 130, 3.2),
		Stock("Fleep Enterprise", 60, 6.5)
	};

	cout.precision(2);	// *.** format
	cout.setf(ios_base::fixed, ios_base::floatfield);// *.** format
	cout.setf(ios_base::showpoint);

	cout << "Stock holdings:\n";
	int st;
	for (st = 0;  st < STKS; st++)
		stocks[st].show();

	Stock top = stocks[0];
	for (st = 1; st < STKS; st++)
		top = top.topval(stocks[st]);
	cout << "\nMost valuable holding:\n";
	top.show();

	return 0;
}
开发者ID:mycmessia,项目名称:C-Primer,代码行数:29,代码来源:useStock2.cpp

示例8: SetStockImgType

void SetStockImgType::revert(ObjectsContainer* objects, UndoersCollector* redoers)
{
  Stock* stock = objects->getObjectT<Stock>(m_stockId);

  // Push another SetStockImgType as redoer
  redoers->pushUndoer(new SetStockImgType(objects, stock));

  stock->setImgType(m_imgtype);
}
开发者ID:Skiles,项目名称:aseprite,代码行数:9,代码来源:set_stock_imgtype.cpp

示例9: SetStockPixelFormat

void SetStockPixelFormat::revert(ObjectsContainer* objects, UndoersCollector* redoers)
{
  Stock* stock = objects->getObjectT<Stock>(m_stockId);

  // Push another SetStockPixelFormat as redoer
  redoers->pushUndoer(new SetStockPixelFormat(objects, stock));

  stock->setPixelFormat(static_cast<PixelFormat>(m_format));
}
开发者ID:eledot,项目名称:aseprite,代码行数:9,代码来源:set_stock_pixel_format.cpp

示例10: revert

void RemoveImage::revert(ObjectsContainer* objects, UndoersCollector* redoers)
{
  Stock* stock = objects->getObjectT<Stock>(m_stockId);
  Image* image = read_object<Image>(objects, m_stream, raster::read_image);

  // Push an AddImage as redoer
  redoers->pushUndoer(new AddImage(objects, stock, m_imageIndex));

  stock->replaceImage(m_imageIndex, image);
}
开发者ID:RobertLowe,项目名称:aseprite,代码行数:10,代码来源:remove_image.cpp

示例11: getTradingCalendar

DatetimeList StockManager::
getTradingCalendar(const KQuery& query, const string& market) {
    Stock stock = getStock("SH000001");
    size_t start_ix = 0, end_ix = 0;
    DatetimeList result;
    if (stock.getIndexRange(query, start_ix, end_ix)) {
        result = stock.getDatetimeList(start_ix, end_ix, query.kType());
    }
    return result;
}
开发者ID:fasiondog,项目名称:hikyuu,代码行数:10,代码来源:StockManager.cpp

示例12: opsTest

  static void opsTest() {
    Stock s = Stock();
    vector<int> list;
    ostringstream oss;

    for(int i = 1; i < 13; i++){
      list.push_back(i);
    }

    int num = 1;
    try {
      s += list; num++;
      s += list; num++;
      s += list; num++; //this num++ should not be executed
    }
    catch (std::invalid_argument & e){
      oss << "Failed at num = " << num;
    }
    assert(oss.str() == "Failed at num = 3");
    oss.str("");
    oss.clear();

    //assert Stock pile has 24 cards now
    assert(s.getSize() == 24);

    try {
      s += 13;
    }
    catch (std::invalid_argument & e){
      oss << e.what();
    }

    //assert exception is caught
    assert(oss.str() == "Invalid card value.\n");
    oss.str("");
    oss.clear();

    vector<int> list2 = {5, 3, 2, 1, 0, 1};

    try{
      s += list2;
    } catch(std::invalid_argument & e){
      assert(false); //should not be executed
    }

    assert(s.getSize() == 30);

    try {
      s += 1;
    }catch(std::logic_error & e){
      oss << e.what();
    }

    assert(oss.str() == "Can't have more than 30 cards in Stock pile!\n");
  }
开发者ID:smsukardi,项目名称:skip-bo,代码行数:55,代码来源:DeckTest.cpp

示例13: revert

void AddImage::revert(ObjectsContainer* objects, UndoersCollector* redoers)
{
  Stock* stock = objects->getObjectT<Stock>(m_stockId);
  Image* image = stock->getImage(m_imageIndex);

  if (image == NULL)
    throw UndoException("One image was not found in the stock");

  redoers->pushUndoer(new RemoveImage(objects, stock, m_imageIndex));

  stock->removeImage(image);
  delete image;
}
开发者ID:Skiles,项目名称:aseprite,代码行数:13,代码来源:add_image.cpp

示例14: switch

double StockUtil::DividendYield(Stock stock, double marketPrice)
{
	if(marketPrice == 0.0){return 0;}

	switch(stock.getStockType() )
	{
	case COMMON:
		return (stock.getLastDividend() / marketPrice);
	case PREFFERED:
		return (stock.getFixedDividend() * stock.getParValue())/ marketPrice;
	default:
		return 0;
	}
}
开发者ID:ankitshri,项目名称:JPMorganTest,代码行数:14,代码来源:StockUtil.cpp

示例15:

bool Stock::operator!=(const Stock& stock) const {
    if (this == &stock)
        return false;

    if (m_data == stock.m_data)
        return false;

    if (!m_data || !stock.m_data)
        return true;

    if( m_data->m_code != stock.code() || m_data->m_market != stock.market())
        return true;

    return false;
}
开发者ID:zklvyy,项目名称:hikyuu,代码行数:15,代码来源:Stock.cpp


注:本文中的Stock类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。