From 9c88d4c246cd82038f67f667f961a6861675d587 Mon Sep 17 00:00:00 2001 From: monoid Date: Mon, 24 Jul 2023 09:10:32 +0900 Subject: [PATCH] feat: add filter toggle button --- deno.json | 2 + gen.py | 8 +- islands/StockList.tsx | 217 +++++++++++++----- notebook.py | 44 ++++ pages.yaml | 13 +- routes/pages/[name].tsx | 2 +- test.ipynb | 497 +++++++++++++++++++++++++++++----------- 7 files changed, 590 insertions(+), 193 deletions(-) create mode 100644 notebook.py diff --git a/deno.json b/deno.json index 0b95123..ecff41f 100644 --- a/deno.json +++ b/deno.json @@ -19,6 +19,8 @@ "preact-render-to-string": "https://esm.sh/*preact-render-to-string@6.2.0", "@preact/signals": "https://esm.sh/*@preact/signals@1.1.3", "@preact/signals-core": "https://esm.sh/*@preact/signals-core@1.2.3", + "auto-animate": "https://esm.sh/@formkit/auto-animate@0.7.0", + "auto-animate/": "https://esm.sh/@formkit/auto-animate@0.7.0/", "twind": "https://esm.sh/twind@0.16.19", "twind/": "https://esm.sh/twind@0.16.19/", "$std/": "https://deno.land/std@0.193.0/" diff --git a/gen.py b/gen.py index 5cf8e0b..a5675c0 100644 --- a/gen.py +++ b/gen.py @@ -156,7 +156,7 @@ def collect(data: DataStore, collector: OutputCollector, corp: database.KRXCorp bollinger_upperband = d25 + 2* d_std25 - a = [d20, d30, d60, d120] + a = [d5, d20, d45, d60] for nday in ndays: if openv[nday] <= d20[nday] and d20[nday] <= close[nday]: collector.collect("양봉사이20일선", corp, stock.index[nday]) @@ -171,13 +171,13 @@ def collect(data: DataStore, collector: OutputCollector, corp: database.KRXCorp if every(lambda i: isRelativeDiffLessThan(i,close,0.01,nday), a): collector.collect("뭉침01", corp, stock.index[nday]) + if d120[nday + 1] < d120[nday]: + collector.collect("뭉침1% 120선 상승", corp, stock.index[nday]) + if every(lambda i: isRelativeDiffLessThan(i,close,0.03,nday), a): collector.collect("뭉침03", corp, stock.index[nday]) if d120[nday + 1] < d120[nday]: collector.collect("뭉침3% 120선 상승", corp, stock.index[nday]) - - if every(lambda i: isRelativeDiffLessThan(i,close,0.05,nday), [d20, d30, d60, d120, d240]): - collector.collect("뭉침 240선까지", corp, stock.index[nday]) if (d5[nday] > d20[nday] and d5[nday + 1] < d20[nday + 1]): collector.collect("cross d20 and d5", corp, stock.index[nday]) diff --git a/islands/StockList.tsx b/islands/StockList.tsx index f7f53ed..c603b6b 100644 --- a/islands/StockList.tsx +++ b/islands/StockList.tsx @@ -1,20 +1,33 @@ import { Button } from "../components/Button.tsx"; -import { useEffect } from "preact/hooks"; +import { useEffect, useRef } from "preact/hooks"; import { ComponentChildren } from "preact"; import { Signal, useSignal } from "@preact/signals"; +import { IS_BROWSER } from "$fresh/runtime.ts"; +import { mapValues } from "$std/collections/map_values.ts"; interface StockProps { pageName: string; } interface ToggleButtonProps { + disabled?: boolean; + toggle: Signal; children?: ComponentChildren; } function ToggleButton(props: ToggleButtonProps) { + const { disabled, toggle, ...rest } = props; return ( - +