24-4-3 갑자기 파이선 자동매매로 널뛰기를 하다.

in AVLE 코리아last month

머신러닝을 공부하다가 갑자기 파이선 자동매매로 널뛰기를 했다. 하루종일 파이선 자동매매와 관련된 프로그램을 따라했다.
이제 대충 파이선으로 자동매매하는 것을 따라할 정도가 되었다. 아직도 답답한 점은 있지만, 불과 달포전과 비교해보더라도 괄목할 만한 상태가 아닐 수 없다. 파이선의 매력이 여기에 있는 것 같다.

특히 인공지능의 도움은 절대적이다. 인공지능 공부하다가 챗지피티로 자동매매하는 프로그램을 작성하는 유튜브가 있어서 심심풀이로 공부하다가 자동매매 쪽으로 하루종일 매달려 있었다.
자동매매하기 위해 만든 코드는 아래와 같다.

매매전략은 간단하게 볼린져 밴드 상단 하단 돌파를 고려하여 매매하는 것으로 했다.
트레이딩 뷰에서 돌아가도록 설치하고 돌려보았는데 잘 돌아간다.
실제하려면 바이넌스나 업비트에서 api만 받아오면 될 것 같다.
이번은 연습이고 실제로 작동할 수 있도록 하기 위한 공부를 좀 더 해보고 실제 돌려 보려고 한다
역시 코딩도 직접 돈이 되는 부분을 공부하니 효율이 높고 집중도도 높아진다.

아래의 코드를 기반으로 좀 더 세밀하게 전략을 가다듬으면 좋은 자동매매 프로그램을 만들 수 있을 것 같다
너무 복잡하면 디버깅 소요가 많이 생길 것 같다.

//@version=5
strategy("Richkids Bollinger Bands Strategy", overlay=true, initial_capital=10000, default_qty_value=100, currency="USD")

// 사용자 인풋
startYear = input.int(2023, title="Start Year")
startMonth = input.int(1, title="Start Month")
startDay = input.int(1, title="Start Day")

start_date = timestamp(startYear, startMonth, startDay, 00, 00)

length = input.int(20, minval=1, title="볼린저 밴드 길이")
mult = input.float(2.0, title="볼린저 밴드 표준편차")
tp_percent = input.float(2.0, title="Take Profit (%)")
sl_percent = input.float(2.0, title="Stop Loss (%)")

// 볼린저 밴드 계산
basis = ta.sma(close, length)
dev = mult * ta.stdev(close, length)
upper = basis + dev
lower = basis - dev

// 조건 변수 선언
longCondition = ta.crossover(close, upper) and (time >= start_date)
shortCondition = ta.crossunder(close, lower) and (time >= start_date)

// 매수 및 매도 조건 체크
if longCondition
strategy.entry("Long", strategy.long)
strategy.exit("Close Long", "Long", limit=strategy.position_avg_price * (1 + tp_percent / 100), stop=strategy.position_avg_price * (1 - sl_percent / 100))

if shortCondition
strategy.entry("Short", strategy.short)
strategy.exit("Close Short", "Short", limit=strategy.position_avg_price * (1 - tp_percent / 100), stop=strategy.position_avg_price * (1 + sl_percent / 100))

// 볼린저 밴드 시각화
plot(upper, "Upper Band", color=color.red)
plot(basis, "Middle Band", color=color.blue)
plot(lower, "Lower Band", color=color.green)

// 매수 및 매도 신호 플로팅
plotshape(series=longCondition and close[1] < upper[1], title="Long Entry Signal", location=location.belowbar, color=color.green, style=shape.triangleup, size=size.small)
plotshape(series=shortCondition and close[1] > lower[1], title="Short Entry Signal", location=location.abovebar, color=color.red, style=shape.triangledown, size=size.small)

Sort:  

Thank you, friend!
I'm @steem.history, who is steem witness.
Thank you for witnessvoting for me.
image.png
please click it!
image.png
(Go to https://steemit.com/~witnesses and type fbslo at the bottom of the page)

The weight is reduced because of the lack of Voting Power. If you vote for me as a witness, you can get my little vote.

This post has been upvoted by @italygame witness curation trail


If you like our work and want to support us, please consider to approve our witness




CLICK HERE 👇

Come and visit Italy Community



어..어렵네요. 그래도 새로운 분야를 공부하시는 모습 멋지십니다.

하다보니 그냥 되더군요. ㅎㅎ

Coin Marketplace

STEEM 0.30
TRX 0.12
JST 0.032
BTC 59110.01
ETH 2990.61
USDT 1.00
SBD 3.72