rungbot_core/lib.rs
1//! `rungbot-core` — the ladder, as pure logic.
2//!
3//! This crate contains the entire strategy and nothing else. It reads no clock, opens no
4//! file, makes no network call and generates no randomness, so it compiles unchanged to
5//! `wasm32-unknown-unknown` for a Cloudflare Worker and to a native binary for the CLI.
6//! The strategy therefore exists in exactly one place.
7//!
8//! ```
9//! use std::collections::BTreeMap;
10//! use rungbot_core::{analyze, Coin, Config, Price, Settings, Venue};
11//!
12//! let cfg = Config::new(
13//! vec![Coin {
14//! symbol: "BTC".into(),
15//! venue: Venue::Binance,
16//! pair: "BTCUSDT".into(),
17//! name: "Bitcoin".into(),
18//! entry: Some(61_000.0),
19//! bands: None,
20//! }],
21//! Settings::default(),
22//! )
23//! .unwrap();
24//!
25//! let mut prices = BTreeMap::new();
26//! prices.insert("BTC".to_string(), Price { price: 54_900.0, chg_24h: Some(-12.0) });
27//!
28//! let out = analyze(&cfg, &prices, &BTreeMap::new(), 1_700_000_000.0);
29//! assert_eq!(out.buys.len(), 1);
30//! assert_eq!(out.buys[0].rung, 1);
31//! ```
32
33#![forbid(unsafe_code)]
34#![deny(clippy::all)]
35
36pub mod analyze;
37pub mod config;
38pub mod decisions;
39pub mod deploy;
40pub mod fmt;
41pub mod housekeeping;
42pub mod indicators;
43pub mod ladder;
44pub mod names;
45pub mod notices;
46pub mod pymath;
47pub mod pyrandom;
48pub mod regime;
49pub mod research;
50pub mod scenarios;
51pub mod sellpolicy;
52pub mod time;
53pub mod watch;
54pub mod yaml;
55
56pub use analyze::{
57 analyze, analyze_with, CoinState, Outcome, Price, Row, Side, Skip, SkipReason, State, Steer,
58 Trade,
59};
60pub use config::{Coin, Config, ConfigError, Settings, Trail, Venue};
61pub use decisions::{Decision, Kind as DecisionKind};
62pub use indicators::{compute as compute_kpi, CoinKpi, KpiThresholds, Phase};
63pub use ladder::{buy_rung_for, ladder_increment, rung_threshold, sell_rung_for, Bands};
64pub use notices::{Notices, Verdict as NoticeVerdict};
65pub use regime::{assess, market_label, running_from_series, Market, Regime, RegimeConfig};
66pub use research::{brief, gate, screen, Candidate, ScreenConfig, ValueFacts, Verdict};
67pub use sellpolicy::{BullState, PolicySell, SellPolicyConfig};
68pub use time::{iso8601, iso8601_micros, utc_day};
69
70/// The crate version, so a Worker and a binary can report the same number.
71pub const VERSION: &str = env!("CARGO_PKG_VERSION");