Skip to content

add a few more helper methods - #24

Merged
MathisWellmann merged 2 commits into
mainfrom
helpers
Sep 4, 2026
Merged

MathisWellmann merged 2 commits into
mainfrom
helpers

Conversation

@MathisWellmann

Copy link
Copy Markdown
Owner

No description provided.

@github-actions

github-actions Bot commented Sep 3, 2026

Copy link
Copy Markdown

Summary

The PR adds convenience accessors Position::to_f64/is_long/is_short and MarketState::best_bid/best_ask with tests, plus a version bump. The Position additions are correct (Currency requires Signed and Into<f64>), but the MarketState additions duplicate existing public API.

Issues

  • src/market_state.rs:85–95 (major): best_bid() and best_ask() return the identical values already exposed by the public getters bid() and ask() generated by #[getset(get_copy = "pub")] on the bid/ask fields (lines 26–33). This leaves two public names for the same state that can drift apart in documentation and call sites. Remove the new accessors (and their test), or rename the existing getters to best_bid()/best_ask() instead of adding parallel methods.

@github-actions

github-actions Bot commented Sep 3, 2026

Copy link
Copy Markdown

Summary

The PR adds convenience accessors to Position (to_f64, is_long, is_short) and MarketState (best_bid, best_ask), with tests and a version bump to 0.138.4. The logic is correct, but the new public methods duplicate existing public API on both types.

Issues

  • src/market_state.rs:85-94 (major): best_bid()/best_ask() are exact duplicates of the already-public bid()/ask() copy getters generated by the CopyGetters derive, giving the same field two public names that can diverge later. Fix: remove the new methods and document the existing bid()/ask() getters as the best bid/ask instead.
  • src/account/position.rs:94-115 (major): is_long()/is_short() duplicate the existing side() method (PositionSide::Long/Short), and to_f64() is just quantity().to_f64(), which callers can already compose from the public quantity() getter and BaseCurrency::to_f64(). Fix: keep side() as the single source of side information and drop the redundant predicates/conversion.

@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown

Summary

The PR adds a minimal ci devShell that CI now develops against (bypassing creusot/hongdown/cargo-* builds), bumps the version to 0.138.4, and adds Position::{to_f64,is_long,is_short} plus MarketState::{best_bid,best_ask} with tests. No correctness bugs found; the flake ci shell covers every command ci.yml runs (the rust binding correctly shadows pkgs.rust via the enclosing let), and to_f64/is_positive/is_negative compile because Currency has Into<f64> and Signed as supertraits.

Issues

  • src/market_state.rs:85–96, major: best_bid()/best_ask() duplicate the public bid()/ask() copy getters already generated by getset on the same fields, so the struct now exposes two public names for the same value, and the "best (highest)/(lowest)" doc claim is not enforced since update_state stores a single bid/ask pair. Drop the new methods and keep using the existing bid()/ask() accessors.

@MathisWellmann
MathisWellmann merged commit 2a0a251 into main Sep 4, 2026
2 checks passed
@MathisWellmann
MathisWellmann deleted the helpers branch September 4, 2026 18:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant