Skip to content

Instantly share code, notes, and snippets.

@StasKoval
Created March 13, 2014 14:56
Show Gist options
  • Save StasKoval/9530017 to your computer and use it in GitHub Desktop.
Save StasKoval/9530017 to your computer and use it in GitHub Desktop.
@coins.each do |c|
#c.cur_name
cur = []
@coin_cur = Coin.where(:cur_name => c.cur_name).last
@coin_10 = Coin.where(:cur_name => c.cur_name).where("date <?", 10.minutes.ago)[-3]
@coin_20 = Coin.where(:cur_name => c.cur_name).where("date <?", 20.minutes.ago)[-5]
if @coin_cur.price.present?
#binding.pry
dif10 = ((@coin_cur.price/@coin_10.price)*100)-100
dif20 = ((@coin_cur.price/@coin_10.price)*100)-100
@results[c.cur_name] = {"volume"=>c.volume24, "price"=>c.price,
'10'=>dif10,'20'=>dif20,
'price_now'=>@coin_cur.price, 'price_10'=>@coin_10.price
}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment