Skip to content

Request a Customer Account Statement Report

Overview

The article describes how to request customer account statement reports.

Reports can show you information about your account activity, balance, orders, and trades for a specified period. To request a report, you need to use the getReportUrl method of the ISystemSettingsProvider object.

How to request a report

In this article you will learn how to use the API to get an instrument using its symbol as the reference.

To get an instrument using its symbol, you need to follow these steps:

  1. Login (see the tutorial Here)

  2. Get the URL of the report.

  3. Use the method.

  1. Login (see the tutorial Here)

  2. Get the URL of the report.

  3. Use the method.

  4. Get a report.

  1. Login (see the tutorial Here)

  2. Get the URL of the report.

  3. Use the method.

  4. Get a report.

Step 1: Login

Follow the steps in the login tutorial Here

Step 2: Get the URL of the report

    function getReportUrl(account, from, to, type, format, langID, callback)
    function getReportUrl(account, from, to, type, format, langID, callback)

To get the URL for the report, we call the getReportUrl() method like this

session.getSystemSettingsProvider().getReportUrl(session.getAccountsManager().getAccountsInfo()[0],
    from, to,
    ReportType.CUSTOMER_ACCOUNT_STATEMENT,
    ReportFormat.HTML,
    "enu",
    new ReportsManagerCallback(this));
However before we do this, we need to perform a few other operations, like adding the DIV where the link to the report will be displayed.
<div class="row mt-3" id="reports" style="display: none;">
    <div class="offset-sm-3 col-sm-12 pb-1" style="font-size: larger;">Reports <button id="refreshReports" class="btn btn-outline-secondary">Refresh</button> <span id="reportsState"></span></div>
    <div id="reportList" class="col-sm-12 border pt-0 pb-3 mt-0" style="display: none; border-color: #adb5bd; background-color: #fff; max-height: 300px; overflow: auto;">
    </div>
</div>
Now that we have the DIv, we need to add some new items to the start of our custom.js file. These will be used as parameters for the report url generator.
const ReportType = FCLite.ReportType
const ReportFormat = FCLite.ReportFormat
let to;
let from;
Next we will need to create the worker class that will generate the HTML that generated and injects the link into our page.
class ReportsWorker {
    showReport(url) {
        let row = document.createElement("div");
        row.className = "row mb-3";
        let col1 = document.createElement("div");
        col1.className = "col-sm-2";
        let col2 = document.createElement("div");
        col2.className = "col-sm-3";

        $("#reportList").empty();
        let htmlurl = '<a href="'+url+'">Click Here to Open Report</a>';
        $(col1).html(htmlurl);

        $(row).append($(col1));
        $("#reportList").append($(row));

        $("#reportList").show();
    }

    getDataManagerStateString(status) {
        return (status.isNotLoaded() ? "Not loaded" : "") +
            (status.isLoading() ? "Loading" : "") +
            (status.isLoaded() ? "Loaded" : "") +
            (status.hasError() ? " (has error)" : "");
    }

    getClass(oldValue, newValue) {
        if (parseFloat(oldValue) < newValue) {
            return 'greater'
        } else if (parseFloat(oldValue) > newValue) {
            return 'lower'
        }
        return ''
    }
}

This method takes an account object, a start date, an end date, a report type, a report format, a language, and a callback function as arguments. The callback function will receive either an error message or a URL that points to the generated report.

Step 3: Use the method

const main = async () => {
    try {
        // Create and log in to a session
        const session = FXConnectLiteSessionFactory.create('GetUrlSample')
        await login(session, options.user, options.password, options.tradingSystemUrl, options.connectionName)

        // Define a callback function that handles the result of the report request.
        const callback: IGetUrlCallback = {
            onError: function (error: string): void {
                console.log("Error: ", error)
            },
            onSuccess: function (url: string): void {
                console.log("Url: ", url)
            },
        }

        // Get the first account from the accounts manager.


        // Log out and exit
        await logout(session)
    } catch (error) {
        console.log('Failure:', { error })
        process.exit(1)
    }

    process.exit(0)
}
const main = async () => {
    try {
        // Create and log in to a session
        const session = FXConnectLiteSessionFactory.create('GetUrlSample')
        await login(session, options.user, options.password, options.tradingSystemUrl, options.connectionName)

        // Define a callback function that handles the result of the report request
        const callback: IGetUrlCallback = {
            onError: function (error: string): void {
                console.log("Error: ", error)
            },
            onSuccess: function (url: string): void {
                console.log("Url: ", url)
            },
        }

        // Get the first account from the accounts manager


        // Log out and exit
        await logout(session)
    } catch (error) {
        console.log('Failure:', { error })
        process.exit(1)
    }

    process.exit(0)
}       

