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

hotfix(agent): publish position limit account info #183

Merged
merged 1 commit into from
Oct 13, 2023
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
10 changes: 10 additions & 0 deletions common/changes/@yuants/agent/2023-10-13-09-13.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@yuants/agent",
"comment": "hotfix: publish account info for position limit account",
"type": "patch"
}
],
"packageName": "@yuants/agent"
}
15 changes: 15 additions & 0 deletions libraries/agent/src/AgentScene.ts
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,21 @@ export const AgentScene = async (terminal: Terminal, agentConf: IAgentConf) => {
positionLimitAccountInfoUnit,
);
positionLimitAccountPerformanceUnit = new AccountPerformanceUnit(kernel, positionLimitAccountInfoUnit);

if (agentConf.publish_account) {
const unit = new BasicUnit(kernel);
const accountInfo$ = new Subject<IAccountInfo>();
terminal.provideAccountInfo(accountInfo$);
unit.onIdle = () => {
accountInfo$.next(positionLimitAccountInfoUnit!.accountInfo);
};
// 装载指标单元
const account_id = positionLimitAccountPerformanceUnit.performance.account_id;
new KernelFramesMetricsUnit(kernel, account_id);
new QuoteMetricsUnit(kernel, account_id, quoteDataUnit);
new PeriodMetricsUnit(kernel, account_id, periodDataUnit);
new AccountPerformanceMetricsUnit(kernel, positionLimitAccountPerformanceUnit);
}
}

let counterpartyAccountInfoUnit: AccountSimulatorUnit | undefined;
Expand Down