마진콜을 방지하기 위한 고레버리지 포지션 관리 전략


생성 날짜: 2023-12-26 16:21:58 마지막으로 수정됨: 2023-12-26 16:21:58
복사: 1 클릭수: 693
avatar of ChaoZhang ChaoZhang
1
집중하다
1621
수행원

마진콜을 방지하기 위한 고레버리지 포지션 관리 전략

개요

이 전략은 높은 레버리지와 추가 보증금 조건을 설정하여 시장의 큰 변동이 있을 때 적시에 포지션을 청산하여 추가 보증금을 방지하는 위험을 관리합니다.

전략 원칙

  1. 높은 레버를 설정하여 레버 비율이 4배
  2. 추가적인 보증금을 설정합니다. 예를 들어, $25,000
  3. 이자율이 추가 보증금보다 낮을 때, 전략은 포지션을 중지합니다.
  4. 이자율이 계속 하락하여 추가 보증금 신호가 발생하면 모든 포지션을 청산하는 전략

위와 같은 설정으로, 시장의 큰 변동으로 권리 이익이 급격히 떨어질 때, 적시에 손실을 막고, 추가 보증금의 위험을 방지할 수 있다.

우위 분석

  1. 개인 부담에 따라 유연하게 레버리지를 설정하여 단편적 손실 위험을 제어할 수 있습니다.
  2. 추가 보증금 제도는 계좌 부진을 방지할 수 있습니다.
  3. 높은 레버리지를 사용하는 경우, 적시에 손실을 막고 최대한 위험을 피합니다.

위험 분석

  1. 높은 레버리지는 수익을 증가시키지만 동시에 위험을 증가시킵니다.
  2. 추가 보증금 라인을 합리적으로 설정해야 합니다.
  3. 손해배상 전략에 대한 최적화

리버리지 비율을 적절하게 조정하여 추가 보증금 라인을 중지 라인과 일치시키는 방법, 중지 전략을 최적화하는 방법 등으로 위험을 줄일 수 있습니다.

최적화 방향

  1. 트렌드 지표와 함께 역동성을 피하십시오.
  2. 손해 차단 방법을 최적화하여 손해 차단을 방지합니다.
  3. 특정 기간 동안 창고를 짓지 않도록 거래하지 않는 구역을 설정합니다.
  4. 기계 학습 알고리즘과 결합하여 동적으로 변수를 조정합니다.

요약하다

이 전략은 높은 레버리지와 추가 보증금 설정을 통해 위험 관리를 구현하여 계정 포항을 방지할 수 있다. 그러나 높은 레버리지도 위험을 증대시키고, 추세 판단, 손해 차단 최적화, 거래 시간 제어 등의 방법으로 위험을 더 줄여야 한다. 또한 기계 학습과 같은 더 복잡한 기술을 사용하여 매개 변수를 동적으로 최적화하여 수익과 위험 사이의 최적의 균형을 찾을 수 있다.

전략 소스 코드
/*backtest
start: 2023-11-25 00:00:00
end: 2023-12-25 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/
//@version=4
//@author=Daveatt

// Breakout on 2H high/low break Strategy

SystemName = "Leverage Strategy"
TradeId = "🙏"

InitCapital             = 100000
InitPosition            = 1
UseMarginCall           = input(true, title="Use Margin Call?")
MarginValue             = input(25000, title="Margin Value", type=input.float)
// use 1 for no leverage
// use 0.1 for be underleveraged and bet 1/10th of a pip value
// use any value > 1 for full-degen mode
UseLeverage             = input(true, title="Use Leverage")
LeverageValue           = input(4, title="Leverage mult (1 for no leverage)", minval=0.1, type=input.float)
// Risk Management
UseRiskManagement       = input(true, title="Use Risk Management?")
// ticks = 1/10th of a pip value
StopLoss                = input(5, title="Stop Loss in ticks value", type=input.float)
TakeProfit              = input(500, title="Take Profit in ticks value", type=input.float)

InitCommission = 0.075
InitPyramidMax = 1
CalcOnorderFills = false
CalcOnTick = true
DefaultQtyType = strategy.cash
DefaultQtyValue = strategy.cash
Currency = currency.USD
Precision = 2
Overlay=false
MaxBarsBack=3000

strategy
 (
 title=SystemName, 
 shorttitle=SystemName, 
 overlay=Overlay 
 )

//////////////////////////// UTILITIES ///////////////////////////

f_print(_txt, _condition) =>

    var _lbl = label(na)
    label.delete(_lbl)

    if _condition
        // saving the candle where we got rekt :(
        _index = barssince(_condition)
        _lbl := label.new(bar_index - _index, highest(100), _txt, xloc.bar_index, yloc.price, size = size.normal, style=label.style_labeldown)

//////////////////////////// STRATEGY LOGIC ///////////////////////////

// Date filterigng
_Date       = input(true, title="[LABEL] DATE")
FromYear = input(2019, "From Year", minval=1900),   FromMonth = input(12, "From Month", minval=1, maxval=12),    FromDay = input(1, "From Day", minval=1, maxval=31)
ToYear = input(2019, "To Year", minval=1900),       ToMonth = input(12, "To Month", minval=1, maxval=12),        ToDay = input(9, "To Day", minval=1, maxval=31)
FromDate = timestamp(FromYear, FromMonth, FromDay, 00, 00)     
ToDate = timestamp(ToYear, ToMonth, ToDay, 23, 59)
TradeDateIsAllowed = true

// non-repainting security version
four_hours_H     = security(syminfo.tickerid, '240', high[1], lookahead=true)
four_hours_L     = security(syminfo.tickerid, '240', low[1], lookahead=true)
buy_trigger     = crossover(close, four_hours_H)
sell_trigger    = crossunder(close, four_hours_L)

// trend states
since_buy  = barssince(buy_trigger)
since_sell = barssince(sell_trigger)
buy_trend  = since_sell > since_buy
sell_trend = since_sell < since_buy 

change_trend = (buy_trend and sell_trend[1]) or (sell_trend and buy_trend[1])

// plot(four_hours_H, title="4H High",  linewidth=2, color=#3c91c2, style=plot.style_linebr, transp=0,
//  show_last=1, trackprice=true)
// plot(four_hours_L, title="4H Low",  linewidth=2, color=#3c91c2, style=plot.style_linebr, transp=0,
//  show_last=1, trackprice=true)

plot(strategy.equity, color=color.blue, linewidth=3, title="Strategy Equity")

// get the entry price
entry_price = valuewhen(buy_trigger or sell_trigger, close, 0)

// SL and TP

SL_price    = buy_trend ? entry_price - StopLoss    : entry_price + StopLoss
is_SL_hit   = buy_trend ? crossunder(low, SL_price) : crossover(high, SL_price) 

TP_price    = buy_trend ? entry_price + TakeProfit  : entry_price - TakeProfit
is_TP_hit   = buy_trend ? crossover(high, TP_price) : crossunder(low, TP_price)

//  Account Margin Management:
f_account_margin_call_cross(_amount)=>
    _return = crossunder(strategy.equity, _amount)

f_account_margin_call(_amount)=>
    _return = strategy.equity <= _amount

is_margin_call_cross    = f_account_margin_call_cross(MarginValue)
is_margin_call          = f_account_margin_call(MarginValue)

plot(strategy.equity, title='strategy.equity', transp=0, linewidth=4)
//plot(barssince(is_margin_call ), title='barssince(is_margin_call)', transp=100)

can_trade = iff(UseMarginCall, not is_margin_call, true)
trade_size  = InitPosition * (not UseLeverage ? 1 : LeverageValue)

// We can take the trade if not liquidated/margined called/rekt

buy_final   = can_trade and buy_trigger and TradeDateIsAllowed
sell_final  = can_trade and sell_trigger and TradeDateIsAllowed

close_long  = buy_trend  and 
 (UseRiskManagement and (is_SL_hit or is_TP_hit)) or sell_trigger

close_short = sell_trend and 
 (UseRiskManagement and (is_SL_hit or is_TP_hit)) or buy_trigger

strategy.entry(TradeId + ' B', long=true, qty=trade_size, when=buy_final)
strategy.entry(TradeId + ' S', long=false, qty=trade_size, when=sell_final)
strategy.close(TradeId + ' B', when=close_long)
strategy.close(TradeId + ' S', when=close_short)

// FULL DEGEN MODE ACTIVATED
// Margin called - Broker closing your account
strategy.close_all(when=is_margin_call)

if UseMarginCall and is_margin_call_cross
    f_print("☠️REKT☠️", is_margin_call_cross)