Sample implementation of server-side UDF-compatible data source for Peatio exchange for TradingView Charting Library.
app/api/api_v2/tools.rb
# encoding: UTF-8
# frozen_string_literal: true
module APIv2
class Tools < Grape::API
desc 'Get server current time, in seconds since Unix epoch.'
get "/timestamp" do
({"serverTime": (Time.now.to_f * 1000).to_i})
end
end
end
app/api/api_v2/entities/market.rb
# encoding: UTF-8
# frozen_string_literal: true
module APIv2
module Entities
class Market < Base
expose :id, documentation: "Unique market id. It's always in the form of xxxyyy, where xxx is the base currency code, yyy is the quote currency code, e.g. 'btcusd'. All available markets can be found at /api/v2/markets."
expose :name
expose :ask_precision
expose :bid_precision
expose :bid_unit
expose :ask_unit
end
end
end
$ npm install
$ npm start