Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: 支持北交所股票 #408

Merged
merged 1 commit into from
Jan 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/explorer/stockProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ export class StockProvider implements TreeDataProvider<LeekTreeItem> {
}
getAStockNodes(stocks: Promise<LeekTreeItem[]>): Promise<LeekTreeItem[]> {
const aStocks: Promise<LeekTreeItem[]> = stocks.then((res: LeekTreeItem[]) => {
const arr = res.filter((item: LeekTreeItem) => /^(sh|sz)/.test(item.type || ''));
const arr = res.filter((item: LeekTreeItem) => /^(sh|sz|bj)/.test(item.type || ''));
return arr;
});

Expand Down
4 changes: 2 additions & 2 deletions src/explorer/stockService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ export default class StockService extends LeekService {
let stockItem: any;
let fixedNumber = 2;
if (params.length > 1) {
if (/^(sh|sz)/.test(code)) {
if (/^(sh|sz|bj)/.test(code)) {
let open = params[1];
let yestclose = params[2];
let price = params[3];
Expand Down Expand Up @@ -552,7 +552,7 @@ export default class StockService extends LeekService {
const stocks = stockResponse.data.stocks || [];
stocks.forEach((item: any) => {
const { code, name } = item;
if (code.startsWith('SH') || code.startsWith('SZ')) {
if (code.startsWith('SH') || code.startsWith('SZ') || code.startsWith('BJ')) {
const _code = code.toLowerCase();
result.push({
label: `${_code} | ${name}`,
Expand Down
4 changes: 2 additions & 2 deletions src/shared/leekConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ export class LeekFundConfig extends BaseConfig {
// 找到前一个同市场的股票
for (let index = currentIndex - 1; index >= 0; index--) {
const previousCode = configArr[index];
if (/^(sh|sz)/.test(code) && /^(sh|sz)/.test(previousCode)) {
if (/^(sh|sz|bj)/.test(code) && /^(sh|sz|bj)/.test(previousCode)) {
previousIndex = index;
break;
}
Expand Down Expand Up @@ -270,7 +270,7 @@ export class LeekFundConfig extends BaseConfig {
//找到后一个同市场的股票
for (let index = currentIndex + 1; index < configArr.length; index++) {
const nextCode = configArr[index];
if (/^(sh|sz)/.test(code) && /^(sh|sz)/.test(nextCode)) {
if (/^(sh|sz|bj)/.test(code) && /^(sh|sz|bj)/.test(nextCode)) {
nextIndex = index;
break;
}
Expand Down
2 changes: 1 addition & 1 deletion src/shared/leekTreeItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ export class LeekTreeItem extends TreeItem {

const isFuture = /nf_/.test(code) || /hf_/.test(code);

// type字段:国内期货前缀 `nf_` 。股票的 type 是交易所 (sz,sh)
// type字段:国内期货前缀 `nf_` 。股票的 type 是交易所 (sz,sh,bj)
const typeText = type;
const symbolText = isFuture ? name : symbol;

Expand Down
2 changes: 1 addition & 1 deletion src/shared/typed.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// 支持的股票类型
export const STOCK_TYPE = ['sh', 'sz', 'hk', 'gb', 'us'];
export const STOCK_TYPE = ['sh', 'sz', 'bj', 'hk', 'gb', 'us'];

export enum SortType {
NORMAL = 0, // 基金默认顺序
Expand Down
2 changes: 1 addition & 1 deletion src/shared/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ export function allMarkets(): Array<string> {
const stocks: Array<string> = LeekFundConfig.getConfig('leek-fund.stocks');
stocks.forEach((item: string) => {
let market = StockCategory.NODATA;
if (/^(sh|sz)/.test(item)) {
if (/^(sh|sz|bj)/.test(item)) {
market = StockCategory.A;
} else if (/^(hk)/.test(item)) {
market = StockCategory.HK;
Expand Down
Loading