peterszombati / xapi-node

xStation5 Trading API for NodeJS/JS
https://peterszombati.github.io/xapi-node/
Other
58 stars 19 forks source link

x.Stream.subscribe.getCandles bug (caused by xOpenHub server side logic) #17

Open peterszombati opened 3 years ago

peterszombati commented 3 years ago

x.Stream.subscribe.getCandles doesn't working if you didn't do a price history request for specific symbol example with BITCOIN:

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

It won't work. You have to do a request to BITCOIN price history then subscribe for candles example with BITCOIN:

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

x.Stream.subscribe.getCandles('BITCOIN')
        .catch(() => { console.error('subscribe for BITCOIN failed')});
solarfrantz commented 3 years ago

Is there anything you can do on your library side that is not a tiny hack since the root 'cause is located on XTB side ? I'm curious, have you tried submitting a bug (through their help desk) on their side ? PS: So far locally, I've found a better solution to do realtime computation of the candles based on the getTickPrices subscription, so I don't have to wait a minute to get a notification from their websocket.

peterszombati commented 3 years ago

Hi @solarfrantz Today I sent an email to support @ xhub . pro

peterszombati commented 3 years ago

@solarfrantz btw they still didn't respond to me, I'm 100% they won't do any changes on their side:)

wtld commented 2 years ago

That's weird because Python code works fine:

import sys
import time
from xAPIConnector import APIClient, APIStreamClient, loginCommand

userId = 999999
password = 'blabla'

client = APIClient()

loginResponse = client.execute(loginCommand(userId=userId, password=password))

if not loginResponse['status']:
    print('Login failed. Error code: {0}'.format(loginResponse['errorCode']))
    sys.exit()

ssid = loginResponse['streamSessionId']

sclient = APIStreamClient(ssId=ssid)

sclient.execute(dict(command='getCandles', symbol='EURUSD', streamSessionId=ssid))

# make it run for 5 minutes
time.sleep(300)

sclient.disconnect()
client.disconnect()

You need official wrapper (xAPIConnector) from here: http://developers.xstore.pro/api/wrappers/ But I remember that about a year ago getCandles wasn't working at all. Maybe they fixed something?

peterszombati commented 2 years ago

@wtld I will check this later

sznowak commented 2 years ago

@peterszombati any info here?

mb-mb commented 2 years ago

@peterszombati any update about this problem ?

KevinKlima commented 2 years ago

Thank you very much for this information. I thought I was going crazy. Calling getCandle sometimes worked for me, other times it didn't. I wondered in vain where I was going wrong, even though I was sure I hadn't changed any critical code. In desperation I tried Google and the very first link got me here. When I call the getLastChart function, then subscribe starts working. Weird but works for me.

Thanks again for this information!

sgflt commented 5 months ago

2024 and found this issue is still alive. Using https://github.com/sgflt/xapi-websocket-client

damiancyrana commented 4 months ago

2024 i odkryłem, że ten problem jest nadal aktualny. Używając https://github.com/sgflt/xapi-websocket-client

did you manage to solve the problem with Command: getCandles ?

sgflt commented 4 months ago

I just call getChartLastRequest before subscription and it seems to be working.

damiancyrana commented 4 months ago

I just call getChartLastRequest before subscription and it seems to be working.

Thanks, I changed the calling order as you wrote and it worked <3

htimi commented 2 months ago

I'm using python that not working for me too. I have the official wrapper but getCandles not working. Sent email to the support waitin for the answer. I'm the only one in this situation. I try call getChartLastRequest before nothing change. Sad

damiancyrana commented 2 months ago

@htimi You must use getChartLastRequest for M1 interval, before retrieving candles

htimi commented 2 months ago

@damiancyrana thanks it works !!!! Maururu (thanks in Polynesia langage)