fxcm / ForexConnectAPI

Designed to trade, retrieve live/history price. Intended to be used to build auto-trading robots, custom trading on FXCM accounts.
132 stars 47 forks source link

Do you have simplified examples? #16

Closed fintechee closed 1 year ago

fintechee commented 1 year ago

Hi FXCM team,

I hope you are doing well.

I checked https://docs.gehtsoftusa.com/fclite/ Some examples have bugs. For example: https://docs.gehtsoftusa.com/fclite/html/samples/js/get_instruments.js //subscribe to instrument instrumentsManager.subscribeInstrument(instrument); //unsubscribe to instrument instrumentsManager.unsubscribeInstrument(instrument); The "instrument" is undefined.

https://docs.gehtsoftusa.com/fclite/html/samples/js/open_position.js var CompleteLoginConnectionStatusChangeListener = /* @class / function (completeLoginResolve, loginReject, session) { this.completeLoginResolve = completeLoginResolve this.loginReject = loginReject this.session = session

this.onConnectionStatusChange = function (status) {
    if (status.isConnected()) {
        this.session.unsubscribeConnectionStatusChange(this) <-------------------here
        this.completeLoginResolve()
    } else if (status.isDisconnected()) {
        this.session.unsubscribeConnectionStatusChange(this) <-------------------here
        this.loginReject()
    }
}

};

I don't understand why both referred to by arrows call unsubscribeConnectionStatusChange.

And, each example will logout just after logging in, which makes most of them hard to understand why and how. Do you have simplified examples? It would be better if we don't need to log out immediately after logging in.

Many thanks.

fxcm-dhalpert commented 1 year ago

the instrument should be defined as array of symbols, for example: instrument = ["GBP/USD", "NAS100"]

add "s" to functions subscribeInstrument and unsubscribeInstrument, like: subscribeInstruments, unsubscribeInstruments

fintechee commented 1 year ago

Hi Daniel,

Thank you for your answer.

Why were the codes in the first example causing the subscription to be cancelled immediately after it was subscribed? Why does the second example call “unsubscribeConnectionStatusChange” in both the connected and disconnected conditions?

Can you provide more simplified examples? Many thanks.

fxcm-dhalpert commented 1 year ago

This sample code just shows how to subscribe and unsubscribe for array of symbols, a real program probably won't be calling both functions at the same time, each function would be triggered by something else, like user input.

fintechee commented 1 year ago

Thank you for your fast response. I saw each example call “unsubscribeConnectionStatusChange” in both the connected and disconnected conditions. Is this a standard usage?

fxcm-dhalpert commented 1 year ago

it just shows how to use listener with subscribeConnectionStatusChange, you can change the unsubscribeConnectionStatusChange() under if (status.isConnected()) to subscribeConnectionStatusChange() https://docs.gehtsoftusa.com/fclite/#IFXConnectLiteSession.html

fintechee commented 1 year ago

Thank you, Daniel.

FXCMAPI commented 1 year ago

close this.