Skip to content

Commit

Permalink
➕ add: 주문 체결에 대한 로깅 추가 #53
Browse files Browse the repository at this point in the history
sieunie committed Nov 13, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent caf6a1a commit 7061ec1
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions BE/src/stock/order/stock-order.service.ts
Original file line number Diff line number Diff line change
@@ -4,6 +4,7 @@ import {
forwardRef,
Inject,
Injectable,
Logger,
} from '@nestjs/common';
import { NotFoundError } from 'rxjs';
import { LessThanOrEqual, MoreThanOrEqual } from 'typeorm';
@@ -21,6 +22,8 @@ export class StockOrderService {
private readonly stockPriceSocketService: StockPriceSocketService,
) {}

private readonly logger = new Logger();

async findAllPendingOrder() {
return this.stockOrderRepository.findBy({
status: StatusType.PENDING,
@@ -112,7 +115,7 @@ export class StockOrderService {

private async executeBuy(order) {
// TODO: 매수 체결 로직 필요...
console.log(`${order.id}번 매수 예약이 체결되었습니다.`);
this.logger.log(`${order.id}번 매수 예약이 체결되었습니다.`, 'BUY');
await this.stockOrderRepository.update(
{ id: order.id },
{ status: StatusType.COMPLETE, completed_at: new Date() },
@@ -121,7 +124,7 @@ export class StockOrderService {

private async executeSell(order) {
// TODO: 매도 체결 로직 필요...
console.log(`${order.id}번 매도 예약이 체결되었습니다.`);
this.logger.log(`${order.id}번 매도 예약이 체결되었습니다.`, 'SELL');
await this.stockOrderRepository.update(
{ id: order.id },
{ status: StatusType.COMPLETE, completed_at: new Date() },

0 comments on commit 7061ec1

Please sign in to comment.