Skip to content
This repository has been archived by the owner on Aug 27, 2024. It is now read-only.

Commit

Permalink
implement basics
Browse files Browse the repository at this point in the history
install backtrader
  • Loading branch information
CelestialCrafter committed Nov 17, 2023
1 parent 8f65d5b commit 260e6cb
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ dependencies:
- zlib=1.2.13=h5eee18b_0
- zstd=1.5.5=hc292b87_0
- pip:
- backtrader==1.9.78.123
- blinker==1.6.3
- certifi==2023.7.22
- dnspython==2.4.2
Expand Down
18 changes: 18 additions & 0 deletions test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
from __future__ import (absolute_import, division, print_function, unicode_literals)
from datetime import datetime

import backtrader as bt

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

data = bt.feeds.YahooFinanceData(dataname='MSFT', fromdate=datetime(2011, 1, 1), todate=datetime(2012, 12, 31))

cerebro.adddata(data)
cerebro.broker.setcash(1000)

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

cerebro.run()

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

0 comments on commit 260e6cb

Please sign in to comment.