Skip to content

Instantly share code, notes, and snippets.

View leonlee's full-sized avatar
🎯
Focusing

Leon Lee leonlee

🎯
Focusing
  • ACAR
  • Beijing
View GitHub Profile
@leonlee
leonlee / validation-strategy.md
Created November 15, 2024 03:40
Business Rule Validation Strategy

You are on the right track. Domain or business validation logic should do more than just report true or false. You want to enable the "user" of your business classes (ie the UI, or your logging system) to do something more than just report to the end-user that something is wrong.

Now, how you do that is completely up to you.

Decision to make: check everything and then report all errors/warnings/information, or stop at the first one you encounter. I would personally opt for the first one and let the UI decide how to use the info. There is a trade-off though: some validations may take longer than others and you may want to check these only if the "simple" ones succeed.

I wouldn't in any case use exceptions to do this. Some people use exceptions because most development environments have a nice way of showing any unhandled exceptions to the user. I think that is just a bad/lazy choice. And not just because it is then hard to decide where the error came from (though stack traces can help there), but also becau

@leonlee
leonlee / read-it-later.txt
Last active November 12, 2024 10:26
ReadItLater
https://blog.cronn.de/en/gradle/java/2021/05/06/gradle-dependencies-gotchas-in-subprojects.html
https://www.evanjones.ca/java-bytebuffer-leak.html
https://www.infoq.com/articles/architecting-java-persistence-patterns-and-strategies/
https://medium.com/airfrance-klm/beautify-your-iterm2-and-prompt-40f148761a49
https://www.adyen.com/knowledge-hub/design-to-duty-adyen-architecture
https://www.adyen.com/knowledge-hub/combating-marketplace-seller-fraud-with-graph-neural-networks
https://ykblog.github.io/posts/pay/%E3%80%90%E6%B8%85%E7%BB%93%E7%AE%97%E3%80%91%E6%B8%85%E7%BB%93%E7%AE%97%E4%B9%8B%E9%93%B6%E8%A1%8C/
https://www.adyen.com/knowledge-hub/injecting-metadata-as-comments
https://mwhittaker.github.io/blog/an_illustrated_proof_of_the_cap_theorem/
https://medium.com/expedia-group-tech/zen-and-the-art-of-maven-dependency-resolution-7d24808ad03
@leonlee
leonlee / closure-table-operations.sql
Created December 31, 2021 07:12 — forked from kentoj/closure-table-operations.sql
Closure Table operations SQL fragments
-- Retrieve descendants
-- ====================
-- retrieve descendants of #4
SELECT c.*
FROM Comments AS c
JOIN TreePaths AS t ON c.comment_id = t.descendant
WHERE t.ancestor = 4;
-- Retrieve ancestors
@leonlee
leonlee / Price divergence
Created March 25, 2021 12:43
乖离率
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © MotorMe
//@version=4
//@version=4
study("Price divergence")
cs=(close-ema(close,20))/ema(close,20)*100
sm=(ema(close,20)-ema(close,60))/ema(close,60)*100
ml=(ema(close,60)-ema(close,120))/ema(close,120)*100
什么是交易策略?
交易策略是一系列规则的集合,包括进场和出场的条件,资金管理和风险控制等。策略有简单和复杂之分,简单的策略通常使用技术指标和价格行为,复杂的策略使用高阶数学和统计模型。通常情况下,我们会认为复杂的模型更优,但实证分析和学术研究表明,复杂的模型往往过度挖掘了历史数据,无法适应剧烈的市场变异,相反简单的模型在长期中更加稳定。
交易策略可划分为3个部分:指标(Indicator),信号(Signal)和规则(Rule)。
指标用于生成交易信号。计算指标的方法多种多样,可以是经济数据或估值指标(如PE和EBITDA),可以是技术指标(如MACD,RSI,MA),也可以是时间序列模型(ARIMA,GARCH)。技术指标在外汇交易中被广泛使用,它们是价格或成交量的函数,主要用于侦测趋势方向,衡量超买超卖状态,以及判断趋势反转。
价格和指标的相互作用形成信号。以均线穿越为例,当5日均线上穿10日均线时买入,当5日均线下穿10日均线时卖出。信号并不局限于买入和卖出,也包含筛子,主要作用是剔除噪音。在均线穿越中,交易员可以增加趋势筛子:只有当价格高于200日均线(上涨趋势),以及5日均线上穿10日均线才做多,如果价格低于200日均线,黄金交叉被视为虚假信号。著名的筛子有趋势筛子,时间筛子,成交量筛子和波动性筛子,它们是信号的重要组成部分。
## `#`开头为注释内容, 选项都有相应的注释说明, 根据需要修改 ##
## 被注释的选项填写的是默认值, 建议在需要修改时再取消注释 ##
## 如果出现`Initializing EpollEventPoll failed.`之类的
## 错误提示, 可以取消event-poll选项的注释 ##
## 文件保存相关 ##
# 文件的保存路径(可使用绝对路径或相对路径), 默认: 当前启动位置
dir=/Users/leon/Downloads
# 启用磁盘缓存, 0为禁用缓存, 需1.16以上版本, 默认:16M
" Settings
set nohud
set nosmoothscroll
set noautofocus " The opposite of autofocus; this setting stops
" sites from focusing on an input box when they load
set typelinkhints
let searchlimit = 30
let scrollstep = 70
let barposition = "bottom"
@leonlee
leonlee / .cvimrc
Last active February 6, 2018 06:23
" Settings
set nohud
set nosmoothscroll
set noautofocus " The opposite of autofocus; this setting stops
" sites from focusing on an input box when they load
set typelinkhints
let searchlimit = 30
let scrollstep = 70
let barposition = "bottom"
#变量定义:
#$TASK_HOME=任务部署后的顶级目录,如: /x/y/finance_group/budget_reset/
#[required] 分组名用于组织任务的目录结构,方便管理
task.group="finance"
#[required] 任务的名称,作为任务的目录名
task.name="budget_reset"
#[required] 任务版本,格式:"X.Y.Z",用于支持多版本部署和回滚,同时只有一个版本运行
task.version="1.0.0"
#[optional] 任务描述,可以包含一些业务描述和注意事项
;; -*- mode: emacs-lisp -*-
;; This file is loaded by Spacemacs at startup.
;; It must be stored in your home directory.
(defun dotspacemacs/layers ()
"Configuration Layers declaration.
You should not put any user code in this function besides modifying the variable
values."
(setq-default
;; Base distribution to use. This is a layer contained in the directory