Datasets:
Upload scripts/lane03_ft.py with huggingface_hub
Browse files- scripts/lane03_ft.py +100 -0
scripts/lane03_ft.py
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Lane 03: ZPE-FT — deterministic codec for delayed public market data.
|
| 2 |
+
Key visual: a row of candlestick bars (financial tick stream). Procedural.
|
| 3 |
+
"""
|
| 4 |
+
import sys, os
|
| 5 |
+
sys.path.insert(0, os.path.dirname(__file__))
|
| 6 |
+
from render_protocol import (
|
| 7 |
+
clean_scene, add_wireframe, set_fill_as_occluder,
|
| 8 |
+
setup_world, render_2x, W2X, H2X,
|
| 9 |
+
)
|
| 10 |
+
import bpy, math, random
|
| 11 |
+
|
| 12 |
+
OUT_2X = "/Users/Zer0pa/ZPE/ZPE-Animation-Workspace/blender-proto/lane03_ft_2x.png"
|
| 13 |
+
OUT_FINAL = "/Users/Zer0pa/ZPE/ZPE-Animation-Workspace/final-572x534/key-visuals/lane03_ZPE-FT.png"
|
| 14 |
+
|
| 15 |
+
scene = clean_scene()
|
| 16 |
+
|
| 17 |
+
# Generate deterministic candlestick stream: 24 bars along X
|
| 18 |
+
random.seed(20098) # fixed seed for reproducibility
|
| 19 |
+
N = 24
|
| 20 |
+
bar_width = 0.04
|
| 21 |
+
gap = 0.02
|
| 22 |
+
total_width = N * bar_width + (N - 1) * gap
|
| 23 |
+
x_start = -total_width / 2 + bar_width / 2
|
| 24 |
+
|
| 25 |
+
# Mean-reverting price series: random walk pulled back toward zero so the
|
| 26 |
+
# chart stays roughly horizontal and fills the frame evenly
|
| 27 |
+
price = 0.0
|
| 28 |
+
prices = []
|
| 29 |
+
for _ in range(N * 2):
|
| 30 |
+
price += random.gauss(0, 0.06) - price * 0.10 # mean-reversion
|
| 31 |
+
prices.append(price)
|
| 32 |
+
|
| 33 |
+
bars = []
|
| 34 |
+
for i in range(N):
|
| 35 |
+
open_p = prices[i * 2]
|
| 36 |
+
close_p = prices[i * 2 + 1]
|
| 37 |
+
lo = min(open_p, close_p)
|
| 38 |
+
hi = max(open_p, close_p)
|
| 39 |
+
body_h = max(0.04, hi - lo)
|
| 40 |
+
body_center_z = (open_p + close_p) / 2
|
| 41 |
+
|
| 42 |
+
x = x_start + i * (bar_width + gap)
|
| 43 |
+
bpy.ops.mesh.primitive_cube_add(size=1, location=(x, 0, body_center_z))
|
| 44 |
+
body = bpy.context.active_object
|
| 45 |
+
body.scale = (bar_width / 2, bar_width / 2, body_h / 2)
|
| 46 |
+
body.name = f"Bar_{i:02d}"
|
| 47 |
+
bars.append(body)
|
| 48 |
+
|
| 49 |
+
# Wick: thin vertical line from bbox-lo to bbox-hi extended by a random amount each side
|
| 50 |
+
wick_extend = random.uniform(0.03, 0.10)
|
| 51 |
+
wick_hi = hi + wick_extend
|
| 52 |
+
wick_lo = lo - wick_extend
|
| 53 |
+
wick_h = wick_hi - wick_lo
|
| 54 |
+
wick_center_z = (wick_hi + wick_lo) / 2
|
| 55 |
+
bpy.ops.mesh.primitive_cube_add(size=1, location=(x, 0, wick_center_z))
|
| 56 |
+
wick = bpy.context.active_object
|
| 57 |
+
wick.scale = (bar_width * 0.06, bar_width * 0.06, wick_h / 2)
|
| 58 |
+
wick.name = f"Wick_{i:02d}"
|
| 59 |
+
bars.append(wick)
|
| 60 |
+
|
| 61 |
+
print(f"[lane03] created {N} bars + {N} wicks = {len(bars)} objects")
|
| 62 |
+
|
| 63 |
+
# Wireframe + fill all bars and wicks
|
| 64 |
+
for b in bars:
|
| 65 |
+
set_fill_as_occluder(b)
|
| 66 |
+
add_wireframe(b, thickness_factor=0.10) # higher factor — these are tiny boxes
|
| 67 |
+
|
| 68 |
+
setup_world()
|
| 69 |
+
|
| 70 |
+
# Camera framing
|
| 71 |
+
all_z = []
|
| 72 |
+
for p in prices:
|
| 73 |
+
all_z.append(p)
|
| 74 |
+
all_z.extend([p + 0.10 for p in prices])
|
| 75 |
+
all_z.extend([p - 0.10 for p in prices])
|
| 76 |
+
z_min, z_max = min(all_z), max(all_z)
|
| 77 |
+
content_height = z_max - z_min
|
| 78 |
+
content_width = total_width
|
| 79 |
+
|
| 80 |
+
# Aspect ratio 1144/1068 ≈ 1.07. Width-limited if content_width > content_height * 1.07
|
| 81 |
+
half_fov = math.atan((36/2) / 50)
|
| 82 |
+
dist_w = (content_width / 2) / math.tan(half_fov) * 1.10 # 10% margin
|
| 83 |
+
dist_h = (content_height / 2) / math.tan(half_fov) * 1.30
|
| 84 |
+
dist = max(dist_w, dist_h)
|
| 85 |
+
|
| 86 |
+
target = bpy.data.objects.new("Target", None)
|
| 87 |
+
target.location = (0, 0, (z_min + z_max) / 2)
|
| 88 |
+
scene.collection.objects.link(target)
|
| 89 |
+
cam_data = bpy.data.cameras.new("Cam"); cam_data.lens = 50
|
| 90 |
+
cam_data.clip_start = 0.001
|
| 91 |
+
cam = bpy.data.objects.new("Cam", cam_data); scene.collection.objects.link(cam)
|
| 92 |
+
cam.location = (0, -dist, (z_min + z_max) / 2)
|
| 93 |
+
trk = cam.constraints.new('TRACK_TO')
|
| 94 |
+
trk.target = target; trk.track_axis = 'TRACK_NEGATIVE_Z'; trk.up_axis = 'UP_Y'
|
| 95 |
+
scene.camera = cam
|
| 96 |
+
print(f"[lane03] content size {content_width:.2f}x{content_height:.2f} cam dist {dist:.2f}")
|
| 97 |
+
|
| 98 |
+
print(f"[lane03] rendering {W2X}x{H2X} → {OUT_2X}")
|
| 99 |
+
render_2x(OUT_2X)
|
| 100 |
+
print(f"[lane03] done")
|