금융공학/BackTrader 공부

BackTrader 0 : Introduce

냥냥펀치데스 2021. 12. 19. 15:23
728x90

Introduce

더보기

 

바이사이드 금융공학에서 퀀트 트레이딩을 하려면 필요한것중에 전략 테스트 와 실제 거래 알고리즘 입니다.

이때 여러가지 패키지를 사용할수 있는데 <예시> 그중에 가장 stars 가 많고, 예시도 많고, 오래되어 증명된 패키지인

BackTrader 을 사용하고 이 패키지를 공부하려고 합니다.

BackTrader 이전에 Bactesting, zipline,Octobot 등을 사용하였지만 워낙 예시가 없고 기능이 몇개 없어서 Backtrader 로 옮겨봤고 BacTrader 의 확장성에 충격을 먹고 이 가능성을 탐구하려고 합니다.

 

Beginning : Up and Running

더보기

Getting up and running involves at least 3 Lines objects:

  • A Data feed
  • A Strategy (actually a class derived from Strategy)
  • A Cerebro (brain in Spanish)

시작하려면 최소한 Data, Strategy, Cerebro 가 필요합니다. 

Quick Start

더보기
from __future__ import (absolute_import, division, print_function,
                        unicode_literals)

import backtrader as bt

if __name__ == '__main__':
    cerebro = bt.Cerebro()

    print('Starting Portfolio Value: %.2f' % cerebro.broker.getvalue())

    cerebro.run()

    print('Final Portfolio Value: %.2f' % cerebro.broker.getvalue())

After the execution the output is:

  • For more Detail : <Click>

Architecture

더보기
BackTrader Architecture
Bactrader module

Reference :

더보기