Understanding Base/QuoteCurrency(), CreateMarket()

HaasScript offers various commands that allow users to query information about the current market or create new markets. Two of these commands are BaseCurrency() and QuoteCurrency(), which return the base currency and quote currency labels of the current market or an optional input market. Another command is CreateMarket(), which generates a market ID that can be used for pulling price data or placing unmanaged orders.

BaseCurrency()

This command returns the base currency label of the current market, or the base currency label of the input market if one is specified.

QuoteCurrency()

This command returns the quote currency label of the current market, or the quote currency label of the input market if one is specified.

CreateMarket()

This command generates a market ID that can be used for pulling price data or placing unmanaged orders. Here’s an example usage of CreateMarket():

base = "BTC"
quote = "USDT"
marketID = CreateMarket({baseCurrency = base, quoteCurrency = quote}) -- Returns the market ID for BTC/USDT

Note that CreateMarket() can also take in additional parameters to specify the exchange and/or trading category.

Understanding BaseCurrency(), QuoteCurrency(), and CreateMarket() is essential for building strategies in HaasScript, as they allow users to interact with the current market and create new markets as needed.

Back to: HaasScript Fundamentals > Built-in Functions