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
什么是交易策略?
交易策略是一系列规则的集合,包括进场和出场的条件,资金管理和风险控制等。策略有简单和复杂之分,简单的策略通常使用技术指标和价格行为,复杂的策略使用高阶数学和统计模型。通常情况下,我们会认为复杂的模型更优,但实证分析和学术研究表明,复杂的模型往往过度挖掘了历史数据,无法适应剧烈的市场变异,相反简单的模型在长期中更加稳定。
交易策略可划分为3个部分:指标(Indicator),信号(Signal)和规则(Rule)。
指标用于生成交易信号。计算指标的方法多种多样,可以是经济数据或估值指标(如PE和EBITDA),可以是技术指标(如MACD,RSI,MA),也可以是时间序列模型(ARIMA,GARCH)。技术指标在外汇交易中被广泛使用,它们是价格或成交量的函数,主要用于侦测趋势方向,衡量超买超卖状态,以及判断趋势反转。
价格和指标的相互作用形成信号。以均线穿越为例,当5日均线上穿10日均线时买入,当5日均线下穿10日均线时卖出。信号并不局限于买入和卖出,也包含筛子,主要作用是剔除噪音。在均线穿越中,交易员可以增加趋势筛子:只有当价格高于200日均线(上涨趋势),以及5日均线上穿10日均线才做多,如果价格低于200日均线,黄金交叉被视为虚假信号。著名的筛子有趋势筛子,时间筛子,成交量筛子和波动性筛子,它们是信号的重要组成部分。
@leonlee
leonlee / iptableflip.sh
Created March 31, 2016 11:06 — forked from lewisd32/iptableflip.sh
Snippet of Unbounce script for restarting HAProxy with zero downtime
echo "Flipping tables! (╯°□°)╯︵ ┻━┻"
num_rules=3
real=3 # exposed to the ELB as port 443
test=4 # used to install test certs for domain verification
health=5 # used by the ELB healthcheck
blue_prefix=855
green_prefix=866
@leonlee
leonlee / vim.markdown
Created March 7, 2016 11:57 — forked from socketwiz/vim.markdown
Vim cheat sheet

##motions

motion description
h Count characters left
l Count characters right
^ To the first character of the line
$ To the last character of the line
f<char> To the counth character occurrence to the right. F<char> to the counth character occurrence to the left
t<char> To 1 character just before the counth character occurrence to the right
T<char> To 1 character just before the counth character occurrence to the left
local redis_c = require "resty.redis"
local ok, new_tab = pcall(require, "table.new")
if not ok or type(new_tab) ~= "function" then
new_tab = function (narr, nrec) return {} end
end
local _M = new_tab(0, 155)
@leonlee
leonlee / dkcleanup.sh
Created November 18, 2015 06:00 — forked from brianclements/dkcleanup.sh
Bash script helper to remove Docker images and containers.
#!/bin/bash
# options:
# remove stopped containers and untagged images
# $ dkcleanup
# remove all stopped|running containers and untagged images
# $ dkcleanup --reset
# remove containers|images|tags matching {repository|image|repository\image|tag|image:tag}
# pattern and untagged images
# $ dkcleanup --purge {image}
@leonlee
leonlee / gist:176f565d560df09988ad
Created November 2, 2015 10:51 — forked from fernandoaleman/gist:5083680
How to update VirtualBox Guest Additions with vagrant
# Start the old vagrant
$ vagrant init centos-6.3
$ vagrant up
# You should see a message like:
# [default] The guest additions on this VM do not match the install version of
# VirtualBox! This may cause things such as forwarded ports, shared
# folders, and more to not work properly. If any of those things fail on
# this machine, please update the guest additions and repackage the
# box.

Spark project AS3 library list

Graphics/Color (AS3)

"20091020
let mapleader=";"
" " " 映射
" " 页面操作
" 一次移动5行
noremap j 5j
noremap k 5k
" 上下滚动