Type/to search
Built-in Functions
Global
Version
Sleep
IsVirtual
Mail
Mail_Go
SetErrorFilter
GetPid
GetLastError
GetCommand
GetMeta
Dial
HttpQuery
HttpQuery_Go
Encode
UnixNano
Unix
GetOS
MD5
DBExec
UUID
EventLoop
__Serve
_G
_D
_N
_C
_Cross
JSON.parse
JSON.stringify
SetChannelData
GetChannelData
Log
Market
Trade
Account
Futures
NetSettings
Threads
threading
Thread
getThread
mainThread
currentThread
Lock
Condition
Event
Dict
pending
Thread
ThreadLock
ThreadEvent
ThreadCondition
ThreadDict
Web3
TA
Talib
talib.CDL2CROWS
talib.CDL3BLACKCROWS
talib.CDL3INSIDE
talib.CDL3LINESTRIKE
talib.CDL3OUTSIDE
talib.CDL3STARSINSOUTH
talib.CDL3WHITESOLDIERS
talib.CDLABANDONEDBABY
talib.CDLADVANCEBLOCK
talib.CDLBELTHOLD
talib.CDLBREAKAWAY
talib.CDLCLOSINGMARUBOZU
talib.CDLCONCEALBABYSWALL
talib.CDLCOUNTERATTACK
talib.CDLDARKCLOUDCOVER
talib.CDLDOJI
talib.CDLDOJISTAR
talib.CDLDRAGONFLYDOJI
talib.CDLENGULFING
talib.CDLEVENINGDOJISTAR
talib.CDLEVENINGSTAR
talib.CDLGAPSIDESIDEWHITE
talib.CDLGRAVESTONEDOJI
talib.CDLHAMMER
talib.CDLHANGINGMAN
talib.CDLHARAMI
talib.CDLHARAMICROSS
talib.CDLHIGHWAVE
talib.CDLHIKKAKE
talib.CDLHIKKAKEMOD
talib.CDLHOMINGPIGEON
talib.CDLIDENTICAL3CROWS
talib.CDLINNECK
talib.CDLINVERTEDHAMMER
talib.CDLKICKING
talib.CDLKICKINGBYLENGTH
talib.CDLLADDERBOTTOM
talib.CDLLONGLEGGEDDOJI
talib.CDLLONGLINE
talib.CDLMARUBOZU
talib.CDLMATCHINGLOW
talib.CDLMATHOLD
talib.CDLMORNINGDOJISTAR
talib.CDLMORNINGSTAR
talib.CDLONNECK
talib.CDLPIERCING
talib.CDLRICKSHAWMAN
talib.CDLRISEFALL3METHODS
talib.CDLSEPARATINGLINES
talib.CDLSHOOTINGSTAR
talib.CDLSHORTLINE
talib.CDLSPINNINGTOP
talib.CDLSTALLEDPATTERN
talib.CDLSTICKSANDWICH
talib.CDLTAKURI
talib.CDLTASUKIGAP
talib.CDLTHRUSTING
talib.CDLTRISTAR
talib.CDLUNIQUE3RIVER
talib.CDLUPSIDEGAP2CROWS
talib.CDLXSIDEGAP3METHODS
talib.AD
talib.ADOSC
talib.OBV
talib.ACOS
talib.ASIN
talib.ATAN
talib.CEIL
talib.COS
talib.COSH
talib.EXP
talib.FLOOR
talib.LN
talib.LOG10
talib.SIN
talib.SINH
talib.SQRT
talib.TAN
talib.TANH
talib.MAX
talib.MAXINDEX
talib.MIN
talib.MININDEX
talib.MINMAX
talib.MINMAXINDEX
talib.SUM
talib.HT_DCPERIOD
talib.HT_DCPHASE
talib.HT_PHASOR
talib.HT_SINE
talib.HT_TRENDMODE
talib.ATR
talib.NATR
talib.TRANGE
talib.BBANDS
talib.DEMA
talib.EMA
talib.HT_TRENDLINE
talib.KAMA
talib.MA
talib.MAMA
talib.MIDPOINT
talib.MIDPRICE
talib.SAR
talib.SAREXT
talib.SMA
talib.T3
talib.TEMA
talib.TRIMA
talib.WMA
talib.LINEARREG
talib.LINEARREG_ANGLE
talib.LINEARREG_INTERCEPT
talib.LINEARREG_SLOPE
talib.STDDEV
talib.TSF
talib.VAR
talib.ADX
talib.ADXR
talib.APO
talib.AROON
talib.AROONOSC
talib.BOP
talib.CCI
talib.CMO
talib.DX
talib.MACD
talib.MACDEXT
talib.MACDFIX
talib.MFI
talib.MINUS_DI
talib.MINUS_DM
talib.MOM
talib.PLUS_DI
talib.PLUS_DM
talib.PPO
talib.ROC
talib.ROCP
talib.ROCR
talib.ROCR100
talib.RSI
talib.STOCH
talib.STOCHF
talib.STOCHRSI
talib.TRIX
talib.ULTOSC
talib.WILLR
talib.AVGPRICE
talib.MEDPRICE
talib.TYPPRICE
talib.WCLPRICE
OS
Structures
Built-in Variables

