@@ -7,55 +7,38 @@ public class OrderPricePolicy {
77 /**
88 * 레벨에 따라 매수/매도 가격을 계산합니다.
99 * @param level 주문 강도 (1~5)
10- * @param platformVWAP 플랫폼 기준 평균 체결 가격
10+ // * @param platformVWAP 플랫폼 기준 평균 체결 가격
1111 * @param unitPrice 호가 단위
12- * @param trendLineRate 플랫폼과 API VWAP의 편차율
12+ // * @param trendLineRate 플랫폼과 API VWAP의 편차율
1313 * @return PricePair (매도/매수 가격)
1414 */
15- public OrderPrice calculatePrice (int level ,
16- double platformVWAP ,
17- double unitPrice ,
18- double trendLineRate ) {
19- double priceOffset = unitPrice * level ;
20- double sellPrice , buyPrice ;
21- double randomOffset = Math .abs (getRandomOffset (platformVWAP ,getDynamicMaxRate (trendLineRate )));
22- double basePrice = normalizeToUnit (platformVWAP , unitPrice ); //기준 가격 (호가 단위 정규화)
15+ public OrderPrice calculatePrice (int level , double apiVWAP , double platformVWAP , double unitPrice ) {
16+ double basePrice = normalizeToUnit (apiVWAP , unitPrice );
17+ double targetPrice = normalizeToUnit (platformVWAP , unitPrice );
2318
19+ // 🔥 점진적 접근: API VWAP에서 Platform VWAP로 20% 씩 이동
20+ double convergenceRate = 0.2 ; // 천천히 접근
21+ double adjustedBase = basePrice + (targetPrice - basePrice ) * convergenceRate ;
2422
25- if (level == 1 ){ //1level일 경우 주문이 겹치도록 설정
26- //체결을 위해 매수가 올리고, 매도가 내리는 계산 적용
27- sellPrice = normalizeToUnit (basePrice - randomOffset ,unitPrice );
28- buyPrice = normalizeToUnit (basePrice + randomOffset ,unitPrice );
29- }
30- //2~3 단계 : orderbook 단위 주문
31- else {
32- randomOffset = getRandomOffset (platformVWAP ,0.001 );
33- //체결 확률 증가용 코드
34- sellPrice = normalizeToUnit (platformVWAP + priceOffset - randomOffset ,unitPrice );
35- buyPrice = normalizeToUnit (platformVWAP - priceOffset + randomOffset ,unitPrice );
36- //안정적인 스프레드 유지
37- // sellPrice = normalizeToUnit(platformVWAP + priceOffset);
38- // buyPrice = normalizeToUnit(platformVWAP - priceOffset);
23+ double priceOffset = unitPrice * level ;
24+
25+ if (level == 1 ) {
26+ // 1레벨: 조정된 기준가 근처 체결 유도
27+ return new OrderPrice (adjustedBase + priceOffset /2 , adjustedBase - priceOffset /2 );
28+ } else {
29+ // 2~5레벨: 조정된 기준가 기준 스프레드
30+ return new OrderPrice (adjustedBase + priceOffset , adjustedBase - priceOffset );
3931 }
40- return new OrderPrice (sellPrice , buyPrice );
4132 }
4233
43- private double getRandomOffset (double basePrice , double maxRate ){
44- //시장가에 해당하는 호가는 거래 체결 강하게 하기 위함
45- double percent = (Math .random () * 2 -1 )*maxRate ;
34+ private double getRandomOffset (double basePrice , double maxRate ) {
35+ double percent = (Math .random () * 2 - 1 ) * maxRate ;
4636 return basePrice * percent ;
4737 }
4838
49- private double getDynamicMaxRate (double trendLineRate ) {
50- // 편차가 벌어지면 벌어질수록 보정폭 확대
51- // 5% = 2.51의 가중치
52- // 11% = 5.51의 가중치
53- return 0.01 + Math .abs (trendLineRate ) * 0.5 ;
54- }
55-
56- private int normalizeToUnit (double price , double unitPrice ){ //호가단위로 변환
57- return (int ) ((double )(Math .round (price / unitPrice )) * unitPrice );
39+ private double normalizeToUnit (double price , double unitPrice ) {
40+ return Math .round (price / unitPrice ) * unitPrice ;
5841 }
5942
60- public record OrderPrice (double sell , double buy ){}
61- }
43+ public record OrderPrice (double sell , double buy ) {}
44+ }
0 commit comments