预测退出, 不关闭

2026年8月10日2 次浏览来源:Dev.to阅读原文

正文保留英文原文(机翻易破坏代码与排版),标题/摘要已提供中文

Pramaana is a crypto research and trading system I built around one constraint: a model prediction is only useful when it describes the event that will actually decide the position.

This article focuses on its path-passage classifier, which estimates which price barrier an asset reaches first.

A 24-hour closing-price forecast can be directionally correct and still describe the wrong trade outcome.

Bracketed positions close when the take-profit level is reached, the stop-loss level is reached, or the holding window expires.

Pramaana trains on that sequence directly: upper barrier first, lower barrier first, or neither within 24 hours.

The feature is interesting because the statistical target and the capital decision refer to the same event.

1.

A closing price cannot recover the trade path A common market model predicts the return between now and a fixed horizon: $$ \text{return} = \log\left(\frac{\text{price at horizon}}{\text{price now}}\right) $$ That target supports many research tasks.

It does not describe a bracketed position.

A bracket order has two exit levels.

One secures a gain and the other limits a loss.

The trade ends when either level is touched, or when the holding period expires.

Sequence determines the result.

Pramaana's earlier close-to-close targets discarded the high and low path inside the holding window.

A later close therefore could not tell the model whether the upper or lower bracket had already been touched.

The repository names the missing information directly: wicks, drawdowns, take-profit hits, and the order in which the barriers were reached.

The problem was in the training target before model choice or tuning entered the discussion.

2.

First-passage classification labels the event that closes the position First-passage is the first time a process reaches a defined level.

Pramaana uses the next hourly bar's open as the reference price because that is the first point available after a signal is formed.

The current methodology places a 200 basis point threshold on each side for most assets.

One basis point is 0.01 percent, so 200 basis points equals 2 percent.

The target schema is explicit in the label module: The helper keeps the three outcomes explicit for each horizon and barrier width.

The next function writes those outcomes into the training frame while preserving rows whose future window is incomplete: Invalid trailing rows stay undefined instead of being forced into one of the three classes.

The diagram shows the full path from signal to the cost-aware score used later in the trading decision.

An hourly bar can cross both thresholds.

Its high and low prove that both levels were touched, but hourly data cannot recover their order.

Pramaana does not invent one.

That observation is treated as unresolved.

Rows near the dataset tail also remain undefined when a complete 24-hour future window does not exist.

Every valid label can therefore be traced back to a specific entry reference, two thresholds, and an observable first touch.

3.

The model and the order use the same geometry The training target uses the same 24-hour horizon and symmetric 2 percent levels as the trade structure.

Pramaana does not predict a broad idea of direction and then ask another component to reinterpret it.

The classifier estimates the outcomes the execution rule can encounter. means the upper exit should occur before the lower exit. carries the opposite ordering. means the bracket remained unresolved when time expired.

This matters because a directional call can eventually be correct after the position has already stopped out.

A long forecast has no value when the loss level is touched before the anticipated rise.

One three-class distribution supports both sides.

The system does not need separate long and short models.

It evaluates the same outcome probabilities under the payoff structure of each position.

4.

Three probabilities become expected basis points Pramaana trains one LightGBM model per asset.

LightGBM is a tree-based classifier that estimates: Those probabilities are inputs, not orders.

The decision layer maps the outcome distribution into a long score and a short score: $$ \text{expected score for a side} = \sum \bigl( P(\text{outcome}) \times \text{net payoff for that side} \bigr) $$ If the upper barrier arrives first, the long side receives the positive bracket payoff after cost and the short side receives the negative one.

The signs reverse when the lower barrier arrives first.

An unresolved window is valued at the horizon close, with trading cost still deducted.

The output is expected basis points, so the ranking layer receives a financial quantity rather than raw model confidence.

A large can still produce a weak long score.

The competing outcome may remain material, the unresolved probability may be high, or fees may consume the margin.

Expected value forces the whole probability distribution through the actual payoff map before a candidate can rank highly.

That distinction makes the score readable from two directions.

An engineer can inspect the probability model.

A portfolio reader can inspect the economic consequence.

5.

Real trading cost changed the entry rule A model can identify direction better than chance and still lose money.

Trading cost reduces every gross forecast.

In Pramaana, that became decisive when the strategy was stressed against the real 35 basis point round-trip cost used by the Coinbase configuration.

Pramaana includes cost in the score instead of subtracting it after ranking.

That prevents a high-confidence but low-value candidate from outranking a less dramatic signal with better net economics.

The first version admitted any score above zero.

Later testing applied the real 35 basis point round-trip cost used in the Coinbase configuration.

The simple threshold failed.

The response changed the decision layer.

The current configuration uses a rolling-percentile gate and a smaller seven-asset universe.

A candidate must rank strongly against the recent score distribution rather than remain barely positive under an easier fee assumption.

The classifier answers what may happen.

The gate determines whether the estimated advantage deserves capital under current execution conditions.

6.

Smaller trees produced more credible probabilities Expected-value scoring depends on probability scale.

A model that reports 99.9 percent for an event occurring roughly half the time will overstate the money attached to that branch.

An audit found that the original LightGBM settings allowed terminal leaves to become too specific.

Some out-of-sample estimates exceeded 99.9 percent even though realized frequencies inside those confidence ranges were much lower.

The model was deliberately constrained: Setting Hardened value Reason Maximum leaves 8 Prevent narrow terminal regions Maximum depth 3 Restrict interaction complexity Minimum rows per leaf 400 Require broad empirical support Feature sampling 50 percent Reduce dependence on one feature subset L1 and L2 regularization 0.1 Pull extreme leaf weights inward After hardening, the largest observed across the audited cycles fell from 0.999 to about 0.83.

Median expected calibration error declined from about 0.21 to 0.08 while rank order remained useful.

Lower confidence was the correct result.

The revised probabilities tracked observed frequencies more closely and stopped one narrow leaf from dominating the expected-return calculation.

Accuracy measures whether the ranking contains information.

Calibration determines whether its probabilities can be multiplied by money.

7.

The target pipeline received its own audit Time-series research can fail before model fitting begins.

A future window placed on the wrong row can leak information from beyond the intended horizon into the target.

Pramaana's audit found such an error in vectorized path-excursion fields used for maximum favorable excursion, maximum adverse excursion, and horizon close.

A double shift moved part of the calculation farther

分享