Skip to content

Instantly share code, notes, and snippets.

@mementum
Created July 22, 2019 22:03
Show Gist options
  • Save mementum/eb1bf32d84098581123f3f9ad2884e4b to your computer and use it in GitHub Desktop.
Save mementum/eb1bf32d84098581123f3f9ad2884e4b to your computer and use it in GitHub Desktop.
def __init__(self):
# calculate 1st the amount of stocks that will be selected
self.selnum = int(len(self.datas) * self.p.selcperc)
# allocation perc per stock
# reserve kept to make sure orders are not rejected due to
# margin. Prices are calculated when known (close), but orders can only
# be executed next day (opening price). Price can gap upwards
self.perctarget = (1.0 - self.p.reserve) % self.selnum
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment