vizflow 0.4.2__py3-none-any.whl → 0.4.4__py3-none-any.whl

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.
vizflow/__init__.py CHANGED
@@ -5,7 +5,7 @@ Usage:
5
5
  import vizflow as vf
6
6
  """
7
7
 
8
- __version__ = "0.4.2"
8
+ __version__ = "0.4.4"
9
9
 
10
10
  from .config import ColumnSchema, Config, get_config, set_config
11
11
  from .io import (
@@ -19,4 +19,4 @@ from .io import (
19
19
  )
20
20
  from .market import CN, CRYPTO, Market, Session
21
21
  from .ops import aggregate, bin, parse_time
22
- from .presets import JYAO_V20251114, YLIN
22
+ from .presets import JYAO_V20251114, PRESETS, YLIN_V20251204
vizflow/config.py CHANGED
@@ -70,9 +70,9 @@ class Config:
70
70
  alpha_schema: dict[str, ColumnSchema] = field(default_factory=dict)
71
71
  trade_schema: dict[str, ColumnSchema] = field(default_factory=dict)
72
72
 
73
- # === Column Mapping ===
74
- column_preset: str | None = None # "ylin" or None
75
- column_rename: dict[str, str] = field(default_factory=dict) # Custom rename map
73
+ # === Column Mapping Presets ===
74
+ trade_preset: str | None = None # "ylin" or None
75
+ alpha_preset: str | None = None # "jyao_v20251114" or None
76
76
 
77
77
  # === Aggregation ===
78
78
  binwidths: dict[str, float] = field(default_factory=dict)
vizflow/io.py CHANGED
@@ -141,7 +141,7 @@ def scan_trade(date: str, config: Config | None = None) -> pl.LazyFrame:
141
141
  >>> config = vf.Config(
142
142
  ... trade_dir=Path("/data/yuanzhao/"),
143
143
  ... trade_pattern="{date}.meords",
144
- ... column_preset="ylin",
144
+ ... trade_preset="ylin_v20251204",
145
145
  ... )
146
146
  >>> vf.set_config(config)
147
147
  >>> df = vf.scan_trade("20241001")
@@ -168,7 +168,7 @@ def scan_trades(config: Config | None = None) -> pl.LazyFrame:
168
168
  >>> config = vf.Config(
169
169
  ... trade_dir=Path("/data/yuanzhao/"),
170
170
  ... trade_pattern="{date}.feather",
171
- ... column_preset="ylin",
171
+ ... trade_preset="ylin_v20251204",
172
172
  ... )
173
173
  >>> vf.set_config(config)
174
174
  >>> df = vf.scan_trades()
@@ -190,7 +190,7 @@ def scan_trades(config: Config | None = None) -> pl.LazyFrame:
190
190
 
191
191
  def _apply_trade_mapping(df: pl.LazyFrame, config: Config) -> pl.LazyFrame:
192
192
  """Apply column rename + schema evolution for trade data."""
193
- df = _apply_rename(df, config)
193
+ df = _apply_rename(df, config.trade_preset)
194
194
  for col_name, schema in config.trade_schema.items():
195
195
  df = df.with_columns(pl.col(col_name).cast(schema.cast_to))
196
196
  return df
@@ -198,22 +198,27 @@ def _apply_trade_mapping(df: pl.LazyFrame, config: Config) -> pl.LazyFrame:
198
198
 
199
199
  def _apply_alpha_mapping(df: pl.LazyFrame, config: Config) -> pl.LazyFrame:
200
200
  """Apply column rename + schema evolution for alpha data."""
201
- df = _apply_rename(df, config)
201
+ df = _apply_rename(df, config.alpha_preset)
202
202
  for col_name, schema in config.alpha_schema.items():
203
203
  df = df.with_columns(pl.col(col_name).cast(schema.cast_to))
204
204
  return df
205
205
 
206
206
 
207
- def _apply_rename(df: pl.LazyFrame, config: Config) -> pl.LazyFrame:
208
- """Apply column rename from preset or custom mapping."""
207
+ def _apply_rename(df: pl.LazyFrame, preset: str | None) -> pl.LazyFrame:
208
+ """Apply column rename from preset name.
209
+
210
+ Args:
211
+ df: LazyFrame to rename columns
212
+ preset: Preset name (e.g., "ylin", "jyao_v20251114") or None
213
+ """
209
214
  # Drop record type prefix column if present (from CSV files)
210
215
  existing = set(df.collect_schema().names())
211
216
  if "#HFTORD" in existing:
212
217
  df = df.drop("#HFTORD")
213
218
  existing.remove("#HFTORD")
214
219
 
215
- # Get rename map from preset or custom
216
- rename_map = _get_rename_map(config)
220
+ # Get rename map from preset
221
+ rename_map = _get_rename_map(preset)
217
222
 
218
223
  if rename_map:
219
224
  existing = set(df.collect_schema().names())
@@ -238,7 +243,7 @@ def scan_alpha(date: str, config: Config | None = None) -> pl.LazyFrame:
238
243
  >>> config = vf.Config(
239
244
  ... alpha_dir=Path("/data/jyao/alpha"),
240
245
  ... alpha_pattern="alpha_{date}.feather",
241
- ... column_preset="jyao_v20251114",
246
+ ... alpha_preset="jyao_v20251114",
242
247
  ... )
243
248
  >>> vf.set_config(config)
244
249
  >>> df = vf.scan_alpha("20251114")
@@ -275,23 +280,17 @@ def scan_alphas(config: Config | None = None) -> pl.LazyFrame:
275
280
  return _apply_alpha_mapping(df, config)
276
281
 
277
282
 
278
- def _get_rename_map(config: Config) -> dict[str, str]:
279
- """Get rename map from preset name or custom dict.
283
+ def _get_rename_map(preset: str | None) -> dict[str, str]:
284
+ """Get rename map from preset name.
280
285
 
281
286
  Args:
282
- config: Config with column_preset or column_rename
287
+ preset: Preset name (e.g., "ylin_v20251204", "jyao_v20251114") or None
283
288
 
284
289
  Returns:
285
290
  Dict mapping old column names to new names
286
291
  """
287
- if config.column_rename:
288
- return config.column_rename
289
- if config.column_preset:
290
- from .presets import JYAO_V20251114, YLIN
291
-
292
- presets = {
293
- "ylin": YLIN,
294
- "jyao_v20251114": JYAO_V20251114,
295
- }
296
- return presets.get(config.column_preset.lower(), {})
297
- return {}
292
+ if not preset:
293
+ return {}
294
+ from .presets import PRESETS
295
+
296
+ return PRESETS.get(preset.lower(), {})
vizflow/presets.py CHANGED
@@ -1,7 +1,7 @@
1
1
  """Column mapping presets for VizFlow."""
2
2
 
3
- # Yuanzhao's log format -> VizFlow standard
4
- YUANZHAO = {
3
+ # ylin's trade format (v2025-12-04)
4
+ YLIN_V20251204 = {
5
5
  # Order columns (18)
6
6
  "symbol": "ukey",
7
7
  "orderId": "order_id",
@@ -59,9 +59,6 @@ YUANZHAO = {
59
59
  "globalCumSellNotional": "cum_sell_filled_notional",
60
60
  }
61
61
 
62
- # Alias: ylin (Yuanzhao's username)
63
- YLIN = YUANZHAO
64
-
65
62
  # jyao's alpha format (v2025-11-14)
66
63
  JYAO_V20251114 = {
67
64
  # Quote columns
@@ -75,10 +72,16 @@ JYAO_V20251114 = {
75
72
  "DataDate": "data_date",
76
73
  # Volume
77
74
  "Volume": "volume",
78
- # Alpha columns (Ŷ - predictions)
75
+ # Predictor columns (x_* = alpha predictions)
79
76
  # Rule: ≤60s → s, >60s → m
80
- "x10s": "alpha_10s",
81
- "x60s": "alpha_60s",
82
- "alpha1": "alpha_3m",
83
- "alpha2": "alpha_30m",
77
+ "x10s": "x_10s",
78
+ "x60s": "x_60s",
79
+ "alpha1": "x_3m",
80
+ "alpha2": "x_30m",
81
+ }
82
+
83
+ # Preset registry for dynamic lookup
84
+ PRESETS: dict[str, dict[str, str]] = {
85
+ "ylin_v20251204": YLIN_V20251204,
86
+ "jyao_v20251114": JYAO_V20251114,
84
87
  }
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: vizflow
3
- Version: 0.4.2
3
+ Version: 0.4.4
4
4
  Requires-Python: >=3.9
5
5
  Requires-Dist: polars>=0.20.0
6
6
  Provides-Extra: dev
@@ -0,0 +1,10 @@
1
+ vizflow/__init__.py,sha256=vYhGrFOQoONxBA6TJ08OQwWFd_UzltTsoZNQryNwnko,480
2
+ vizflow/config.py,sha256=zSZnhdHzgXSqhDenHcHKm4CDGrMpKAdkNNRoUYYF1uc,6530
3
+ vizflow/io.py,sha256=zmN0fFQOTmSBEBKangMExr0Q5mC2gajZM6GgdAyWkw4,8824
4
+ vizflow/market.py,sha256=MtNz_nnZxC66Aq-i2PXEwaFCTknijFWYZUUv6798k2s,2493
5
+ vizflow/ops.py,sha256=NL-Gtv-m_O1hv-0RUb9Wt43916HsQ5tYK_0e_uKR90w,4062
6
+ vizflow/presets.py,sha256=h91NZoOH4YAx0bbsaNigECf9WOcWh1QZavguunWkaLE,2452
7
+ vizflow/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
8
+ vizflow-0.4.4.dist-info/METADATA,sha256=NxMcTJ5fQKbB6GPak9dHARYTp9h0WwcDwxQAhrHcxRU,388
9
+ vizflow-0.4.4.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
10
+ vizflow-0.4.4.dist-info/RECORD,,
@@ -1,10 +0,0 @@
1
- vizflow/__init__.py,sha256=xqq6sMoOrly9Jo3B2mAJSe2yyeH5-h2862p9r5LUWf0,461
2
- vizflow/config.py,sha256=IiVau-4WyO_7NOWlR7Tw58RpDeGFYBbgkNzH7xuQIUg,6544
3
- vizflow/io.py,sha256=gtejbHRmgbClOGXrj6qfPw7Rz2LWmIFk2ohqlkPlY48,8874
4
- vizflow/market.py,sha256=MtNz_nnZxC66Aq-i2PXEwaFCTknijFWYZUUv6798k2s,2493
5
- vizflow/ops.py,sha256=NL-Gtv-m_O1hv-0RUb9Wt43916HsQ5tYK_0e_uKR90w,4062
6
- vizflow/presets.py,sha256=3mkwDeAJqYAKnMzOWTHzevdsAmRzsgk0Y83Ml5aGXKM,2357
7
- vizflow/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
8
- vizflow-0.4.2.dist-info/METADATA,sha256=_ASajAOnZZG49eLujsUzjHnCxJGj69Sryhjnf-pV1Qs,388
9
- vizflow-0.4.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
10
- vizflow-0.4.2.dist-info/RECORD,,