PriorityMailbox to the aid:
http://doc.akka.io/docs/akka/2.4.14/java/mailboxes.html#PriorityMailbox

HTH,
Guido.

On Sunday, November 27, 2016 at 10:00:44 PM UTC, adrian...@gmail.com wrote:
>
> I have heard a lot of good things about Akka. I have a stream of price , 
> and I need to create two moving average of the price. And finally I have a 
> strategy that listens to these signals => price, moving average price 1 and 
> moving average price 2 and makes some decisions.
>
> I implemented this via actors but unfortunately I have a problem of order, 
> that a) I don’t know how to specify a timestamp or priority order to the 
> messages or events generated.
>
> final ActorSystem actorSystem = ActorSystem.create("backtest");    
> final ActorRef strat = ActorSystem.actorOf(Props.create(Strategy.class));
> final ActorRef acref = 
> ActorSystem.actorOf(Props.create(PriceCSVReader.class));
> final ActorRef ma5 = 
> ActorSystem.actorOf(Props.create(MovingAverage.class,5,"price"));
> final ActorRef ma20 = 
> ActorSystem.actorOf(Props.create(MovingAverage.class,20,"price"));
>
> actrSystem.eventStream().subscribe(strat,PriceEvent.class);    
> actrSystem.eventStream().subscribe(ma5,PriceEvent.class);    
> actrSystem.eventStream().subscribe(ma20,PriceEvent.class);
>
> acref.tell(new ReadPriceFromCSV("c:\price.csv"));
>
> Where PriceEvent is a simple class with a string id and a double value. 
> Moving average class listens to the price and compute a moving average and 
> create a new PriceEvent each time.
>
> The strategy listens to all these PriceEvents and using their id can 
> distinguish them.
>
>

-- 
>>>>>>>>>>      Read the docs: http://akka.io/docs/
>>>>>>>>>>      Check the FAQ: 
>>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>>      Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to