Ruby Constantly consume external API and share output across processes -
i'm writing trading bot on ruby , need calculations based on exchange's orderbook depth data across several daemons (daemons gem).
the problem right i'm fetching data via exchange's api separately in each daemon, ran api calls limit (40 requests/second). that's why i'm trying utilize ruby drb share orderbook data across several processes (daemons) in order not sending unnecessary api calls.
although m not sure how consume api on server side , provide latest actual data client process. in sample code below, client data actual @ moment when started server
server_daemon.rb
require 'drb' exchange = exchange.new api_key: env['apikey'], secret_key: env['secret'] shared_orderbook = exchange.orderbook limit: 50 drb.start_service('druby://127.0.0.1:61676', shared_orderbook) puts 'listening connection… ' drb.thread.join
client_daemon.rb
require 'drb' drb.start_service puts shared_data = drbobject.new_with_uri('druby://127.0.0.1:61676')
Comments
Post a Comment