Some Python tools
Project description
pyttkl
Links
Description
Some Python tools
kits.py
- This module contains utility functions for handling strings, lists, and other data types.
- Extensions related to logging
- Extensions related to argparse
tmat.py
- A Trivial Matrix concept implementation that can read and write
pd.DataFrame. - Although internally it is stored as numpy-compatible data, considering
pd.DataFrame(ndarray), it essentially wraps an ndarray or adds row and column names. load_tmat(filename, mmap_mode='c'): Automatically determines the payload type based on the meta information in the file and reads it. If the payload is mmap, you can specifymmap_mode.save_tmat(filename, tmat, compress='zstd'): Allows compressing the payload with zstd. There are more options in the code. It can also save as mmap.
Installation
You can install this package using pip:
pip install .
Design
tmat format:
- Design Goals:
-
- Compatible with numpy's ndarray
-
- Compatible with pandas' DataFrame
-
- Supports compression
-
- Supports mmap
-
- Supports multiple data types
-
- Native support for both C++ and Python
-
- Understandable by quantitative researchers by reading the code
-
- Example:
TMT\n{header_length: 954}\n{"columns": ["a", "b", "c"], "rows": [1, 2, 3], "dtype": "int32", "compress": "zstd"}\n{payload} - Header: 4-byte magic number,
TMT\n - JSON string
{"header_length": 954}\n. Ifheader_length > 0, the following meta is a payload compressed with lz4 of lengthheader_length. Otherwise, it is a plain JSON string.- Trick: Use
head -2 KLINE/OPEN/202401.tmtto view the file header.
- Trick: Use
- Meta: JSON string
{"columns": ["a", "b", "c"], "rows": [1, 2, 3], "dtype": "int32", "compress": "zstd"}\n - Payload: Binary data. The specific format depends on the meta content.
- If
{"compress": "zstd"}, it is zstd-compressed binary data. It can also be lz4 or zstd. - Otherwise, it is plain binary data, which can be directly loaded with mmap. You can specify the loading mode with
mmap_mode.- Trick: You can use pandas and numpy's inplace operations to modify the file content directly. Be sure to check
ndarray.flagswhen using it.
- Trick: You can use pandas and numpy's inplace operations to modify the file content directly. Be sure to check
- If
TODOS or NO-TODOS
There are many things that can be done, but to keep the project simple and at a level understandable by quantitative researchers, many TODOs become NO TODOs. Of course, if anyone thinks something can be improved, feel free to create an issue.
-
TODOs
- Code comments
- Code documentation
- Restrict exposed APIs
-
NO TODOs
- Multithreading
Requirements
- Python 3.11 or higher
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 pyttkl-0.1.1.tar.gz.
File metadata
- Download URL: pyttkl-0.1.1.tar.gz
- Upload date:
- Size: 2.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
74dce03376ae06745c8104726209796208ae03777ddc14c89e940a93dbf80e54
|
|
| MD5 |
c3896133f02b0b3e6627cf7cd372c9f9
|
|
| BLAKE2b-256 |
06934ce1f589a46df0e2dd165abe3ac4a12228964990eaee4c36cbff8bd8eee6
|
File details
Details for the file pyttkl-0.1.1-py3-none-any.whl.
File metadata
- Download URL: pyttkl-0.1.1-py3-none-any.whl
- Upload date:
- Size: 2.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
26d60093862f4217bfbf82749d28f0f05467e89ea3cf72b3541dc5f9748b6c99
|
|
| MD5 |
b8b797e7bff5e032003caa2792fdb962
|
|
| BLAKE2b-256 |
658292e0fea45bce60437c429c99c46673f24f33df006c9e42d0f1b484c9acbb
|