42 lines
1.5 KiB
Python
42 lines
1.5 KiB
Python
from fastapi import FastAPI
|
|
from fastapi.testclient import TestClient
|
|
|
|
from app.analysis.levels import Side
|
|
from app.analysis.manual_lines import ManualLine, ManualLineStore
|
|
from app.api.routes import router
|
|
from app.bars.models import Timeframe
|
|
from app.config import Settings
|
|
from app.runtime import Runtime
|
|
|
|
|
|
def test_a_fibonacci_is_not_a_confluence_level(tmp_path):
|
|
store = ManualLineStore(tmp_path / "lines.json")
|
|
store.add(ManualLine(
|
|
id="ml_fib", tf=Timeframe.M15, side=Side.RESISTANCE,
|
|
anchor_t=1000, anchor_p=6500, slope=-1 / 1800, last_t=2800,
|
|
created_at=1000, kind="fibonacci", note="swing",
|
|
))
|
|
assert store.levels() == []
|
|
assert store.drawings()[0].drawing_kind == "fibonacci"
|
|
|
|
|
|
def test_creating_a_fibonacci_returns_the_drawing_not_a_level(tmp_path):
|
|
app = FastAPI()
|
|
app.include_router(router)
|
|
app.state.runtime = Runtime(Settings(
|
|
manual_lines_path=tmp_path / "lines.json",
|
|
events_path=tmp_path / "events.json",
|
|
alert_state_path=tmp_path / "alerts.json",
|
|
chart_auth_token="",
|
|
))
|
|
client = TestClient(app)
|
|
response = client.post("/api/lines", json={
|
|
"tf": "15m", "side": "resistance",
|
|
"anchor_t": 1000, "anchor_p": 6500, "end_t": 2800, "end_p": 6400,
|
|
"kind": "fibonacci", "note": "high to low",
|
|
})
|
|
assert response.status_code == 201
|
|
body = response.json()
|
|
assert body["kind"] == "fibonacci"
|
|
assert "weight" not in body
|
|
assert app.state.runtime.manual_lines.levels() == []
|