Created
May 28, 2020 22:02
-
-
Save buddies2705/a3e1aeed01f1ea63cb1bbec4b322d328 to your computer and use it in GitHub Desktop.
Strategy Optimiser
This file contains hidden or 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
| import itertools | |
| from pyalgotrade.optimizer import local | |
| from accumulator import Accumulator | |
| from pyalgotrade.bar import Frequency | |
| from pyalgotrade.barfeed import csvfeed | |
| import multiprocessing | |
| multiprocessing.set_start_method('spawn', True) | |
| def parameters_generator(): | |
| instrument = ["BTC"] | |
| offset = [f / 1000 for f in range(0, 1000)][:100] | |
| percentage = [f / 100 for f in range(0, 50)] | |
| return itertools.product(instrument, offset, percentage) | |
| def main(): | |
| feed = csvfeed.GenericBarFeed(frequency=Frequency.MINUTE) | |
| feed.addBarsFromCSV("BTC", "sampledata.csv") | |
| # Plot the strategy. | |
| local.run(Accumulator, feed, parameters_generator()) | |
| # The if __name__ == '__main__' part is necessary if running on Windows. | |
| if __name__ == '__main__': | |
| # Load the bar feed from the CSV files. | |
| main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment