# 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](https://tradelocker.com/api)
---
## Table of Contents
1. [Getting Started](#getting-started)
2. [Installation](#installation)
3. [Usage](#usage)
4. [Contributing](#contributing)
5. [License](#license)
## 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:
```shell
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.
```python
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:
1. Clone 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](https://github.com/ivosluganovic/tl/blob/main/LICENSE.txt) for more details.
Raw data
{
"_id": null,
"home_page": null,
"name": "tradelocker",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.11",
"maintainer_email": null,
"keywords": "tradelocker, api, rest, trading, algotrading, algo, bots, strategies",
"author": "TradeLocker",
"author_email": "admin@tradelocker.com",
"download_url": "https://files.pythonhosted.org/packages/ab/81/ab0ad00a33529313df23f0df85bfb519e3afdf534be2b516aa622c3c3b4d/tradelocker-0.49.1.tar.gz",
"platform": null,
"description": "# TradeLocker Python API Wrapper\n\nThis project provides a Python wrapper for TradeLocker's public API. It simplifies the process of making requests to the API by providing Pythonic interfaces.\n\nA full description of the TradeLocker's public API can be found at [TradeLocker API Documentation](https://tradelocker.com/api)\n\n---\n\n## Table of Contents\n\n1. [Getting Started](#getting-started)\n2. [Installation](#installation)\n3. [Usage](#usage)\n4. [Contributing](#contributing)\n5. [License](#license)\n\n## Getting Started\n\nTo use this Python wrapper, you'll need the username, password and the id of the server that you use to access TradeLocker.\nIf you don't already have access, you need to find a broker that supports TradeLocker and create an account.\n\n## Installation\n\nThis package requires Python 3.11 or later.\nThe easiest way to install this package is using pip:\n\n```shell\npip install tradelocker\n```\n\n## Usage\n\nHere's a simple example on how to use the TradeLocker Python API wrapper.\nThe code below initializes a TLAPI object with authentication data.\nIt 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.\n\n```python\nfrom tradelocker import TLAPI\nimport time, random\n\n# Initialize the API client with the information you use to login\ntl = TLAPI(environment = \"https://demo.tradelocker.com\", username = \"user@email.com\", password = \"YOUR_PASS\", server = \"SERVER_NAME\")\n\nsymbol_name = \"BTCUSD\" # \"RANDOM\"\nall_instruments = tl.get_all_instruments()\nif symbol_name == \"RANDOM\":\n\tinstrument_id = int(random.choice(all_instruments['tradableInstrumentId']))\nelse:\n\tinstrument_id = tl.get_instrument_id_from_symbol_name(symbol_name)\nprice_history = tl.get_price_history(instrument_id, resolution=\"1D\", start_timestamp=0, end_timestamp=0,lookback_period=\"5D\")\nlatest_price = tl.get_latest_asking_price(instrument_id)\norder_id = tl.create_order(instrument_id, quantity=0.01, side=\"buy\", type_=\"market\")\nif order_id:\n\tprint(f\"Placed order with id {order_id}, sleeping for 2 seconds.\")\n\ttime.sleep(2)\n\ttl.close_position(order_id)\n\tprint(f\"Closed order with id {order_id}.\")\nelse:\n\tprint(\"Failed to place order.\")\n```\n\nFor more detailed examples, see the `examples` directory.\n\n## Contributing\n\nTo contribute to the development of this project, please create an issue, or a pull request.\n\nSteps to create a pull request:\n\n1. Clone the project.\n2. Create your feature branch (`git checkout -b feature/YourFeature`).\n3. Commit your changes (`git commit -am 'Add some feature'`).\n4. Push to the branch (`git push origin feature/YourFeature`).\n5. Create a new Merge Request.\n\n## License\n\nThis project is licensed under the terms of the MIT license. See [LICENSE](https://github.com/ivosluganovic/tl/blob/main/LICENSE.txt) for more details.\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Python client for TradeLocker's Trading API",
"version": "0.49.1",
"project_urls": {
"Issues": "https://github.com/tradelocker/tradelocker-python/issues",
"Source": "https://github.com/tradelocker/tradelocker-python/"
},
"split_keywords": [
"tradelocker",
" api",
" rest",
" trading",
" algotrading",
" algo",
" bots",
" strategies"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "5772f660df43f8135cd7415222ad7e033d2ead420d9b408c32109e803257ad5e",
"md5": "f002ea16242a9ec08fc0b5990ae053cd",
"sha256": "9a9cee6c9b43d7c48215bab11af1ee4fa46de05af770923dfb0617d22afff3a2"
},
"downloads": -1,
"filename": "tradelocker-0.49.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "f002ea16242a9ec08fc0b5990ae053cd",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.11",
"size": 21449,
"upload_time": "2024-11-05T18:18:18",
"upload_time_iso_8601": "2024-11-05T18:18:18.297097Z",
"url": "https://files.pythonhosted.org/packages/57/72/f660df43f8135cd7415222ad7e033d2ead420d9b408c32109e803257ad5e/tradelocker-0.49.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "ab81ab0ad00a33529313df23f0df85bfb519e3afdf534be2b516aa622c3c3b4d",
"md5": "b81de1a9626c906aef523ef7c1c09b6f",
"sha256": "afb74a78f7aa5748a091136f4478e43f81511de93ab0b4c819c754288959ac1d"
},
"downloads": -1,
"filename": "tradelocker-0.49.1.tar.gz",
"has_sig": false,
"md5_digest": "b81de1a9626c906aef523ef7c1c09b6f",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.11",
"size": 21361,
"upload_time": "2024-11-05T18:18:19",
"upload_time_iso_8601": "2024-11-05T18:18:19.586685Z",
"url": "https://files.pythonhosted.org/packages/ab/81/ab0ad00a33529313df23f0df85bfb519e3afdf534be2b516aa622c3c3b4d/tradelocker-0.49.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-11-05 18:18:19",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "tradelocker",
"github_project": "tradelocker-python",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "tradelocker"
}