모의투자 관리 기능 추가
This commit is contained in:
@@ -29,6 +29,24 @@ public class GcPaperAccount {
|
||||
@Builder.Default
|
||||
private BigDecimal realizedPnl = BigDecimal.ZERO;
|
||||
|
||||
@Column(name = "reserved_cash", precision = 20, scale = 2, nullable = false)
|
||||
@Builder.Default
|
||||
private BigDecimal reservedCash = BigDecimal.ZERO;
|
||||
|
||||
@Column(name = "initial_capital_snapshot", precision = 20, scale = 2)
|
||||
private BigDecimal initialCapitalSnapshot;
|
||||
|
||||
@Column(name = "reset_count", nullable = false)
|
||||
@Builder.Default
|
||||
private Integer resetCount = 0;
|
||||
|
||||
@Column(name = "last_reset_at")
|
||||
private LocalDateTime lastResetAt;
|
||||
|
||||
@Column(name = "status", length = 20, nullable = false)
|
||||
@Builder.Default
|
||||
private String status = "ACTIVE";
|
||||
|
||||
@Column(name = "created_at", nullable = false, updatable = false)
|
||||
private LocalDateTime createdAt;
|
||||
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
package com.goldenchart.entity;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import lombok.*;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Entity
|
||||
@Table(name = "gc_paper_cash_ledger")
|
||||
@Getter @Setter @NoArgsConstructor @AllArgsConstructor @Builder
|
||||
public class GcPaperCashLedger {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@Column(name = "account_id", nullable = false)
|
||||
private Long accountId;
|
||||
|
||||
@Column(name = "entry_type", length = 30, nullable = false)
|
||||
private String entryType;
|
||||
|
||||
@Column(name = "amount", precision = 20, scale = 2, nullable = false)
|
||||
private BigDecimal amount;
|
||||
|
||||
@Column(name = "cash_before", precision = 20, scale = 2, nullable = false)
|
||||
private BigDecimal cashBefore;
|
||||
|
||||
@Column(name = "cash_after", precision = 20, scale = 2, nullable = false)
|
||||
private BigDecimal cashAfter;
|
||||
|
||||
@Column(name = "ref_trade_id")
|
||||
private Long refTradeId;
|
||||
|
||||
@Column(name = "symbol", length = 50)
|
||||
private String symbol;
|
||||
|
||||
@Column(name = "created_at", nullable = false, updatable = false)
|
||||
private LocalDateTime createdAt;
|
||||
|
||||
@PrePersist
|
||||
protected void onCreate() {
|
||||
createdAt = LocalDateTime.now();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package com.goldenchart.entity;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import lombok.*;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Entity
|
||||
@Table(name = "gc_paper_daily_snapshot",
|
||||
uniqueConstraints = @UniqueConstraint(name = "uk_paper_snapshot_account_date",
|
||||
columnNames = {"account_id", "snapshot_date"}))
|
||||
@Getter @Setter @NoArgsConstructor @AllArgsConstructor @Builder
|
||||
public class GcPaperDailySnapshot {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@Column(name = "account_id", nullable = false)
|
||||
private Long accountId;
|
||||
|
||||
@Column(name = "snapshot_date", nullable = false)
|
||||
private LocalDate snapshotDate;
|
||||
|
||||
@Column(name = "cash_balance", precision = 20, scale = 2, nullable = false)
|
||||
private BigDecimal cashBalance;
|
||||
|
||||
@Column(name = "stock_eval_amount", precision = 20, scale = 2, nullable = false)
|
||||
private BigDecimal stockEvalAmount;
|
||||
|
||||
@Column(name = "total_asset", precision = 20, scale = 2, nullable = false)
|
||||
private BigDecimal totalAsset;
|
||||
|
||||
@Column(name = "daily_pnl", precision = 20, scale = 2, nullable = false)
|
||||
@Builder.Default
|
||||
private BigDecimal dailyPnl = BigDecimal.ZERO;
|
||||
|
||||
@Column(name = "daily_return_pct", precision = 10, scale = 4, nullable = false)
|
||||
@Builder.Default
|
||||
private BigDecimal dailyReturnPct = BigDecimal.ZERO;
|
||||
|
||||
@Column(name = "cumulative_return_pct", precision = 10, scale = 4, nullable = false)
|
||||
@Builder.Default
|
||||
private BigDecimal cumulativeReturnPct = BigDecimal.ZERO;
|
||||
|
||||
@Column(name = "created_at", nullable = false, updatable = false)
|
||||
private LocalDateTime createdAt;
|
||||
|
||||
@PrePersist
|
||||
protected void onCreate() {
|
||||
createdAt = LocalDateTime.now();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
package com.goldenchart.entity;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import lombok.*;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Entity
|
||||
@Table(name = "gc_paper_order")
|
||||
@Getter @Setter @NoArgsConstructor @AllArgsConstructor @Builder
|
||||
public class GcPaperOrder {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@Column(name = "account_id", nullable = false)
|
||||
private Long accountId;
|
||||
|
||||
@Column(name = "symbol", length = 50, nullable = false)
|
||||
private String symbol;
|
||||
|
||||
@Column(name = "side", length = 10, nullable = false)
|
||||
private String side;
|
||||
|
||||
@Column(name = "order_type", length = 20, nullable = false)
|
||||
@Builder.Default
|
||||
private String orderType = "LIMIT";
|
||||
|
||||
@Column(name = "limit_price", precision = 20, scale = 2)
|
||||
private BigDecimal limitPrice;
|
||||
|
||||
@Column(name = "quantity", precision = 30, scale = 12, nullable = false)
|
||||
private BigDecimal quantity;
|
||||
|
||||
@Column(name = "filled_quantity", precision = 30, scale = 12, nullable = false)
|
||||
@Builder.Default
|
||||
private BigDecimal filledQuantity = BigDecimal.ZERO;
|
||||
|
||||
@Column(name = "status", length = 20, nullable = false)
|
||||
@Builder.Default
|
||||
private String status = "PENDING";
|
||||
|
||||
@Column(name = "reserved_cash", precision = 20, scale = 2, nullable = false)
|
||||
@Builder.Default
|
||||
private BigDecimal reservedCash = BigDecimal.ZERO;
|
||||
|
||||
@Column(name = "reserved_qty", precision = 30, scale = 12, nullable = false)
|
||||
@Builder.Default
|
||||
private BigDecimal reservedQty = BigDecimal.ZERO;
|
||||
|
||||
@Column(name = "order_kind", length = 20, nullable = false)
|
||||
@Builder.Default
|
||||
private String orderKind = "limit";
|
||||
|
||||
@Column(name = "source", length = 20, nullable = false)
|
||||
@Builder.Default
|
||||
private String source = "MANUAL";
|
||||
|
||||
@Column(name = "strategy_id")
|
||||
private Long strategyId;
|
||||
|
||||
@Column(name = "created_at", nullable = false, updatable = false)
|
||||
private LocalDateTime createdAt;
|
||||
|
||||
@Column(name = "updated_at")
|
||||
private LocalDateTime updatedAt;
|
||||
|
||||
@Column(name = "filled_at")
|
||||
private LocalDateTime filledAt;
|
||||
|
||||
@PrePersist
|
||||
protected void onCreate() {
|
||||
createdAt = LocalDateTime.now();
|
||||
updatedAt = LocalDateTime.now();
|
||||
}
|
||||
|
||||
@PreUpdate
|
||||
protected void onUpdate() {
|
||||
updatedAt = LocalDateTime.now();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.goldenchart.entity;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import lombok.*;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Entity
|
||||
@Table(name = "gc_paper_reset_log")
|
||||
@Getter @Setter @NoArgsConstructor @AllArgsConstructor @Builder
|
||||
public class GcPaperResetLog {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@Column(name = "account_id", nullable = false)
|
||||
private Long accountId;
|
||||
|
||||
@Column(name = "reset_at", nullable = false)
|
||||
private LocalDateTime resetAt;
|
||||
|
||||
@Column(name = "initial_capital", precision = 20, scale = 2, nullable = false)
|
||||
private BigDecimal initialCapital;
|
||||
|
||||
@Column(name = "cash_before", precision = 20, scale = 2, nullable = false)
|
||||
private BigDecimal cashBefore;
|
||||
|
||||
@Column(name = "positions_json", columnDefinition = "JSON")
|
||||
private String positionsJson;
|
||||
|
||||
@Column(name = "reason", length = 200)
|
||||
private String reason;
|
||||
|
||||
@PrePersist
|
||||
protected void onCreate() {
|
||||
if (resetAt == null) resetAt = LocalDateTime.now();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
package com.goldenchart.entity;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import lombok.*;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Entity
|
||||
@Table(name = "gc_paper_symbol_allocation",
|
||||
uniqueConstraints = @UniqueConstraint(name = "uk_paper_alloc_account_symbol",
|
||||
columnNames = {"account_id", "symbol"}))
|
||||
@Getter @Setter @NoArgsConstructor @AllArgsConstructor @Builder
|
||||
public class GcPaperSymbolAllocation {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@Column(name = "account_id", nullable = false)
|
||||
private Long accountId;
|
||||
|
||||
@Column(name = "symbol", length = 50, nullable = false)
|
||||
private String symbol;
|
||||
|
||||
@Column(name = "korean_name", length = 100)
|
||||
private String koreanName;
|
||||
|
||||
@Column(name = "max_invest_krw", precision = 20, scale = 2, nullable = false)
|
||||
@Builder.Default
|
||||
private BigDecimal maxInvestKrw = BigDecimal.ZERO;
|
||||
|
||||
@Column(name = "budget_pct", precision = 8, scale = 4)
|
||||
private BigDecimal budgetPct;
|
||||
|
||||
@Column(name = "strategy_id")
|
||||
private Long strategyId;
|
||||
|
||||
@Column(name = "is_active", nullable = false)
|
||||
@Builder.Default
|
||||
private Boolean isActive = true;
|
||||
|
||||
@Column(name = "pinned", nullable = false)
|
||||
@Builder.Default
|
||||
private Boolean pinned = false;
|
||||
|
||||
@Column(name = "sort_order", nullable = false)
|
||||
@Builder.Default
|
||||
private Integer sortOrder = 0;
|
||||
|
||||
@Column(name = "created_at", nullable = false, updatable = false)
|
||||
private LocalDateTime createdAt;
|
||||
|
||||
@Column(name = "updated_at")
|
||||
private LocalDateTime updatedAt;
|
||||
|
||||
@PrePersist
|
||||
protected void onCreate() {
|
||||
createdAt = LocalDateTime.now();
|
||||
updatedAt = LocalDateTime.now();
|
||||
}
|
||||
|
||||
@PreUpdate
|
||||
protected void onUpdate() {
|
||||
updatedAt = LocalDateTime.now();
|
||||
}
|
||||
}
|
||||
@@ -54,6 +54,15 @@ public class GcPaperTrade {
|
||||
@Column(name = "cash_after", precision = 20, scale = 2, nullable = false)
|
||||
private BigDecimal cashAfter;
|
||||
|
||||
@Column(name = "realized_pnl_delta", precision = 20, scale = 2)
|
||||
private BigDecimal realizedPnlDelta;
|
||||
|
||||
@Column(name = "position_qty_after", precision = 30, scale = 12)
|
||||
private BigDecimal positionQtyAfter;
|
||||
|
||||
@Column(name = "note", length = 200)
|
||||
private String note;
|
||||
|
||||
@Column(name = "created_at", nullable = false, updatable = false)
|
||||
private LocalDateTime createdAt;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user