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

Set the current exchange rate of the exchange object.

exchange.SetRate(rate)

Examples

Set the rate to 7 so prices are multiplied by 7, then restore it to 1.

javascript
function main(){ Log(exchange.GetTicker()) // Set exchange rate conversion exchange.SetRate(7) Log(exchange.GetTicker()) // Set to 1, no conversion exchange.SetRate(1) }
python
def main(): Log(exchange.GetTicker()) exchange.SetRate(7) Log(exchange.GetTicker()) exchange.SetRate(1)
rust
fn main() { Log!(exchange.GetTicker(None)); // Set exchange rate conversion exchange.SetRate(7); Log!(exchange.GetTicker(None)); // Set to 1, no conversion exchange.SetRate(1); }

Returns

TypeDescription

number

The exchange rate before this call.

Arguments

NameTypeRequiredDescription

rate

number

Yes

Conversion rate; a value less than or equal to 0 is treated as 1 (no conversion).

See Also

Remarks

If an exchange rate has been set with exchange.SetRate(), for example 7, then the prices in the ticker, depth, K-line, order and position data obtained through this exchange object, as well as the quote-currency Balance and FrozenBalance of the account, are multiplied by 7; amounts are not converted.
When placing orders (exchange.Buy(), exchange.Sell(), exchange.CreateOrder()), the price you pass is taken as a converted price and is divided by the rate back into the original currency before being sent to the exchange; non-positive prices such as -1 for market orders are not converted. Prices for exchange.ModifyOrder() and condition orders are not converted and must be given in the exchange's original currency.
For example, if exchange is an exchange quoted in US dollars, after exchange.SetRate(7) all live prices are multiplied by 7 and become close to CNY-denominated prices.