Skip to navigation

Setting Management

View as MarkdownOpen in Claude

Introduction

Beginning with TWS API 10.44, users are able to view and modify TWS settings via the API. Currently the supported settings include Orders, Precautions, and API Settings. These settings map to those found in TWS’s Global Configuration window.

Important: The Read-Only setting within TWS must be manually disabled before any configuration updates will be permitted.


Request Configuration

EClient.reqConfigProtoBuf(configRequestProto)

Requests the current TWS configuration settings.

configRequestProto
ConfigRequestProto

A ConfigRequestProto object. The reqId field is required to track the request.


from ibapi.protobuf.ConfigRequest_pb2 import ConfigRequest as ConfigRequestProto
configRequestProto = ConfigRequestProto()
configRequestProto.reqId = self.nextOrderId()
self.reqConfigProtoBuf(configRequestProto)

Receive Configuration

EWrapper.configResponseProtoBuf(configResponseProto)

Returns the current TWS configuration settings.

The response object contains the following sub-objects, each representing a section of TWS Global Configuration:

  • LockAndExitConfig — lock and exit settings
  • MessageConfig — message configuration settings
  • ApiConfig — API-specific settings
  • OrdersConfig — order settings including precautionary limits
configResponseProto
ConfigResponseProto

A ConfigResponseProto object containing the full configuration response.


def configResponseProtoBuf(self, configResponseProto):
print("ConfigResponseProtoBuf:", configResponseProto)

Update Configuration

EClient.updateConfigProtoBuf(updateConfigRequestProto)

Sends updated configuration settings to TWS.

updateConfigRequestProto
UpdateConfigRequestProto

An UpdateConfigRequestProto object containing the settings to update.


from ibapi.protobuf.UpdateConfigRequest_pb2 import UpdateConfigRequest as UpdateConfigRequestProto
from ibapi.protobuf.ApiSettingsConfig_pb2 import ApiSettingsConfig as ApiSettingsConfigProto
updateConfigRequestProto = UpdateConfigRequestProto()
updateConfigRequestProto.reqId = self.nextOrderId()
apiSettingsConfigProto = ApiSettingsConfigProto()
apiSettingsConfigProto.createApiMessageLogFile = True
apiSettingsConfigProto.includeMarketDataInLogFile = True
apiSettingsConfigProto.loggingLevel = 5
updateConfigRequestProto.apiSettingsConfig.CopyFrom(apiSettingsConfigProto)
self.updateConfigProtoBuf(updateConfigRequestProto)

Receive Configuration Update Response

EWrapper.updateConfigResponseProtoBuf(updateConfigResponseProto)

Returns the result of a configuration update request.

The response object contains:

  • message — a human-readable summary of what changed
  • changedFields — list of fields that were successfully updated
  • errors — list of any errors encountered during the update
  • UpdateConfigWarning — any warnings related to the update
updateConfigResponseProto
UpdateConfigResponseProto

An UpdateConfigResponseProto object containing the update result.


def updateConfigResponseProtoBuf(self, updateConfigResponseProto):
print("UpdateConfigResponseProtoBuf:", updateConfigResponseProto)