Initial commit

This commit is contained in:
Yaser
2026-08-13 19:50:53 +03:30
commit 38084458fe
879 changed files with 95198 additions and 0 deletions

View File

@@ -0,0 +1,49 @@
# frozen_string_literal: true
module API
module V2
module CoinGecko
module Entities
class Orderbook < API::V2::Entities::Base
expose(
:ticker_id,
documentation: {
type: String,
desc: 'A pair such as "BTC_ETH", with delimiter between different cryptoassets.'
}
) do |orderbook|
orderbook.market.underscore_name
end
expose(
:timestamp,
documentation: {
type: Integer,
desc: 'Unix timestamp in milliseconds for when the last updated time occurred'
}
) do
DateTime.now.strftime('%Q').to_i
end
expose(
:asks,
documentation: {
type: BigDecimal,
is_array: true,
desc: 'An array containing 2 elements. The offer price and quantity for each bid order.'
}
)
expose(
:bids,
documentation: {
type: BigDecimal,
is_array: true,
desc: 'An array containing 2 elements. The ask price and quantity for each ask order.'
}
)
end
end
end
end
end

View File

@@ -0,0 +1,41 @@
# frozen_string_literal: true
module API
module V2
module CoinGecko
module Entities
class Pair < API::V2::Entities::Base
expose(
:ticker_id,
documentation: {
type: String,
desc: 'Identifier of a ticker with delimiter to separate base/target, eg. BTC_ETH.'
}
) do |market|
market.underscore_name
end
expose(
:base,
documentation: {
type: String,
desc: 'Symbol/currency code of a the base cryptoasset, eg. BTC.'
}
) do |market|
market[:base_unit].upcase
end
expose(
:target,
documentation: {
type: String,
desc: 'Symbol/currency code of the target cryptoasset, eg. ETH.'
}
) do |market|
market[:quote_unit].upcase
end
end
end
end
end
end

View File

@@ -0,0 +1,111 @@
# frozen_string_literal: true
module API
module V2
module CoinGecko
module Entities
class Ticker < API::V2::Entities::Base
expose(
:ticker_id,
documentation: {
type: String,
desc: 'Identifier of a ticker with delimiter to separate base/target, eg. BTC_ETH.'
}
) do |ticker|
ticker[:market].underscore_name
end
expose(
:base_currency,
documentation: {
type: String,
desc: 'Symbol/currency code of base pair, eg. BTC.'
}
) do |ticker|
ticker[:market][:base_unit].upcase
end
expose(
:target_currency,
documentation: {
type: String,
desc: 'Symbol/currency code of target pair, eg. ETH.'
}
) do |ticker|
ticker[:market][:quote_unit].upcase
end
expose(
:last_price,
documentation: {
type: BigDecimal,
desc: 'Last transacted price of base currency based on given target currency.'
}
) do |ticker|
ticker[:last]
end
expose(
:base_volume,
documentation: {
type: BigDecimal,
desc: '24 hour trading volume in base pair volume.'
}
) do |ticker|
ticker[:amount]
end
expose(
:target_volume,
documentation: {
type: BigDecimal,
desc: '24 hour trading volume in base pair volume.'
}
) do |ticker|
ticker[:volume]
end
expose(
:bid,
documentation: {
type: BigDecimal,
desc: 'Current highest bid price.'
}
) do |ticker|
OrderBid.get_depth(ticker[:market].id).flatten.first.to_d
end
expose(
:ask,
documentation: {
type: BigDecimal,
desc: 'Current lowest ask price.'
}
) do |ticker|
OrderAsk.get_depth(ticker[:market].id).flatten.first.to_d
end
expose(
:high,
documentation: {
type: BigDecimal,
desc: 'The highest trade price during last 24 hours (0.0 if no trades executed during last 24 hours).'
}
) do |ticker|
ticker[:high]
end
expose(
:low,
documentation: {
type: BigDecimal,
desc: 'The lowest trade price during last 24 hours (0.0 if no trades executed during last 24 hours).'
}
) do |ticker|
ticker[:low]
end
end
end
end
end
end