资源加载中... loading...

Built-in variables

EXCHANGE

exchange

exchange is an exchange object, which is the first exchange object added to the strategy live trading settings, backtest settings, and all interactions with the exchange are realized through the member functions of this object.

object

function main() {
    Log("On the live trading page or backtest page, the first exchange object name added: ", exchange.GetName(), ", label:", exchange.GetLabel())
}
def main():
    Log("On the live trading page or backtest page, the first exchange object name added: ", exchange.GetName(), ", label:", exchange.GetLabel())
void main() {
    Log("On the live trading page or backtest page, the first exchange object name added: ", exchange.GetName(), ", label:", exchange.GetLabel());
}

{@var/EXCHANGE/exchanges exchanges}, {@fun/Account/exchange.GetName exchange.GetName}, {@fun/Account/exchange.GetLabel exchange.GetLabel}

exchanges

exchanges is an array of exchange objects, containing all the exchange objects added in the strategy live trading settings, backtest settings, exchanges[0], which is {@var/EXCHANGE exchange}. The exchange objects added in the strategy live trading settings or backtest settings correspond to exchanges[0], exchanges[1], exchanges[2], exchanges[n]… in the order they are added.

array

function main() {
    for(var i = 0; i < exchanges.length; i++) {
        Log("Index of the added exchange object (the first one is 0 and so on):", i, "Name:", exchanges[i].GetName(), "Label:", exchanges[i].GetLabel())
    }
}
def main():
    for i in range(len(exchanges)):
        Log("Index of the added exchange object (the first one is 0 and so on):", i, "Name:", exchanges[i].GetName(), "Label:", exchanges[i].GetLabel())
void main() {
    for(int i = 0; i < exchanges.size(); i++) {
        Log("Index of the added exchange object (the first one is 0 and so on):", i, "Name:", exchanges[i].GetName(), "Label:", exchanges[i].GetLabel());
    }
}

{@var/EXCHANGE exchange}, {@fun/Account/exchange.GetName exchange.GetName}, {@fun/Account/exchange.GetLabel exchange.GetLabel}

ORDER_STATE

ORDER_STATE_PENDING

ORDER_STATE_PENDING is the value of the Status attribute in the {@struct/Order Order} structure, indicating that the order status is unfinished.

number

The value of ORDER_STATE_PENDING is 0.

{@var/ORDER_STATE/ORDER_STATE_CLOSED ORDER_STATE_CLOSED}, {@var/ORDER_STATE/ORDER_STATE_CANCELED ORDER_STATE_CANCELED}, {@var/ORDER_STATE/ORDER_STATE_UNKNOWN ORDER_STATE_UNKNOWN}

ORDER_STATE_CLOSED

ORDER_STATE_CLOSED is the value of the Status attribute in the {@struct/Order Order} structure, indicating that the order status is completed.

number

The value of ORDER_STATE_CLOSED is 1.

{@var/ORDER_STATE/ORDER_STATE_PENDING ORDER_STATE_PENDING}, {@var/ORDER_STATE/ORDER_STATE_CANCELED ORDER_STATE_CANCELED}, {@var/ORDER_STATE/ORDER_STATE_UNKNOWN ORDER_STATE_UNKNOWN}

ORDER_STATE_CANCELED

ORDER_STATE_CANCELED is the value of the Status attribute in the {@struct/Order Order} structure, indicating that the order status is cancelled.

number

The value of ORDER_STATE_CANCELED is 2.

{@var/ORDER_STATE/ORDER_STATE_PENDING ORDER_STATE_PENDING}, {@var/ORDER_STATE/ORDER_STATE_CLOSED ORDER_STATE_CLOSED}, {@var/ORDER_STATE/ORDER_STATE_UNKNOWN ORDER_STATE_UNKNOWN}

ORDER_STATE_UNKNOWN

ORDER_STATE_UNKNOWN is the value of the Status attribute in the {@struct/Order Order} structure, indicating that the order status is unknown (other status).

number

The value of ORDER_STATE_UNKNOWN is 3. For ORDER_STATE_UNKNOWN status, you can call {@fun/Market/exchange.GetRawJSON exchange.GetRawJSON} function to get the status information of the original order, check the specific description according to the exchange documentation.

