Loading presentation...

Present Remotely

Send the link below via email or IM

Copy

Present to your audience

Start remote presentation

  • Invited audience members will follow you as you navigate and present
  • People invited to a presentation do not need a Prezi account
  • This link expires 10 minutes after you close the presentation
  • A maximum of 30 users can follow your presentation
  • Learn more about this feature in our knowledge base article

Do you really want to delete this prezi?

Neither you, nor the coeditors you shared it with will be able to recover it again.

DeleteCancel

Make your likes visible on Facebook?

Connect your Facebook account to Prezi and let your likes appear on your timeline.
You can change this under Settings & Account at any time.

No, thanks

How we design a trading strategy

No description
by

Jingru Li

on 25 November 2013

Comments (0)

Please log in to add your comment.

Report abuse

Transcript of How we design a trading strategy

How we design a trading strategy
Data Research
Mixed Strategy
Strategy Code and optimizor
BBands parameters
Lookback
Standard deviation

Future Plan
1.
Further optimization of parameters
Add additional functions to strategies
Additional methods setting volume of Limit order & market order and price of limit order.


Methods:
What do we want from the data?
Indicators
Find trend using close price
Other indicators in TTR
(open-close)/close
(low2-low1)/low1
(high+low)/2
chart_Series(dataList[[1]], type="line")
addBbands()
addMACD()
2.
How we deal with part 2 data:
1.test with current strategy
2.cross validation
3.robustness test


Background
Background ……………………………………..Sue
Data research …………………….Anna & Evan
Strategy description………………………….Zoe
Code analysis…………………………………….Eric
Future plan………………………………………..Eve



Structure

Literature:
Evan.G, William.N and K.Greet, 1999, “Pairs Trading: performance of a relative value arbitrage rule”, Working paper
Daniel.H, 2004, “Pairs Trading, Convergence Trading, Cointegration”, working paper
StockChart, n.d., “Moving Average Convergence-Divergence (MACD)” viewed 10 Novmber 2013<http://stockcharts.com/help/doku.php?id=chart_school:technical_indicators:moving_average_conve >
Investopedia, n.d., ”Bollinger Band” viewed 10 November 2013< http://www.investopedia.com/terms/b/bollingerbands.asp>


trade signal
Objective
Result
Method

Simple_limit parameters
Spreadpercentage
InventoryLimits

Simple_limit_with position size
Similar to simple_limit
Maxposition size

Result
getOrders <- function(store, newRowList, currentPos, params) {
allzero <- rep(0,length(newRowList))
if (is.null(store))
store <- initStore(newRowList,params$series)
else
store <- updateStore(store, newRowList, params$series)
marketOrders <- -currentPos
pos <- allzero
if (store$iter > params$lookback) {
startIndex <- store$iter - params$lookback
#cat(startIndex,store$iter,'\n')
for (i in 1:length(params$series)) {
cl <- newRowList[[params$series[i]]]$Close
bbands <- last(BBands(store$cl[startIndex:store$iter,i],
n=params$lookback,sd=params$sdParam))[c("dn","up")]
if (cl < bbands["dn"]) {
pos[params$series[i]] <- 1
}
else if (cl > bbands["up"]) {
pos[params$series[i]] <- -1
}
}
}
marketOrders <- marketOrders + pos
return(list(store=store,marketOrders=marketOrders,
limitOrders1=allzero,
limitPrices1=allzero,
limitOrders2=allzero,
limitPrices2=allzero))
}

getOrders <- function(store, newRowList, currentPos, params) {

#cat("currentPos", formatC(currentPos,3),"\n")

# check if current inventory is above a limit and if so exit completely
# with a market order

marketOrders <- ifelse(abs(currentPos) > params$inventoryLimits, -currentPos, 0)

# use the range (High-Low) as a indicator for a reasonable "spread" for
# this pseudo market making strategy
spread <- sapply(1:length(newRowList),function(i)
params$spreadPercentage * (newRowList[[i]]$High -
newRowList[[i]]$Low))

limitOrders1 <- rep(1,length(newRowList)) # BUY LIMIT ORDERS
limitPrices1 <- sapply(1:length(newRowList),function(i) newRowList[[i]]$Close - spread[i]/2)

limitOrders2 <- rep(-1,length(newRowList)) # SELL LIMIT ORDERS
limitPrices2 <- sapply(1:length(newRowList),function(i) newRowList[[i]]$Close + spread[i]/2)

return(list(store=store,marketOrders=marketOrders,
limitOrders1=limitOrders1,
limitPrices1=limitPrices1,
limitOrders2=limitOrders2,
limitPrices2=limitPrices2))
}

Optimization of strategy
source('data.R')
source('backtester_v3.1.R')

source('strategies/bbands.R')

numOfDays <- 200
dataList <- getData(part=1)
dataList <- lapply(dataList, function(x) x[1:numOfDays])

sMult <- 0.2 # slippage multiplier

lookbackSeq <- seq(from=20,to=40,by=10)
sdParamSeq <- seq(from=1.5,to=2,by=0.5)
# sdParamSeq <- seq(from=1.5,to=2,length.out=100) # the way to specify how
# many options you want for this param
paramsList <- list(lookbackSeq,sdParamSeq)

numberComb <- prod(sapply(paramsList,length))

resultsMatrix <- matrix(nrow=numberComb,ncol=3)
colnames(resultsMatrix) <- c("lookback","sdParam","SharpeRatio")
pfolioPnLList <- vector(mode="list",length=numberComb)
count <- 1

for (lookback in lookbackSeq) {
for (sdParam in sdParamSeq) {
params <- list(lookback=lookback,sdParam=sdParam,series=1:4)
results <- backtest(dataList, getOrders, params, sMult)
pfolioPnL <- plotResults(dataList,results$pnlList)
pfolioSharpe <- pfolioPnL$sharpeAgg
resultsMatrix[count,] <- c(lookback,sdParam,pfolioSharpe)
pfolioPnLList[[count]]<- pfolioPnL
cat("Just completed",count,"out of",numberComb,"\n")
print(resultsMatrix[count,])
count <- count + 1
}
}

print(resultsMatrix[order(resultsMatrix[,"SharpeRatio"]),])


Pair Trading
Pair trending
Bollinger Bands
Trend following
MACD
idea: trend following or momentum trading
using indicators to show the price trend to move upwards or downwards
observe current trend direction and decide whether to buy or sell
risk control: decide when to enter, exit or wait
methods: Copycat

Trend Following Strategy

Pair Trading Strategy – series 1&2, 3&4, 9&10
Limit Order Trading Strategy – series 5,6,7
BBands Strategy – series 8
Trend Following Strategy


Mixed Strategy

idea: Marketmaking, make small money near yesterday’s close price.
buy limit order
low < limit price
sell limit order
high > limit price

Limit Order Trading Strategy

idea: Mean reversion, automatic buy and sell
buy –
when below lower band
sell –
when above upper band

BBands Strategy

idea: spread trading
pairs 1&2, 3&4
buy under-performer,
sell over-performer
converse pairs 9&10
buy over-performer,
sell under-performer


Pairs Trading Strategy
Full transcript