> For clean Markdown of any page, append .md to the page URL. > For a complete documentation index, see https://okx-demo.ferndocs.com/api/api-reference/grid-trading/place-recurring-order/llms.txt. > For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://okx-demo.ferndocs.com/_mcp/server. # Place recurring buy order POST https://www.okx.com/api/v5/tradingBot/recurring/order-algo Content-Type: application/json Create a recurring buy (dollar-cost averaging) strategy that periodically invests a fixed amount across a basket of currencies. Reference: https://okx-demo.ferndocs.com/api/api-reference/grid-trading/place-recurring-order ## Authentication - `OK-ACCESS-KEY` header (required) — Your API key. - `OK-ACCESS-SIGN` header (required) — Base64-encoded HMAC-SHA256 signature of the prehash string. - `OK-ACCESS-TIMESTAMP` header (required) — ISO 8601 UTC timestamp, e.g. 2020-12-08T09:08:57.715Z. - `OK-ACCESS-PASSPHRASE` header (required) — The passphrase you set when creating the API key. ## Request ### Body (application/json) This endpoint expects an object. - `stgyName` (string, required) — Custom name for trading bot, no more than 40 characters - `recurringList` (list of ApiV5TradingBotRecurringOrderAlgoPostRequestBodyContentApplicationJsonSchemaRecurringListItems, required) — Recurring buy info - `period` (enum, required) — Period `monthly` `weekly` `daily` `hourly` - Allowed values: `monthly`, `weekly`, `daily`, `hourly` - `recurringTime` (string, required) — Recurring buy time, the value range is an integer of [0,23] When the period is `hourly`, the parameter is the time of the first investment occurs. - `timeZone` (string, required) — UTC time zone, the value range is an integer of [-12,14] e.g. "8" representing UTC+8 (East 8 District), Beijing Time - `amt` (string, required) — Quantity invested per cycle - `investmentCcy` (enum, required) — The invested quantity unit, can only be `USDT`/`USDC` - Allowed values: `USDT`, `USDC` - `tdMode` (enum, required) — Trading mode Margin mode: `cross` Non-Margin mode: `cash` - Allowed values: `cross`, `cash` - `recurringDay` (string, optional) — Recurring buy date When the period is `monthly`, the value range is an integer of [1,28] When the period is `weekly`, the value range is an integer of [1,7] When the period is `daily`/`hourly`, the parameter is not required. - `recurringHour` (enum, optional) — Recurring buy by hourly `1`/`4`/`8`/`12`, e.g. `4` represents "recurring buy every 4 hour" When the period is `hourly`, the parameter is required. - Allowed values: `0`, `6`, `12`, `18` - `algoClOrdId` (string, optional) — Client-supplied Algo ID There will be a value when algo order attaching algoClOrdId is triggered, or it will be "". A combination of case-sensitive alphanumerics, all numbers, or all letters of up to 32 characters. - `tag` (string, optional) — Order tag A combination of case-sensitive alphanumerics, all numbers, or all letters of up to 16 characters. - `tradeQuoteCcy` (string, optional) — The quote currency for trading. ## Response ### 200 Successful response - `code` (string, optional) — Result code. `0` means success; any other value is an error code. - `msg` (string, optional) — Error message. Empty on success. - `data` (list of ApiV5TradingBotRecurringOrderAlgoPostResponsesContentApplicationJsonSchemaDataItems, optional) ## Types ### ApiV5TradingBotRecurringOrderAlgoPostRequestBodyContentApplicationJsonSchemaRecurringListItems - `ccy` (string, optional) — Currency to invest in, e.g. BTC. - `ratio` (string, optional) — Proportion of the amount allocated to this currency, e.g. 0.2 for 20%. ### ApiV5TradingBotRecurringOrderAlgoPostResponsesContentApplicationJsonSchemaDataItems - `algoId` (string, optional) — Algo ID - `algoClOrdId` (string, optional) — Client-supplied Algo ID - `sCode` (string, optional) — The code of the event execution result, 0 means success - `sMsg` (string, optional) — Rejection message if the request is unsuccessful ## Examples **Request** ```json { "stgyName": "BTC-ETH DCA", "recurringList": [ {} ], "period": "weekly", "recurringTime": "12", "timeZone": "8", "amt": "100", "investmentCcy": "USDT", "tdMode": "cash" } ``` **Response** ```json { "code": "0", "msg": "", "data": [ { "algoId": "560472804207104000", "algoClOrdId": "", "sCode": "0", "sMsg": "", "tag": "" } ] } ``` **SDK Code** ```python gridTrading_placeRecurringOrder_example import requests url = "https://www.okx.com/api/v5/tradingBot/recurring/order-algo" payload = { "stgyName": "BTC-ETH DCA", "recurringList": [{}], "period": "weekly", "recurringTime": "12", "timeZone": "8", "amt": "100", "investmentCcy": "USDT", "tdMode": "cash" } headers = { "OK-ACCESS-KEY": "", "Content-Type": "application/json" } response = requests.post(url, json=payload, headers=headers) print(response.json()) ``` ```javascript gridTrading_placeRecurringOrder_example const url = 'https://www.okx.com/api/v5/tradingBot/recurring/order-algo'; const options = { method: 'POST', headers: {'OK-ACCESS-KEY': '', 'Content-Type': 'application/json'}, body: '{"stgyName":"BTC-ETH DCA","recurringList":[{}],"period":"weekly","recurringTime":"12","timeZone":"8","amt":"100","investmentCcy":"USDT","tdMode":"cash"}' }; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` ```go gridTrading_placeRecurringOrder_example package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://www.okx.com/api/v5/tradingBot/recurring/order-algo" payload := strings.NewReader("{\n \"stgyName\": \"BTC-ETH DCA\",\n \"recurringList\": [\n {}\n ],\n \"period\": \"weekly\",\n \"recurringTime\": \"12\",\n \"timeZone\": \"8\",\n \"amt\": \"100\",\n \"investmentCcy\": \"USDT\",\n \"tdMode\": \"cash\"\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("OK-ACCESS-KEY", "") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` ```ruby gridTrading_placeRecurringOrder_example require 'uri' require 'net/http' url = URI("https://www.okx.com/api/v5/tradingBot/recurring/order-algo") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["OK-ACCESS-KEY"] = '' request["Content-Type"] = 'application/json' request.body = "{\n \"stgyName\": \"BTC-ETH DCA\",\n \"recurringList\": [\n {}\n ],\n \"period\": \"weekly\",\n \"recurringTime\": \"12\",\n \"timeZone\": \"8\",\n \"amt\": \"100\",\n \"investmentCcy\": \"USDT\",\n \"tdMode\": \"cash\"\n}" response = http.request(request) puts response.read_body ``` ```java gridTrading_placeRecurringOrder_example import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://www.okx.com/api/v5/tradingBot/recurring/order-algo") .header("OK-ACCESS-KEY", "") .header("Content-Type", "application/json") .body("{\n \"stgyName\": \"BTC-ETH DCA\",\n \"recurringList\": [\n {}\n ],\n \"period\": \"weekly\",\n \"recurringTime\": \"12\",\n \"timeZone\": \"8\",\n \"amt\": \"100\",\n \"investmentCcy\": \"USDT\",\n \"tdMode\": \"cash\"\n}") .asString(); ``` ```php gridTrading_placeRecurringOrder_example request('POST', 'https://www.okx.com/api/v5/tradingBot/recurring/order-algo', [ 'body' => '{ "stgyName": "BTC-ETH DCA", "recurringList": [ {} ], "period": "weekly", "recurringTime": "12", "timeZone": "8", "amt": "100", "investmentCcy": "USDT", "tdMode": "cash" }', 'headers' => [ 'Content-Type' => 'application/json', 'OK-ACCESS-KEY' => '', ], ]); echo $response->getBody(); ``` ```csharp gridTrading_placeRecurringOrder_example using RestSharp; var client = new RestClient("https://www.okx.com/api/v5/tradingBot/recurring/order-algo"); var request = new RestRequest(Method.POST); request.AddHeader("OK-ACCESS-KEY", ""); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"stgyName\": \"BTC-ETH DCA\",\n \"recurringList\": [\n {}\n ],\n \"period\": \"weekly\",\n \"recurringTime\": \"12\",\n \"timeZone\": \"8\",\n \"amt\": \"100\",\n \"investmentCcy\": \"USDT\",\n \"tdMode\": \"cash\"\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` ```swift gridTrading_placeRecurringOrder_example import Foundation let headers = [ "OK-ACCESS-KEY": "", "Content-Type": "application/json" ] let parameters = [ "stgyName": "BTC-ETH DCA", "recurringList": [[]], "period": "weekly", "recurringTime": "12", "timeZone": "8", "amt": "100", "investmentCcy": "USDT", "tdMode": "cash" ] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://www.okx.com/api/v5/tradingBot/recurring/order-algo")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = postData as Data let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ```