quantitative 0.4.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d6730ed9b986e266555841b22c4b0850e5faab7200e8e9a1ba9aadf2c285e39c
4
- data.tar.gz: 4000b1b078dcf483092ac7215c96f8eb1400c095053d43e434b5375ca2aa8400
3
+ metadata.gz: 8d68c387b70e811a933f804ccc410a9a7eb5382b40c01f806cd446d8d3f893ec
4
+ data.tar.gz: 4d19edc74c74e80ff5cd14bfe0906efad8ee7518ef15e17e7365faf9067b83cf
5
5
  SHA512:
6
- metadata.gz: 1824dc31f57b53162ca63008adcc3d863738641821622b7c166121b3ff4766d9a7994f677857c4b8d9b71200479254c52b299868b7312922149daccf172d9b70
7
- data.tar.gz: c92e33aaab91f5c5ed58932742842c8e248e61d26725a771cb787853d6d5130991a31f3f1ab15cfec489c888f0be7d1a41d7881420fad5117375ca6c5d456a4a
6
+ metadata.gz: '08c361a6745b972d50d47b6f73a4e455ae56e5a8a770b1c62ef2ca21e2893c4831e655be702c25c02f0af2edffb561b6db75a7ecc15b080c780442f0eeede8a7'
7
+ data.tar.gz: e29e29bd0bdaf461bbb9581dda8aac99c8dab99c947e31a133710aa62c2ee4a7aa078297cf2f1868a795d7384a834e3dd4a69d124f4017cdf8854b936349415f
data/CHANGELOG.md ADDED
@@ -0,0 +1,50 @@
1
+ # Changelog
2
+
3
+ All notable changes to `quantitative` will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ---
9
+
10
+ ## [0.5.0] — 2026-05-22
11
+
12
+ ### Changed (breaking)
13
+
14
+ - **`Quant::AssetClass::CLASSES` renamed `:treasury_note` → `:treasury`.** The single `:treasury` symbol now covers the full US-government-debt family (bills, notes, bonds, TIPS). Maturity becomes listing metadata, not an AssetClass distinction. Breaking for consumers that exhaustively switch on the `CLASSES` set or pattern-match on `:treasury_note`.
15
+
16
+ Migration: `s/:treasury_note/:treasury/g` across consumer code. Where maturity-aware behavior is needed (e.g., yield-curve segmentation), consult the listing's metadata rather than the AssetClass label.
17
+
18
+ ### Added
19
+
20
+ - `Quant::AssetClass::CLASSES` gains six new entries: `:adr, :cash, :etn, :forward, :swap, :warrant`. Final catalog is 19 entries: `adr, bond, cash, commodity, cryptocurrency, etf, etn, forex, forward, future, mbs, mutual_fund, option, preferred_stock, reit, stock, swap, treasury, warrant`.
21
+ - Per-class spec coverage in `spec/lib/quant/asset_class_spec.rb` — each catalog entry is `valid?`, the 19-count invariant is asserted, and `:treasury_note` rejection is a regression guard against re-introducing the retired symbol.
22
+
23
+ ---
24
+
25
+ ## [0.4.1] — 2026-05
26
+
27
+ ### Fixed
28
+
29
+ - **`Quant::Ticks::OHLC#initialize` and `Quant::Ticks::Spot#initialize` now preserve fractional volumes as `Float`.** A prior regression in both classes coerced `@base_volume` and `@target_volume` via `.to_i`, silently truncating fractional values to integers — a serious correctness issue for crypto markets (and any other domain where fractional base/target volumes are normal, such as fractional-share trading and many futures markets). For example, a kline with `base_volume: 0.12345` was previously stored as `0`. Existing spec assertions used `eq(2.0)` which masked the regression because Ruby's `==` coerces `2 == 2.0 → true`; the values *appeared* correct in tests while being silently truncated in production. Both initializers now coerce via `.to_f`. Trade count (`@trades`) continues to use `.to_i` as it is genuinely an integer.
30
+
31
+ Affected files:
32
+ - `lib/quant/ticks/ohlc.rb` (lines 51–52)
33
+ - `lib/quant/ticks/spot.rb` (lines 46–47)
34
+
35
+ Backwards compatibility: this is a behavior change for callers reading `tick.base_volume` / `tick.target_volume`. Code that did `volume == 2` continues to work (Ruby coerces). Code that did `volume.is_a?(Integer)` will see `false` where it previously saw `true`; such code was implicitly relying on the bug and should be updated to `is_a?(Numeric)` or `is_a?(Float)`. Code that did `volume + 0.5` continues to work, but the result is now precise instead of truncating to integer-then-promoting.
36
+
37
+ ### Added
38
+
39
+ - Regression-guard specs in `spec/lib/quant/ticks/ohlc_spec.rb` and `spec/lib/quant/ticks/spot_spec.rb` that explicitly assert `Float` class membership and use fractional values (`0.12345`, `5_678.901_234`) so a future `.to_i` regression would fail loudly rather than silently coerce.
40
+ - This CHANGELOG.
41
+
42
+ ---
43
+
44
+ ## [0.4.0] — prior baseline
45
+
46
+ Prior baseline before this CHANGELOG was introduced. Subsequent entries above will track changes from 0.4.1 forward.
47
+
48
+ [0.5.0]: https://github.com/mwlang/quantitative/compare/v0.4.1...v0.5.0
49
+ [0.4.1]: https://github.com/mwlang/quantitative/compare/v0.4.0...v0.4.1
50
+ [0.4.0]: https://github.com/mwlang/quantitative/releases/tag/v0.4.0
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- quantitative (0.4.0)
4
+ quantitative (0.5.0)
5
5
  csv
6
6
  oj (~> 3.10)
7
7
  zeitwerk (~> 2.6)
@@ -42,11 +42,15 @@ module Quant
42
42
  # profit from changes in exchange rates.
43
43
  class AssetClass
44
44
  CLASSES = %i(
45
+ adr
45
46
  bond
47
+ cash
46
48
  commodity
47
49
  cryptocurrency
48
50
  etf
51
+ etn
49
52
  forex
53
+ forward
50
54
  future
51
55
  mbs
52
56
  mutual_fund
@@ -54,7 +58,9 @@ module Quant
54
58
  preferred_stock
55
59
  reit
56
60
  stock
57
- treasury_note
61
+ swap
62
+ treasury
63
+ warrant
58
64
  ).freeze
59
65
 
60
66
  attr_reader :asset_class
@@ -45,8 +45,11 @@ module Quant
45
45
  @low_price = low_price.to_f
46
46
  @close_price = close_price.to_f
47
47
 
48
- @base_volume = (volume || base_volume).to_i
49
- @target_volume = (target_volume || @base_volume).to_i
48
+ # Volumes are floats, not ints — crypto markets and many futures markets express
49
+ # fractional base/target volumes routinely (e.g., 0.12345 BTC). Existing specs already
50
+ # asserted Float values (`eq(2.0)`); a prior `.to_i` regression silently truncated.
51
+ @base_volume = (volume || base_volume).to_f
52
+ @target_volume = (target_volume || @base_volume).to_f
50
53
  @trades = trades.to_i
51
54
 
52
55
  @green = green.nil? ? compute_green : green
@@ -39,8 +39,12 @@ module Quant
39
39
  @close_timestamp = extract_time(timestamp || close_timestamp || Quant.current_time)
40
40
  @open_timestamp = @close_timestamp
41
41
 
42
- @base_volume = (volume || base_volume).to_i
43
- @target_volume = (target_volume || @base_volume).to_i
42
+ # Volumes are floats, not ints — crypto markets and many futures markets express
43
+ # fractional base/target volumes routinely (e.g., 0.12345 BTC). Existing specs already
44
+ # asserted Float values (`eq(2.0)`); a prior `.to_i` regression silently truncated.
45
+ # See OHLC for the same fix.
46
+ @base_volume = (volume || base_volume).to_f
47
+ @target_volume = (target_volume || @base_volume).to_f
44
48
 
45
49
  @trades = trades.to_i
46
50
  super()
data/lib/quant/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Quant
4
- VERSION = "0.4.0"
4
+ VERSION = "0.5.0"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: quantitative
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Lang
@@ -62,6 +62,7 @@ files:
62
62
  - ".rubocop.yml"
63
63
  - ".ruby-version"
64
64
  - ".yardopts"
65
+ - CHANGELOG.md
65
66
  - CODE_OF_CONDUCT.md
66
67
  - DISCLAIMER.md
67
68
  - Gemfile
@@ -155,7 +156,7 @@ metadata:
155
156
  allowed_push_host: https://rubygems.org
156
157
  homepage_uri: https://github.com/mwlang/quantitative
157
158
  source_code_uri: https://github.com/mwlang/quantitative
158
- changelog_uri: https://github.com/mwlang/quantitative
159
+ changelog_uri: https://github.com/mwlang/quantitative/blob/main/CHANGELOG.md
159
160
  rdoc_options: []
160
161
  require_paths:
161
162
  - lib