No project description provided
Project description
Table of Contents
Client for HaasOnline API. Allows automation of Haas trading infrastructure.
Features
- API Client handles communication
- Utilities to create, execute, monitor backtests
- Classes for key entities like markets, accounts, etc.
- Custom result handling
Usage
First of all it required to create executor which will interact with API:
from haaslib import api
executor = api.RequestsExecutor(host="127.0.0.1", port=8090, state=api.Guest())
Guest executor can use some open endpoints, but it's better to authenticate and use all of them:
executor = executor.authenticate(email="admin@admin.com", password="adm2inadm4in!")
Now it's possible to use all provided endpoint wrappers. Let's create lab and backtest it. Lab requires market, account and script to be created, so they could be acuired in the following way:
import random
market = random.choice(api.get_all_markets(executor))
account = random.choice(api.get_accounts(executor))
script = random.choice(api.get_all_scripts(executor))
Then we can create our lab:
from haaslib.model import CreateLabRequest
lab_details = api.create_lab(
executor,
CreateLabRequest(
script_id=script.script_id,
name="My first lab",
account_id=account.account_id,
market=market.as_market_tag(),
interval=0,
default_price_data_style="CandleStick",
),
)
Now you can see in Haas Web UI (reload page if it was opened already).
To start backtesting lab module could be used.
from haaslib import lab
from haaslib.domain import BacktestPeriod
backtesting_result = lab.backtest(
executor,
lab_details.lab_id,
BacktestPeriod(period_type=BacktestPeriod.Type.DAY, count=20),
)
Full example lives in examples/syncexecutor.py with some other.
License
This project is licensed under the MIT license.
Let me know if any other sections would be useful to add or if an example should be expanded/clarified! Tried to provide basic overview and configuration to help users get started.
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file haaslib-0.1.0.tar.gz.
File metadata
- Download URL: haaslib-0.1.0.tar.gz
- Upload date:
- Size: 9.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.9.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5278e33b8e6612e2ecff51f30cf21faec8edb713e8fcd8aa3ae1fd7004d06dbc
|
|
| MD5 |
1fb6bed16bef36e828cd81c377c7c298
|
|
| BLAKE2b-256 |
44d01e224c5455a4fa406a5ded2e6630b0a591a6a3f41368c5d0abb9998e826d
|
File details
Details for the file haaslib-0.1.0-py3-none-any.whl.
File metadata
- Download URL: haaslib-0.1.0-py3-none-any.whl
- Upload date:
- Size: 10.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.9.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
409d1afae20acf7955b6311434ad54d07919926d9d2cc4e9567b6950a972e610
|
|
| MD5 |
70ab9674b88b94e0bcb6a4ef1b8cf349
|
|
| BLAKE2b-256 |
18910bc445e0049c8a9c1fc04acc98950c524543f12e1f4330f4438cc338b1b1
|