Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getCandles listener never gets triggered #16

Closed
solarfrantz opened this issue Apr 24, 2021 · 3 comments
Closed

getCandles listener never gets triggered #16

solarfrantz opened this issue Apr 24, 2021 · 3 comments

Comments

@solarfrantz
Copy link

solarfrantz commented Apr 24, 2021

I've tried to get the realtime candles, even waited more the one minute as the official docs says and apparently the listener never gets called, see the code from below:

const x = new XAPI.default({
    accountId: <MY-ACCOUNT-ID>,
    password: <MY-PASSWORD>,
    type: 'demo' // or demo
});

x.connect();

x.onReady(async () => {
    console.log('Connection is ready');

    x.Stream.listen.getCandles((data) => {
        // THIS IS NEVER REACHED
        console.log("GOT DATA", data);
    });

    x.Stream.subscribe.getCandles('BITCOIN')
        .catch(() => { console.error('subscribe for BITCOIN failed')});

})

Am I doing something wrong ?

PS: getTickPrices works as expected

@peterszombati
Copy link
Owner

Hi @solarfrantz
I found the bug,
its caused by xOpenHub server logic.

for quick fix you have to do this request before subscribe for candles

x.getPriceHistory({
  symbol: 'BITCOIN',
  period: PERIOD_FIELD.PERIOD_M1,
  ticks: -1
})

I close this ticket and create another one

@peterszombati
Copy link
Owner

I created a new issue related to this: #17

@solarfrantz
Copy link
Author

That's very odd, have you tried also submitting a bug on their API's, maybe they'll fix it and we won't have to do this ugly workaround ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants