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 / 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
set runtimepath+=~/.vimperator/plugin
let mapleader=";"
noremap j 3j
noremap k 3k
noremap J <C-d>
noremap K <C-u>
map <Leader>s :stop<cr>
noremap h gT
noremap l gt
"vundle pre-config
set nocompatible
filetype off
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
"vundle bundles & plugins
Plugin 'VundleVim/Vundle.vim'
Bundle 'tpope/vim-endwise'
Bundle 'tpope/vim-git'