고정 네트워크 거래 전략

저자:차오장, 날짜: 2023-11-16 17:09:45
태그:

img

전반적인 설명

이 전략은 각 그리드 계층 사이의 시작 가격과 비율을 설정하여 고정 그리드 거래 접근 방식을 채택합니다. 그 다음 낮은 구매-높은 판매 그리드 거래 전략을 구현하기 위해 비율을 기반으로 10 고정 구매 및 판매 가격을 계산합니다.

전략 논리

이 전략은 먼저 시작 가격과 네트워크 거리의 비율을 설정합니다.그 다음 시작 가격과 비율을 기반으로 10 계층의 구매 및 판매 가격을 계산합니다.

구매 가격 공식:

b1=sprice-(sprice*p1)

b2=sprice-(sprice*p2)

b3=sprice-(sprice*p3)

여기 p1~p10은 격자 비율을 기준으로 층별로 계산되는 비율입니다.

판매 가격 공식:

s1=b1+(sprice*p1)

s2=b2+(sprice*p1)

s3=b3+(sprice*p1)

매수 조건은 닫기 가격이 매수 가격보다 낮을 때 실행됩니다.

if (close

strategy.entry ((b1, strategy.long, when=(close

마찬가지로, 판매 조건은 닫기 가격이 판매 가격보다 높을 때 작동합니다.

if (close>s1)

strategy.exit("b1", when=(close>s1))

이것은 낮은 구매-높은 판매 전력 거래 전략을 구현합니다.

장점

고정 네트워크 전략은 다음과 같은 장점을 가지고 있습니다.

  1. 시장의 시기를 맞추지 않고 자동으로 낮은 구매, 높은 판매를 달성하고, 거래 어려움을 줄입니다.

  2. 적당한 격자 거리를 설정하면 위험을 효과적으로 통제하고 추격을 피할 수 있습니다.

  3. 시장이 상승하든 하든 수익성이 있습니다.

  4. 다양한 시장 조건에 대한 네트워크 파라미어 조정에 대한 유연성

  5. 격자층을 추가함으로써 위치 크기를 확장합니다.

  6. 스톱 로스를 포함하면 극한 시장에서 큰 손실을 피할 수 있습니다.

위험성

이 전략은 또한 몇 가지 위험을 안고 있습니다.

  1. 거래 수수료는 범위 시장에서 수익을 소비합니다.

  2. 부적절한 시작 가격과 그리드 설정은 손실로 이어집니다.

  3. 가격 격차는 극단적인 상황에서는 손실을 초래할 수 있습니다.

  4. 기계 거래는 주문 삽입 위험이 있습니다.

  5. 집중적인 사건은 손실을 증폭시킬 수 있습니다.

해결책:

  1. 수익 > 수수료를 보장하기 위해 그리드 매개 변수를 최적화합니다.

  2. 최적의 시작 가격과 그리드 거리를 찾기 위한 백테스트

  3. 스톱 로스를 추가해서 리스크를 제어합니다.

  4. 오더 가격을 느려서 삽입을 피하세요.

  5. 최대 손실을 제한하도록 위험 통제를 설정합니다.

개선

이 전략은 다음과 같은 방법으로 강화될 수 있습니다.

  1. 변동성에 따라 그리드 거리를 동적으로 조정합니다.

  2. 동적으로 시작값을 설정하기 위해 가격 범위를 계산합니다.

  3. 가격 예측과 그리드를 조정하기 위해 ML 모델을 추가합니다.

  4. 역사적인 스톱 로스 포인트를 기반으로 스톱 로스를 최적화합니다.

  5. 이윤 수준에 따라 포지션 크기를 포함합니다.

  6. 자본 활용을 극대화하기 위해 포지션 관리를 최적화하십시오.

  7. TWAP를 사용하여 실행을 개선하여 영향 비용을 줄이십시오.

결론

이 전략은 시작 가격과 그리드 비율을 기반으로 구매 및 판매 가격을 설정하여 자동 낮은 구매-높은 판매를 달성하여 고정 그리드 거래를 구현합니다. 이윤 잠금 및 손실 통제를 위해 매개 변수, 동적 조정 및 스톱 손실을 최적화하여 위험을 관리하는 것이 중요합니다. 고급 ML 및 돈 관리 기술을 통합하면 전략 수익성과 승률을 더욱 향상시킬 수 있습니다.


/*backtest
start: 2022-11-09 00:00:00
end: 2023-11-15 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Lionkind

//@version=5
strategy("Grid HW", overlay = true, margin_long = 1, margin_short = 1)

// Fix 35k price as starting point and 1% as a distance

sprice=input(40500,"Starting price")
gridpercent=input(1,"Percent")

// calculate the % of the 10 layers 

p1=((gridpercent*1)/100)
p2=((gridpercent*2)/100)
p3=((gridpercent*3)/100)
p4=((gridpercent*4)/100)
p5=((gridpercent*5)/100)
p6=((gridpercent*6)/100)
p7=((gridpercent*7)/100)
p8=((gridpercent*8)/100)
p9=((gridpercent*9)/100)
p10=((gridpercent*10)/100)

//set buy prices 

b1=sprice-(sprice*p1)
b2=sprice-(sprice*p2)
b3=sprice-(sprice*p3)
b4=sprice-(sprice*p4)
b5=sprice-(sprice*p5)
b6=sprice-(sprice*p6)
b7=sprice-(sprice*p7)
b8=sprice-(sprice*p8)
b9=sprice-(sprice*p9)
b10=sprice-(sprice*p10)

//set sell prices

s1=b1+(sprice*p1)
s2=b2+(sprice*p1)
s3=b3+(sprice*p1)
s4=b4+(sprice*p1)
s5=b5+(sprice*p1)
s6=b6+(sprice*p1)
s7=b7+(sprice*p1)
s8=b8+(sprice*p1)
s9=b9+(sprice*p1)
s10=b10+(sprice*p1)

//Long conditions

lc1=close<b1
lc2=close<b2
lc3=close<b3
lc4=close<b4
lc5=close<b5
lc6=close<b6
lc7=close<b7
lc8=close<b8
lc9=close<b9
lc10=close<b10

//exit conditions
ec1=close>s1
ec2=close>s2
ec3=close>s3
ec4=close>s4
ec5=close>s5
ec6=close>s6
ec7=close>s7
ec8=close>s8
ec9=close>s9
ec10=close>s10

//long orders
if (lc1)
    strategy.entry("b1", strategy.long, when=(lc1))
    
if (lc2)
    strategy.entry("b2", strategy.long, when=(lc2))
    
if (lc3)
    strategy.entry("b3", strategy.long, when=(lc3))    
if (lc4)
    strategy.entry("b4", strategy.long, when=(lc4))    
if (lc5)
    strategy.entry("b5", strategy.long, when=(lc5))
if (lc6)
    strategy.entry("b6", strategy.long, when=(lc6))
if (lc7)
    strategy.entry("b7", strategy.long, when=(lc7))    
if (lc8)
    strategy.entry("b8", strategy.long, when=(lc8))    
if (lc9)
    strategy.entry("b9", strategy.long, when=(lc9))    
if (lc10)
    strategy.entry("b10", strategy.long, when=(lc10))
    
//exit orders   
if (ec1)
    strategy.exit("b1", when=(ec1), limit=1)
if (ec2)
    strategy.exit("b2", when=(ec2), limit=1)
if (ec3)
    strategy.exit("b3", when=(ec3), limit=1)
if (ec4)
    strategy.exit("b4", when=(ec4), limit=1)
if (ec5)
    strategy.exit("b5", when=(ec5), limit=1)
if (ec6)
    strategy.exit("b6", when=(ec6), limit=1)
if (ec7)
    strategy.exit("b7", when=(ec7), limit=1)
if (ec8)
    strategy.exit("b8", when=(ec8), limit=1)
if (ec9)
    strategy.exit("b9", when=(ec9), limit=1)
if (ec10)
    strategy.exit("b10", when=(ec10), limit=1)
    

plot(b1,color=color.green)
plot(s1, color=color.red)
plot(b2, color=color.purple)

더 많은