BEAM 대역에 기초한 비트코인 달러 비용 평균

저자:차오장, 날짜: 2024-02-18 15:40:42
태그:

img

전반적인 설명

이 전략은 벤 코웬의 위험 수준 이론에 기초하고 있으며 BEAM 밴드 레벨을 사용하여 유사한 접근 방식을 구현하는 것을 목표로합니다. 상부 BEAM 레벨은 로그리듬을 취한 후 200주 이동 평균이며, 하위 레벨은 200주 이동 평균 자체입니다. 이것은 우리에게 0에서 1까지의 범위를 제공합니다. 가격은 0.5 레벨 밴드 아래에있을 때 구매 주문이 발급되며, 상위에있을 때 판매 주문이 발급됩니다.

전략 논리

이 전략은 주로 벤 코웬이 제안한 BEAM 밴드 이론에 의존한다. BTC의 가격 변화에 따라 가격은 10개의 다른 위험 수준을 나타내는 0과 1 사이의 10개의 영역으로 나눌 수 있다. 레벨 0은 200주 이동 평균에 가까운 가격으로 가장 낮은 위험을 나타낸다. 레벨 5은 중간 위험 가치 영역을 나타낸다. 레벨 10은 상단열에 접근하는 가격으로 가장 높은 위험을 나타낸다.

가격이 최저 수준으로 떨어지면 전략은 점진적으로 긴 포지션을 증가시킵니다. 구체적으로, 가격이 0 대와 0.5 대 사이의 경우 매월 정해진 날에 구매 주문이 발급됩니다. 밴드 수가 감소함에 따라 구매 금액이 점차 증가합니다. 예를 들어, 밴드 5에서는 구매 금액이 월간 DCA 총액의 20%입니다. 밴드 1에서는 구매 금액이 월간 DCA 총액의 100%로 증가합니다.

가격 상승이 최고 수준에 도달하면 전략은 점진적으로 위치를 줄일 것입니다. 구체적으로, 가격이 대역 0.5을 초과하면 판매 주문이 비례적으로 발행됩니다. 대역 수가 증가함에 따라 판매 포지션은 점진적으로 증가합니다. 예를 들어 대역 6에서는 6.67%가 판매됩니다. 대역 10에서는 모든 포지션이 판매됩니다.

이점 분석

이 BEAM 대역 DCA 전략의 가장 큰 장점은 가격이 가장 낮아지면 바닥 낚시로 BTC 거래의 변동성 특성을 완전히 활용하고 가격이 최고로 올랐을 때 수익을 취한다는 것입니다. 이 접근법은 구매 또는 판매 기회를 놓치지 않을 것입니다. 구체적인 장점은 다음과 같이 요약 할 수 있습니다.

  1. BEAM 이론을 사용하여 자산 과소평가 판단과 과학적으로 위험을 피합니다.
  2. 가장 좋은 구매 및 판매 기회를 잡기 위해 BTC 변동성 특성을 최대한 활용한다.
  3. 투자비용을 효과적으로 통제하고 장기적으로 안정적인 수익을 얻기 위해 비용 평균화 방법을 채택한다.
  4. 수동 개입 없이 자동으로 구매 및 판매 거래를 실행하여 운영 위험을 줄입니다.
  5. 사용자 정의 가능한 매개 변수는 시장 변화에 적응하기 위해 전략을 유연하게 조정할 수 있습니다.

요약하면, 이것은 변동적인 BTC 시장 조건에서 장기적으로 안정적인 수익을 창출할 수 있는 정교한 매개 변수 조정 전략입니다.

위험 분석

BEAM 대역 DCA 전략은 많은 장점을 가지고 있지만, 여전히 몇 가지 잠재적인 위험을 인식해야합니다. 주요 위험 포인트는 다음과 같이 요약 될 수 있습니다.

  1. BEAM 이론과 매개 변수 설정은 주관적인 판단에 의존하며, 잘못된 판단의 가능성이 있습니다.
  2. BTC 추세는 예측하기 어렵고 손실 위험이 있습니다.
  3. 자동 거래는 시스템 고장 및 매개 변수 해킹에 의해 부정적인 영향을 받을 수 있습니다.
  4. 과도한 변동은 손실을 증가시킬 수 있습니다.

