This commit is contained in:
fasiondog 2024-08-20 16:03:50 +08:00
parent 24f56e72a9
commit 6fe37d6dbe
4 changed files with 72 additions and 76 deletions

View File

@ -9,25 +9,25 @@
"name": "stderr",
"output_type": "stream",
"text": [
"2024-04-06 01:24:41,451 [INFO] hikyuu version: 2.0.0_202404040113_RELEASE_windows_x64 [<module>] (D:\\workspace\\hikyuu\\hikyuu\\__init__.py:93) [hikyuu::hku_info]\n"
"2024-08-20 16:00:57,364 [INFO] hikyuu version: 2.1.1_202408182226_RELEASE_windows_x64 [<module>] (D:\\workspace\\hikyuu\\hikyuu\\__init__.py:97) [hikyuu::hku_info]\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"2024-04-06 01:24:41.867 [HKU-I] - Using MYSQL BaseInfoDriver (BaseInfoDriver.cpp:58)\n",
"2024-04-06 01:24:41.890 [HKU-I] - Loading market information... (StockManager.cpp:532)\n",
"2024-04-06 01:24:41.902 [HKU-I] - Loading stock type information... (StockManager.cpp:545)\n",
"2024-04-06 01:24:41.914 [HKU-I] - Loading stock information... (StockManager.cpp:460)\n",
"2024-04-06 01:24:42.064 [HKU-I] - Loading stock weight... (StockManager.cpp:562)\n",
"2024-04-06 01:24:43.250 [HKU-I] - Loading KData... (StockManager.cpp:133)\n",
"2024-04-06 01:24:43.958 [HKU-I] - Preloading all day kdata to buffer! (StockManager.cpp:171)\n",
"2024-04-06 01:24:43.959 [HKU-I] - Preloading all week kdata to buffer! (StockManager.cpp:174)\n",
"2024-04-06 01:24:43.959 [HKU-I] - Preloading all month kdata to buffer! (StockManager.cpp:177)\n",
"2024-04-06 01:24:43.963 [HKU-I] - 0.71s Loaded Data. (StockManager.cpp:150)\n",
"CPU times: total: 500 ms\n",
"Wall time: 3.35 s\n"
"2024-08-20 16:00:57.865 [HKU-I] - Using MYSQL BaseInfoDriver (BaseInfoDriver.cpp:58)\n",
"2024-08-20 16:00:57.883 [HKU-I] - Loading market information... (StockManager.cpp:481)\n",
"2024-08-20 16:00:57.890 [HKU-I] - Loading stock type information... (StockManager.cpp:494)\n",
"2024-08-20 16:00:57.897 [HKU-I] - Loading stock information... (StockManager.cpp:409)\n",
"2024-08-20 16:00:58.045 [HKU-I] - Loading stock weight... (StockManager.cpp:511)\n",
"2024-08-20 16:00:59.275 [HKU-I] - Loading KData... (StockManager.cpp:134)\n",
"2024-08-20 16:01:00.831 [HKU-I] - Preloading all day kdata to buffer! (StockManager.cpp:179)\n",
"2024-08-20 16:01:00.832 [HKU-I] - Preloading all week kdata to buffer! (StockManager.cpp:179)\n",
"2024-08-20 16:01:00.832 [HKU-I] - Preloading all month kdata to buffer! (StockManager.cpp:179)\n",
"2024-08-20 16:01:00.902 [HKU-I] - 1.63s Loaded Data. (StockManager.cpp:159)\n",
"CPU times: total: 625 ms\n",
"Wall time: 4.01 s\n"
]
}
],
@ -78,7 +78,7 @@
" current borrow_cash: 0.00,\n",
" current borrow_asset: 0.00,\n",
" Position: \n",
" SZ000001 平安银行 2017-01-03 00:00:00 1762 100.00 911.00 1046.00 135.00 14.82% 0.14%\n",
" SZ000001 平安银行 2017-01-03 00:00:00 1854 100.00 911.00 1029.00 118.00 12.95% 0.12%\n",
" Short Position: \n",
" Borrow Stock: \n",
"}\n"
@ -148,21 +148,21 @@
" <th>SZ000001</th>\n",
" <td>平安银行</td>\n",
" <td>2017-01-03</td>\n",
" <td>1762</td>\n",
" <td>1854</td>\n",
" <td>100</td>\n",
" <td>911.0</td>\n",
" <td>1046.0</td>\n",
" <td>135.0</td>\n",
" <td>14.81888</td>\n",
" <td>1029.0</td>\n",
" <td>118.0</td>\n",
" <td>12.952799</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" 证券名称 买入日期 已持仓天数 持仓数量 投入金额 当前市值 盈亏金额 盈亏比例\n",
"证券代码 \n",
"SZ000001 平安银行 2017-01-03 1762 100 911.0 1046.0 135.0 14.81888"
" 证券名称 买入日期 已持仓天数 持仓数量 投入金额 当前市值 盈亏金额 盈亏比例\n",
"证券代码 \n",
"SZ000001 平安银行 2017-01-03 1854 100 911.0 1029.0 118.0 12.952799"
]
},
"execution_count": 3,
@ -259,7 +259,7 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": 6,
"metadata": {},
"outputs": [],
"source": [
@ -271,7 +271,7 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": 7,
"metadata": {},
"outputs": [],
"source": [
@ -298,28 +298,30 @@
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": 8,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"买入SZ000001 11.470 1000\n",
"卖出SZ000001 11.140 1000\n",
"买入SZ000001 11.500 1000\n",
"卖出SZ000001 11.290 1000\n",
"买入SZ000001 10.580 1000\n",
"卖出SZ000001 10.460 1000\n",
"买入SZ000001 9.420 1000\n",
"卖出SZ000001 9.100 1000\n",
"买入SZ000001 9.330 1000\n",
"卖出SZ000001 9.160 1000\n",
"买入SZ000001 9.330 1000\n",
"卖出SZ000001 10.550 1000\n",
"买入SZ000001 10.560 1000\n",
"卖出SZ000001 10.350 1000\n",
"买入SZ000001 10.560 1000\n"
"买入SZ000001, 价格: 9.33, 数量: 1000.0 预期止损价: 0.0, 预期目标价: nan, 信号来源: SystemPart.SIGNAL\n",
"卖出SZ000001, 价格: 9.16, 数量: 1000.0, 信号来源: SystemPart.SIGNAL\n",
"买入SZ000001, 价格: 9.33, 数量: 1000.0 预期止损价: 0.0, 预期目标价: nan, 信号来源: SystemPart.SIGNAL\n",
"卖出SZ000001, 价格: 10.55, 数量: 1000.0, 信号来源: SystemPart.SIGNAL\n",
"买入SZ000001, 价格: 10.56, 数量: 1000.0 预期止损价: 0.0, 预期目标价: nan, 信号来源: SystemPart.SIGNAL\n",
"卖出SZ000001, 价格: 10.35, 数量: 1000.0, 信号来源: SystemPart.SIGNAL\n",
"买入SZ000001, 价格: 10.56, 数量: 1000.0 预期止损价: 0.0, 预期目标价: nan, 信号来源: SystemPart.SIGNAL\n",
"卖出SZ000001, 价格: 10.43, 数量: 1000.0, 信号来源: SystemPart.SIGNAL\n",
"买入SZ000001, 价格: 10.58, 数量: 1000.0 预期止损价: 0.0, 预期目标价: nan, 信号来源: SystemPart.SIGNAL\n",
"卖出SZ000001, 价格: 11.12, 数量: 1000.0, 信号来源: SystemPart.SIGNAL\n",
"买入SZ000001, 价格: 10.4, 数量: 1000.0 预期止损价: 0.0, 预期目标价: nan, 信号来源: SystemPart.SIGNAL\n",
"卖出SZ000001, 价格: 9.94, 数量: 1000.0, 信号来源: SystemPart.SIGNAL\n",
"买入SZ000001, 价格: 10.31, 数量: 1000.0 预期止损价: 0.0, 预期目标价: nan, 信号来源: SystemPart.SIGNAL\n",
"卖出SZ000001, 价格: 10.12, 数量: 1000.0, 信号来源: SystemPart.SIGNAL\n",
"买入SZ000001, 价格: 10.22, 数量: 1000.0 预期止损价: 0.0, 预期目标价: nan, 信号来源: SystemPart.SIGNAL\n",
"卖出SZ000001, 价格: 10.11, 数量: 1000.0, 信号来源: SystemPart.SIGNAL\n",
"买入SZ000001, 价格: 10.13, 数量: 1000.0 预期止损价: 0.0, 预期目标价: nan, 信号来源: SystemPart.SIGNAL\n"
]
}
],

File diff suppressed because one or more lines are too long

View File

@ -72,10 +72,10 @@ class TestOrderBroker:
pass
def buy(self, code, price, num, stoploss, goal_price, part_from):
print("买入:%s %.3f %i" % (code, price, num))
print(f"买入:{code}, 价格: {price}, 数量: {num} 预期止损价: {stoploss}, 预期目标价: {goal_price}, 信号来源: {part_from}")
def sell(self, code, price, num, stoploss, goal_price, part_from):
print("卖出:%s %.3f %i" % (code, price, num))
print(f"卖出:{code}, 价格: {price}, 数量: {num}, 信号来源: {part_from}")
def crtOB(broker, name="NO_NAME"):

View File

@ -80,6 +80,8 @@ void export_OrderBroker(py::module& m) {
:param float price:
:param float num: )")
.def("get_asset_info", &OrderBrokerBase::getAssetInfo)
.def("_buy", &OrderBrokerBase::_buy,
R"(_buy(self, datetime, market, code, price, num)