3.4Account history

The history on an account - closed trades and credit movements - is potentially (a) very large and (b) time-consuming to collect from the broker's back-end system. The Framework.TradeHistory is empty by default, and must explicitly be filled by using Framework.RequestAccountHistory().

You can be notified when the history loads (or is later added to) in three ways.

Firstly, you can provide a callback to Framework.RequestAccountHistory(). For example:

Framework.RequestAccountHistory(function (response) {

// Framework.TradeHistory will now have been populated.

// If new closed trades are later added to the history, there will be further calls

// to this callback function.

});

Or, you can use the Promise version of the function, pRequestAccountHistory():

await Framework.pRequestAccountHistory();

// Framework.TradeHistory will now have been populated

Or, you can set up a message handler and watch for messages of type ACCOUNT_HISTORY.

There can be a long delay between using Framework.RequestAccountHistory() and receiving the initial history. You may get an almost immediate response (asynchronous) if another widget has already initiated collection of the history or, at the other extreme, there can be a delay of many seconds while the framework has to make multiple calls to the broker server to collect the initial history.

The contents and detail of the history are slightly variable depending on the capabilities of the account. For example, a couple of broker back-end systems can only provide the historic trades on an account, not the credit movements.