# 세 개의 최적화 결과를 테이블 형식으로 정리해 출력한다
    from IPython.core.display import display, HTML
    pd.options.display.float_format = '{:.2%}'.format
    
    # 첫 번째 최적화 결과
    display( HTML( '<h2>Historical returns</h2>') )
    display( pd.DataFrame( { 'Weight': opt1[ 'weights' ] }, index=tickers).T )
    
    # 두 번째 최적화 결과
    display( HTML( '<h2>Implied returns</h2>' ) )
    display( pd.DataFrame( { 'Weight': opt2[ 'weights' ] }, index=tickers ).T )
    
    # 세 번째 최적화 결과
    display( HTML( '<h2>Implied returns with adjusted views</h2>' ) )
    display( pd.DataFrame( { 'Weight': opt3[ 'weights' ] }, index=tickers ).T )
    
    # plotAssets와 plotFrontier는 차트를 그리기 위한 함수다
    def plotAssets( tickers, R, C, color='black' ):
    
    # 포트폴리오 구성 자산 출력
        plt.scatter( [ C[i, i] ** .5 for i in range( n ) ], R, marker='x', color=color )
        for i in range( n ):
            plt.text( C[i, i] ** .5, R[i], ' %s' % tickers[i], verticalalignment='center', color=color )
    
    
    
    신간 소식 구독하기
    뉴스레터에 가입하시고 이메일로 신간 소식을 받아 보세요.