@dshtrading/router 0.1.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/LICENSE +75 -0
- package/lib/catalog.d.ts +46 -0
- package/lib/catalog.js +1073 -0
- package/lib/index.d.ts +136 -0
- package/lib/index.js +244 -0
- package/lib/tools.js +128 -0
- package/package.json +40 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
Copyright (c) 2026 zhu1090093659 (dsh-trading)
|
|
2
|
+
|
|
3
|
+
# PolyForm Noncommercial License 1.0.0
|
|
4
|
+
|
|
5
|
+
<https://polyformproject.org/licenses/noncommercial/1.0.0>
|
|
6
|
+
|
|
7
|
+
## Acceptance
|
|
8
|
+
|
|
9
|
+
In order to get any license under these terms, you must agree to them as both strict obligations and conditions to all your licenses.
|
|
10
|
+
|
|
11
|
+
## Copyright License
|
|
12
|
+
|
|
13
|
+
The licensor grants you a copyright license for the software to do everything you might do with the software that would otherwise infringe the licensor's copyright in it for any permitted purpose. However, you may only distribute the software according to [Distribution License](#distribution-license) and make changes or new works based on the software according to [Changes and New Works License](#changes-and-new-works-license).
|
|
14
|
+
|
|
15
|
+
## Distribution License
|
|
16
|
+
|
|
17
|
+
The licensor grants you an additional copyright license to distribute copies of the software. Your license to distribute covers distributing the software with changes and new works permitted by [Changes and New Works License](#changes-and-new-works-license).
|
|
18
|
+
|
|
19
|
+
## Notices
|
|
20
|
+
|
|
21
|
+
You must ensure that anyone who gets a copy of any part of the software from you also gets a copy of these terms or the URL for them above, as well as copies of any plain-text lines beginning with `Required Notice:` that the licensor provided with the software. For example:
|
|
22
|
+
|
|
23
|
+
> Required Notice: Copyright Yoyodyne, Inc. (http://example.com)
|
|
24
|
+
|
|
25
|
+
## Changes and New Works License
|
|
26
|
+
|
|
27
|
+
The licensor grants you an additional copyright license to make changes and new works based on the software for any permitted purpose.
|
|
28
|
+
|
|
29
|
+
## Patent License
|
|
30
|
+
|
|
31
|
+
The licensor grants you a patent license for the software that covers patent claims the licensor can license, or becomes able to license, that you would infringe by using the software.
|
|
32
|
+
|
|
33
|
+
## Noncommercial Purposes
|
|
34
|
+
|
|
35
|
+
Any noncommercial purpose is a permitted purpose.
|
|
36
|
+
|
|
37
|
+
## Personal Uses
|
|
38
|
+
|
|
39
|
+
Personal use for research, experiment, and testing for the benefit of public knowledge, personal study, private entertainment, hobby projects, amateur pursuits, or religious observance, without any anticipated commercial application, is use for a permitted purpose.
|
|
40
|
+
|
|
41
|
+
## Noncommercial Organizations
|
|
42
|
+
|
|
43
|
+
Use by any charitable organization, educational institution, public research organization, public safety or health organization, environmental protection organization, or government institution is use for a permitted purpose regardless of the source of funding or obligations resulting from the funding.
|
|
44
|
+
|
|
45
|
+
## Fair Use
|
|
46
|
+
|
|
47
|
+
You may have "fair use" rights for the software under the law. These terms do not limit them.
|
|
48
|
+
|
|
49
|
+
## No Other Rights
|
|
50
|
+
|
|
51
|
+
These terms do not allow you to sublicense or transfer any of your licenses to anyone else, or prevent the licensor from granting licenses to anyone else. These terms do not imply any other licenses.
|
|
52
|
+
|
|
53
|
+
## Patent Defense
|
|
54
|
+
|
|
55
|
+
If you make any written claim that the software infringes or contributes to infringement of any patent, your patent license for the software granted under these terms ends immediately. If your company makes such a claim, your patent license ends immediately for work on behalf of your company.
|
|
56
|
+
|
|
57
|
+
## Violations
|
|
58
|
+
|
|
59
|
+
The first time you are notified in writing that you have violated any of these terms, or done anything with the software not covered by your licenses, your licenses can nonetheless continue if you come into full compliance with these terms, and take practical steps to correct past violations, within 32 days of receiving notice. Otherwise, all your licenses end immediately.
|
|
60
|
+
|
|
61
|
+
## No Liability
|
|
62
|
+
|
|
63
|
+
***As far as the law allows, the software comes as is, without any warranty or condition, and the licensor will not be liable to you for any damages arising out of these terms or the use or nature of the software, under any kind of legal claim.***
|
|
64
|
+
|
|
65
|
+
## Definitions
|
|
66
|
+
|
|
67
|
+
The **licensor** is the individual or entity offering these terms, and the **software** is the software the licensor makes available under these terms.
|
|
68
|
+
|
|
69
|
+
**You** refers to the individual or entity agreeing to these terms.
|
|
70
|
+
|
|
71
|
+
**Your company** is any legal entity, sole proprietorship, or other kind of organization that you work for, plus all organizations that have control over, are under the control of, or are under common control with that organization. **Control** means ownership of substantially all the assets of an entity, or the power to direct its management and policies by vote, contract, or otherwise. Control can be direct or indirect.
|
|
72
|
+
|
|
73
|
+
**Your licenses** are all the licenses granted to you for the software under these terms.
|
|
74
|
+
|
|
75
|
+
**Use** means anything you do with the software requiring one of your licenses.
|
package/lib/catalog.d.ts
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
//#region src/catalog.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* 内置标的字典(host 侧 SSOT,issue #33 / P4):每市场常见标的的 symbol + 中文名
|
|
4
|
+
* 静态种子。原为 client-ui-trading 内部常量(且无消费方),升位到 router 供
|
|
5
|
+
* `instruments_search` 工具与桥共用;**静态快照**——新上市标的靠动态全集
|
|
6
|
+
* (registry.active(market).listInstruments?())与本表并集兜底。
|
|
7
|
+
*
|
|
8
|
+
* 词汇纪律:symbol 一律市场规范词汇(docs/symbol-vocabulary.md)。
|
|
9
|
+
*
|
|
10
|
+
* 纯数据模块(零依赖,浏览器/Node 双端安全)。
|
|
11
|
+
* @module @dshtrading/router/catalog
|
|
12
|
+
*/
|
|
13
|
+
/** 市场词汇(与 api MarketId 同词汇;本地定义保持本模块零依赖)。 */
|
|
14
|
+
type CatalogMarket = 'crypto' | 'us' | 'cn' | 'hk';
|
|
15
|
+
interface CatalogEntry {
|
|
16
|
+
symbol: string;
|
|
17
|
+
name: string;
|
|
18
|
+
pinyin?: string;
|
|
19
|
+
}
|
|
20
|
+
declare const SYMBOL_CATALOG: Record<CatalogMarket, CatalogEntry[]>;
|
|
21
|
+
/** 注入某市场的动态标的全集(由桥端点拉取并入)。 */
|
|
22
|
+
declare function setDynamicCatalog(market: CatalogMarket, entries: Array<{
|
|
23
|
+
symbol: string;
|
|
24
|
+
name?: string;
|
|
25
|
+
pinyin?: string;
|
|
26
|
+
}>): void;
|
|
27
|
+
/** 累加/增量更新某市场的动态标的名称(由实时行情查询或联想补齐触发)。 */
|
|
28
|
+
declare function updateDynamicCatalog(market: CatalogMarket, entries: Array<{
|
|
29
|
+
symbol: string;
|
|
30
|
+
name?: string;
|
|
31
|
+
pinyin?: string;
|
|
32
|
+
}>): void;
|
|
33
|
+
/** 获取静态快照 ∪ 动态全集融合后的标的列表(静态优先保留中文名,动态补充新标的)。 */
|
|
34
|
+
declare function getMergedCatalog(market: CatalogMarket): CatalogEntry[];
|
|
35
|
+
/**
|
|
36
|
+
* 联想搜索:静态 ∪ 动态全集融合,symbol 前缀/包含(大小写不敏感)或中文名包含,返回前 limit 条。
|
|
37
|
+
* 空查询返回空(不打扰)。
|
|
38
|
+
*/
|
|
39
|
+
declare function searchSymbols(market: CatalogMarket, query: string, limit?: number): CatalogEntry[];
|
|
40
|
+
/** 跨市场联想:全部市场字典合并搜索(自选页签的添加是跨市场的)。 */
|
|
41
|
+
interface Suggestion extends CatalogEntry {
|
|
42
|
+
market: CatalogMarket;
|
|
43
|
+
}
|
|
44
|
+
declare function searchAllMarkets(query: string, limit?: number): Suggestion[];
|
|
45
|
+
//#endregion
|
|
46
|
+
export { CatalogEntry, CatalogMarket, SYMBOL_CATALOG, Suggestion, getMergedCatalog, searchAllMarkets, searchSymbols, setDynamicCatalog, updateDynamicCatalog };
|