Class: BankOfThailand::Resources::ExchangeRate

Inherits:
BankOfThailand::Resource show all
Defined in:
lib/bank_of_thailand/resources/exchange_rate.rb

Overview

Weighted-average Interbank Exchange Rate - THB / USD

This API provides weighted-average interbank exchange rates calculated from daily interbank purchases and sales of US Dollar (against THB) for transactions worth more than or equal to 1 million USD.

Constant Summary collapse

BASE_URL =

Base URL for this API (overrides the global base URL)

"https://gateway.api.bot.or.th/Stat-ReferenceRate/v2"

Instance Attribute Summary

Attributes inherited from BankOfThailand::Resource

#client

Instance Method Summary collapse

Methods inherited from BankOfThailand::Resource

#initialize

Constructor Details

This class inherits a constructor from BankOfThailand::Resource

Instance Method Details

#annual(start_period:, end_period:) ⇒ Hash

Get annual weighted-average interbank exchange rate

Examples:

Get annual rates

client.exchange_rate.annual(
  start_period: "2020",
  end_period: "2024"
)

Parameters:

  • start_period (String)

    Start year in YYYY format (e.g., "2017")

  • end_period (String)

    End year in YYYY format (e.g., "2017")

Returns:

  • (Hash)

    Response containing annual exchange rate data



84
85
86
87
88
89
90
# File 'lib/bank_of_thailand/resources/exchange_rate.rb', line 84

def annual(start_period:, end_period:)
  get_with_base_url(
    "#{BASE_URL}/ANNUAL_REF_RATE/",
    start_period: start_period,
    end_period: end_period
  )
end

#daily(start_period:, end_period:) ⇒ Hash

Get daily weighted-average interbank exchange rate

Examples:

Get daily rates for a date range

client.exchange_rate.daily(
  start_period: "2025-01-01",
  end_period: "2025-01-31"
)

Parameters:

  • start_period (String)

    Start date in YYYY-MM-DD format (e.g., "2017-06-30")

  • end_period (String)

    End date in YYYY-MM-DD format (e.g., "2017-06-30")

Returns:

  • (Hash)

    Response containing daily exchange rate data



27
28
29
30
31
32
33
# File 'lib/bank_of_thailand/resources/exchange_rate.rb', line 27

def daily(start_period:, end_period:)
  get_with_base_url(
    "#{BASE_URL}/DAILY_REF_RATE/",
    start_period: start_period,
    end_period: end_period
  )
end

#monthly(start_period:, end_period:) ⇒ Hash

Get monthly weighted-average interbank exchange rate

Examples:

Get monthly rates

client.exchange_rate.monthly(
  start_period: "2025-01",
  end_period: "2025-03"
)

Parameters:

  • start_period (String)

    Start period in YYYY-MM format (e.g., "2017-06")

  • end_period (String)

    End period in YYYY-MM format (e.g., "2017-06")

Returns:

  • (Hash)

    Response containing monthly exchange rate data



46
47
48
49
50
51
52
# File 'lib/bank_of_thailand/resources/exchange_rate.rb', line 46

def monthly(start_period:, end_period:)
  get_with_base_url(
    "#{BASE_URL}/MONTHLY_REF_RATE/",
    start_period: start_period,
    end_period: end_period
  )
end

#quarterly(start_period:, end_period:) ⇒ Hash

Get quarterly weighted-average interbank exchange rate

Examples:

Get quarterly rates

client.exchange_rate.quarterly(
  start_period: "2025-Q1",
  end_period: "2025-Q2"
)

Parameters:

  • start_period (String)

    Start period in YYYY-QN format (e.g., "2017-Q1")

  • end_period (String)

    End period in YYYY-QN format (e.g., "2017-Q1")

Returns:

  • (Hash)

    Response containing quarterly exchange rate data



65
66
67
68
69
70
71
# File 'lib/bank_of_thailand/resources/exchange_rate.rb', line 65

def quarterly(start_period:, end_period:)
  get_with_base_url(
    "#{BASE_URL}/QUARTERLY_REF_RATE/",
    start_period: start_period,
    end_period: end_period
  )
end