From 8a7a9c357f5d831b145c76e9bfd4abd658e15930 Mon Sep 17 00:00:00 2001 From: Matthias Vonend Date: Tue, 20 Apr 2021 16:34:50 +0200 Subject: [PATCH] no message --- backend/src/agent/brains/random.brain.ts | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/backend/src/agent/brains/random.brain.ts b/backend/src/agent/brains/random.brain.ts index 9e73a93..c2a35fd 100644 --- a/backend/src/agent/brains/random.brain.ts +++ b/backend/src/agent/brains/random.brain.ts @@ -35,12 +35,18 @@ export class RandomBrain extends Brain { this.logger.log( `Agent ${this.agent.id} with brain ${this.constructor.name} creates an order`, ); + + const operation = + Math.random() > 0.5 ? OperationType.BUY : OperationType.SELL; + this.marketService.placeOrder({ aktenId: this.stock, - price: Math.random() + v, + price: + v + + (operation === OperationType.SELL ? Math.random() : -Math.random()), stockCount: Math.ceil(Math.random() * 100), - operation: - Math.random() > 0.5 ? OperationType.BUY : OperationType.SELL, + operation, + token: this.token, }); });