-
-
Save ryanlake10288/e1868c481f81d0627299 to your computer and use it in GitHub Desktop.
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 pykka | |
import pykka.gevent | |
class Worker(pykka.gevent.GeventActor): | |
def __init__(self, **kwargs): | |
super(Worker, self).__init__() | |
self.inputs = kwargs.get('inputs') | |
def on_receive(self, message): | |
if message.get('command') == 'backtest': | |
print self.__backtestLogic() | |
else: | |
None | |
def on_stop(self): | |
print "stopping %s"% self.inputs | |
def on_start(self): | |
print "starting %s"% self.inputs | |
def __backtestLogic (self): | |
return "winner %s"% self.inputs | |
actors =[] | |
for k in ['ibm','msft','orcl','spy','cvx','iwm','intl','xle','c']: | |
actors.append( Worker.start(inputs=k) ) | |
for a in actors: | |
a.tell({'command': 'backtest'}) | |
for a in actors: | |
a.stop() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment