Skip to content

Instantly share code, notes, and snippets.

@buddies2705
Created May 28, 2020 22:02
Show Gist options
  • Select an option

  • Save buddies2705/a3e1aeed01f1ea63cb1bbec4b322d328 to your computer and use it in GitHub Desktop.

Select an option

Save buddies2705/a3e1aeed01f1ea63cb1bbec4b322d328 to your computer and use it in GitHub Desktop.
Strategy Optimiser
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