TradeLocker Python API Wrapper
This project provides a Python wrapper for TradeLocker's public API. It simplifies the process of making requests to the API by providing Pythonic interfaces.
A full description of the TradeLocker's public API can be found at TradeLocker API Documentation
Table of Contents
Getting Started
To use this Python wrapper, you'll need the username, password and the id of the server that you use to access TradeLocker. If you don't already have access, you need to find a broker that supports TradeLocker and create an account.
Installation
This package requires Python 3.11 or later. The easiest way to install this package is using pip:
pip install tradelocker
Usage
Here's a simple example on how to use the TradeLocker Python API wrapper. The code below initializes a TLAPI object with authentication data. It then: fetches price history and latest price, creates an order that converts into a position, waits for 2 seconds, and finally closes the same position.
from tradelocker import TLAPI
import time, random
# Initialize the API client with the information you use to login
tl = TLAPI(environment = "https://demo.tradelocker.com", username = "user@email.com", password = "YOUR_PASS", server = "SERVER_NAME")
symbol_name = "BTCUSD" # "RANDOM"
all_instruments = tl.get_all_instruments()
if symbol_name == "RANDOM":
instrument_id = int(random.choice(all_instruments['tradableInstrumentId']))
else:
instrument_id = tl.get_instrument_id_from_symbol_name(symbol_name)
price_history = tl.get_price_history(instrument_id, resolution="1D", start_timestamp=0, end_timestamp=0,lookback_period="5D")
latest_price = tl.get_latest_asking_price(instrument_id)
order_id = tl.create_order(instrument_id, quantity=0.01, side="buy", type_="market")
if order_id:
print(f"Placed order with id {order_id}, sleeping for 2 seconds.")
time.sleep(2)
tl.close_position(order_id)
print(f"Closed order with id {order_id}.")
else:
print("Failed to place order.")
For more detailed examples, see the examples directory.
Contributing
To contribute to the development of this project, please create an issue, or a pull request.
Steps to create a pull request:
- Clone the project.
- Create your feature branch (
git checkout -b feature/YourFeature). - Commit your changes (
git commit -am 'Add some feature'). - Push to the branch (
git push origin feature/YourFeature). - Create a new Merge Request.
License
This project is licensed under the terms of the MIT license. See LICENSE for more details.
Metadata
Release files for tradelocker 0.56.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| tradelocker-0.56.2.tar.gz | 23.8 kB | Without provenance | Details for tradelocker-0.56.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| tradelocker-0.56.2-py3-none-any.whl | Python 3 | none | any | Details for tradelocker-0.56.2-py3-none-any.whl |
Total release size: 48.1 kB
Release files / tradelocker-0.56.2.tar.gz
| Download URL | tradelocker-0.56.2.tar.gz |
|---|---|
| Size | 23.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
cc097176f65ea091bc0b55fc6a62d1eee738c6842632d247561e133bcd0974f1
|
|
BLAKE2b-256 checksum How to use checksums |
8c93ca1f8042048bd2c7472f67c2597b32e2658d714709b5c2bfce6f3aa67b98
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.3 CPython/3.12.6 Darwin/23.5.0
|
Release files / tradelocker-0.56.2-py3-none-any.whl
| Download URL | tradelocker-0.56.2-py3-none-any.whl |
|---|---|
| Size | 24.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4463bfd66f49c5cb957418925f25f93372310eb2411073c7d01a156d1a360759
|
|
BLAKE2b-256 checksum How to use checksums |
75b0601a989b9d67f397f6990ecbae71dcde8e3ff8f40fcb420b828324d044a5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.3 CPython/3.12.6 Darwin/23.5.0
|
Security for tradelocker 0.56.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.