Step 4: Get a report

//From Date, Now

session.getSystemSettingsProvider().getReportUrl(session.getAccountsManager().getAccountsInfo()[0],
        new Date(2022, 1, 10), new Date(0),
        ReportType.CUSTOMER_ACCOUNT_STATEMENT,
        ReportFormat.HTML,
        "enu",
        callback);

https://fxpa.fxcorporate.com/fxpa/getreport.app/?token=CFDA48A22C4DE939917A4AB9E6A95B1ABF116CDF&cn=U100R8&report_name=REPORT_NAME_CUSTOMER_ACCOUNT_STATEMENT&lc=enu&outFormat=HTML&account=1144007343&from=2/10/2022

//Since Open, To Date

session.getSystemSettingsProvider().getReportUrl(session.getAccountsManager().getAccountsInfo()[0],
        new Date(0), new Date(2022, 1, 15),
        ReportType.CUSTOMER_ACCOUNT_STATEMENT,
        ReportFormat.HTML,
        "enu",
        callback);

https://fxpa.fxcorporate.com/fxpa/getreport.app/?token=2331A83132B3F00DCBDC8254DAFBC17D55ACB946&cn=U100R8&report_name=REPORT_NAME_CUSTOMER_ACCOUNT_STATEMENT&lc=enu&outFormat=HTML&account=1144007343&till=2/15/2022

//Since Open, Now

session.getSystemSettingsProvider().getReportUrl(session.getAccountsManager().getAccountsInfo()[0],
    new Date(0), new Date(0),
        ReportType.CUSTOMER_ACCOUNT_STATEMENT,
        ReportFormat.HTML,
        "enu",
        callback);

https://fxpa.fxcorporate.com/fxpa/getreport.app/?token=ED3065DEF693CA467406203998B7F166C6838C69&cn=U100R8&report_name=REPORT_NAME_CUSTOMER_ACCOUNT_STATEMENT&lc=enu&outFormat=HTML&account=1144007343

Here we will add the jQuery that will be executed when you click the "Get Report" button As you can see, all the user account info is passed to the method by calling the getAccountInfo() method. The parameters that we pass to the getReportUrl() method, are those that we created at the start of the file.

$('#refreshReports').click(function () {      
    from = new Date('2021-07-31');
    to = new Date('2022-08-03');

    session.getSystemSettingsProvider().getReportUrl(session.getAccountsManager().getAccountsInfo()[0],
        from, to,
        ReportType.CUSTOMER_ACCOUNT_STATEMENT,
        ReportFormat.HTML,
        "enu",
        new ReportsManagerCallback(this));
});

Step 4: Get a report

The last parameter in our call to get the report URL was for an instance of the worker callback class. As you can see, here, when we have success, we call our worker classes showReport method which generates the HTML and outputs the link for the user to click.

var ReportsManagerCallback = /** @class */ (function () {
    function ReportsManagerCallback() { 
    }
    ReportsManagerCallback.prototype.onSuccess = function (responseObject) {
        reportsWorker = new ReportsWorker();
        reportsWorker.showReport(responseObject);
    };
    ReportsManagerCallback.prototype.onError = function (errorObject) {  
        console.log(errorObject.getMessage());
    };
    return ReportsManagerCallback;
}());

Provide the following parameters:

Account ID: The unique identifier of the account you want to generate a report for.

Start date and end date: The dates that define the beginning and the end of the report period. You can use any date format that is supported by JavaScript’s Date object.

Report type: The type of report you want to generate. You can choose from different report types, such as CUSTOMER_ACCOUNT_STATEMENT, CUSTOMER_TRADE_ACTIVITY, or CUSTOMER_TRADE_SUMMARY.

Report format: The format of the report output. You can choose from different formats, such as HTML, PDF, or CSV.

Language: The language of the report content. You can use any language code that is supported by FCLite, such as enu for English or deu for German.

Time zone: The time zone of the date and time values in the report. You can either use UTC for universal time or SERVER for the time zone of the server.

When you have got reports, you can:

  1. Subscribe and Unsubscribe to instruments.
  2. Create a market order.
  3. Create an entry order.

Conclusion

In this article you have learned how to request a report with the getReportUrl() method.

Download the sample Node TypeScript, Node JavaScript, JavaScript.

Note

Questions and answers

How exactly can you get a report "From Inception" and "Till Now"?

It's in public method IsystemSettingsProvider.getReportUrl(). To skip the date parameter, you need to specify a year of date.