hikyuu 2.1.0__cp39-none-win_amd64.whl → 2.1.2__cp39-none-win_amd64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- hikyuu/cpp/boost_date_time-mt.dll +0 -0
- hikyuu/cpp/boost_serialization-mt.dll +0 -0
- hikyuu/cpp/boost_wserialization-mt.dll +0 -0
- hikyuu/cpp/core39.pyd +0 -0
- hikyuu/cpp/hikyuu.dll +0 -0
- hikyuu/cpp/sqlite3.dll +0 -0
- hikyuu/examples/notebook/006-TradeManager.ipynb +41 -39
- hikyuu/examples/notebook/008-Pickle.ipynb +27 -35
- hikyuu/extend.py +3 -1
- hikyuu/fetcher/stock/zh_stock_a_qmt.py +49 -0
- hikyuu/gui/HikyuuTDX.py +13 -7
- hikyuu/gui/data/MainWindow.py +126 -126
- hikyuu/gui/spot_server.py +16 -7
- hikyuu/gui/start_qmt.py +36 -0
- hikyuu/include/hikyuu/DataType.h +2 -1
- hikyuu/include/hikyuu/KRecord.h +1 -1
- hikyuu/include/hikyuu/Stock.h +1 -1
- hikyuu/include/hikyuu/StockManager.h +3 -0
- hikyuu/include/hikyuu/StrategyContext.h +7 -2
- hikyuu/include/hikyuu/analysis/combinate.h +1 -1
- hikyuu/include/hikyuu/config.h +0 -12
- hikyuu/include/hikyuu/data_driver/base_info/table/HistoryFinanceTable.h +2 -2
- hikyuu/include/hikyuu/doc.h +2 -2
- hikyuu/include/hikyuu/global/GlobalSpotAgent.h +1 -0
- hikyuu/include/hikyuu/global/GlobalTaskGroup.h +4 -2
- hikyuu/include/hikyuu/global/SpotRecord.h +52 -0
- hikyuu/include/hikyuu/global/agent/SpotAgent.h +14 -41
- hikyuu/include/hikyuu/hikyuu.h +1 -0
- hikyuu/include/hikyuu/strategy/{AccountTradeManager.h → BrokerTradeManager.h} +97 -95
- hikyuu/include/hikyuu/strategy/RunPortfolioInStrategy.h +36 -0
- hikyuu/include/hikyuu/strategy/RunSystemInStrategy.h +37 -0
- hikyuu/include/hikyuu/strategy/Strategy.h +174 -0
- hikyuu/include/hikyuu/trade_manage/FundsRecord.h +8 -8
- hikyuu/include/hikyuu/trade_manage/OrderBrokerBase.h +66 -14
- hikyuu/include/hikyuu/trade_manage/PositionRecord.h +12 -12
- hikyuu/include/hikyuu/trade_manage/TradeManager.h +9 -0
- hikyuu/include/hikyuu/trade_manage/TradeManagerBase.h +19 -0
- hikyuu/include/hikyuu/utilities/FilterNode.h +267 -0
- hikyuu/include/hikyuu/utilities/LRUCache11.h +230 -0
- hikyuu/include/hikyuu/{Log.h → utilities/Log.h} +91 -113
- hikyuu/include/hikyuu/utilities/Null.h +1 -0
- hikyuu/include/hikyuu/utilities/Parameter.h +2 -1
- hikyuu/include/hikyuu/utilities/ResourcePool.h +636 -0
- hikyuu/include/hikyuu/utilities/SpendTimer.h +10 -9
- hikyuu/include/hikyuu/utilities/TimerManager.h +25 -11
- hikyuu/include/hikyuu/utilities/any_to_string.h +142 -0
- hikyuu/include/hikyuu/utilities/arithmetic.h +71 -35
- hikyuu/include/hikyuu/utilities/base64.h +59 -0
- hikyuu/include/hikyuu/utilities/config.h +41 -0
- hikyuu/include/hikyuu/utilities/datetime/Datetime.h +42 -31
- hikyuu/include/hikyuu/utilities/datetime/TimeDelta.h +24 -13
- hikyuu/include/hikyuu/utilities/db_connect/DBCondition.h +48 -48
- hikyuu/include/hikyuu/utilities/db_connect/DBConnect.h +10 -0
- hikyuu/include/hikyuu/utilities/db_connect/DBConnectBase.h +5 -22
- hikyuu/include/hikyuu/utilities/db_connect/DBUpgrade.h +3 -3
- hikyuu/include/hikyuu/utilities/db_connect/SQLException.h +1 -1
- hikyuu/include/hikyuu/utilities/db_connect/SQLResultSet.h +1 -1
- hikyuu/include/hikyuu/utilities/db_connect/SQLStatementBase.h +7 -7
- hikyuu/include/hikyuu/utilities/db_connect/TableMacro.h +1 -2
- hikyuu/include/hikyuu/utilities/db_connect/mysql/MySQLConnect.h +9 -9
- hikyuu/include/hikyuu/utilities/db_connect/mysql/MySQLStatement.h +18 -18
- hikyuu/include/hikyuu/utilities/db_connect/sqlite/SQLiteConnect.h +3 -3
- hikyuu/include/hikyuu/utilities/db_connect/sqlite/SQLiteStatement.h +2 -2
- hikyuu/include/hikyuu/utilities/db_connect/sqlite/SQLiteUtil.h +6 -6
- hikyuu/include/hikyuu/{exception.h → utilities/exception.h} +15 -16
- hikyuu/include/hikyuu/utilities/http_client/HttpClient.h +229 -0
- hikyuu/include/hikyuu/utilities/http_client/nng_wrap.h +517 -0
- hikyuu/include/hikyuu/utilities/http_client/url.h +25 -0
- hikyuu/include/hikyuu/utilities/{IniParser.h → ini_parser/IniParser.h} +10 -5
- hikyuu/include/hikyuu/utilities/ini_parser/__init__.py +1 -0
- hikyuu/include/hikyuu/utilities/md5.h +41 -0
- hikyuu/include/hikyuu/utilities/mo/__init__.py +1 -0
- hikyuu/include/hikyuu/utilities/mo/mo.h +48 -0
- hikyuu/include/hikyuu/utilities/mo/moFileReader.h +836 -0
- hikyuu/include/hikyuu/{global → utilities}/node/NodeClient.h +25 -18
- hikyuu/include/hikyuu/{global → utilities}/node/NodeError.h +1 -1
- hikyuu/include/hikyuu/{global → utilities}/node/NodeMessage.h +3 -2
- hikyuu/include/hikyuu/utilities/node/NodeServer.h +246 -0
- hikyuu/include/hikyuu/utilities/node/__init__.py +1 -0
- hikyuu/include/hikyuu/utilities/os.h +16 -15
- hikyuu/include/hikyuu/utilities/snowflake.h +110 -0
- hikyuu/include/hikyuu/utilities/string_view.h +70 -0
- hikyuu/include/hikyuu/utilities/thread/MQStealThreadPool.h +3 -3
- hikyuu/include/hikyuu/utilities/thread/MQThreadPool.h +3 -3
- hikyuu/include/hikyuu/utilities/thread/StealThreadPool.h +3 -3
- hikyuu/include/hikyuu/utilities/thread/ThreadPool.h +3 -3
- hikyuu/include/hikyuu/version.h +4 -4
- hikyuu/interactive.py +42 -137
- hikyuu/sqlite3.dll +0 -0
- hikyuu/strategy/__init__.py +0 -1
- hikyuu/strategy/strategy_demo1.py +53 -0
- hikyuu/strategy/strategy_demo2.py +47 -0
- hikyuu/strategy/strategy_demo3.py +24 -0
- hikyuu/trade_manage/broker.py +27 -11
- hikyuu/trade_manage/broker_easytrader.py +52 -6
- hikyuu/trade_manage/broker_mail.py +17 -20
- hikyuu/vcruntime140.dll +0 -0
- hikyuu/vcruntime140_1.dll +0 -0
- hikyuu-2.1.2.dist-info/METADATA +115 -0
- {hikyuu-2.1.0.dist-info → hikyuu-2.1.2.dist-info}/RECORD +105 -79
- {hikyuu-2.1.0.dist-info → hikyuu-2.1.2.dist-info}/top_level.txt +4 -2
- hikyuu/README.rst +0 -79
- hikyuu/include/hikyuu/strategy/StrategyBase.h +0 -156
- hikyuu/strategy/demo/__init__.py +0 -3
- hikyuu/strategy/strategy.py +0 -27
- hikyuu-2.1.0.dist-info/METADATA +0 -126
- /hikyuu/include/hikyuu/{global/node → utilities/http_client}/__init__.py +0 -0
- {hikyuu-2.1.0.dist-info → hikyuu-2.1.2.dist-info}/LICENSE +0 -0
- {hikyuu-2.1.0.dist-info → hikyuu-2.1.2.dist-info}/WHEEL +0 -0
- {hikyuu-2.1.0.dist-info → hikyuu-2.1.2.dist-info}/entry_points.txt +0 -0
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2024 hikyuu.org
|
|
3
|
+
*
|
|
4
|
+
* Created on: 2024-07-26
|
|
5
|
+
* Author: fasiondog
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
#ifndef HKU_UTILS_HTTP_CLIENT_H
|
|
10
|
+
#define HKU_UTILS_HTTP_CLIENT_H
|
|
11
|
+
|
|
12
|
+
#include "hikyuu/utilities/config.h"
|
|
13
|
+
#if !HKU_ENABLE_HTTP_CLIENT
|
|
14
|
+
#error "Don't enable http client, please config with --http_client=y"
|
|
15
|
+
#endif
|
|
16
|
+
|
|
17
|
+
#include <string>
|
|
18
|
+
#include <nlohmann/json.hpp>
|
|
19
|
+
#include "nng_wrap.h"
|
|
20
|
+
|
|
21
|
+
#ifndef HKU_UTILS_API
|
|
22
|
+
#define HKU_UTILS_API
|
|
23
|
+
#endif
|
|
24
|
+
|
|
25
|
+
namespace hku {
|
|
26
|
+
|
|
27
|
+
using json = nlohmann::json;
|
|
28
|
+
|
|
29
|
+
class HKU_UTILS_API HttpClient;
|
|
30
|
+
|
|
31
|
+
class HKU_UTILS_API HttpResponse final {
|
|
32
|
+
friend class HKU_UTILS_API HttpClient;
|
|
33
|
+
|
|
34
|
+
public:
|
|
35
|
+
HttpResponse();
|
|
36
|
+
~HttpResponse();
|
|
37
|
+
|
|
38
|
+
HttpResponse(const HttpResponse&) = delete;
|
|
39
|
+
HttpResponse& operator=(const HttpResponse&) = delete;
|
|
40
|
+
|
|
41
|
+
HttpResponse(HttpResponse&& rhs);
|
|
42
|
+
HttpResponse& operator=(HttpResponse&& rhs);
|
|
43
|
+
|
|
44
|
+
const std::string& body() const noexcept {
|
|
45
|
+
return m_body;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
hku::json json() const {
|
|
49
|
+
return json::parse(m_body);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
int status() const noexcept {
|
|
53
|
+
return nng_http_res_get_status(m_res);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
std::string reason() noexcept {
|
|
57
|
+
return nng_http_res_get_reason(m_res);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
std::string getHeader(const std::string& key) noexcept {
|
|
61
|
+
const char* hdr = nng_http_res_get_header(m_res, key.c_str());
|
|
62
|
+
return hdr ? std::string(hdr) : std::string();
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
size_t getContentLength() noexcept {
|
|
66
|
+
std::string slen = getHeader("Content-Length");
|
|
67
|
+
return slen.empty() ? 0 : std::stoi(slen);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
private:
|
|
71
|
+
void _resizeBody(size_t len) {
|
|
72
|
+
m_body.resize(len);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
nng_http_res* get() const noexcept {
|
|
76
|
+
return m_res;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
void reset();
|
|
80
|
+
|
|
81
|
+
private:
|
|
82
|
+
nng_http_res* m_res{nullptr};
|
|
83
|
+
std::string m_body;
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
class HKU_UTILS_API HttpClient {
|
|
87
|
+
public:
|
|
88
|
+
HttpClient() = default;
|
|
89
|
+
explicit HttpClient(const std::string& url, int32_t timeout_ms = NNG_DURATION_DEFAULT)
|
|
90
|
+
: m_url(nng::url(url)), m_timeout_ms(timeout_ms) {};
|
|
91
|
+
virtual ~HttpClient();
|
|
92
|
+
|
|
93
|
+
HttpClient(const HttpClient&) = delete;
|
|
94
|
+
HttpClient& operator=(const HttpClient&) = delete;
|
|
95
|
+
|
|
96
|
+
HttpClient(HttpClient&& rhs)
|
|
97
|
+
: m_default_headers(std::move(rhs.m_default_headers)),
|
|
98
|
+
m_url(std::move(rhs.m_url)),
|
|
99
|
+
m_client(std::move(rhs.m_client)),
|
|
100
|
+
m_aio(std::move(rhs.m_aio)),
|
|
101
|
+
m_conn(std::move(rhs.m_conn)),
|
|
102
|
+
#if HKU_ENABLE_HTTP_CLIENT_SSL
|
|
103
|
+
m_tls_cfg(std::move(rhs.m_tls_cfg)),
|
|
104
|
+
m_ca_file(std::move(rhs.m_ca_file)),
|
|
105
|
+
#endif
|
|
106
|
+
m_timeout_ms(rhs.m_timeout_ms) {
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
HttpClient& operator=(HttpClient&& rhs) {
|
|
110
|
+
if (this != &rhs) {
|
|
111
|
+
m_default_headers = std::move(rhs.m_default_headers);
|
|
112
|
+
m_url = std::move(rhs.m_url);
|
|
113
|
+
m_client = (std::move(rhs.m_client));
|
|
114
|
+
m_aio = std::move(rhs.m_aio);
|
|
115
|
+
m_conn = std::move(rhs.m_conn);
|
|
116
|
+
#if HKU_ENABLE_HTTP_CLIENT_SSL
|
|
117
|
+
m_tls_cfg = std::move(rhs.m_tls_cfg);
|
|
118
|
+
m_ca_file = std::move(rhs.m_ca_file);
|
|
119
|
+
#endif
|
|
120
|
+
m_timeout_ms = rhs.m_timeout_ms;
|
|
121
|
+
rhs.m_timeout_ms = NNG_DURATION_DEFAULT;
|
|
122
|
+
}
|
|
123
|
+
return *this;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
bool valid() const noexcept {
|
|
127
|
+
return m_url.valid();
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
const std::string& url() const noexcept {
|
|
131
|
+
return m_url.raw_url();
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
void setUrl(const std::string& url) noexcept {
|
|
135
|
+
m_url = nng::url(url);
|
|
136
|
+
reset();
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// #define NNG_DURATION_INFINITE (-1)
|
|
140
|
+
// #define NNG_DURATION_DEFAULT (-2)
|
|
141
|
+
// #define NNG_DURATION_ZERO (0)
|
|
142
|
+
void setTimeout(int32_t ms) {
|
|
143
|
+
if (m_timeout_ms != ms) {
|
|
144
|
+
m_timeout_ms = ms;
|
|
145
|
+
reset();
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
void setDefaultHeaders(const HttpHeaders& headers) {
|
|
150
|
+
m_default_headers = headers;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
void setDefaultHeaders(HttpHeaders&& headers) {
|
|
154
|
+
m_default_headers = std::move(headers);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
void setCaFile(const std::string& filename);
|
|
158
|
+
|
|
159
|
+
void reset();
|
|
160
|
+
|
|
161
|
+
HttpResponse request(const std::string& method, const std::string& path,
|
|
162
|
+
const HttpParams& params, const HttpHeaders& headers, const char* body,
|
|
163
|
+
size_t body_len, const std::string& content_type);
|
|
164
|
+
|
|
165
|
+
HttpResponse get(const std::string& path, const HttpHeaders& headers = HttpHeaders()) {
|
|
166
|
+
return request("GET", path, HttpParams(), headers, nullptr, 0, "");
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
HttpResponse get(const std::string& path, const HttpParams& params,
|
|
170
|
+
const HttpHeaders& headers) {
|
|
171
|
+
return request("GET", path, params, headers, nullptr, 0, "");
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
HttpResponse post(const std::string& path, const HttpParams& params, const HttpHeaders& headers,
|
|
175
|
+
const char* body, size_t len, const std::string& content_type) {
|
|
176
|
+
return request("POST", path, params, headers, body, len, content_type);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
HttpResponse post(const std::string& path, const HttpHeaders& headers, const char* body,
|
|
180
|
+
size_t len, const std::string& content_type) {
|
|
181
|
+
return request("POST", path, HttpParams(), headers, body, len, content_type);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
HttpResponse post(const std::string& path, const HttpParams& params, const HttpHeaders& headers,
|
|
185
|
+
const std::string& content, const std::string& content_type = "text/plaint") {
|
|
186
|
+
return post(path, params, headers, content.data(), content.size(), content_type);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
HttpResponse post(const std::string& path, const HttpHeaders& headers,
|
|
190
|
+
const std::string& content, const std::string& content_type = "text/plaint") {
|
|
191
|
+
return post(path, HttpParams(), headers, content, content_type);
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
HttpResponse post(const std::string& path, const HttpParams& params, const HttpHeaders& headers,
|
|
195
|
+
const json& body) {
|
|
196
|
+
return post(path, params, headers, body.dump(), "application/json");
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
HttpResponse post(const std::string& path, const HttpHeaders& headers, const json& body) {
|
|
200
|
+
return post(path, HttpParams(), headers, body);
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
HttpResponse post(const std::string& path, const json& body) {
|
|
204
|
+
return post(path, HttpHeaders(), body);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
private:
|
|
208
|
+
void _connect();
|
|
209
|
+
HttpResponse _readResChunk(const std::string& method, const std::string& uri,
|
|
210
|
+
const HttpHeaders& headers, const char* body, size_t body_len,
|
|
211
|
+
const std::string& content_type);
|
|
212
|
+
|
|
213
|
+
private:
|
|
214
|
+
HttpHeaders m_default_headers;
|
|
215
|
+
nng::url m_url;
|
|
216
|
+
nng::http_client m_client;
|
|
217
|
+
nng::aio m_aio;
|
|
218
|
+
nng::http_conn m_conn;
|
|
219
|
+
#if HKU_ENABLE_HTTP_CLIENT_SSL
|
|
220
|
+
nng::tls_config m_tls_cfg;
|
|
221
|
+
std::string m_ca_file;
|
|
222
|
+
#endif
|
|
223
|
+
|
|
224
|
+
int32_t m_timeout_ms{NNG_DURATION_DEFAULT};
|
|
225
|
+
};
|
|
226
|
+
|
|
227
|
+
} // namespace hku
|
|
228
|
+
|
|
229
|
+
#endif
|