{@var/ORDER_STATE/ORDER_STATE_PENDING ORDER_STATE_PENDING}, {@var/ORDER_STATE/ORDER_STATE_CLOSED ORDER_STATE_CLOSED}, {@var/ORDER_STATE/ORDER_STATE_CANCELED ORDER_STATE_CANCELED}

ORDER_TYPE

ORDER_TYPE_BUY

ORDER_TYPE_BUY is the value of the Type attribute in the {@struct/Order Order} structure, indicating the buy order type.

number

The value of ORDER_TYPE_BUY is 0.

{@var/ORDER_TYPE/ORDER_TYPE_SELL ORDER_TYPE_SELL}

ORDER_TYPE_SELL

ORDER_TYPE_SELL is the value of the Type attribute in the {@struct/Order Order} structure, indicating the sell order type.

number

The value of ORDER_TYPE_SELL is 1.

{@var/ORDER_TYPE/ORDER_TYPE_BUY ORDER_TYPE_BUY}

POSITION_DIRECTION

PD_LONG

PD_LONG is the value of the Type attribute in the {@struct/Position Position} structure, indicating the long position type.

number

The value of PD_LONG is 0. For long positions in the contract market, use exchange.SetDirection(“closebuy”) to set the direction to close the position and close the position of that type.

{@var/POSITION_DIRECTION/PD_SHORT PD_SHORT}

PD_SHORT

PD_SHORT is the value of the Type attribute in the {@struct/Position Position} structure, indicating the short position type.

number

The value of PD_SHORT is 1. For short positions in the contract market, use exchange.SetDirection(“closesell”) to set the direction of closing the position and close the position of that type.

{@var/POSITION_DIRECTION/PD_LONG PD_LONG}

ORDER_OFFSET

ORDER_OFFSET_OPEN

ORDER_OFFSET_OPEN is the value of the Offset attribute in the {@struct/Order Order} structure, indicating that the order is in the open direction.

number

The value of ORDER_OFFSET_OPEN is 0.

{@var/ORDER_OFFSET/ORDER_OFFSET_CLOSE ORDER_OFFSET_CLOSE}

ORDER_OFFSET_CLOSE

ORDER_OFFSET_CLOSE is the value of the Offset attribute in the {@struct/Order Order} structure, indicating that the order is in the close direction.

number

The value of ORDER_OFFSET_CLOSE is 1.

{@var/ORDER_OFFSET/ORDER_OFFSET_OPEN ORDER_OFFSET_OPEN}

PERIOD

PERIOD_M1

Indicates the constant of the 1-minute K-line period with a value of 60.

number

{@fun/Market/exchange.GetRecords exchange.GetRecords}, {@var/PERIOD/PERIOD_M3 PERIOD_M3}, {@var/PERIOD/PERIOD_M5 PERIOD_M5}, {@var/PERIOD/PERIOD_M15 PERIOD_M15}, {@var/PERIOD/PERIOD_M30 PERIOD_M30}, {@var/PERIOD/PERIOD_H1 PERIOD_H1}, {@var/PERIOD/PERIOD_H2 PERIOD_H2}, {@var/PERIOD/PERIOD_H4 PERIOD_H4}, {@var/PERIOD/PERIOD_H6 PERIOD_H6}, {@var/PERIOD/PERIOD_H12 PERIOD_H12}, {@var/PERIOD/PERIOD_D1 PERIOD_D1}, {@var/PERIOD/PERIOD_D3 PERIOD_D3}, {@var/PERIOD/PERIOD_W1 PERIOD_W1}

PERIOD_M3

Indicates the constant of the 3-minute K-line period with a value of 180.

number

{@fun/Market/exchange.GetRecords exchange.GetRecords}, {@var/PERIOD/PERIOD_M1 PERIOD_M1}, {@var/PERIOD/PERIOD_M5 PERIOD_M5}, {@var/PERIOD/PERIOD_M15 PERIOD_M15}, {@var/PERIOD/PERIOD_M30 PERIOD_M30}, {@var/PERIOD/PERIOD_H1 PERIOD_H1}, {@var/PERIOD/PERIOD_H2 PERIOD_H2}, {@var/PERIOD/PERIOD_H4 PERIOD_H4}, {@var/PERIOD/PERIOD_H6 PERIOD_H6}, {@var/PERIOD/PERIOD_H12 PERIOD_H12}, {@var/PERIOD/PERIOD_D1 PERIOD_D1}, {@var/PERIOD/PERIOD_D3 PERIOD_D3}, {@var/PERIOD/PERIOD_W1 PERIOD_W1}

