Giter Site home page Giter Site logo

Websockets about bitfinex-api-rb HOT 8 CLOSED

arvicco avatar arvicco commented on June 11, 2024
Websockets

from bitfinex-api-rb.

Comments (8)

erubboli-bfx avatar erubboli-bfx commented on June 11, 2024 1

Hi @arvicco, you should use the listen_account method passing a block, this is a full working example :

require 'bitfinex'

Bitfinex::Client.configure do |conf|
    conf.api_key = ENV["BFX_KEY"]
    conf.secret = ENV["BFX_SECRET"]
end

client = Bitfinex::Client.new

client.listen_account do |c|
  puts "account: #{c.inspect}"
end

client.listen_ticker do |t|
  puts "tick: #{t.inspect}"
end

client.listen_book do |b|
  puts "book: #{b.inspect}"
end

client.listen_trades do |b|
  puts "trades: #{b.inspect}"
end

client.listen!

from bitfinex-api-rb.

arvicco avatar arvicco commented on June 11, 2024 1

Ah, sorry - it works now, I wasn't using the module API correctly - you need to call it's methods on Bitfinex::Client.

from bitfinex-api-rb.

prdn avatar prdn commented on June 11, 2024

We are working on the websocket feed, should be ready soon.

from bitfinex-api-rb.

arvicco avatar arvicco commented on June 11, 2024

Great! I messed around with it a bit and got public channels working with code like:

bws = Bitfinex::Websocket::EMClient.new
bws.on ('open') { |_| bws.send( event: 'subscribe', channel: 'trades', pair: 'BTCUSD') }
bws.on ('message') { | json |  pp JSON.parse(json) }
bws.run!

I'm still not sure how to handle auth though, in order to receive account-specific channels. Maybe you happen have a Ruby snippet handy that you could share? I'm a bit obtuse with Javascript.

from bitfinex-api-rb.

prdn avatar prdn commented on June 11, 2024

@arvicco have a look here: #7

from bitfinex-api-rb.

arvicco avatar arvicco commented on June 11, 2024

Thanks! I tried to use new WebsocketConnection module to do ws auth, but no luck so far: 'websocket_connection.rb:27:in ws_auth': undefined methodsign' for main:Object (NoMethodError)'

from bitfinex-api-rb.

arvicco avatar arvicco commented on June 11, 2024

Great job, guys! It does all I need atm.

from bitfinex-api-rb.

ilyacherevkov avatar ilyacherevkov commented on June 11, 2024

Do I understand correctly that this websocket API is for live feed only? And it's not suited to place/cancel orders etc?

from bitfinex-api-rb.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.