koishi-plugin-monetary-bourse 3.0.0-alpha.20 → 3.0.0
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.
- package/assets/fonts/README.md +8 -0
- package/assets/fonts/RobotoMono-Bold.ttf +0 -0
- package/assets/fonts/RobotoMono-Regular.ttf +0 -0
- package/lib/index.js +36 -0
- package/lib/templates/holding-card.html +3 -1
- package/lib/templates/stock-chart.html +2 -0
- package/lib/templates/trade-result.html +3 -1
- package/package.json +2 -1
- package/readme.md +28 -5
|
Binary file
|
|
Binary file
|
package/lib/index.js
CHANGED
|
@@ -32,12 +32,46 @@ var import_koishi2 = require("koishi");
|
|
|
32
32
|
// src/render.ts
|
|
33
33
|
var import_koishi = require("koishi");
|
|
34
34
|
var import_path = require("path");
|
|
35
|
+
var import_url = require("url");
|
|
35
36
|
var import_fs = require("fs");
|
|
36
37
|
var templatesDir = (0, import_path.resolve)(__dirname, "templates");
|
|
38
|
+
var assetsDir = (0, import_path.resolve)(__dirname, "..", "assets");
|
|
39
|
+
var assetsBaseUrl = (0, import_url.pathToFileURL)(assetsDir).toString().replace(/\/$/, "");
|
|
40
|
+
function getAssetUrl(relativePath) {
|
|
41
|
+
return `${assetsBaseUrl}/${relativePath}`;
|
|
42
|
+
}
|
|
43
|
+
__name(getAssetUrl, "getAssetUrl");
|
|
44
|
+
function getFontFaceCss() {
|
|
45
|
+
const fontRegularUrl = getAssetUrl("fonts/RobotoMono-Regular.ttf");
|
|
46
|
+
const fontBoldUrl = getAssetUrl("fonts/RobotoMono-Bold.ttf");
|
|
47
|
+
return `
|
|
48
|
+
@font-face {
|
|
49
|
+
font-family: 'Roboto Mono';
|
|
50
|
+
src: url('${fontRegularUrl}') format('truetype');
|
|
51
|
+
font-weight: 400;
|
|
52
|
+
font-style: normal;
|
|
53
|
+
font-display: swap;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
@font-face {
|
|
57
|
+
font-family: 'Roboto Mono';
|
|
58
|
+
src: url('${fontBoldUrl}') format('truetype');
|
|
59
|
+
font-weight: 700;
|
|
60
|
+
font-style: normal;
|
|
61
|
+
font-display: swap;
|
|
62
|
+
}
|
|
63
|
+
`;
|
|
64
|
+
}
|
|
65
|
+
__name(getFontFaceCss, "getFontFaceCss");
|
|
66
|
+
function injectFontFace(template) {
|
|
67
|
+
return template.replace("{{FONT_FACE}}", getFontFaceCss());
|
|
68
|
+
}
|
|
69
|
+
__name(injectFontFace, "injectFontFace");
|
|
37
70
|
async function renderHoldingImage(ctx, logger2, username, holding, pending, currency) {
|
|
38
71
|
try {
|
|
39
72
|
const templatePath = (0, import_path.resolve)(templatesDir, "holding-card.html");
|
|
40
73
|
let template = await import_fs.promises.readFile(templatePath, "utf-8");
|
|
74
|
+
template = injectFontFace(template);
|
|
41
75
|
const data = {
|
|
42
76
|
username,
|
|
43
77
|
holding,
|
|
@@ -66,6 +100,7 @@ async function renderTradeResultImage(ctx, logger2, tradeType, stockName, amount
|
|
|
66
100
|
try {
|
|
67
101
|
const templatePath = (0, import_path.resolve)(templatesDir, "trade-result.html");
|
|
68
102
|
let template = await import_fs.promises.readFile(templatePath, "utf-8");
|
|
103
|
+
template = injectFontFace(template);
|
|
69
104
|
const tradeIndex = priceHistory.length - 1;
|
|
70
105
|
const status = tradeMeta?.status ?? "settled";
|
|
71
106
|
const pendingMinutes = tradeMeta?.pendingMinutes ?? 0;
|
|
@@ -127,6 +162,7 @@ async function renderStockImage(ctx, logger2, data, name2, viewLabel, current, h
|
|
|
127
162
|
}) : [];
|
|
128
163
|
const templatePath = (0, import_path.resolve)(templatesDir, "stock-chart.html");
|
|
129
164
|
let html = await import_fs.promises.readFile(templatePath, "utf-8");
|
|
165
|
+
html = injectFontFace(html);
|
|
130
166
|
const colorScheme = {
|
|
131
167
|
mainColor: isUp ? "#f23645" : "#089981",
|
|
132
168
|
gradientStart: isUp ? "rgba(242, 54, 69, 0.25)" : "rgba(8, 153, 129, 0.25)",
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -1,12 +1,28 @@
|
|
|
1
|
-
|
|
1
|
+
<h1 align="center">koishi-plugin-monetary-bourse</h1>
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
<p align="center">
|
|
4
|
+
为 Koishi 提供基于 <code>monetary</code> 通用货币系统的股票交易所功能。
|
|
5
|
+
</p>
|
|
4
6
|
|
|
5
|
-
|
|
7
|
+
<p align="center">
|
|
8
|
+
<a href="https://www.npmjs.com/package/koishi-plugin-monetary-bourse"><img src="https://img.shields.io/npm/v/koishi-plugin-monetary-bourse?style=for-the-badge&logo=npm" alt="npm" /></a>
|
|
9
|
+
<a href="https://github.com/BYWled/koishi-plugin-monetary-bourse"><img src="https://img.shields.io/github/stars/BYWled/koishi-plugin-monetary-bourse?style=for-the-badge&logo=github" alt="GitHub Stars" /></a>
|
|
10
|
+
</p>
|
|
11
|
+
|
|
12
|
+
<p align="center">
|
|
13
|
+
<a href="https://gitee.com/BYWled/koishi-plugin-monetary-bourse"><img src="https://img.shields.io/badge/Gitee-代码镜像-C71D23?style=for-the-badge&logo=gitee&logoColor=white" alt="Gitee Mirror" /></a>
|
|
14
|
+
<a href="https://gitcode.com/BYWled/koishi-plugin-monetary-bourse"><img src="https://img.shields.io/badge/GitCode-代码镜像-2962FF?style=for-the-badge" alt="GitCode Mirror" /></a>
|
|
15
|
+
</p>
|
|
16
|
+
|
|
17
|
+
<p align="center">
|
|
18
|
+
<a href="https://github.com/BYWled/koishi-plugin-monetary-bourse">GitHub</a> ·
|
|
19
|
+
<a href="https://gitee.com/BYWled/koishi-plugin-monetary-bourse">Gitee</a> ·
|
|
20
|
+
<a href="https://gitcode.com/BYWled/koishi-plugin-monetary-bourse">GitCode</a>
|
|
21
|
+
</p>
|
|
6
22
|
|
|
7
23
|
本插件模拟了一个具备自动宏观调控、25种经典K线形态、智能概率博弈和可视化交割单的深度拟真股票市场。用户可以使用机器人通用的货币(如信用点)进行股票买卖、炒股理财。
|
|
8
24
|
|
|
9
|
-
> 版本:**3.0.0
|
|
25
|
+
> 版本:**3.0.0**
|
|
10
26
|
|
|
11
27
|
## ✨ 特性
|
|
12
28
|
|
|
@@ -17,11 +33,15 @@
|
|
|
17
33
|
- **🖼️ 全可视化交互**:
|
|
18
34
|
- **专业走势图**:复刻 TradingView 风格的深色玻璃拟态 K 线图,包含动态呼吸灯、渐变填充与详细指标。
|
|
19
35
|
- **持仓资产卡片**:精美渲染个人持仓、成本分析、浮动盈亏比及排队中的挂单详情。
|
|
20
|
-
-
|
|
36
|
+
- **交易交割单**:买卖成交瞬间生成**交易回单图片**,在 K 线图上精确标记买卖点位,直观展示单笔盈亏与买入成本线。
|
|
37
|
+
- **内置字体**:使用 Roboto Mono 字体,确保图表中的数字和文本清晰易读。
|
|
21
38
|
- **❄️ 资金冻结与挂单排队**:
|
|
22
39
|
- 交易采用 T+0 机制,但大额资金/股票会根据金额计算**动态冻结时间**。
|
|
23
40
|
- 挂单采用**串行排队模式**,同一用户的多个挂单需依次读秒,防止通过拆单绕过冻结机制,增加博弈深度。
|
|
24
41
|
- **💸 手续费与精度控制**:支持卖出手续费配置,回单展示净到账金额;可开启整数精度模式,适配不支持小数的货币体系。
|
|
42
|
+
- **📊 分红与新闻系统**:
|
|
43
|
+
- 定期分红:根据持仓占比和预设利润率进行分红,支持分红播报。
|
|
44
|
+
- 新闻触发:当价格偏离宏观目标超过设定阈值时,自动从利好/利空新闻库中随机选取并播报,增加市场氛围。
|
|
25
45
|
- **🧭 宏观周期固定刷新**:支持固定时刻刷新宏观目标周期,便于在活动时段塑造更清晰的趋势节奏。
|
|
26
46
|
- **🏦 银行联动**:支持与[ `koishi-plugin-monetary-bank`](https://github.com/BYWled/koishi-plugin-monetary-bank)[](https://www.npmjs.com/package/koishi-plugin-monetary-bank) 联动,现金不足时自动扣除银行活期存款。
|
|
27
47
|
|
|
@@ -197,6 +217,9 @@ negativeNews:
|
|
|
197
217
|
|
|
198
218
|
详细的更新日志请查看 [CHANGELOG.md](./CHANGELOG.md)。
|
|
199
219
|
|
|
220
|
+
## 🙏 第三方资源/致谢
|
|
221
|
+
- Roboto Mono 字体(SIL OPEN FONT LICENSE Version 1.1):[字体链接](https://fonts.google.com/specimen/Roboto+Mono)
|
|
222
|
+
|
|
200
223
|
---
|
|
201
224
|
|
|
202
225
|
**开发者**: BYWled
|