Esempio n. 1
0
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;
}
Esempio n. 2
0
bool StockManager::addStock(const Stock& stock) {
    string market_code(stock.market_code());
    boost::to_upper(market_code);
    if(m_stockDict.find(market_code) != m_stockDict.end()) {
        HKU_ERROR("The stock had exist! "
                << market_code
                << " [StockManager::addStock]");
        return false;
    }

    m_stockDict[market_code] = stock;
    return true;
}