The exchange.ModifyOrder() function is used to modify existing regular orders, allowing modification of order price and quantity. Supports modifying other order attributes through additional parameters (depending on exchange API support).

exchange.ModifyOrder(orderId, side, price, amount)

Examples

  • Modify the price and quantity of a regular order.

    javascript
    function main() { // Create a limit buy order var id = exchange.CreateOrder("SOL_USDT.swap", "buy", 88, 1) Log("Original Order ID:", id) Sleep(2000) // Query original order information var order = exchange.GetOrder(id) Log("Original Order Info:", order) Sleep(1000) // Modify order price and quantity var newId = exchange.ModifyOrder(id, "buy", 77, 2) Log("Modified Order ID:", newId) Sleep(2000) // Query modified order information var newOrder = exchange.GetOrder(newId) Log("Modified Order Info:", newOrder) // Cancel order exchange.CancelOrder(newId) }
    python
    def main(): # Create a limit buy order id = exchange.CreateOrder("SOL_USDT.swap", "buy", 88, 1) Log("Original Order ID:", id) Sleep(2000) # Query original order information order = exchange.GetOrder(id) Log("Original Order Info:", order) Sleep(1000) # Modify order price and quantity newId = exchange.ModifyOrder(id, "buy", 77, 2) Log("Modified Order ID:", newId) Sleep(2000) # Query modified order information newOrder = exchange.GetOrder(newId) Log("Modified Order Info:", newOrder) # Cancel order exchange.CancelOrder(newId)
    c++
    void main() { // Create a limit buy order auto id = exchange.CreateOrder("SOL_USDT.swap", "buy", 88, 1); Log("Original Order ID:", id); Sleep(2000); // Query original order information auto order = exchange.GetOrder(id); Log("Original Order Info:", order); Sleep(1000); // Modify order price and quantity auto newId = exchange.ModifyOrder(id, "buy", 77, 2); Log("Modified Order ID:", newId); Sleep(2000); // Query modified order information auto newOrder = exchange.GetOrder(newId); Log("Modified Order Info:", newOrder); // Cancel order exchange.CancelOrder(newId); }
  • Use additional parameters (option) to modify the order's price matching mode.

    javascript
    function main() { // Create a limit buy order var id = exchange.CreateOrder("SOL_USDT.swap", "buy", 77, 1) Log("Original Order ID:", id) Sleep(2000) // Modify order and set price matching mode to QUEUE_20 // Pass additional parameters (JSON format) through side parameter var option = {"priceMatch": "QUEUE_20"} var sideWithOption = "buy;" + JSON.stringify(option) var newId = exchange.ModifyOrder(id, sideWithOption, -1, 2) Log("Modified Order ID:", newId) Sleep(2000) // Query modified order information var newOrder = exchange.GetOrder(newId) Log("Modified Order Info:", newOrder) // Cancel order exchange.CancelOrder(newId) }
    python
    import json def main(): # Create a limit buy order id = exchange.CreateOrder("SOL_USDT.swap", "buy", 77, 1) Log("Original Order ID:", id) Sleep(2000) # Modify order and set price matching mode to QUEUE_20 # Pass additional parameters (JSON format) through side parameter option = {"priceMatch": "QUEUE_20"} sideWithOption = "buy;" + json.dumps(option) newId = exchange.ModifyOrder(id, sideWithOption, -1, 2) Log("Modified Order ID:", newId) Sleep(2000) # Query modified order information newOrder = exchange.GetOrder(newId) Log("Modified Order Info:", newOrder) # Cancel order exchange.CancelOrder(newId)
    c++
    void main() { // Create a limit buy order auto id = exchange.CreateOrder("SOL_USDT.swap", "buy", 77, 1); Log("Original Order ID:", id); Sleep(2000); // Modify order and set price matching mode to QUEUE_20 // Pass additional parameters (JSON format) through side parameter json option = R"({"priceMatch": "QUEUE_20"})"_json; string sideWithOption = "buy;" + option.dump(); auto newId = exchange.ModifyOrder(id, sideWithOption, -1, 2); Log("Modified Order ID:", newId); Sleep(2000); // Query modified order information auto newOrder = exchange.GetOrder(newId); Log("Modified Order Info:", newOrder); // Cancel order exchange.CancelOrder(newId); }

Returns

TypeDescription

string / null

Returns the order ID when order modification is successful, returns null when modification fails. The returned order ID may be the same as or different from the original order ID, depending on the exchange API implementation. Some exchanges return a new order ID after order modification, while others keep the order ID unchanged.

Arguments

NameTypeRequiredDescription

orderId

string

Yes

The orderId parameter specifies the original order ID to be modified. The order ID format is consistent with the order ID returned by the exchange.CreateOrder function, composed of the exchange symbol code and the exchange's original order ID, separated by a comma. For example: "ETH-USDT,1547130415509278720".

side

string

Yes

The side parameter specifies the trading direction of the order.

For spot exchange objects, the optional values for the side parameter are: buy, sell. buy means buy, sell means sell.

For futures exchange objects, the optional values for the side parameter are: buy, closebuy, sell, closesell. buy means open long position, closebuy means close long position, sell means open short position, closesell means close short position.

Supports additional parameters (option): Additional parameters can be passed through the side parameter in the format: "side;{JSON object}" or "side;key=value&key=value".

For example: "buy;{\"priceMatch\":\"QUEUE_20\"}" or "buy;priceMatch=QUEUE_20".

Additional parameters are used to modify other order attributes (such as price matching mode, etc.), and the specific supported parameters depend on the exchange API.

price

number

Yes

The price parameter sets the new price for the order. When the price is -1, it indicates no price modification, or it may be converted to a market order depending on the exchange API implementation.

amount

number

Yes

The amount parameter sets the new order quantity. When the quantity is -1, it indicates no quantity modification. Note that when the order is a spot market buy order, the order quantity is the purchase amount; for some spot exchanges, the market buy order quantity is the trading coin quantity.

See Also

Remarks

The order ID returned by the exchange.ModifyOrder() function may behave differently depending on the exchange API implementation. Some exchange APIs will update the returned order ID, while others keep it unchanged. It is recommended to use the returned new order ID for subsequent operations.

The exchange.ModifyOrder() function does not validate parameter validity according to exchange interface rules and will submit parameters directly to the exchange API. When invalid parameters are passed (such as price or quantity being -1), the parameters may be ignored by the exchange, and the order maintains its original attributes unchanged.

Supports passing additional parameters (option) through the side parameter to modify other order attributes. Additional parameters need to be merged with the side parameter in the format "side;{JSON object}" (recommended) or "side;key=value" (URL encoding format). For example, to modify price matching mode: "buy;{\"priceMatch\":\"QUEUE_20\"}".

For market order modification of regular orders, you need to check specifically whether the exchange API supports it. Some exchanges do not support market order modification operations.

When modifying orders, other order attributes (such as order type, position mode, account mode, leverage, order validity rules, etc.) usually retain the original order settings. If you need to modify these attributes, you can pass them through additional parameters (option), provided the exchange API supports it.

Some exchange APIs may convert orders to market orders when price parameters are not received (price is -1 or null). For spot market buy orders, note that the order quantity unit may be amount rather than coin quantity.

Support for order modification functionality depends on the specific exchange. Some exchanges may not support order modification functionality or only support modification of certain parameters. Please consult the corresponding exchange's API documentation before use.