Exemplo n.º 1
0
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;
}
Exemplo n.º 2
0
HKU_API std::ostream & operator<<(std::ostream& os, const PositionRecord& record) {
    Stock stock = record.stock;
    int precision = 2;
    std::string market(""), code(""), name("");
    if(!stock.isNull()){
        market = stock.market();
        code = stock.code();
#if defined(BOOST_WINDOWS) && (PY_VERSION_HEX >= 0x03000000)
        name = utf8_to_gb(stock.name());
#else
        name = stock.name();
#endif
    } else {
        precision = stock.precision();
    }

    price_t costPrice = 0.0;
    if (record.number != 0.0) {
        costPrice = roundEx((record.buyMoney - record.sellMoney)
                / record.number, precision);
    }

    string strip(", ");
    os << std::fixed;
    os.precision(precision);
    os << "Position(" << market
            << strip << code
            << strip << name
            << strip << record.takeDatetime
            << strip << record.cleanDatetime
            << strip << record.number
            << strip << costPrice
            << strip << record.stoploss
            << strip << record.goalPrice
            << strip << record.totalNumber
            << strip << record.buyMoney
            << strip << record.totalCost
            << strip << record.totalRisk
            << strip << record.sellMoney << ")";
    os.unsetf(std::ostream::floatfield);
    os.precision();
    return os;
}