New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Run sample #6
Merged
Merged
Run sample #6
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,42 @@ | ||
# from __future__ import (absolute_import, division, print_function, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
# unicode_literals) | ||
|
||
import datetime # For datetime objects | ||
import os.path # To manage paths | ||
import sys # To find out the script name (in argv[0]) | ||
|
||
# Import the backtrader platform | ||
import backtrader as bt | ||
|
||
if __name__ == '__main__': | ||
# Create a cerebro entity | ||
cerebro = bt.Cerebro() | ||
|
||
# Datas are in a subfolder of the samples. Need to find where the script is | ||
# because it could have been called from anywhere | ||
modpath = os.path.dirname(os.path.abspath(sys.argv[0])) | ||
datapath = os.path.join(modpath, '/opt/backtrader/datas/orcl-1995-2014.txt') | ||
|
||
# Create a Data Feed | ||
data = bt.feeds.YahooFinanceCSVData( | ||
dataname=datapath, | ||
# Do not pass values before this date | ||
fromdate=datetime.datetime(2000, 1, 1), | ||
# Do not pass values after this date | ||
todate=datetime.datetime(2000, 12, 31), | ||
reverse=False) | ||
|
||
# Add the Data Feed to Cerebro | ||
cerebro.adddata(data) | ||
|
||
# Set our desired cash start | ||
cerebro.broker.setcash(100000.0) | ||
|
||
# Print out the starting conditions | ||
print('Starting Portfolio Value: %.2f' % cerebro.broker.getvalue()) | ||
|
||
# Run over everything | ||
cerebro.run() | ||
|
||
# Print out the final result | ||
print('Final Portfolio Value: %.2f' % cerebro.broker.getvalue()) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🐳 backtrader を
/opt
へ cloneする