# External Settlement

## External system adjustment

> 1: When a user places an order within a platform, the platform will send this request to an external system. This request must be replied to within 3 seconds, otherwise the platform will consider it as a timeout and cancel the operation, while also sending a 'cancel external system adjustment' to the external system to maintain data consistency. 2: Special note, when calling the 'cancel external system adjustment' interface, if an exception occurs or the correct response is not received, it will retry a specified number of times and then abort subsequent operations.  !\[]\(<https://www.processon.com/view/link/64a4e5122383dc0d3e2b982c>)

```json
{"openapi":"3.0.1","info":{"title":"Default module","version":"1.0.0"},"tags":[{"name":"External Settlement"}],"servers":[{"url":"https://prewppc-3.cmfbl.com/api","description":"PRE测试公司439"}],"security":[],"paths":{"/":{"post":{"summary":"External system adjustment","deprecated":false,"description":"1: When a user places an order within a platform, the platform will send this request to an external system. This request must be replied to within 3 seconds, otherwise the platform will consider it as a timeout and cancel the operation, while also sending a 'cancel external system adjustment' to the external system to maintain data consistency. 2: Special note, when calling the 'cancel external system adjustment' interface, if an exception occurs or the correct response is not received, it will retry a specified number of times and then abort subsequent operations.  ![](https://www.processon.com/view/link/64a4e5122383dc0d3e2b982c)","tags":["External Settlement"],"parameters":[{"name":"trace","in":"header","description":"Global link identifier","required":true,"schema":{"type":"string"}},{"name":"companyId","in":"header","description":"Company Id, country where the user is located","required":false,"schema":{"type":"integer"}},{"name":"timestamp","in":"header","description":"Request initiation timestamp, accurate to the millisecond, 13 digits","required":true,"schema":{"type":"number"}}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"thirdServerCode":{"type":"string","description":"Unique customer number for third-party systems"},"userName":{"type":"string","description":"TradeBoss user identity unique number","title":"","maxLength":48},"currency":{"type":"string","description":"Account currency code, standard ISO 3-character currency unit","title":"","maxLength":16},"bizType":{"type":"integer","description":"Business type, 1-Market price open; 2-Market price close; 10-Limit price pending order; 11-Stop loss pending order; 12-Limit price open"},"operationType":{"type":"string","description":"Operation type, OPEN_POSITION=Opening position, NORMAL_CLOSE=Normal closing, ABNORMAL_OVERTRADING=Abnormal overtrading. When it is NORMAL_CLOSE or OPEN_POSITION, the amount can only be a positive number; when it is ABNORMAL_OVERTRADING, the amount is a negative number. The external system can independently decide whether to continue deducting the quota to complete this transaction, or ignore this request."},"amount":{"type":"string","description":"Amount, combined with operationType"},"amountDigits":{"type":"integer","description":"Amount decimal places"},"orderId":{"type":"integer","format":"long","description":"Order ID"},"requestUniqueNo":{"type":"string","description":"Request unique number, multiple requests need to maintain business idempotence","maxLength":48},"requestTime":{"type":"integer","format":"long","description":"Request initiation timestamp, accurate to the millisecond, 13 digits"},"ip":{"type":"string","description":"User IP"},"metadata":{"type":"string","description":"Remarks, JSON format","maxLength":200}},"required":["currency","userName","amount","requestUniqueNo","ip","requestTime","amountDigits","bizType","operationType","orderId","thirdServerCode"]}}}},"responses":{"200":{"description":"","content":{"application/json":{"schema":{"type":"object","properties":{"bizCode":{"type":"string","description":"Module identifier code, the service module that the current request will ultimately process, can be empty"},"code":{"type":"string","description":"Status return code, code=0, indicates the current request operation is successful, other codes indicate operation failure"},"msg":{"type":"string","description":"Status description"},"tm":{"type":"integer","format":"int64","description":"Processing time (milliseconds)"},"trace":{"type":"string","description":"Global link flag, consistent with the trace in the request header, for easy problem location"},"msgParams":{"type":"string","description":"Placeholder parameter string in the return status description, multiple parameters separated by commas, used to handle variable information in the status description, providing a user-friendly interactive experience"},"data":{"type":"object","properties":{},"description":"Response result body"},"ok":{"type":"boolean","description":"Operation success, true=success, false=failure"},"fail":{"type":"boolean","description":"Operation failure, true=success, false=failure"}}}}},"headers":{}}}}}}}
```

## Transfer to CP when closing position

> When a member has finished a game they have bet on and has a net win amount, CATS2 will send this request to the CP system. The CP system needs to adjust the member's account balance. This request will be sent continuously until it is processed and responded to correctly.

```json
{"openapi":"3.0.1","info":{"title":"Default module","version":"1.0.0"},"tags":[{"name":"External Settlement"}],"servers":[{"url":"https://prewppc-3.cmfbl.com/api","description":"PRE测试公司439"}],"security":[],"paths":{"/global/tradeapi.app.OrderApiService.queryPBOOrderPage":{"post":{"summary":"Transfer to CP when closing position","deprecated":true,"description":"When a member has finished a game they have bet on and has a net win amount, CATS2 will send this request to the CP system. The CP system needs to adjust the member's account balance. This request will be sent continuously until it is processed and responded to correctly.","tags":["External Settlement"],"parameters":[{"name":"companyId","in":"header","description":"","required":false,"schema":{"type":"string"}},{"name":"token","in":"header","description":"","required":false,"schema":{"type":"string"}},{"name":"lang","in":"header","description":"","required":false,"schema":{"type":"string"}},{"name":"group","in":"header","description":"","required":false,"schema":{"type":"string"}},{"name":"trace","in":"header","description":"","required":false,"schema":{"type":"string"}},{"name":"version","in":"header","description":"","required":false,"schema":{"type":"string"}}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"username":{"type":"string","description":"Unique customer identity number","title":"","maxLength":48},"currency":{"type":"string","description":"Account currency code, standard ISO 3-character currency unit","title":"","maxLength":16},"amount":{"type":"string","description":"Operation amount"},"amountDigist":{"type":"integer","description":"Amount decimal places"},"txid":{"type":"string","description":"Unique transaction number, business idempotent needs to be maintained for multiple requests","maxLength":48},"requesttime":{"type":"integer","format":"long","description":"Request initiation timestamp, accurate to the millisecond, 13 digits"},"ip":{"type":"string","description":"User IP"},"remark":{"type":"string","description":"Third-party business remark information","maxLength":200}},"required":["currency","username","amount","txid","remark","ip","amountDigist"]}}}},"responses":{"200":{"description":"","content":{"application/json":{"schema":{"type":"object","properties":{"bizCode":{"type":"string","description":"Module identifier code"},"code":{"type":"string","description":"Status Return Code, code=0 indicates current request operation success, other codes handle exceptions"},"msg":{"type":"string","description":"Status description"},"tm":{"type":"integer","format":"int64","description":"Processing time (milliseconds)"},"trace":{"type":"string","description":"Tracking code"},"msgParams":{"type":"string","description":"Placeholder parameter string in return description, multiple parameters separated by commas"},"data":{"type":"object","properties":{},"description":"Message body"},"ok":{"type":"boolean"},"fail":{"type":"boolean"}}}}},"headers":{}}}}}}}
```

## Cancel external system adjustment

> When an 'external system adjustment' request times out or the external system returns an error message, the platform will send this request to the external system to ensure data consistency.

```json
{"openapi":"3.0.1","info":{"title":"Default module","version":"1.0.0"},"tags":[{"name":"External Settlement"}],"servers":[{"url":"https://prewppc-3.cmfbl.com/api","description":"PRE测试公司439"}],"security":[],"paths":{"/get-user-amount":{"post":{"summary":"Cancel external system adjustment","deprecated":false,"description":"When an 'external system adjustment' request times out or the external system returns an error message, the platform will send this request to the external system to ensure data consistency.","tags":["External Settlement"],"parameters":[{"name":"trace","in":"header","description":"Global link identifier","required":true,"schema":{"type":"string"}},{"name":"companyId","in":"header","description":"Company Id, country where the user is located","required":false,"schema":{"type":"integer"}},{"name":"timestamp","in":"header","description":"Request initiation timestamp, accurate to the millisecond, 13 digits","required":true,"schema":{"type":"number"}}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"thirdServerCode":{"type":"string","description":"Unique customer number for third-party systems"},"userName":{"type":"string","description":"TradeBoss user identity unique number","title":"","maxLength":48},"currency":{"type":"string","description":"Account currency code, standard ISO 3-character currency unit","title":"","maxLength":16},"bizType":{"type":"integer","description":"Business type, 1-Market price open; 2-Market price close; 10-Limit price pending order; 11-Stop loss pending order; 12-Limit price open"},"amount":{"type":"string","description":"Amount, can only be a positive number"},"amountDigits":{"type":"integer","description":"Amount decimal places"},"orderId":{"type":"integer","format":"long","description":"Order ID"},"requestUniqueNo":{"type":"string","description":"Request unique number, multiple requests need to maintain business idempotence","maxLength":48},"reverseRequestUniqueNo":{"type":"string","description":"This number corresponds to the requestUniqueNo when the 'external system adjusts the amount' request was made. The external system needs to check if this number has been processed. If processed correctly, the correct amount needs to be returned to the client; if the request was received but not processed correctly, return code=US_0000001. If no request with this number was received, return code=US_0000002"},"requestTime":{"type":"integer","format":"long","description":"Request initiation timestamp, accurate to the millisecond, 13 digits"},"ip":{"type":"string","description":"User IP"},"cancelRemark":{"type":"string","description":"Cancellation reason","maxLength":200},"metadata":{"type":"string","description":"Remarks, JSON format","maxLength":200}},"required":["currency","userName","amount","requestUniqueNo","ip","requestTime","amountDigits","bizType","cancelRemark","reverseRequestUniqueNo"]}}}},"responses":{"200":{"description":"","content":{"application/json":{"schema":{"type":"object","properties":{"bizCode":{"type":"string","description":"Module identifier code, the service module that the current request will ultimately process, can be empty"},"code":{"type":"string","description":"Status return code, code=0, indicates the current request operation is successful, other codes indicate operation failure"},"msg":{"type":"string","description":"Status description"},"tm":{"type":"integer","format":"int64","description":"Processing time (milliseconds)"},"trace":{"type":"string","description":"Global link flag, consistent with the trace in the request header, for easy problem location"},"msgParams":{"type":"string","description":"Placeholder parameter string in the return status description, multiple parameters separated by commas, used to handle variable information in the status description, providing a user-friendly interactive experience"},"data":{"type":"object","properties":{},"description":"Response result body"},"ok":{"type":"boolean","description":"Operation success, true=success, false=failure"},"fail":{"type":"boolean","description":"Operation failure, true=success, false=failure"}}}}},"headers":{}}}}}}}
```

## External System Credit Limit Adjustment

> 1: When a user places an order within the TradeBoss platform, the platform sends this request to an external system. The external system must respond within 3 seconds, otherwise the TradeBoss platform will consider it as a timeout and cancel the operation. At the same time, it will also send a "Cancel external system credit limit adjustment" request to maintain data consistency with the external system.\
> \
> 2: It is important to note that when calling the "Cancel external system credit limit adjustment" interface, if any exceptions occur or if a correct response is not received, there will be specified retries before aborting subsequent operations.<br>

```json
{"openapi":"3.0.1","info":{"title":"Default module","version":"1.0.0"},"tags":[{"name":"External Settlement"}],"servers":[{"url":"https://prewppc-3.cmfbl.com/api","description":"PRE测试公司439"}],"security":[],"paths":{"/external-system-credit-limit-adjustment":{"post":{"summary":"External System Credit Limit Adjustment","deprecated":false,"description":"1: When a user places an order within the TradeBoss platform, the platform sends this request to an external system. The external system must respond within 3 seconds, otherwise the TradeBoss platform will consider it as a timeout and cancel the operation. At the same time, it will also send a \"Cancel external system credit limit adjustment\" request to maintain data consistency with the external system.\n\n2: It is important to note that when calling the \"Cancel external system credit limit adjustment\" interface, if any exceptions occur or if a correct response is not received, there will be specified retries before aborting subsequent operations.\n","tags":["External Settlement"],"parameters":[{"name":"trace","in":"header","description":"Global Link Identifier.","required":true,"schema":{"type":"string"}},{"name":"companyId","in":"header","description":"Company Id,User's company ID","required":true,"schema":{"type":"integer"}},{"name":"timestamp","in":"header","description":"Request initiation timestamp, accurate to the millisecond, 13 digits.","required":true,"schema":{"type":"number"}}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"thirdServerCode":{"type":"string","description":"Third-party system customer unique identifier"},"userName":{"type":"string","title":"","maxLength":48,"description":"TradeBoss user identity unique identifier"},"currency":{"type":"string","title":"","maxLength":16,"description":"Account currency code, standard ISO 3-character currency unit."},"bizType":{"type":"integer","description":"Business types: 1 - Market order open; 2 - Market order close; 10 - Limit price stop order; 11 - Stop loss stop order; 12 - Limit price open"},"operationType":{"type":"string","description":"The operation types are OPEN_POSITION for opening a position, NORMAL_CLOSE for normal closing, and ABNORMAL_OVERTRADING for abnormal overtrading. When the operation type is NORMAL_CLOSE or OPEN_POSITION, the amount can only be a positive number. When it is ABNORMAL_OVERTRADING, the amount should be negative. The third-party system can decide whether to continue deducting quotas to complete this transaction or ignore this request."},"amount":{"type":"string","description":"Amount, used in conjunction with operationType."},"amountDigits":{"type":"integer","description":"Amount decimal places."},"orderId":{"type":"integer","format":"long","description":"Order ID."},"requestUniqueNo":{"type":"string","maxLength":48,"description":"Request for a unique identifier, multiple requests need to maintain business idempotence."},"requestTime":{"type":"integer","format":"long","description":"Request initiation timestamp, accurate to the millisecond, 13 digits"},"ip":{"type":"string","description":"User IP"},"metadata":{"type":"string","description":"Remarks information, in JSON format.","maxLength":200}},"required":["currency","userName","amount","requestUniqueNo","ip","requestTime","amountDigits","bizType","operationType","orderId","thirdServerCode"]}}}},"responses":{"200":{"description":"","content":{"application/json":{"schema":{"type":"object","properties":{"bizCode":{"type":"string","description":"Module identification code, the service module that ultimately handles the current request, can be empty."},"code":{"type":"string","description":"Status return code, code=0 indicates the current request operation is successful, other codes indicate operation failure."},"msg":{"type":"string","description":"Status Description."},"tm":{"type":"integer","format":"int64","description":"Processing Time (Milliseconds)"},"trace":{"type":"string","description":"The global link identifier is consistent with the trace in the request header, which facilitates problem localization."},"msgParams":{"type":"string","description":"Return the placeholder parameter string in the status description, with multiple parameters separated by commas, used to process variable information in the status description and provide a user-friendly interactive experience."},"data":{"type":"object","properties":{},"description":"Response body."},"ok":{"type":"boolean","description":"The operation was successful if true, and failed if false."},"fail":{"type":"boolean","description":"The operation was successful if false, and failed if true."}}}}},"headers":{}}}}}}}
```

## Cancel external system credit limit adjustment

> When "External System Credit Limit Adjustment", if the request times out or the external system returns an error message, TradeBoss platform will send this request to the external system in order to maintain data consistency.

```json
{"openapi":"3.0.1","info":{"title":"Default module","version":"1.0.0"},"tags":[{"name":"External Settlement"}],"servers":[{"url":"https://prewppc-3.cmfbl.com/api","description":"PRE测试公司439"}],"security":[],"paths":{"/cancel-external-system-credit-limit-adjustment":{"post":{"summary":"Cancel external system credit limit adjustment","deprecated":false,"description":"When \"External System Credit Limit Adjustment\", if the request times out or the external system returns an error message, TradeBoss platform will send this request to the external system in order to maintain data consistency.","tags":["External Settlement"],"parameters":[{"name":"trace","in":"header","description":"Global Link Identifier.","required":true,"schema":{"type":"string"}},{"name":"companyId","in":"header","description":"Company Id,User's company ID","required":true,"schema":{"type":"integer"}},{"name":"timestamp","in":"header","description":"Request initiation timestamp, accurate to the millisecond, 13 digits.","required":false,"schema":{"type":"number"}}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"thirdServerCode":{"type":"string","description":"Third-party system customer unique identifier"},"userName":{"type":"string","description":"TradeBoss user identity unique identifier","title":"","maxLength":48},"currency":{"type":"string","description":"Account currency code, standard ISO 3-character currency unit","title":"","maxLength":16},"bizType":{"type":"integer","description":"Business type, 1-market price opening; 2-market price closing; 10-limit price pre-embedded order; 11-stop loss pre-embedded order; 12-limit price opening"},"amount":{"type":"string","description":"Amount, can only be positive"},"amountDigits":{"type":"integer","description":"Amount decimal places"},"orderId":{"type":"integer","format":"long","description":"Order ID"},"requestUniqueNo":{"type":"string","description":"Request unique number, multiple requests need to maintain business idempotence.","maxLength":48},"reverseRequestUniqueNo":{"type":"string","description":"This number corresponds to the request_unique_no when the \"third-party system transfer\" was requested earlier. The third-party system needs to check whether this number has been processed. If it is correctly processed, it needs to return the correct amount to the customer. If a request is received but not processed correctly, return code=US_0000001. If no request with this number is received, return code=US_0000002."},"requestTime":{"type":"integer","format":"long","description":"Request initiation timestamp accurate up to milliseconds and in a format of 13 digits."},"ip":{"type":"string","description":"User IP address"},"cancelRemark":{"type":"string","description":"Cancellation reason","maxLength":200},"metadata":{"type":"string","description":"Remarks information in JSON format","maxLength":200}},"required":["currency","userName","amount","requestUniqueNo","ip","requestTime","amountDigits","bizType","cancelRemark","reverseRequestUniqueNo","thirdServerCode"]}}}},"responses":{"200":{"description":"","content":{"application/json":{"schema":{"type":"object","properties":{"bizCode":{"type":"string","description":"Module identification code, the service module that ultimately processes the current request, can be empty."},"code":{"type":"string","description":"The status return code, code=0, indicates that the current request operation is successful. Other codes indicate operation failure."},"msg":{"type":"string","description":"Status Description."},"tm":{"type":"integer","format":"int64","description":"Processing Time (Milliseconds)"},"trace":{"type":"string","description":"Global link identifier, consistent with the trace in the request header for easy problem locating."},"msgParams":{"type":"string","description":"Return the placeholder parameter string in the status description, with multiple parameters separated by commas, used to process variable information in the status description and provide a user-friendly interactive experience."},"data":{"type":"object","properties":{},"description":"Response Body"},"ok":{"type":"boolean","description":"The operation was successful if true, and failed if false."},"fail":{"type":"boolean","description":"The operation was successful if false, and failed if true."}}}}},"headers":{}}}}}}}
```
