A python based API for XTB trading using websocket_client.
Project description
XTBApi
Api for XTB trading platform.
A python based API for XTB trading using websocket_client.
Installing / Getting started
To install the API, just clone the repository.
git clone git@github.com:federico123579/XTBApi.git
cd XTBApi/
python3 -m venv env
. env/bin/activate
pip install .
Then you can use XTBApi like this simple tutorial.
from XTBApi.api import Client
# FIRST INIT THE CLIENT
client = Client()
# THEN LOGIN
client.login("{user_id}", "{password}", mode={demo,real})
# CHECK IF MARKET IS OPEN FOR EURUSD
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 100 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 >= 100:
client.close_trade(trade) # CLOSE TRADE
# CLOSE ALL OPEN TRADES
client.close_all_trades()
# THEN LOGOUT
client.logout()
Api Reference
REQUIRED - SOON
Documentation still in progess
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file monedadigitalx-1.0a7.post2.tar.gz
.
File metadata
- Download URL: monedadigitalx-1.0a7.post2.tar.gz
- Upload date:
- Size: 8.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.10.11
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | dc896810d19979c0033db70e629abcfa5dca201dfee2fd26cdf0cc908a29d6ec |
|
MD5 | ad1566069cde126ee86dd02e62e4b4c6 |
|
BLAKE2b-256 | 01b09e8c624e63a4be4ef7dfa2cdef391c91a802d64882d4d1b2de3b73e35341 |
File details
Details for the file monedadigitalx-1.0a7.post2-py3-none-any.whl
.
File metadata
- Download URL: monedadigitalx-1.0a7.post2-py3-none-any.whl
- Upload date:
- Size: 7.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.10.11
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d6ca41f736412351734c6cff75f2161bec2e9d1e4edf81a46ef5cde5a7e92271 |
|
MD5 | dedfb95b81a7eb2687074d02eeea0080 |
|
BLAKE2b-256 | 9d4ea8ff3371f4ca5b089aabaabfcc68731c2576165c6497b3c57d7c97830dc7 |