Skip to content

Commit

Permalink
re-compiling with clang12, qt5.15.2@
Browse files Browse the repository at this point in the history
  • Loading branch information
yssource committed Jun 17, 2021
1 parent 94cf161 commit 8254156
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 34 deletions.
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,12 @@ if(CMAKE_VERSION VERSION_LESS "3.7.0")
endif()

find_package(Qt5 REQUIRED Core Network Sql Xml Qml)
find_package(pybind11 REQUIRED)
# add_subdirectory(pybind11)
add_subdirectory(binding)

get_target_property(QtCore_location Qt5::Core LOCATION)
get_filename_component(QtCore_libdir ${QtCore_location} DIRECTORY)

enable_testing()
# message(status ${CONAN_LIBS})
message(status ${CONAN_LIBS})
15 changes: 9 additions & 6 deletions abquant.profile
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,27 @@ os_build=Linux
arch=x86_64
arch_build=x86_64
compiler=clang
compiler.version=11
compiler.libcxx=libstdc++11
compiler.version=12
compiler.libcxx=libc++
build_type=Release
# build_type=Debug
[options]
qt:shared=True
qt:qtdeclarative=True
qt:qttools=True
qt:qtwebsockets=True
qt:with_vulkan=True
[build_requires]
*: cmake/3.20.3, ninja/1.10.2
[env]
# CC=$PROFILE_DIR/ccache-clang
# CXX=$PROFILE_DIR/ccache-clang++

CC="ccache clang"
CXX="ccache clang++"
CPP="ccache cpp"

# CC="clang"
# CXX="clang++"
# CPP="cpp"
// CC="clang"
// CXX="clang++"
// CPP="cpp"

CONAN_CMAKE_GENERATOR=Ninja
15 changes: 4 additions & 11 deletions abquant/apis/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ def get_price(
start_date: Union[datetime.date, datetime.datetime, str],
end_date: Optional[Union[datetime.date, datetime.datetime, str]] = None,
frequency: Optional[str] = "1d",
fields: List[str] = [],
fields: Optional[List[str]] = [],
adjust_type: Optional[str] = "pre",
skip_suspended: Optional[bool] = False,
expect_df: Optional[bool] = False,
) -> Union[pd.DataFrame, pd.Series]:
) -> pd.DataFrame:
"""
:param order_book_ids: 合约代码,合约代码,可传入order_book_id, order_book_id list, symbol, symbol list
:param start_date: 开始日期,用户必须指定
Expand Down Expand Up @@ -81,9 +81,6 @@ def get_price(
#...
"""

if fields is None:
fields = ["open", "close", "high", "low", "vol"]

