Skip to content

Commit

Permalink
move util of action out from models
Browse files Browse the repository at this point in the history
  • Loading branch information
yssource committed Jun 23, 2021
1 parent 6d2dcc3 commit 6fbcfd1
Show file tree
Hide file tree
Showing 8 changed files with 55 additions and 38 deletions.
7 changes: 0 additions & 7 deletions binding/stockday/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,6 @@ class PyStockDay : public std::enable_shared_from_this<PyStockDay>
m_sda_ptr = std::make_shared<StockDayAction>(qcodes, m_start.c_str(), m_end.c_str(), m_xdxr);
};

// size_t toQfq() noexcept
// {
// auto fq = m_sda_ptr->to_fq_type(FQ_TYPE::PRE);
// // fq->write<std::ostream, index_type, double, int>(std::cout);
// return fq->get_index().size();
// }

template <class T>
std::vector<T> to_series(const string& col) noexcept
{
Expand Down
3 changes: 1 addition & 2 deletions binding/test/test_indexday.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
# -*- coding: utf-8 -*-

import unittest

import pandas as pd

from pyabqindexday import PyIndexDay as indexday
from pyabquant import PyAbquant
from pyabqindexday import PyIndexDay as indexday

pd.set_option("display.max_rows", None)
pd.set_option("display.max_columns", None)
Expand Down
4 changes: 2 additions & 2 deletions binding/test/test_stockday.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

import unittest
import math
import pandas as pd

from pyabqstockday import PyStockDay as stockday
from pyabquant import FQ_TYPE, PyAbquant
from pyabqstockday import PyStockDay as stockday

import pandas as pd

pd.set_option("display.max_rows", None)
pd.set_option("display.max_columns", None)
Expand Down
1 change: 0 additions & 1 deletion cxx/src/actions/indexday_p.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ class IndexDayAction::impl
public:
impl(IndexDayAction& sa, QStringList codes, const char* start, const char* end, FQ_TYPE xdxr);
MyDataFramePtr get_dataframe(const IndexDayAction& sa) const;
MyDataFramePtr to_fq_type(FQ_TYPE fq);
QStringList get_codes(const IndexDayAction&) const { return m_codes; };
QList<IndexDay> get_securities(const IndexDayAction&) const { return m_indexdays; };
QVector<const char*> get_columns(const IndexDayAction&) const { return m_columns; };
Expand Down
45 changes: 23 additions & 22 deletions cxx/src/actions/utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include <vector>

#include "DataFrame/DataFrame.h"
#include "abquant/helpers/applicationhelper.h"
#include "xtensor/xarray.hpp"

namespace abq
Expand Down Expand Up @@ -123,29 +124,29 @@ inline QDebug operator<<(QDebug debug, INSTRUMENT_TYPE ins)
return debug;
}

enum class MIN_FREQ : short int { ONE = 0x01, FIVE = 0x05, FIFTEEN = 0x0F, THIRTY = 0x1E, SIXTY = 0x3C };
// enum class MIN_FREQ : short int { ONE = 0x01, FIVE = 0x05, FIFTEEN = 0x0F, THIRTY = 0x1E, SIXTY = 0x3C };

inline QDebug operator<<(QDebug debug, MIN_FREQ freq)
{
switch (freq) {
case MIN_FREQ::ONE:
debug << "MIN_FREQ::ONE";
break;
case MIN_FREQ::FIVE:
debug << "MIN_FREQ::FIVE";
break;
case MIN_FREQ::FIFTEEN:
debug << "MIN_FREQ::FIFTEEN";
break;
case MIN_FREQ::THIRTY:
debug << "MIN_FREQ::THIRTY";
break;
case MIN_FREQ::SIXTY:
debug << "MIN_FREQ::SIXTY";
break;
}
return debug;
}
// inline QDebug operator<<(QDebug debug, MIN_FREQ freq)
// {
// switch (freq) {
// case MIN_FREQ::ONE:
// debug << "MIN_FREQ::ONE";
// break;
// case MIN_FREQ::FIVE:
// debug << "MIN_FREQ::FIVE";
// break;
// case MIN_FREQ::FIFTEEN:
// debug << "MIN_FREQ::FIFTEEN";
// break;
// case MIN_FREQ::THIRTY:
// debug << "MIN_FREQ::THIRTY";
// break;
// case MIN_FREQ::SIXTY:
// debug << "MIN_FREQ::SIXTY";
// break;
// }
// return debug;
// }

template <template <typename...> class base, typename derived>
struct is_base_of_template_impl {
Expand Down
26 changes: 26 additions & 0 deletions cxx/src/helpers/applicationhelper.h
Original file line number Diff line number Diff line change
@@ -1,12 +1,38 @@
#ifndef APPLICATIONHELPER_H
#define APPLICATIONHELPER_H

#include <QtCore/QDebug>
#include <TGlobal>

class T_HELPER_EXPORT ApplicationHelper
{
};

namespace abq
{
enum class MIN_FREQ : short int { ONE = 0x01, FIVE = 0x05, FIFTEEN = 0x0F, THIRTY = 0x1E, SIXTY = 0x3C };

inline QDebug operator<<(QDebug debug, MIN_FREQ freq)
{
switch (freq) {
case MIN_FREQ::ONE:
debug << "MIN_FREQ::ONE";
break;
case MIN_FREQ::FIVE:
debug << "MIN_FREQ::FIVE";
break;
case MIN_FREQ::FIFTEEN:
debug << "MIN_FREQ::FIFTEEN";
break;
case MIN_FREQ::THIRTY:
debug << "MIN_FREQ::THIRTY";
break;
case MIN_FREQ::SIXTY:
debug << "MIN_FREQ::SIXTY";
break;
}
return debug;
}
} // namespace abq

#endif // APPLICATIONHELPER_H
4 changes: 2 additions & 2 deletions cxx/src/models/indexmin.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
#include <QVariant>
#include <TAbstractModel>
#include <TGlobal>
// #include "abquant/helpers/applicationhelper.h"
#include "abquant/actions/utils.hpp"

#include "abquant/helpers/applicationhelper.h"

class TModelObject;
class IndexMinObject;
Expand Down
3 changes: 1 addition & 2 deletions cxx/src/models/stockmin.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
#include <QVariant>
#include <TAbstractModel>
#include <TGlobal>
// #include "abquant/helpers/applicationhelper.h"
#include "abquant/actions/utils.hpp"
#include "abquant/helpers/applicationhelper.h"

class TModelObject;
class StockMinObject;
Expand Down

0 comments on commit 6fbcfd1

Please sign in to comment.