Tengo el siguiente lib:
module Bitfinex
module V1::TradesClient
# Get a list of the most recent trades for the given symbol.
#
# @param symbol [IOTUSD] the name of the symbol
# @param params :timestamp [time] Only show trades at or after this timestamp.
# @param params :limit_trades [int] Limit the number of trades returned. Must be >= 1.
# @return [Array]
# @example:
# client.trades
def trades(symbol="btcusd", params={})
check_params(params, %i{timestamp limit_trades})
get("trades/#{symbol}", params).body
end
# Listen to the trades using websocket.
#
# @param pair [string]
# @param block [Block] The code to be executed when a new trade is executed
# @example:
# client.listen_trades do |trade|
# puts trade.inspect
# end
def listen_trades(pair="BTCUSD", &block)
raise BlockMissingError unless block_given?
register_channel pair:pair, channel: 'trades', &block
end
end
end
Qué debo hacer para:
puts client.listen
Ir sumando los
amount
desell
y debuys
.
gem: https://github.com/bitfinexcom/bitfinex-api-rb
doc: https://docs.bitfinex.com/v1/reference#rest-public-trades