Type/to search
Built-in Functions
Global
Log
Market
Trade
Account
Futures
Exchange
exchange.GetName
exchange.GetLabel
exchange.GetCurrency
exchange.SetCurrency
exchange.GetQuoteCurrency
exchange.GetPeriod
exchange.SetMaxBarLen
exchange.SetPrecision
exchange.GetRate
exchange.SetRate
exchange.SetBase
exchange.GetBase
exchange.SetProxy
exchange.SetTimeout
exchange.Encode
IO
Network
Storage
Threads
TA
Talib
OS
Structures
Built-in Variables and Constants
Conventions
Exchanges

Get the exchange rate currently set for the exchange object.

exchange.GetRate()

Examples

Read the default rate, then read it again after setting a rate.

javascript
function main() { Log(exchange.GetRate()) // Output: 1 (default when SetRate has not been called) exchange.SetRate(7) Log(exchange.GetRate()) // Output: 7 }
python
def main(): Log(exchange.GetRate()) # Output: 1 (default when SetRate has not been called) exchange.SetRate(7) Log(exchange.GetRate()) # Output: 7
rust
fn main() { Log!(exchange.GetRate()); // Output: 1 (default when SetRate has not been called) exchange.SetRate(7); Log!(exchange.GetRate()); // Output: 7 }

Returns

TypeDescription

number

The current exchange rate value of the exchange object.

See Also

Remarks

If the conversion rate has not been set by calling exchange.SetRate(), the exchange.GetRate() function will return the default rate value 1, meaning that the data related to the currently displayed quote currency (quoteCurrency) has not been converted by any exchange rate.

If an exchange rate value has been set using exchange.SetRate(), for example exchange.SetRate(7), then the prices in the data obtained through the exchange object—such as tickers, market depth, K-lines, orders and positions—will be multiplied by the set rate 7 for conversion; prices passed when placing orders are taken as converted prices and divided by the rate before being sent, see exchange.SetRate.

If exchange corresponds to an exchange that uses the US dollar as its quote currency, after calling exchange.SetRate(7), all prices in live trading will be multiplied by 7, converting them to prices close to the Chinese yuan (CNY). At this point, the rate value obtained through exchange.GetRate() is 7.