PERIOD_M5

Indicates the constant of the 5-minute K-line period with a value of 300.

number

{@fun/Market/exchange.GetRecords exchange.GetRecords}, {@var/PERIOD/PERIOD_M1 PERIOD_M1}, {@var/PERIOD/PERIOD_M3 PERIOD_M3}, {@var/PERIOD/PERIOD_M15 PERIOD_M15}, {@var/PERIOD/PERIOD_M30 PERIOD_M30}, {@var/PERIOD/PERIOD_H1 PERIOD_H1}, {@var/PERIOD/PERIOD_H2 PERIOD_H2}, {@var/PERIOD/PERIOD_H4 PERIOD_H4}, {@var/PERIOD/PERIOD_H6 PERIOD_H6}, {@var/PERIOD/PERIOD_H12 PERIOD_H12}, {@var/PERIOD/PERIOD_D1 PERIOD_D1}, {@var/PERIOD/PERIOD_D3 PERIOD_D3}, {@var/PERIOD/PERIOD_W1 PERIOD_W1}

PERIOD_M15

Indicates the constant of the 15-minute K-line period with a value of 900.

number

{@fun/Market/exchange.GetRecords exchange.GetRecords}, {@var/PERIOD/PERIOD_M1 PERIOD_M1}, {@var/PERIOD/PERIOD_M3 PERIOD_M3}, {@var/PERIOD/PERIOD_M5 PERIOD_M5}, {@var/PERIOD/PERIOD_M30 PERIOD_M30}, {@var/PERIOD/PERIOD_H1 PERIOD_H1}, {@var/PERIOD/PERIOD_H2 PERIOD_H2}, {@var/PERIOD/PERIOD_H4 PERIOD_H4}, {@var/PERIOD/PERIOD_H6 PERIOD_H6}, {@var/PERIOD/PERIOD_H12 PERIOD_H12}, {@var/PERIOD/PERIOD_D1 PERIOD_D1}, {@var/PERIOD/PERIOD_D3 PERIOD_D3}, {@var/PERIOD/PERIOD_W1 PERIOD_W1}

PERIOD_M30

Indicates the constant of the 30-minute K-line period with a value of 1800.

number

{@fun/Market/exchange.GetRecords exchange.GetRecords}, {@var/PERIOD/PERIOD_M1 PERIOD_M1}, {@var/PERIOD/PERIOD_M3 PERIOD_M3}, {@var/PERIOD/PERIOD_M5 PERIOD_M5}, {@var/PERIOD/PERIOD_M15 PERIOD_M15}, {@var/PERIOD/PERIOD_H1 PERIOD_H1}, {@var/PERIOD/PERIOD_H2 PERIOD_H2}, {@var/PERIOD/PERIOD_H4 PERIOD_H4}, {@var/PERIOD/PERIOD_H6 PERIOD_H6}, {@var/PERIOD/PERIOD_H12 PERIOD_H12}, {@var/PERIOD/PERIOD_D1 PERIOD_D1}, {@var/PERIOD/PERIOD_D3 PERIOD_D3}, {@var/PERIOD/PERIOD_W1 PERIOD_W1}

PERIOD_H1

Indicates the constant of the 1-hour K-line period with a value of 3600.

number

{@fun/Market/exchange.GetRecords exchange.GetRecords}, {@var/PERIOD/PERIOD_M1 PERIOD_M1}, {@var/PERIOD/PERIOD_M3 PERIOD_M3}, {@var/PERIOD/PERIOD_M5 PERIOD_M5}, {@var/PERIOD/PERIOD_M15 PERIOD_M15}, {@var/PERIOD/PERIOD_M30 PERIOD_M30}, {@var/PERIOD/PERIOD_H2 PERIOD_H2}, {@var/PERIOD/PERIOD_H4 PERIOD_H4}, {@var/PERIOD/PERIOD_H6 PERIOD_H6}, {@var/PERIOD/PERIOD_H12 PERIOD_H12}, {@var/PERIOD/PERIOD_D1 PERIOD_D1}, {@var/PERIOD/PERIOD_D3 PERIOD_D3}, {@var/PERIOD/PERIOD_W1 PERIOD_W1}

PERIOD_H2

Indicates the constant of the 2-hour K-line period with a value of 7200.

