mirror of
https://gitee.com/fasiondog/hikyuu.git
synced 2024-12-02 11:58:21 +08:00
53 lines
1.4 KiB
C++
53 lines
1.4 KiB
C++
/*
|
|
* OrderBrokerBase.cpp
|
|
*
|
|
* Created on: 2017年6月28日
|
|
* Author: fasiondog
|
|
*/
|
|
|
|
#include "OrderBrokerBase.h"
|
|
|
|
namespace hku {
|
|
|
|
HKU_API std::ostream& operator<<(std::ostream& os, const OrderBrokerBase& broker) {
|
|
os << "OrderBroker(" << broker.name() << ")";
|
|
return os;
|
|
}
|
|
|
|
HKU_API std::ostream& operator<<(std::ostream& os, const OrderBrokerPtr& broker) {
|
|
os << "OrderBroker(" << broker->name() << ")";
|
|
return os;
|
|
}
|
|
|
|
OrderBrokerBase::OrderBrokerBase() : m_name("NO_NAME") {}
|
|
|
|
OrderBrokerBase::OrderBrokerBase(const string& name) : m_name(name) {}
|
|
|
|
OrderBrokerBase::~OrderBrokerBase() {}
|
|
|
|
Datetime OrderBrokerBase::buy(Datetime datetime, const string& market, const string& code,
|
|
price_t price, double num) {
|
|
Datetime tradetime;
|
|
try {
|
|
tradetime = _buy(datetime, market, code, price, num);
|
|
} catch (...) {
|
|
HKU_ERROR("Unknow error in BUY operation!!!");
|
|
tradetime = Null<Datetime>();
|
|
}
|
|
return tradetime;
|
|
}
|
|
|
|
Datetime OrderBrokerBase::sell(Datetime datetime, const string& market, const string& code,
|
|
price_t price, double num) {
|
|
Datetime tradetime;
|
|
try {
|
|
tradetime = _sell(datetime, market, code, price, num);
|
|
} catch (...) {
|
|
HKU_ERROR("Unknow error in SELL operation!!!");
|
|
tradetime = Null<Datetime>();
|
|
}
|
|
return tradetime;
|
|
}
|
|
|
|
} /* namespace hku */
|