First commit
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
"""Deterministic price data for tests (no randomness, so results never drift between Python versions)."""
|
||||
import math
|
||||
|
||||
from app import marketdata
|
||||
|
||||
|
||||
def wave(n, phase=0.0, drift=0.06, amp=14.0, period=24.0, start=1_500_000_000, step=86400, base=100.0):
|
||||
"""Rising prices with swings. Volume is heavier on up-moves, as in a real rally, so the
|
||||
strategy finds trends to enter."""
|
||||
out, prev = [], base
|
||||
for i in range(n):
|
||||
close = base + amp * math.sin(i / period + phase) + drift * i + 2.0 * math.sin(i / 5.0 + phase)
|
||||
up = max(0.0, (close - prev) / prev * 100)
|
||||
out.append(marketdata.Candle(start + i * step, close * 1.008, close * 0.992, close,
|
||||
1000 * (1 + 3 * up) * (1.0 + 0.2 * math.sin(i / 3.0))))
|
||||
prev = close
|
||||
return out
|
||||
Reference in New Issue
Block a user