Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

monedadigitalx-1.0a7.post1.tar.gz (8.3 kB view details)

Uploaded Source

Built Distribution

monedadigitalx-1.0a7.post1-py3-none-any.whl (7.9 kB view details)

Uploaded Python 3

File details

Details for the file monedadigitalx-1.0a7.post1.tar.gz.

File metadata

  • Download URL: monedadigitalx-1.0a7.post1.tar.gz
  • Upload date:
  • Size: 8.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.10.11

File hashes

Hashes for monedadigitalx-1.0a7.post1.tar.gz
Algorithm Hash digest
SHA256 4836e5e8119da5807350bb69862c5750615539597171bc5e280752d29b0565f6
MD5 0265595775f1c36ceb1e96a6ce992d1c
BLAKE2b-256 7edfa57339bc4d0a94bf466d69e35c84c7efb2383e9450cd5a09ac5a0c8b2e46

See more details on using hashes here.

File details

Details for the file monedadigitalx-1.0a7.post1-py3-none-any.whl.

File metadata

File hashes

Hashes for monedadigitalx-1.0a7.post1-py3-none-any.whl
Algorithm Hash digest
SHA256 708a381f0b75335cf98650d54c784978b2adc25156e5c3d62eee9c434a0acd85
MD5 fcaee1ac1aae94da95c4c0bbe126ed53
BLAKE2b-256 8352e89a88df94e42ae4525f74400693f62eb41b3da48e14b63a7ed97c32c0fd

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page