Skip to content

Commit

Permalink
typo, format cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
yssource committed Mar 22, 2022
1 parent adcabb3 commit 8b3735a
Show file tree
Hide file tree
Showing 12 changed files with 45 additions and 72 deletions.
3 changes: 2 additions & 1 deletion binding/emconceptbase/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ PYBIND11_MODULE(pyabqemconceptbase, m)

py::class_<PyEmConceptBase> sm_class(m, "PyEmConceptBase");
sm_class.def(py::init<std::vector<std::string>>())
.def("to_series", &PyEmConceptBase::to_series<double>, R"pbdoc(to_series double to_series double function.)pbdoc")
.def("to_series", &PyEmConceptBase::to_series<double>,
R"pbdoc(to_series double to_series double function.)pbdoc")
.def("to_series_int", &PyEmConceptBase::to_series<int>, R"pbdoc(to_series int to_series double function.)pbdoc")
.def("to_series_string", &PyEmConceptBase::to_series<std::string>,
R"pbdoc(to_series string to_series string function.)pbdoc");
Expand Down
27 changes: 0 additions & 27 deletions binding/indexmin/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,33 +17,6 @@ set(core_libraries "${abquant_lib_dir}/libabqcontroller.so;${abquant_lib_dir}/li
set(binding_library_dir ${CMAKE_CURRENT_SOURCE_DIR}/../../lib/)


# ==================================== RPATH configuration ====================================


# =============================================================================================
# !!! (The section below is deployment related, so in a real world application you will want to
# take care of this properly with some custom script or tool).
# =============================================================================================
# Enable rpaths so that the built shared libraries find their dependencies.
set(CMAKE_SKIP_BUILD_RPATH FALSE)
set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
set(CMAKE_INSTALL_RPATH ${CMAKE_CURRENT_SOURCE_DIR} ${QtCore_libdir})
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
# =============================================================================================
# !!! End of dubious section.
# =============================================================================================


# # ====================== Shiboken target for generating binding C++ files ====================
# get_target_property(qtcore_M_QT5_INCLUDES Qt5::Core INTERFACE_INCLUDE_DIRECTORIES)
set(qtcore_M_QT5_INCLUDES ${Qt5Core_INCLUDE_DIRS})

list(JOIN qtcore_M_QT5_INCLUDES ";-I" M_QT5_INCLUDES)

message(STATUS "${M_QT5_INCLUDES}")
set(M_QT5_INCLUDES ${M_QT5_INCLUDES})


# =============================== CMake target - binding_library =============================

# Set the cpp files which will be used for the bindings library.
Expand Down
40 changes: 20 additions & 20 deletions cxx/src/actions/security.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,8 @@ QList<S> SecurityAction<A>::run(const QStringList codes, const char* start, cons
{
QFuture<QList<S>> future = QtConcurrent::run(this, &self_type::get_price<S>, codes, start, end);

QList<S> secriies = future.result();
return secriies;
QList<S> securities = future.result();
return securities;
}

template <typename A>
Expand All @@ -170,8 +170,8 @@ QList<S> SecurityAction<A>::run(const QStringList codes, const char* start, cons
{
QFuture<QList<S>> future = QtConcurrent::run(this, &self_type::get_price<S>, codes, start, end, freq);

QList<S> secriies = future.result();
return secriies;
QList<S> securities = future.result();
return securities;
}

template <typename A>
Expand All @@ -180,26 +180,26 @@ QList<S> SecurityAction<A>::run(const QStringList codes, int category)
{
QFuture<QList<S>> future = QtConcurrent::run(this, &self_type::get_price<S>, codes, category);

QList<S> secriies = future.result();
return secriies;
QList<S> securities = future.result();
return securities;
}

template <typename A>
template <typename S>
QList<S> SecurityAction<A>::run(const char* end)
{
QFuture<QList<S>> future = QtConcurrent::run(this, &self_type::get_all_securities<S>, end);
QList<S> secriies = future.result();
return secriies;
QList<S> securities = future.result();
return securities;
}

template <typename A>
template <typename S>
QList<S> SecurityAction<A>::run(const QStringList codes, const char* end)
{
QFuture<QList<S>> future = QtConcurrent::run(this, &self_type::get_all_securities<S>, codes, end);
QList<S> secriies = future.result();
return secriies;
QList<S> securities = future.result();
return securities;
}

template <typename A>
Expand All @@ -220,9 +220,9 @@ QList<S> SecurityAction<A>::get_price(const QStringList codes, const char* start
TDatabaseContext::setCurrentDatabaseContext(sa);
bool EnableTransactions = true;
TDatabaseContext::setTransactionEnabled(EnableTransactions);
QList<S> secriies = S::get_price(codes, start_d, end_d);
QList<S> securities = S::get_price(codes, start_d, end_d);
commitTransactions();
return secriies;
return securities;
}

template <typename A>
Expand All @@ -235,9 +235,9 @@ QList<S> SecurityAction<A>::get_price(const QStringList codes, const char* start
TDatabaseContext::setCurrentDatabaseContext(sa);
bool EnableTransactions = true;
setTransactionEnabled(EnableTransactions);
QList<S> secriies = S::get_price(codes, start_d, end_d, freq);
QList<S> securities = S::get_price(codes, start_d, end_d, freq);
commitTransactions();
return secriies;
return securities;
}

template <typename A>
Expand All @@ -248,9 +248,9 @@ QList<S> SecurityAction<A>::get_price(const QStringList codes, int category)
TDatabaseContext::setCurrentDatabaseContext(sa);
bool EnableTransactions = true;
setTransactionEnabled(EnableTransactions);
QList<S> secriies = S::get_price(codes, category);
QList<S> securities = S::get_price(codes, category);
commitTransactions();
return secriies;
return securities;
}

template <typename A>
Expand All @@ -262,9 +262,9 @@ QList<S> SecurityAction<A>::get_all_securities(const char* end)
TDatabaseContext::setCurrentDatabaseContext(sa);
bool EnableTransactions = true;
setTransactionEnabled(EnableTransactions);
QList<S> secriies = S::get_all_securities(end_d);
QList<S> securities = S::get_all_securities(end_d);
commitTransactions();
return secriies;
return securities;
}

template <typename A>
Expand All @@ -276,9 +276,9 @@ QList<S> SecurityAction<A>::get_all_securities(const QStringList codes, const ch
TDatabaseContext::setCurrentDatabaseContext(sa);
bool EnableTransactions = true;
setTransactionEnabled(EnableTransactions);
QList<S> secriies = S::get_all_securities(codes, end_d);
QList<S> securities = S::get_all_securities(codes, end_d);
commitTransactions();
return secriies;
return securities;
}

template <typename A>
Expand Down
14 changes: 8 additions & 6 deletions cxx/src/actions/utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,11 +159,13 @@ struct is_base_of_template_impl {
template <template <typename...> class base, typename derived>
using is_base_of_template = typename is_base_of_template_impl<base, derived>::type;

#define CHECK_COLUMN_EXIST(col) \
std::vector<const char*> cols = {"open", "close", "high", "low", "vol", "amount"}; \
if (std::none_of(cols.cbegin(), cols.cend(), [col](const char* c) { return QString(c) == QString(col); })) { \
QString msg = QString(col) + QString(" series are not available here."); \
throw std::runtime_error(msg.toStdString()); \
}
#define CHECK_COLUMN_EXIST(col) \
do { \
std::vector<const char*> cols = {"open", "close", "high", "low", "vol", "amount"}; \
if (std::none_of(cols.cbegin(), cols.cend(), [col](const char* c) { return QString(c) == QString(col); })) { \
QString msg = QString(col) + QString(" series are not available here."); \
throw std::runtime_error(msg.toStdString()); \
} \
} while (false)

} // namespace abq
1 change: 1 addition & 0 deletions cxx/src/models/stockmin.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <QVariant>
#include <TAbstractModel>
#include <TGlobal>

#include "abquant/helpers/applicationhelper.h"

class TModelObject;
Expand Down
10 changes: 3 additions & 7 deletions cxx/test/actions/indexday/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,18 @@
****************************************************************************/

#include <QtTest/QtTest>
#include <iostream>
#include <utility>

#include "abquant/actions/abquant.hpp"
#include "abquant/actions/security.hpp"
#include "abquant/actions/indexday.hpp"
#include "abquant/actions/security.hpp"
#include "abquant/actions/utils.hpp"
#include <iostream>
#include <utility>

#include "string"

using namespace abq;
using namespace std;


class TestIndexDay : public QObject
{
Q_OBJECT
Expand All @@ -42,11 +40,9 @@ void TestIndexDay::initTestCase()

IndexDayAction ia(codes, start, end);


auto ind = ia.make_indicator();
}


void TestIndexDay::cleanupTestCase() {}

ABQ_TEST_MAIN(TestIndexDay)
Expand Down
4 changes: 2 additions & 2 deletions cxx/test/actions/indexmin/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ int main(int argc, char* argv[])

QStringList codes = {"000001", "000002", "000003"};
// QStringList codes = {"000001"};
const char* start = "2017-01-01 00:00:00";
const char* end = "2019-12-01 23:55:00";
const char* start = "2022-01-01 00:00:00";
const char* end = "2022-12-01 23:55:00";
MIN_FREQ freq = MIN_FREQ::FIVE;

auto begin = std::chrono::high_resolution_clock::now();
Expand Down
8 changes: 4 additions & 4 deletions cxx/test/actions/indicator/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
#include <QtTest/QtTest>

#include "abquant/actions/abquant.hpp"
#include "abquant/actions/security.hpp"
#include "abquant/actions/indexday.hpp"
#include "abquant/actions/indicator.hpp"
#include "abquant/actions/security.hpp"
#include "abquant/actions/stockday.hpp"
#include "abquant/actions/stockmin.hpp"
#include "abquant/actions/stockxdxr.hpp"
Expand Down Expand Up @@ -55,10 +55,10 @@ void TestIndicator::initTestCase()
const char* start = "2017-01-01";
const char* end = "2019-12-01";

sa = std::make_shared<StockDayAction>(codes, start, end);
sa = std::make_shared<StockDayAction>(codes, start, end);
indstockday = sa->make_indicator();

ia = std::make_shared<IndexDayAction>(codes, start, end);
ia = std::make_shared<IndexDayAction>(codes, start, end);
indindexday = ia->make_indicator();
}

Expand All @@ -84,7 +84,7 @@ void TestIndicator::roc_data()
QTest::addColumn<double>("rocma");
QTest::addColumn<double>("rocma_result");

const char* col = "close";
const char* col = "close";
roc_return_type roc_map = indstockday->ROC(col, 12, 6);
series_no_cvp_type roc_actual = roc_map["ROC"];
series_no_cvp_type rocma_actual = roc_map["ROCMA"];
Expand Down
2 changes: 1 addition & 1 deletion cxx/test/actions/securitylist/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ void TestSecurityList::initTestCase() {}
void TestSecurityList::initTestCase_data()
{
QStringList s_codes = {"000001", "300001", "600000"};
const char* end = "2019-12-01";
const char* end = "2022-12-01";

auto sa = std::make_shared<SecurityListAction<StockList>>();
auto sa2 = std::make_shared<SecurityListAction<StockList>>(s_codes, end);
Expand Down
4 changes: 2 additions & 2 deletions cxx/test/actions/stockmin/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ int main(int argc, char* argv[])

QStringList codes = {"000001", "000002", "000003"};
// QStringList codes = {"000001"};
const char* start = "2017-01-01 00:00:00";
const char* end = "2019-12-01 23:55:00";
const char* start = "2022-01-01 00:00:00";
const char* end = "2022-12-01 23:55:00";
MIN_FREQ freq = MIN_FREQ::FIVE;

auto begin = std::chrono::high_resolution_clock::now();
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ norecursedirs =
dist
build
.tox
testpaths = abquant/tests
testpaths = tests

[aliases]
build = bdist_wheel
Expand Down
2 changes: 1 addition & 1 deletion tests/test_get_price.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def test_singleton():
def test_get_price():
code = "000001"
start = "1989-01-01"
end = "2019-01-01"
end = "2022-01-01"
expected = get_price(code, start, end)
assert "000001" in expected.code()
# time.sleep(10)

0 comments on commit 8b3735a

Please sign in to comment.