Is this possible?
A general purpose multi-agent system
Have you met GIL?
ØMQ is very cool - If you don't have a project that needs it... ¡create one!
Agents are independent, but they must know the addresses of other agents
from osbrain import run_nameserver
from osbrain import run_agent
if __name__ == '__main__':
# System deployment
ns = run_nameserver()
agent = run_agent('Example', ns)
# Log a message
agent.log_info('Hello world!')
import time
from osbrain import random_nameserver
from osbrain import run_agent
def log_message(agent, message):
agent.log_info('received: %s' % message)
if __name__ == '__main__':
# System deployment
ns = random_nameserver()
sender = run_agent('Alice', ns)
receiver = run_agent('Bob', ns)
# System configuration
addr = sender.bind('PUSH', alias='main')
receiver.connect(addr, handler=log_message)
# Send messages
while True:
time.sleep(1)
sender.send('main', 'Hello, world!')
import time
from osbrain import random_nameserver
from osbrain import run_agent
from osbrain import BaseAgent
class Push(BaseAgent):
def on_init(self):
self.bind('PUSH', alias='main')
def hello(self):
self.send('main', 'Hello, world!')
def log_message(agent, message):
agent.log_info('received: %s' % message)
if __name__ == '__main__':
# System deployment
ns = random_nameserver()
sender = run_agent('Alice', ns, base=Push)
receiver = run_agent('Bob', ns)
# System configuration
receiver.connect(sender.addr('main'), handler=log_message)
# Send messages
while True:
time.sleep(1)
sender.hello()
from osmarkets.brain import Brain
from osmarkets.architecture import OandaArchitecture
class Example(Brain):
def on_new_bar(self, series):
# Algorithm
if series[0].close > series[1].close:
side = 'buy'
else:
side = 'sell'
# Order
self.send_order(side=side,
size=100,
symbol=series.bsid.symbol)
if __name__ == '__main__':
system = OandaArchitecture(logging=True,
account_id=123456,
access_token='123abc-345def',
environment='live')
system.stream(['EUR_USD'])
system.add_brain('example', base=Example)
system['example'].set_attr(DEBUG=True)
system['example'].subscribe(('EUR_USD', 1, 'Minutes'), 100)
♥ Python ♥
hired = [name for name, CV in candidates
if CV in inbox('rrhh@opensistemas.com') and CV]