Trading features configuration
You can configure trading features using the broker_config
property of the Widget Constructor.
This property is primarily used to specify the configFlags
object, which contains a list of configuration flags.
Some flags only enable or disable trading elements in the UI,
while others activate more advanced features that require corresponding methods to be implemented in the Broker API.
Consider the Widget Constructor with the following properties.
const datafeed = new Datafeeds.UDFCompatibleDatafeed("https://demo-feed-data.tradingview.com");
new TradingView.widget({
container: "chartContainer",
locale: "en",
library_path: "charting_library/",
datafeed: datafeed,
symbol: "AAPL",
interval: "1D",
broker_factory: function(host) { return new Brokers.BrokerSample(host, datafeed); },
broker_config: {
configFlags: {
supportEditAmount: false,
supportOrdersHistory: true,
},
},
})
In the code sample, the supportEditAmount
flag disables the order quantity control in the Order Ticket when users modify orders.
This flag only affects the UI.
The supportOrdersHistory
flag enables the History page in the Account Manager.
On this page, users can see details about all their orders with final statuses.
However, in addition to enabling supportOrdersHistory
, you should also do the following:
- Implement the
ordersHistory
method to provide the library with the user's order history. - Add the
historyColumns
property to theAccountManagerInfo
object to define and display data columns.