if isinstance(start_date, (datetime.datetime,)):
start_date = start_date.strftime("%Y-%m-%d %H:%M:%S")
if isinstance(end_date, (datetime.datetime,)):
Expand All @@ -93,9 +90,10 @@ def get_price(
start_date = start_date.split(" ")[0] # type: ignore
end_date = end_date.split(" ")[0] # type: ignore

if fields is None or not fields:
fields = ["open", "close", "high", "low", "vol"]
if isinstance(fields, (str,)):
fields = [fields]

for field in fields:
if field in ["volume"]:
field = "vol"
Expand Down Expand Up @@ -161,7 +159,6 @@ def get_price(
else:
datetime_ = sm.to_series_string("datetime")
df = pd.DataFrame({"code": code, "datetime": datetime_})
print(df)
except Exception:
raise RuntimeError("fail to get_price")

Expand All @@ -177,10 +174,6 @@ def get_price(
else:
df.set_index(["code", "datetime"], inplace=True)

if len(fields) == 1:
# return pd.Series
return df[fields[0]] # type: ignore
# print(df)
return df


Expand Down
26 changes: 17 additions & 9 deletions conanfile.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from conans import ConanFile, CMake, tools, Meson, RunEnvironment
from conans import ConanFile, CMake, tools, RunEnvironment
import os
import shutil
import platform
import pathlib
import shutil

Expand All @@ -13,14 +12,22 @@ class AbquantConan(ConanFile):
settings = "os", "arch", "compiler", "build_type"
options = {"shared": [True, False], "fPIC": [True, False]}
default_options = {
"shared": False,
"shared": True,
"fPIC": True,
"qt:qtdeclarative": True,
"qt:qttools": True,
"qt:qtwebsockets": True,
"qt:with_vulkan": True,
}

generators = ["cmake", "qmake"]
generators = (
"qt",
"qmake",
"cmake",
"virtualrunenv",
"cmake_find_package",
"cmake_find_package_multi",
)

@property
def _prefix(self):
Expand Down Expand Up @@ -59,11 +66,15 @@ def config_options(self):
if self.settings.os == "Windows":
del self.options.fPIC

def build_requirements(self):
self.build_requires("cmake/3.20.3")
self.build_requires("ninja/1.10.2")

def requirements(self):
self.requires("qt/5.12.8@{}/{}".format("bincrafters", "stable"))
self.requires("qt/5.15.2@")
self.requires("xtensor/0.21.3@")
self.requires("dataframe/1.15.0@")
self.requires("pybind11/2.6.1@")
self.requires("pybind11/2.6.2@")

def _build_with_qmake(self):
tools.mkdir(self.build_subfolder(kind_="qbuild"))
Expand Down Expand Up @@ -150,6 +161,3 @@ def build(self):
self._build_with_qmake()
if pathlib.Path.cwd().name == "cbuild":
self._build_with_cmake()

# def package_info(self):
# self.env_info.CMAKE_PREFIX_PATH.append(self.package_folder)
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,5 @@ exclude = '''
| setup.py
)
'''

[tool.pyright]
14 changes: 7 additions & 7 deletions tests/apis/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def test_get_price_day_stock_date_with_single_field():
fields = ["open"]
actual = get_price(code, start, end, fields=fields)
ulog.debug(actual)
assert isinstance(actual, pd.Series)
assert isinstance(actual, pd.DataFrame)


def test_get_price_day_stock_datetime_with_single_field():
Expand All @@ -21,7 +21,7 @@ def test_get_price_day_stock_datetime_with_single_field():
fields = ["open"]
actual = get_price(code, start, end, fields=fields)
ulog.debug(actual)
assert isinstance(actual, pd.Series)
assert isinstance(actual, pd.DataFrame)


def test_get_price_day_index_date_with_single_field():
Expand All @@ -31,7 +31,7 @@ def test_get_price_day_index_date_with_single_field():
fields = ["open"]
actual = get_price(code, start, end, fields=fields)
ulog.debug(actual)
assert isinstance(actual, pd.Series)
assert isinstance(actual, pd.DataFrame)


def test_get_price_day_index_datetime_with_single_field():
Expand All @@ -41,7 +41,7 @@ def test_get_price_day_index_datetime_with_single_field():
fields = ["open"]
actual = get_price(code, start, end, fields=fields)
ulog.debug(actual)
assert isinstance(actual, pd.Series)
assert isinstance(actual, pd.DataFrame)


def test_get_price_day_stock_date_with_multi_field():
Expand Down Expand Up @@ -91,7 +91,7 @@ def test_get_price_min_stock_with_single_field():
fields = ["open"]
actual = get_price(code, start, end, frequency="1min", fields=fields)
ulog.debug(actual)
assert isinstance(actual, pd.Series)
assert isinstance(actual, pd.DataFrame)


def test_get_price_min_stock_with_multi_field():
Expand Down Expand Up @@ -133,13 +133,13 @@ def test_get_security_info_stock_type():
code = "000001.XSHE"
actual = get_security_info(code, INSTRUMENT_TYPE.CS)
ulog.debug(actual)
assert isinstance(actual, pd.Series)
assert isinstance(actual, pd.DataFrame)
assert actual.display_name == "平安银行"


def test_get_security_info_index_type():
code = "399006.XSHE"
actual = get_security_info(code, INSTRUMENT_TYPE.INDX)
ulog.debug(actual)
assert isinstance(actual, pd.Series)
assert isinstance(actual, pd.DataFrame)
assert actual.display_name == "创业板指"

0 comments on commit 8254156

Please sign in to comment.