diff --git a/apps/account-composer/src/index.ts b/apps/account-composer/src/index.ts index 6b95b0580..464b3eb29 100644 --- a/apps/account-composer/src/index.ts +++ b/apps/account-composer/src/index.ts @@ -2,7 +2,20 @@ import { IAccountInfo, formatTime } from '@yuants/data-model'; import { Terminal } from '@yuants/protocol'; import Ajv from 'ajv'; import addFormats from 'ajv-formats'; -import { combineLatest, defer, filter, groupBy, map, mergeMap, retry, shareReplay, tap, toArray } from 'rxjs'; +import { + combineLatest, + defer, + filter, + groupBy, + map, + mergeMap, + retry, + shareReplay, + tap, + throttleTime, + timeout, + toArray, +} from 'rxjs'; import { IAccountCompositionRelation, acrSchema } from './model'; const TERMINAL_ID = process.env.TERMINAL_ID || `AccountComposer`; @@ -30,34 +43,36 @@ defer(() => terminal.queryDataRecords({ type: 'acco group.pipe( toArray(), tap((x) => { - const accountInfo$ = combineLatest( - x.map((y) => - terminal.useAccountInfo(y.source_account_id).pipe( - // - map( - (x): IAccountInfo => ({ - ...x, - money: { - // - ...x.money, - equity: x.money.equity * y.multiple, - balance: x.money.balance * y.multiple, - profit: x.money.profit * y.multiple, - used: x.money.used * y.multiple, - free: x.money.free * y.multiple, - }, - positions: x.positions.map((p) => ({ - ...p, - volume: p.volume * y.multiple, - free_volume: p.free_volume * y.multiple, - floating_profit: p.floating_profit * y.multiple, - })), - }), + const accountInfo$ = defer(() => + combineLatest( + x.map((y) => + terminal.useAccountInfo(y.source_account_id).pipe( + map( + (x): IAccountInfo => ({ + ...x, + money: { + ...x.money, + equity: x.money.equity * y.multiple, + balance: x.money.balance * y.multiple, + profit: x.money.profit * y.multiple, + used: x.money.used * y.multiple, + free: x.money.free * y.multiple, + }, + positions: x.positions.map((p) => ({ + ...p, + volume: p.volume * y.multiple, + free_volume: p.free_volume * y.multiple, + floating_profit: p.floating_profit * y.multiple, + })), + }), + ), + timeout(30_000), ), ), ), ).pipe( - // + retry(), + throttleTime(1000), map((accountInfos): IAccountInfo => { return { account_id: group.key, diff --git a/common/changes/@yuants/app-account-composer/2024-03-05-17-26.json b/common/changes/@yuants/app-account-composer/2024-03-05-17-26.json new file mode 100644 index 000000000..4e24c236e --- /dev/null +++ b/common/changes/@yuants/app-account-composer/2024-03-05-17-26.json @@ -0,0 +1,10 @@ +{ + "changes": [ + { + "packageName": "@yuants/app-account-composer", + "comment": "timeout and throttle", + "type": "patch" + } + ], + "packageName": "@yuants/app-account-composer" +} \ No newline at end of file diff --git a/ui/web/src/modules/AccountInfo/AccountInfoPanel.tsx b/ui/web/src/modules/AccountInfo/AccountInfoPanel.tsx index cde4df978..245a9c8c1 100644 --- a/ui/web/src/modules/AccountInfo/AccountInfoPanel.tsx +++ b/ui/web/src/modules/AccountInfo/AccountInfoPanel.tsx @@ -172,7 +172,7 @@ registerPage('AccountInfoPanel', () => { )?.[0]; return ( - +

{accountInfo.account_id}

最后更新时间: {formatTime(updatedAt)} (Ping {renderedAt - updatedAt}ms) @@ -182,6 +182,7 @@ registerPage('AccountInfoPanel', () => { align="center" size="small" row + style={{ width: '100%' }} data={[ { key: '净值',