Skip to main content

TradeLocker Python API Wrapper

This project provides a Python wrapper for the TradeLocker Algo Trading public API. It simplifies the process of making requests to the API by providing Pythonic interfaces.

Full description of the TradeLocker Algo Trading public API can be found at TradeLocker API Documentation


Table of Contents

  1. Getting Started
  2. Installation
  3. Usage
  4. Contributing
  5. License

Getting Started

To use this Python wrapper, you'll need the username and password 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.7 or later. You can install the TradeLocker Python API Wrapper using pip:

Local pip wheel

hatch build
pip install dist/tradelocker[*].whl

From PyPi

# While still published only on test.pypi.org:
pip install -i https://test.pypi.org/simple --extra-index-url https://pypi.org/simple/ tradelocker

### From gitlab repo:

```shell
pip install git+https://gitlab.tradelocker.com/tradelocker-bots/tradelocker-bots.git@tradelocker_api

After publishing to the main pypi repo:

pip3 install tradelocker


### Pushing to PyPi (or TestPyPi)
```shell
hatch run test
hatch version minor
hatch build
hatch publish [--repo test]

Usage

Here's an example of how to use the TradeLocker Python API wrapper:

from tradelocker import TLAPI
import time, random

# Initialize the API client with the information you use to login
tl = TLAPI(environment = "demo", 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:

  1. Fork the project.
  2. Create your feature branch (git checkout -b feature/YourFeature).
  3. Commit your changes (git commit -am 'Add some feature').
  4. Push to the branch (git push origin feature/YourFeature).
  5. 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.37.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tradelocker 0.37.0
File Size Uploaded Provenance Actions
tradelocker-0.37.0.tar.gz 18.7 kB Without provenance Details for tradelocker-0.37.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for tradelocker 0.37.0
File Interpreter ABI Platform Actions
tradelocker-0.37.0-py3-none-any.whl Python 3 none any Details for tradelocker-0.37.0-py3-none-any.whl

Total release size: 37.3 kB

Release files / tradelocker-0.37.0.tar.gz

Download URL tradelocker-0.37.0.tar.gz
Size 18.7 kB
Tags Source
SHA-256 checksum
How to use checksums
d63f3543fada3a7de1b5c97f3f6eb3391fbe33e89fca9e29a45aeb322c404505
BLAKE2b-256 checksum
How to use checksums
19b6c50fac139032b1ec85516d8b6df53a27537903a600499ca3dc3d57ae5e13
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.7.1 CPython/3.12.1 Darwin/23.1.0

Release files / tradelocker-0.37.0-py3-none-any.whl

Download URL tradelocker-0.37.0-py3-none-any.whl
Size 18.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ac26609ca2cf911edc3748cfcdaca519441a3f00ded24031f6e8dbc8a57bc6d9
BLAKE2b-256 checksum
How to use checksums
c8ff6466a7f86f13e036e6e741113b4c3914fa37c03ede1eaeae3d67320e2e65
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.7.1 CPython/3.12.1 Darwin/23.1.0

Security for tradelocker 0.37.0

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page