number

{@fun/Market/exchange.GetRecords exchange.GetRecords}, {@var/PERIOD/PERIOD_M1 PERIOD_M1}, {@var/PERIOD/PERIOD_M3 PERIOD_M3}, {@var/PERIOD/PERIOD_M5 PERIOD_M5}, {@var/PERIOD/PERIOD_M15 PERIOD_M15}, {@var/PERIOD/PERIOD_M30 PERIOD_M30}, {@var/PERIOD/PERIOD_H1 PERIOD_H1}, {@var/PERIOD/PERIOD_H4 PERIOD_H4}, {@var/PERIOD/PERIOD_H6 PERIOD_H6}, {@var/PERIOD/PERIOD_H12 PERIOD_H12}, {@var/PERIOD/PERIOD_D1 PERIOD_D1}, {@var/PERIOD/PERIOD_D3 PERIOD_D3}, {@var/PERIOD/PERIOD_W1 PERIOD_W1}

PERIOD_H4

Indicates the constant of the 4-hour K-line period with a value of 14400.

number

{@fun/Market/exchange.GetRecords exchange.GetRecords}, {@var/PERIOD/PERIOD_M1 PERIOD_M1}, {@var/PERIOD/PERIOD_M3 PERIOD_M3}, {@var/PERIOD/PERIOD_M5 PERIOD_M5}, {@var/PERIOD/PERIOD_M15 PERIOD_M15}, {@var/PERIOD/PERIOD_M30 PERIOD_M30}, {@var/PERIOD/PERIOD_H1 PERIOD_H1}, {@var/PERIOD/PERIOD_H2 PERIOD_H2}, {@var/PERIOD/PERIOD_H6 PERIOD_H6}, {@var/PERIOD/PERIOD_H12 PERIOD_H12}, {@var/PERIOD/PERIOD_D1 PERIOD_D1}, {@var/PERIOD/PERIOD_D3 PERIOD_D3}, {@var/PERIOD/PERIOD_W1 PERIOD_W1}

PERIOD_H6

Indicates the constant of the 6-hour K-line period with a value of 21600.

number

{@fun/Market/exchange.GetRecords exchange.GetRecords}, {@var/PERIOD/PERIOD_M1 PERIOD_M1}, {@var/PERIOD/PERIOD_M3 PERIOD_M3}, {@var/PERIOD/PERIOD_M5 PERIOD_M5}, {@var/PERIOD/PERIOD_M15 PERIOD_M15}, {@var/PERIOD/PERIOD_M30 PERIOD_M30}, {@var/PERIOD/PERIOD_H1 PERIOD_H1}, {@var/PERIOD/PERIOD_H2 PERIOD_H2}, {@var/PERIOD/PERIOD_H4 PERIOD_H4}, {@var/PERIOD/PERIOD_H12 PERIOD_H12}, {@var/PERIOD/PERIOD_D1 PERIOD_D1}, {@var/PERIOD/PERIOD_D3 PERIOD_D3}, {@var/PERIOD/PERIOD_W1 PERIOD_W1}

PERIOD_H12

Indicates the constant of the 12-hour K-line period with a value of 43200.

number

{@fun/Market/exchange.GetRecords exchange.GetRecords}, {@var/PERIOD/PERIOD_M1 PERIOD_M1}, {@var/PERIOD/PERIOD_M3 PERIOD_M3}, {@var/PERIOD/PERIOD_M5 PERIOD_M5}, {@var/PERIOD/PERIOD_M15 PERIOD_M15}, {@var/PERIOD/PERIOD_M30 PERIOD_M30}, {@var/PERIOD/PERIOD_H1 PERIOD_H1}, {@var/PERIOD/PERIOD_H2 PERIOD_H2}, {@var/PERIOD/PERIOD_H4 PERIOD_H4}, {@var/PERIOD/PERIOD_H6 PERIOD_H6}, {@var/PERIOD/PERIOD_D1 PERIOD_D1}, {@var/PERIOD/PERIOD_D3 PERIOD_D3}, {@var/PERIOD/PERIOD_W1 PERIOD_W1}

PERIOD_D1

Indicates the constant of the 1-day K-period with the value of 86400.

number

{@fun/Market/exchange.GetRecords exchange.GetRecords}, {@var/PERIOD/PERIOD_M1 PERIOD_M1}, {@var/PERIOD/PERIOD_M3 PERIOD_M3}, {@var/PERIOD/PERIOD_M5 PERIOD_M5}, {@var/PERIOD/PERIOD_M15 PERIOD_M15}, {@var/PERIOD/PERIOD_M30 PERIOD_M30}, {@var/PERIOD/PERIOD_H1 PERIOD_H1}, {@var/PERIOD/PERIOD_H2 PERIOD_H2}, {@var/PERIOD/PERIOD_H4 PERIOD_H4}, {@var/PERIOD/PERIOD_H6 PERIOD_H6}, {@var/PERIOD/PERIOD_H12 PERIOD_H12}, {@var/PERIOD/PERIOD_D3 PERIOD_D3}, {@var/PERIOD/PERIOD_W1 PERIOD_W1}

PERIOD_D3

Indicates the constant of the 3-day K-period with a value of 259200.

number

{@fun/Market/exchange.GetRecords exchange.GetRecords}, {@var/PERIOD/PERIOD_M1 PERIOD_M1}, {@var/PERIOD/PERIOD_M3 PERIOD_M3}, {@var/PERIOD/PERIOD_M5 PERIOD_M5}, {@var/PERIOD/PERIOD_M15 PERIOD_M15}, {@var/PERIOD/PERIOD_M30 PERIOD_M30}, {@var/PERIOD/PERIOD_H1 PERIOD_H1}, {@var/PERIOD/PERIOD_H2 PERIOD_H2}, {@var/PERIOD/PERIOD_H4 PERIOD_H4}, {@var/PERIOD/PERIOD_H6 PERIOD_H6}, {@var/PERIOD/PERIOD_H12 PERIOD_H12}, {@var/PERIOD/PERIOD_D1 PERIOD_D1}, {@var/PERIOD/PERIOD_W1 PERIOD_W1}

PERIOD_W1

Indicates the constant of the 1-week K-line period with the value 604800.

number

{@fun/Market/exchange.GetRecords exchange.GetRecords}, {@var/PERIOD/PERIOD_M1 PERIOD_M1}, {@var/PERIOD/PERIOD_M3 PERIOD_M3}, {@var/PERIOD/PERIOD_M5 PERIOD_M5}, {@var/PERIOD/PERIOD_M15 PERIOD_M15}, {@var/PERIOD/PERIOD_M30 PERIOD_M30}, {@var/PERIOD/PERIOD_H1 PERIOD_H1}, {@var/PERIOD/PERIOD_H2 PERIOD_H2}, {@var/PERIOD/PERIOD_H4 PERIOD_H4}, {@var/PERIOD/PERIOD_H6 PERIOD_H6}, {@var/PERIOD/PERIOD_H12 PERIOD_H12}, {@var/PERIOD/PERIOD_D1 PERIOD_D1}, {@var/PERIOD/PERIOD_D3 PERIOD_D3}

LOG_TYPE

LOG_TYPE_BUY

LOG_TYPE_BUY is an optional value for the LogType parameter of the {@fun/Trade/exchange.Log exchange.Log} function, which sets the log printed by the exchange.Log function to be the buy order log. The value of LOG_TYPE_BUY is 0.

number

{@var/LOG_TYPE/LOG_TYPE_SELL LOG_TYPE_SELL}, {@var/LOG_TYPE/LOG_TYPE_CANCEL LOG_TYPE_CANCEL}

LOG_TYPE_SELL

LOG_TYPE_SELL is an optional value for the LogType parameter of the {@fun/Trade/exchange.Log exchange.Log} function, which sets the log printed by the exchange.Log function to be the sell order log. The value of LOG_TYPE_SELL is 1.

number

{@var/LOG_TYPE/LOG_TYPE_BUY LOG_TYPE_BUY}, {@var/LOG_TYPE/LOG_TYPE_CANCEL LOG_TYPE_CANCEL}

LOG_TYPE_CANCEL

LOG_TYPE_CANCEL is an optional value for the LogType parameter of the {@fun/Trade/exchange.Log exchange.Log} function, which sets the log printed by the exchange.Log function to be the order cancellation log. The value of LOG_TYPE_CANCEL is 2.

number

{@var/LOG_TYPE/LOG_TYPE_BUY LOG_TYPE_BUY}, {@var/LOG_TYPE/LOG_TYPE_SELL LOG_TYPE_SELL}

Structures