mirror of
https://gitee.com/fasiondog/hikyuu.git
synced 2024-11-30 19:08:48 +08:00
add Strategy continue
This commit is contained in:
parent
82ae061b92
commit
8e6b2e0f42
10
hikyuu_cpp/hikyuu/strategy/StrategyBase.cpp
Normal file
10
hikyuu_cpp/hikyuu/strategy/StrategyBase.cpp
Normal file
@ -0,0 +1,10 @@
|
||||
/*
|
||||
* Copyright(C) 2021 hikyuu.org
|
||||
*
|
||||
* Create on: 2021-02-16
|
||||
* Author: fasiondog
|
||||
*/
|
||||
|
||||
#include "StrategyBase.h"
|
||||
|
||||
namespace hku {} // namespace hku
|
46
hikyuu_cpp/hikyuu/strategy/StrategyBase.h
Normal file
46
hikyuu_cpp/hikyuu/strategy/StrategyBase.h
Normal file
@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright(C) 2021 hikyuu.org
|
||||
*
|
||||
* Create on: 2021-02-16
|
||||
* Author: fasiondog
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../DataType.h"
|
||||
#include "../StrategyContext.h"
|
||||
#include "../utilities/Parameter.h"
|
||||
#include "../trade_sys/portfolio/Portfolio.h"
|
||||
|
||||
namespace hku {
|
||||
|
||||
class HKU_API StrategyBase {
|
||||
PARAMETER_SUPPORT
|
||||
|
||||
public:
|
||||
StrategyBase() {}
|
||||
virtual ~StrategyBase() {}
|
||||
|
||||
const string& name() const {
|
||||
return m_name;
|
||||
}
|
||||
|
||||
void name(const string& name) {
|
||||
m_name = name;
|
||||
}
|
||||
|
||||
// virtual void start() = 0;
|
||||
virtual void on_bar() = 0;
|
||||
|
||||
private:
|
||||
string m_name;
|
||||
StrategyContext m_context;
|
||||
|
||||
TMPtr m_tm;
|
||||
SYSPtr m_sys;
|
||||
PFPtr m_portfolio;
|
||||
};
|
||||
|
||||
typedef shared_ptr<StrategyBase> StrategyPtr;
|
||||
|
||||
} // namespace hku
|
@ -37,6 +37,7 @@ class HKU_API TradeManagerBase {
|
||||
|
||||
public:
|
||||
TradeManagerBase();
|
||||
virtual ~TradeManagerBase() {}
|
||||
|
||||
/** 账户名称 */
|
||||
const string& name() const {
|
||||
|
@ -41,6 +41,7 @@ void export_trade_sys_main();
|
||||
void export_agent_main();
|
||||
|
||||
void export_StrategeContext();
|
||||
void export_strategy_main();
|
||||
|
||||
KData Py_GetKData(const string& market_code, py::object start = py::long_(0),
|
||||
py::object end = py::long_(Null<int64_t>()), KQuery::KType ktype = KQuery::DAY,
|
||||
@ -123,6 +124,7 @@ BOOST_PYTHON_MODULE(core) {
|
||||
export_trade_manage_main(); // must after export_trade_sys_main
|
||||
|
||||
export_StrategeContext();
|
||||
export_strategy_main();
|
||||
|
||||
export_agent_main();
|
||||
|
||||
|
34
hikyuu_pywrap/strategy/_StrategyBase.cpp
Normal file
34
hikyuu_pywrap/strategy/_StrategyBase.cpp
Normal file
@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright(C) 2021 hikyuu.org
|
||||
*
|
||||
* Create on: 2021-02-16
|
||||
* Author: fasiondog
|
||||
*/
|
||||
|
||||
#include <boost/python.hpp>
|
||||
#include <hikyuu/strategy/StrategyBase.h>
|
||||
#include "../_Parameter.h"
|
||||
|
||||
using namespace boost::python;
|
||||
using namespace hku;
|
||||
|
||||
class StrategyBaseWrap : public StrategyBase, public wrapper<StrategyBase> {
|
||||
public:
|
||||
StrategyBaseWrap() : StrategyBase() {}
|
||||
virtual ~StrategyBaseWrap() {}
|
||||
|
||||
void on_bar() override {
|
||||
this->get_override("on_bar")();
|
||||
}
|
||||
};
|
||||
|
||||
const string& (StrategyBase::*strategy_get_name)() const = &StrategyBase::name;
|
||||
void (StrategyBase::*strategy_set_name)(const string&) = &StrategyBase::name;
|
||||
|
||||
void export_Strategy() {
|
||||
class_<StrategyBaseWrap, boost::noncopyable>("StrategyBase", init<>())
|
||||
.add_property("name",
|
||||
make_function(strategy_get_name, return_value_policy<copy_const_reference>()),
|
||||
strategy_set_name)
|
||||
.def("on_bar", pure_virtual(&StrategyBase::on_bar));
|
||||
}
|
12
hikyuu_pywrap/strategy/_strategy_main.cpp
Normal file
12
hikyuu_pywrap/strategy/_strategy_main.cpp
Normal file
@ -0,0 +1,12 @@
|
||||
/*
|
||||
* Copyright(C) 2021 hikyuu.org
|
||||
*
|
||||
* Create on: 2021-02-16
|
||||
* Author: fasiondog
|
||||
*/
|
||||
|
||||
void export_Strategy();
|
||||
|
||||
void export_strategy_main() {
|
||||
export_Strategy();
|
||||
}
|
Loading…
Reference in New Issue
Block a user