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.9"

Python Bindings

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

pip install stock-trek

Usage

Implement the StockTrekAlgorithm and Default traits for your algorithm and register it with the annotation #[register_algorithm(default)]:

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

pub struct MyAlgo;

impl Default for MyAlgo {
    fn default() -> Self {
        Self
    }
}

#[register_algorithm(default)]
impl StockTrekAlgorithm for MyAlgo {
    fn create_signal(&self, context: StockTrekContext) -> StockTrekSignal {
        StockTrekSignal::builder()
            .instrument(
                Instrument::builder()
                    .product(stock_trek::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.9-cp38-abi3-win_amd64.whl (328.2 kB view details)

Uploaded CPython 3.8+Windows x86-64

stock_trek-0.2.9-cp38-abi3-manylinux_2_28_x86_64.whl (503.1 kB view details)

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

stock_trek-0.2.9-cp38-abi3-manylinux_2_28_aarch64.whl (507.1 kB view details)

Uploaded CPython 3.8+manylinux: glibc 2.28+ ARM64

stock_trek-0.2.9-cp38-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl (900.7 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.9-cp38-abi3-win_amd64.whl.

File metadata

File hashes

Hashes for stock_trek-0.2.9-cp38-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 43fda70d67ff721719b62b17d41c550f913d0714a00fd055e7d847b80b3506c7
MD5 7aa48e9858dfa3212a2ff5851f0de12f
BLAKE2b-256 e2d9e6ffcde8ebf25ad479f22c006cfecc3019d9d4c47193216da7a878633d46

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stock_trek-0.2.9-cp38-abi3-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 a112c6de70f3710b05a057458ae6427b956f82fdc51073a15743a127b59c9185
MD5 32996b1f9cbf17630c3c901f3d5aa9e5
BLAKE2b-256 6531a1319befde1fc5e6bdc1b768ac2593308fe9585789223440c9ab3bbd8164

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stock_trek-0.2.9-cp38-abi3-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 bf1383dfd14d5a12b04d460f7ed69bf7994665b805c02d83ba93e2f3bdbefe58
MD5 93042e146f2d57a241407af24de30341
BLAKE2b-256 24c25f4c51716f0b644d8b60615144f1e6f12e5849209596e9b4f2d4679b90e2

See more details on using hashes here.

File details

Details for the file stock_trek-0.2.9-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.9-cp38-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 e43c0bcabf57ca91965b69a597b6ab1c5a68aede068d7b75948060a05f5e4bee
MD5 a0901373bf597f5352bb0d42113c7fb4
BLAKE2b-256 424e481400467995f59c19400115b65b5385ae1cffba3d2dade55540e4163b84

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