Skip to main content

Stock Trek time-series analysis python bindings

Project description

stock-trek

A lightweight, composable time series and statistical toolkit designed for running crypto bots on stock-trek.com. Rust-native core with optional Python bindings

Overview

stock-trek provides core abstractions and utilities for working with market data, including:

  • Order books
  • Aligned/Rolling windows
  • Ticks
  • Statistical and analytical functions

Installation

Add to your Cargo.toml:

[dependencies]
stock-trek = "0.2.8"

Python Bindings

stock-trek also provides Python bindings which can be installed via

pip install stock-trek

Usage

Implement the StockTrekAlgorithm trait and register it with the annotation #[register_algorithm]:

use stock_trek::prelude::*;
use stock_trek::signal::*;

pub struct MyAlgo;

#[register_algorithm]
impl StockTrekAlgorithm for MyAlgo {
    fn create_signal(&self, context: StockTrekContext) -> StockTrekSignal {
        StockTrekSignal::builder()
            .instrument(
                Instrument::builder()
                    .product(crate::signal::InstrumentProduct::Spot)
                    .base("BTC")
                    .quote("USDT"),
            )
            .market_context(
                MarketContext::builder()
                    .market_regime(
                        MarketRegime::builder()
                            .classifications(
                                MarketRegimeClassifications::builder()
                                    .confidence(0.5)
                                    .dominant("")
                                    .top_alternatives(std::collections::HashMap::from([
                                        ("dskfsd".into(), 0.21),
                                        ("irewtnvc".into(), 0.17),
                                        ("cfhwrehk".into(), 0.15),
                                    ]))
                                    .unclassified(0.2),
                            )
                            .cycle(
                                MarketRegimeCycle::builder()
                                    .accumulation(0.3)
                                    .distribution(0.5)
                                    .markdown(0.1)
                                    .markup(0.2)
                                    .neutral(0.8),
                            )
                            .trend(
                                MarketRegimeTrend::builder()
                                    .bearish(0.6)
                                    .bullish(0.2)
                                    .sideways(0.2),
                            )
                            .volatility(
                                MarketRegimeVolatility::builder()
                                    .snapshot(
                                        MarketRegimeVolatilitySnapshot::builder()
                                            .high(0.1)
                                            .low(0.9),
                                    )
                                    .trend(
                                        MarketRegimeVolatilityTrend::builder()
                                            .compression(0.5)
                                            .expansion(0.5),
                                    ),
                            ),
                    )
                    .regime_persistence(
                        RegimePersistence::builder()
                            .regime_persistence_confidence(0.7)
                            .remaining_durations_millis(483648732),
                    ),
            )
            .prediction(
                Prediction::builder()
                    .horizon_confidences_by_millis(HorizonConfidencesByMillis(
                        std::collections::HashMap::from([
                            ("vgfhgkfd".into(), 549357438),
                            ("cdiotkjr".into(), 549357438),
                        ]),
                    ))
                    .optimal_horizon_millis(1000)
                    .percentage_changes(
                        ConfidencePercentageChanges::builder()
                            .p01(-10.2)
                            .p05(-5.1)
                            .p10(-0.4)
                            .p25(3.9)
                            .p50(10.2)
                            .p75(16.5)
                            .p90(19.4)
                            .p95(20.4)
                            .p99(20.8),
                    )
                    .risk(
                        PredictionRisk::builder()
                            .percentage_risks(
                                PredictionRiskPercentageRisks::builder()
                                    .cvar_95(-6.8)
                                    .cvar_99(-7.2)
                                    .max_drawdown_95(25.3)
                                    .max_drawdown_99(31.8)
                                    .var_95(-3.7)
                                    .var_99(-4.5),
                            )
                            .risk_factors(std::collections::HashMap::from([
                                ("dvxvxvvodsgrg".into(), 0.63),
                                ("cnnfgvcxojtnn".into(), 0.41),
                            ])),
                    )
                    .validity_duration_millis(1_000_000),
            )
            .try_into()
            .expect("Expected StockTrekSignal")
    }
}

Stock-Trek verifies code before running it and disallows certain syntax elements. To verify code locally, install it with

cargo install stock-trek

then run the verify command with

stock-trek verify --file ./path/to/my/code/file.rs

Roadmap

Planned features include:

  • Technical indicators (EMA, RSI, MACD, etc.)
  • Backtesting and simulation utilities

Status

This project is in early development (0.x). APIs may change.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

stock_trek-0.2.8-cp38-abi3-win_amd64.whl (328.8 kB view details)

Uploaded CPython 3.8+Windows x86-64

stock_trek-0.2.8-cp38-abi3-manylinux_2_28_x86_64.whl (503.5 kB view details)

Uploaded CPython 3.8+manylinux: glibc 2.28+ x86-64

stock_trek-0.2.8-cp38-abi3-manylinux_2_28_aarch64.whl (507.6 kB view details)

Uploaded CPython 3.8+manylinux: glibc 2.28+ ARM64

stock_trek-0.2.8-cp38-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl (904.1 kB view details)

Uploaded CPython 3.8+macOS 10.12+ universal2 (ARM64, x86-64)macOS 10.12+ x86-64macOS 11.0+ ARM64

File details

Details for the file stock_trek-0.2.8-cp38-abi3-win_amd64.whl.

File metadata

File hashes

Hashes for stock_trek-0.2.8-cp38-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 c4c430f3c95b727d9d0944cf7bc86e96226be0b9e3a9ba6c7b6f2f96cc3a8c7d
MD5 d7a84c29665239a55e9bb46cc4165e86
BLAKE2b-256 353b16201df791903c1130ded028a751955f7008bcd0d08faa5fa13fe37623f9

See more details on using hashes here.

File details

Details for the file stock_trek-0.2.8-cp38-abi3-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for stock_trek-0.2.8-cp38-abi3-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 01d8454c5e9f04604b33fdc499ef816ec522779608e99418f8a65c21a0d40f3e
MD5 24e08d434aa252ec12092d7913cd924d
BLAKE2b-256 dfc9fe21a56a919c4c86f8fa27844f4eb121678804b6ec49e6e78d096775c1eb

See more details on using hashes here.

File details

Details for the file stock_trek-0.2.8-cp38-abi3-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for stock_trek-0.2.8-cp38-abi3-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 e5fbaf050c664604daf5ffa5e2aebb9fc2ed8798697ab7e3d9d9310229be3cca
MD5 633d0c10eea1b2a137b88f44630f90df
BLAKE2b-256 2bd125a4552991ce885d3456cbffe367633bdac9a9a3a84f201a0b6c00df051d

See more details on using hashes here.

File details

Details for the file stock_trek-0.2.8-cp38-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl.

File metadata

File hashes

Hashes for stock_trek-0.2.8-cp38-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 7fc1df19c06623854126831d6d82a861e6322da471844a2ab4af22fefe075181
MD5 71340e2a6269cbb66fe091815c3fcfb7
BLAKE2b-256 6fe35fe524ab801c2c444c2a2d6b28747e645d83803a2bee215884fa6141c7fe

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page