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
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!')
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)
hired = [name for name, CV in candidates
if CV in inbox('rrhh@opensistemas.com') and CV]