위험을 줄이기 위해 다음의 조치를 취할 수 있습니다.

  1. BEAM 이론 판단의 정확성을 향상시키기 위해 매개 변수 설정을 최적화합니다.
  2. 단일 손실 금액을 줄이기 위해 포지션 크기를 적절히 줄이십시오.
  3. 자동화 거래의 운영 위험을 줄이기 위해 부재 및 오류 용인 능력을 높일 것
  4. 너무 큰 단 하나 손실을 피하기 위해 중지 손실 포인트를 설정합니다.

최적화

위의 위험을 감수하여 이 전략의 최적화는 다음에 초점을 맞출 수 있습니다.

  1. BEAM 이론 매개 변수를 최적화: 모델 정확성을 향상시키기 위해 로그 매개 변수, 백테스트 사이클 등을 조정합니다.
  2. 포지션 제어 최적화: 월간 DCA 금액, 단일 손실 금액을 제어하기 위해 구매/판매 비율을 조정;
  3. 자동화된 거래 보안을 높여서, 과잉 서버, 로컬 프로세싱 등을 설정하여 오류 용인성을 향상시킵니다.
  4. 스톱 로스 모듈을 추가합니다. 손실을 효과적으로 제어하기 위해 역사적 변동성을 기반으로 합리적인 스톱 로스 포인트를 설정합니다.

이러한 조치들을 통해 전략의 안정성과 안전성이 크게 향상될 수 있습니다.

결론

BEAM 밴드 DCA 평균 비용 전략은 매우 실용적인 양적 거래 전략이다. 거래 결정을 안내하기 위해 BEAM 이론을 성공적으로 활용하고, 구매 비용을 제어하기 위해 비용 평균 모델로 보완합니다. 동시에 손실 확대를 방지하기 위해 스톱 로스 포인트를 설정하여 위험 관리에주의를 기울입니다. 매개 변수 최적화 및 모듈 추가로,이 전략은 BTC 시장에서 장기적인 안정적인 수익을 얻기 위해 양적 거래에 중요한 도구가 될 수 있습니다. 양적 거래 실무자들에 의해 추가 연구와 응용이 필요합니다.


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

// © gjfsdrtytru - BEAM DCA Strategy {
// Based on Ben Cowen's risk level strategy, this aims to copy that method but with BEAM band levels.
// Upper BEAM level is derived from ln(price/200W MA)/2.5, while the 200W MA is the floor price. This is our 0-1 range. 
// Buy limit orders are set at the < 0.5 levels and sell orders are set at the > 0.5 level.
//@version=5
strategy(
  title                 = "BEAM DCA Strategy Monthly", 
  shorttitle            = "BEAM DCA M",
  overlay               = true,
  pyramiding            = 500,
  default_qty_type      = strategy.percent_of_equity,
  default_qty_value     = 0,
  initial_capital       = 0) //}

// Inputs { ————————————————————————————————————————————————————————————————————
T_ceiling   = input.string("Off", "Diminishing Returns", ["Off","Linear","Parabolic"], "Account for diminishing returns as time increases")
day         = input.int(1, "DCA Day of Month",1,28,1,"Select day of month for buy orders.")
DCAamount   = input.int(1000,"DCA Amount",400,tooltip="Enter the maximum amount you'd be willing to DCA for any given month.")
T_buy       = input(true,"Buy Orders","Toggle buy orders.")
T_sell      = input(true,"Sell Orders","Toggle sell orders.")

// Time period
testStartYear   = input.int(2018,   title="Backtest Start Year",    minval=2010,maxval=2100,group="Backtest Period")
testStartMonth  = input.int(1,      title="Backtest Start Month",   minval=1,   maxval=12,  group="Backtest Period")
testStartDay    = input.int(1,      title="Backtest Start Day",     minval=1,   maxval=31,  group="Backtest Period")
testPeriodLen   = input.int(9999,   title="Backtest Period (days)", minval=1,               group="Backtest Period",tooltip="Days until strategy ends") * 86400000 // convert days into UNIX time
testPeriodStart = timestamp(testStartYear,testStartMonth,testStartDay,0,0)
testPeriodStop  = testPeriodStart + testPeriodLen
testPeriod() => true
// ——————————————————————————————————————————————————————————————————————————— }
// Diminishing Returns { ———————————————————————————————————————————————————————
x = bar_index + 1
assetDivisor= 2.5
switch
    T_ceiling == "Linear"   => assetDivisor:= 3.50542 - 0.000277696 * x
    T_ceiling == "Parabolic"=> assetDivisor:= -0.0000001058992338 * math.pow(x,2) + 0.000120729 * x + 3.1982
// ——————————————————————————————————————————————————————————————————————————— }
// Risk Levels { ———————————————————————————————————————————————————————————————
cycleLen = 1400
getMaLen() =>
    if bar_index < cycleLen
        bar_index + 1
    else
        cycleLen

// Define Risk Bands
price       = close
riskLow     = ta.sma(price,getMaLen())
risk1       = riskLow * math.exp((assetDivisor)*0.1)
risk2       = riskLow * math.exp((assetDivisor)*0.2)
risk3       = riskLow * math.exp((assetDivisor)*0.3)
risk4       = riskLow * math.exp((assetDivisor)*0.4)
risk5       = riskLow * math.exp((assetDivisor)*0.5)
risk6       = riskLow * math.exp((assetDivisor)*0.6)
risk7       = riskLow * math.exp((assetDivisor)*0.7)
risk8       = riskLow * math.exp((assetDivisor)*0.8)
risk9       = riskLow * math.exp((assetDivisor)*0.9)
riskHigh    = riskLow * math.exp((assetDivisor))

// Plot Risk Bands
p_low       = plot(riskLow,   "Beam Risk 0.0",color.new(#0042F0,50),3,editable=false)
p_band1     = plot(risk1,     "Beam Risk 0.1",color.new(#0090F5,20),1,editable=false)
p_band2     = plot(risk2,     "Beam Risk 0.2",color.new(#00C6DB,20),1,editable=false)
p_band3     = plot(risk3,     "Beam Risk 0.3",color.new(#00F5BD,20),1,editable=false)
p_band4     = plot(risk4,     "Beam Risk 0.4",color.new(#00F069,20),1,editable=false)
p_band5     = plot(risk5,     "Beam Risk 0.5",color.new(#00DB08,50),3,editable=false)
p_band6     = plot(risk6,     "Beam Risk 0.6",color.new(#E8D20C,20),1,editable=false)
p_band7     = plot(risk7,     "Beam Risk 0.7",color.new(#F2B40C,20),1,editable=false)
p_band8     = plot(risk8,     "Beam Risk 0.8",color.new(#DC7A00,20),1,editable=false)
p_band9     = plot(risk9,     "Beam Risk 0.9",color.new(#F2520C,20),1,editable=false)
p_band10    = plot(riskHigh,  "Beam Risk 1.0",color.new(#F01102,50),3,editable=false)
// ——————————————————————————————————————————————————————————————————————————— }
// Order Execution { ———————————————————————————————————————————————————————————
band5   = price<risk5 and price>risk4
band4   = price<risk4 and price>risk3
band3   = price<risk3 and price>risk2
band2   = price<risk2 and price>risk1
band1   = price<risk1

// DCA buy order weights
y       = DCAamount / 5
switch
    band5 => y:= y * 1
    band4 => y:= y * 2
    band3 => y:= y * 3
    band2 => y:= y * 4
    band1 => y:= y * 5

// Contracts per order
contracts =(y/price)

if testPeriod()
// Buy orders
    if T_buy == true
        if dayofmonth == day
            strategy.entry("Risk Band 5",strategy.long,qty=contracts,when=band5)
            strategy.entry("Risk Band 4",strategy.long,qty=contracts,when=band4)
            strategy.entry("Risk Band 3",strategy.long,qty=contracts,when=band3)
            strategy.entry("Risk Band 2",strategy.long,qty=contracts,when=band2)
            strategy.entry("Risk Band 1",strategy.long,qty=contracts,when=band1)
// Sell orders 
    if T_sell == true
        if strategy.opentrades > 5
            strategy.exit("Risk Band 6",qty_percent=6.67,limit=risk6) 
            strategy.exit("Risk Band 7",qty_percent=14.28,limit=risk7)
            strategy.exit("Risk Band 8",qty_percent=25.00,limit=risk8)
            strategy.exit("Risk Band 9",qty_percent=44.44,limit=risk9)
            strategy.exit("Risk Band 10",qty_percent=100,limit=riskHigh)
// ——————————————————————————————————————————————————————————————————————————— }
// Info { ——————————————————————————————————————————————————————————————————————

// Line plot of avg. entry price
plot(strategy.position_size > 0 ? strategy.position_avg_price : na,"Average Entry",color.red,trackprice=true,editable=false)

// Unrealised PNL
uPNL = price/strategy.position_avg_price

// Realised PNL
realPNL = 0.
for i = 0 to strategy.closedtrades-1
    realPNL += strategy.closedtrades.profit(i)

// Size of open position in ($)
openPosSize = 0.
for i = 0 to strategy.opentrades-1
    openPosSize += strategy.opentrades.size(i) * strategy.position_avg_price

// Size of closed position in ($)
closePosSize = 0.
if strategy.closedtrades > 0
    for i = 0 to strategy.closedtrades-1
        closePosSize += strategy.closedtrades.size(i) * strategy.closedtrades.entry_price(i)

invested    = openPosSize+closePosSize                              // Total capital ($) put into strategy
equity      = openPosSize+closePosSize+strategy.openprofit+realPNL  // Total current equity ($) in strategy (counting realised PNL)
ROI         = (equity-invested) / invested * 100                    // ROI of strategy (compare capital invested to excess return)

// // Info Table
// var table table1 = table.new(position.bottom_right,2,9,color.black,color.gray,1,color.gray,2)

// table.cell(table1,0,0,"Capital Invested",   text_color=color.white,text_halign=text.align_right)
// table.cell(table1,0,1,"Open Position",      text_color=color.white,text_halign=text.align_right)
// table.cell(table1,0,2,"Average Entry",      text_color=color.white,text_halign=text.align_right)
// table.cell(table1,0,3,"Last Price",         text_color=color.white,text_halign=text.align_right)
// table.cell(table1,0,4,"Open PNL (%)",       text_color=color.white,text_halign=text.align_right)
// table.cell(table1,0,5,"Open PNL ($)",       text_color=color.white,text_halign=text.align_right)
// table.cell(table1,0,6,"Realised PNL ($)",   text_color=color.white,text_halign=text.align_right)
// table.cell(table1,0,7,"Total Equity",       text_color=color.white,text_halign=text.align_right)
// table.cell(table1,0,8,"Strategy ROI",       text_color=color.white,text_halign=text.align_right)

// table.cell(table1,1,0,"$" + str.tostring(invested,                      "#,###.00"),      text_halign=text.align_right,text_color = color.white)
// table.cell(table1,1,1,"$" + str.tostring(openPosSize,                   "#,###.00"),      text_halign=text.align_right,text_color = color.white)
// table.cell(table1,1,2,"$" + str.tostring(strategy.position_avg_price,   "#,###.00"),      text_halign=text.align_right,text_color = color.white)
// table.cell(table1,1,3,"$" + str.tostring(price,                         "#,###.00"),      text_halign=text.align_right,text_color = color.white)
// table.cell(table1,1,4,      str.tostring((uPNL-1)*100,                  "#,###.00") + "%",text_halign=text.align_right,text_color = uPNL > 1 ? color.lime : color.red)
// table.cell(table1,1,5,"$" + str.tostring(strategy.openprofit,           "#,###.00"),      text_halign=text.align_right,text_color = uPNL > 1 ? color.lime : color.red)
// table.cell(table1,1,6,"$" + str.tostring(realPNL,                       "#,###.00"),      text_halign=text.align_right,text_color = color.white)
// table.cell(table1,1,7,"$" + str.tostring(equity,                        "#,###.00"),      text_halign=text.align_right,text_color = color.white)
// table.cell(table1,1,8,      str.tostring(ROI,                           "#,###.00") + "%",text_halign=text.align_right,text_color = ROI > 1 ? color.lime : color.red)
// // ——————————————————————————————————————————————————————————————————————————— }

더 많은