Skip to content

Commit

Permalink
clang 16, conan ^1.58.0
Browse files Browse the repository at this point in the history
  • Loading branch information
yssource committed Nov 18, 2023
1 parent 1c7ab45 commit 3bab743
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 85 deletions.
2 changes: 1 addition & 1 deletion abquant.profile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ os_build=Linux
arch=x86_64
arch_build=x86_64
compiler=clang
compiler.version=15
compiler.version=16
compiler.libcxx=libc++
build_type=Release

Expand Down
40 changes: 40 additions & 0 deletions cxx/src/actions/indicator_p.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/****************************************************************************
* Copyright (c) 2020-present Jimmy M. Gong *
* All rights reserved. *
* *
* Distributed under the terms of the GPL3 and LGPL3 Licenses. *
* *
* The full license is in the file LICENSE, distributed with this software. *
****************************************************************************/

#pragma once

#include "DataFrame/DataFrame.h"

namespace abq
{
using namespace std;
using namespace hmdf;
using index_type = std::string;
using MyDataFrame = StdDataFrame<index_type>;
using MyDataFramePtr = std::shared_ptr<MyDataFrame>;

using xseries_cst_type = const xt::xarray<double>&;
using xseries_type = xt::xarray<double>&;
using series_cst_type = const std::vector<double>&;
using series_type = std::vector<double>&;
using xseries_no_cvp_type = std::decay<xseries_type>::type;
using series_no_cvp_type = std::decay<series_type>::type;

using roc_return_type = std::unordered_map<const char*, std::vector<double>>;

namespace indicator
{
xseries_no_cvp_type SMA(xseries_cst_type series, size_t N, size_t M);
xseries_no_cvp_type REF(xseries_cst_type series, int N);
xseries_no_cvp_type DIFF(xt::xarray<index_type> index, xseries_cst_type series, const char* col, long N);
xseries_no_cvp_type MA(xt::xarray<index_type> index, xseries_cst_type series, const char* col, size_t N);
roc_return_type ROC(xt::xarray<index_type> index, xseries_cst_type series, const char* col = "close", size_t N = 12,
size_t M = 6);
} // namespace indicator
} // namespace abq
5 changes: 2 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ url = "https://mirrors.aliyun.com/pypi/simple"
default = true

[tool.poetry.dependencies]
# python = ">=3.9,<3.11"
python = "^3.10"
python = ">=3.9,<3.11"
numpy = "^1.22.2"
pandas = "^1.2.4"
click = "^7.1.2"
Expand All @@ -29,7 +28,7 @@ requests = "^2.27.1"
tqdm = "^4.62.3"

[tool.poetry.dev-dependencies]
conan = "^1.53.0"
conan = "^1.58.0"
black = "^21.5b1"
pytest = "^6.2.4"
pudb = "^2021.1"
Expand Down
102 changes: 21 additions & 81 deletions tests/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import sys
import time

import pprint
import numpy as np
import pandas as pd

Expand All @@ -10,87 +11,26 @@
pd.set_option('display.max_columns', None)
pd.set_option('display.width', None)

from foo import *


def to_np(stocks):
# for var in stocks:
# print(var.open())

"""转化为numpy结构数组"""
t_type = np.dtype(
{
"names": ["date", "证券代码", "open", "high", "close", "low"],
"formats": ["U10", "U10", "d", "d", "d", "d"],
}
)
return np.array(
[(s.date(), s.code(), s.open(), s.high(), s.close(), s.low()) for s in stocks],
dtype=t_type,
)


def to_df(stocks):
"""转化为pandas的DataFrame"""
return pd.DataFrame.from_records(to_np(stocks), index="date")


def main():
ida = IndexDayAction.getInstance()
print(type(ida))
ida2 = IndexDayAction.getInstance()
print(type(ida2))
if ida == ida2:
print("====================")
idxs = ida.run("000001", "1989-01-01", "2019-01-01")
print("---m-----")
return idxs


def xdxr():
x = Xdxr()
# df = x.getXdxr()
# dfx = x.getIdxs()
# df = x.get_columns()
df = x.getData()
# df = x.hello()
# df = x.getVec()
return df

def stockmin():
sa = StockMinAction.getInstance()
ss = sa.toPython()
# print(ss)
return ss
from pytdx.hq import TdxHq_API
api = TdxHq_API(heartbeat=True)


if __name__ == "__main__":
# ida = IndexDayAction.getInstance()
# # try:
# # ida = IndexDayAction().getInstance()
# # except Exception as e:
# # print(e)

# idxs = main()
# print('--------')
# for idx in idxs:
# print("{} {}".format(idx.id(), idx.code()))
# print('----2----')
# time.sleep(3)
# sys.exit(0)

# df = xdxr()
# print("-----rrrrrrrrrr------")
# dnp = to_df(df)
# # dnp = to_np(df)
# print("--2222222---rrrrrrrrrr------")
# print(dnp)

# print("-----rrrrrrrrrr------")
# for e in df:
# print("code: {}, open: {}, high: {}".format(e.code(), e.open(), e.high()))
# print("--2222222---rrrrrrrrrr------")
# print(df)
s3 = stockmin()
for e in s3:
print("datetime: {} code: {}, open: {}, high: {}".format(e.datetime(), e.code(), e.open(), e.high()))
with api.connect('119.147.212.81', 7709):
# import pudb; pudb.set_trace()
# dt=api.get_minute_time_data(0, '002154')
# dt=api.get_minute_time_data(0, '002773')
# dt=api.get_minute_time_data(1, '600300')
# dt = api.to_df(dt) # 返回DataFrame
# print(dt)
# pprint.pprint(dt)


# log.info("获取股票列表")
# import pudb; pudb.set_trace()
stocks = api.get_security_list(0, 1000)
pprint.pprint(stocks)

# log.info("获取k线")
# data = api.get_security_bars(9, 0, '000001', 4, 3)
# pprint.pprint(data)

0 comments on commit 3bab743

Please sign in to comment.