量化交易学习笔记(二)-实例化Cerebro引擎-代理已经手握一笔资金准备进行交易
from __future__ import (absolute_import, division, print_function, unicode_literals) #引入backtrader import backtrader as bt #实例化Cerebro引擎(Cerebro西班牙语中大脑的意思) cerebro = bt.Cerebro() #代理已经手握一笔资金准备进行交易 cerebro.broker.setcash(100000.0) #打印输出结果 print('Starting Portfolio Value: %.2f' % cerebro.broker.getvalue()) #cerebro在数据上循环执行 cerebro.run() #打印输出结果 print('Final Portfolio Value: %.2f' % cerebro.broker.getvalue())
输出结果:
C:Python38python.exe F:/test/test/demo3.py Starting Portfolio Value: 100000.00 Final Portfolio Value: 100000.00 Process finished with exit code 0