커뮤니티
포인트
쿠폰
내 강의실
국비 신청 내역
증명서
계정
로그아웃
학습 질문
개발 일지
나의 활동
답변 완료
간기/장기 이평 적용하기
undefined주차
북마크
홍*표
댓글
1
추천
0
조회수
5
조회수
5
답변 완료

* 겪고 있는 문제 상황을 최대한 자세하게 작성해주세요.

* 문제 해결을 위해 어떤 시도를 해보았는지 구체적으로 함께 알려주세요.


함수 작성하는 데,자꾸 IndentationError가 ..

강의 화면과 똑같이 코드를 작성 했는 데 오류가 나는 이유를 모르 겠네요..

살려주세요..ㅠㅠ



전체 화면 캡처보고 계신 화면 전체를 캡처해 주시면, 튜터님들이 빠르게 상황을 이해할 수 있어요.




def get_return_sl(code,short,long):

  df = fdr.DataReader('code','2018')

  df = df[['Close']].copy()

  df['ma1']=df['Close'].rolling(short).mean().shift(1)

  df['ma2']=df['Close'].rolling(long).mean().shift(1

  df['action'] = np.where(df['ma1']>df['ma2'],'buy','sell')

  cond1 = (df['action'] == 'buy') & (df['action'].shift(1) == 'sell')

  cond2 = (df['action'] == 'sell') & (df['action'].shift(1) == 'buy')

  df_buy = df[cond1].reset_index()

  df_buy.columns = ['날짜','종가(buy)','이평값1','이평값2','액션']

  df_sell = df[cond2].reset_index()

  df_sell.columns = ['날짜','종가(sell)','이평값1','이평값2','액션']

  df_result = pd.concat([df_buy,df_sell],axis=1)

  df_result['수익률'] = df_result['종가(sell)'] / df_result['종가(buy)']

  df_final = (df_result[['수익률']].cumprod().tail(1) - 1) * 100

  df_final['단기'] = short

  df_final['장기'] = long

  return df_final


File "<tokenize>", line 15

df_final = (df_result[['수익률']].cumprod().tail(1) - 1) * 100

^

IndentationError: unindent does not match any outer indentation level


취소
 공유
취소
댓글 0
댓글 알림
나의얼굴