Skip to content
This repository has been archived by the owner on Jul 23, 2024. It is now read-only.

Login CommandFailed: command failed #2

Open
Rohanlogs opened this issue Apr 10, 2020 · 5 comments
Open

Login CommandFailed: command failed #2

Rohanlogs opened this issue Apr 10, 2020 · 5 comments

Comments

@Rohanlogs
Copy link

Hey, I'm having trouble logging in:

from XTBApi.api import Client

client = Client()
client.login("{[email protected]}", "{password}") #demo by default

print('market: ', client.check_if_market_open([EURUSD]) )

# BUY ONE VOLUME (FOR EURUSD THAT CORRESPONDS TO 100000 units)
client.open_trade('buy', EURUSD, 1)

# SEE IF ACTUAL GAIN IS ABOVE X THEN CLOSE THE TRADE
trades = client.update_trades() # GET CURRENT TRADES
trade_ids = [trade_id for trade_id in trades.keys()]
for trade in trade_ids:
    actual_profit = client.get_trade_profit(trade) # CHECK PROFIT
    if actual_profit >= 50:
        print('closing..', client.close_trade(trade) ) # CLOSE TRADE

client.close_all_trades()
client.logout()

Its throwing this error:

2020-04-10 12:34:21 - DEBUG - XTBApi.api - BaseClient inited
2020-04-10 12:34:21 - INFO - XTBApi.api.Client - Client inited
2020-04-10 12:34:21 - DEBUG - XTBApi.api.Client - took 0.6212158203125 s.
Traceback (most recent call last):
  File "...\XTBApi\api.py", line 151, in login
    response = self._send_command(data)
  File "...\XTBApi\api.py", line 137, in _send_command
    raise CommandFailed(res)
XTBApi.exceptions.CommandFailed: command failed

Process finished with exit code 1
@Djaramillo39
Copy link

Bear in mind that your your login information is different than that you use to enter the xStation platform

@lemassykoi
Copy link

which type of login should be used ? the one with mail address or the numeric one ?
neither one is working for me

@lemassykoi
Copy link

please ?

@lemassykoi
Copy link

I finally find an answer :

#!/usr/bin/env python3

from XTBApi.api import Client

client = Client()
client.login("1234567", "myPassword", mode="real")

print('market: ', client.check_if_market_open(['EURUSD']) )
client.logout()

is working.

@Danielization
Copy link

"user_id" should be the account number that xStation5 provided, not the email address you registered.

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

No branches or pull requests

4 participants