class Ubea::Exchange::BitcoinDeEur
Public Instance Methods
fiat_currency()
click to toggle source
# File lib/ubea/exchanges/bitcoin_de_eur.rb, line 4 def fiat_currency "EUR" end
refresh_order_book!()
click to toggle source
# File lib/ubea/exchanges/bitcoin_de_eur.rb, line 12 def refresh_order_book! html = get_html("https://www.bitcoin.de/en/market") or return asks = format_asks_bids(html, "offer") bids = format_asks_bids(html, "order") return if asks.empty? || asks.size != bids.size mark_as_refreshed @order_book = OrderBook.new(asks: asks, bids: bids) end
trade_fee()
click to toggle source
# File lib/ubea/exchanges/bitcoin_de_eur.rb, line 8 def trade_fee BigDecimal.new("0.005").freeze # 0.5% - see https://www.bitcoin.de/en/infos#gebuehren end
Private Instance Methods
format_asks_bids(html, type)
click to toggle source
# File lib/ubea/exchanges/bitcoin_de_eur.rb, line 26 def format_asks_bids(html, type) return unless html.match(/<tbody id="trade_#{type}_results_table_body"(.+?)<\/tbody>/m) Regexp.last_match[1].each_line.select { |line| line.include?("data-critical-price") }.map do |line| return unless line.match(/<tr[^>]+data-critical-price="([\d\.]+)" data-amount="([\d\.]+)">/) Offer.new(price: Money.new(Regexp.last_match[1], fiat_currency), volume: Regexp.last_match[2]).freeze end end