Frequently Asked Questions
Trading Pairs in General
What is "model"?
Even if we consider only mean reversion subset of pairs trading (yes, there are more), there is still multiple ways of how to do it, which differ mostly in math behind generating entry and exit signals.
We refer to the mean reversion stategy details (the math and logic in signal generation) as to a model.
Is it better to trade intraday (during the whole day) or just at the end of the day (EOD)?
You can decide if you will handle entry/exit signals during the whole trading day (intraday trading) or if you restrict trading session to some short trading interval to imitate EOD (end-of-day) trading. There are advantages / disadvantages to both approaches.
Intraday Trading
- generates more signals = more trades = more commissions paid
- worse average profit per trade
- usually smoother equity
- real mean-reversion strategy with capped profits
EOD Trading
- less trades = less capital spent on commissions
- better average profit per trade
- equity not that smooth
- sometimes it makes additional profit caused by not exiting at exit threshold but later
- real trading results are much closer to EOD backtests
There are also hybrid setups possible (for instance, entering positions EOD but closing intraday or vice versa).
How risk control is handled in pairs trading?
In portfolios assembled from pairs trading strategies risk control is based on three main principles:
- Time based stop (each position is closed after N days in every case)
- Minimizing exposure to single pair strategy (diversification; you trade divide your margin to many pair strategies)
- Updating the portfolio constantly (replacing weak performers by strong performers)
Using traditional loss % based stop-losses is tricky and not very effective here, because strategies are composed from multiple legs and positions are commonly held over nights and weekends. One cannot control risk properly using just stop orders when dealing with positions like these due to price gaps which are very common in setups like this.
The better approach is just to divide the margin used into many "small" pairs strategies to avoid putting "all the eggs into the same basket".
This is the reason we do not implement traditional stop-losses.
Pair Trading Lab Website
Which instruments can I use for testing?
You can use all US stocks, ETFs and in addition any instrument available at Google Finance as long as history data (via the Download to spreadsheet link!) is available. Use same stock codes as on Google Finance, including the exchange prefix.
Unfortunately Google Finance decided to close their public historical data API, so at the moment you can only use US stocks and ETFs listed on following exchanges:
Futures are not supported.
Which models can I use for testing?
These models are currently supported in the online backtester engine:
- Ratio - the original model based on ratio of instrument prices, moving average and standard deviation
- Residual - model based on linear regression (OLS) and standard deviation
- Kalman - experimental model based on Kalman filter (education purpose only)
- Kalman-grid - profit-optimizing model based on whole grid of Kalman filters
- Kalman-auto - margin-usage optimizing model based on whole grid of Kalman filters
These models are currently supported in PTL Trader:
- Ratio
- Residual
- Kalman-grid
- Kalman-auto
Detailed Information About Models
What data is used for analyses, backtests, studies and pre-screened database?
In September 2013 we introduced the data^HQ system for US stock market data. How does it work? We aggregate financial and corporate event data from multiple data providers and we try to automate the data correction process based on multiple data streams. We focus on correcting unadjusted data issues with splits and reverse splits, which cause most problems for our algorithms. There are more details about the data^HQ system in this forum thread.
Remark: data^HQ is used only for US stocks and ETFs. For other markets, or in case data^HQ is not available, Google Finance data are used as a fallback.
Using of data^HQ is indicated in backtest/study result by this HQ sign.
Is this data adjusted for splits and dividends?
Data provided by data^HQ system (all US equities) is adjusted for all capital-related corporate actions - splits, reverse splits, capital returns, special dividends, stock dividends, demergers and spin-offs. Data is not adjusted for ordinary divindends as this would not be correct.
Data provided by Google Finance is adjusted for splits, reverse splits, demergers and spin-offs. For more info about how Google Finance data is adjusted, please consults Google's financial data specifications.
What are features and limitations of the online backtesting engine?
The backtester powering this website is a quite simple engine running on end-of-day close prices. Close prices only are used to calculate model statistics and to generate trade signals.
Features:
- commissions are simulated; for now only IB Fixed Rate Pricing for US Equities commission profile is applied (in future we will support more commission charging profiles)
- bid-ask spread simulation is supported since Nov 2016
- custom margin setups (CFDs, ...)
Limitations:
- ordinary dividends are not simulated (we plan to include this feature in the future)
- slippage and execution latency is not simulated
- intraday execution is not simulated (as it runs over EOD data)
- equity borrowing costs (loan fees) of short positions are not simulated
- all equities are treated as easy-to-borrow and no short position is subject of early sales (forced buy-ins) or short-squeezes
- backtests are performed using consolidated EOD prices, which can inflate results for particular pairs (with correlation >0.99 or <-0.99), see the next section for more detail
My backtests show results “too good to be true” with “Warning: This backtest may indicate inflated performance due to consolidated prices noise!”. What does this mean?
Pair Trading Lab calculates backtests and analyses using consolidated, end-of-day prices. This is fine for many strategies, but unfortunately with mean-reversion strategies over US-based equity baskets (like pairs trading) it introduces a problem in certain situations.
Why? The issue appears if equities are listed on a primary exchange (like NASDAQ), but in addition they are being traded at multiple secondary venues at the same time (like BATS, ...) while prices being consolidated over all these venues. The problem is then that if you have two equities (AAA and BBB), it is not guaranteed that close prices you get are from the same venue and same moment. This creates additional "virtual" noise in close prices, which is not too significant for most of pairs, but for pairs like VXX/VIXY, UVXY/TVIX and others, which have correlation over 0.99 and very low standard deviation of their ratio/spread, it inflates backtest result so much that it cannot be really trusted for these particular pairs. This is why you get the warning.
You must understand that these pairs are intensively traded by HFT traders doing statistical arbitrages in market microstructure and they won't allow you to profit in real. To confirm that your strategy works on pairs like this you would have to backtest preferably using tick data, or at least with quality intraday data. Backtesting using non-consolidated (official primary exchange) EOD prices should also help, but these data are really difficult to get.
Example: https://www.pairtradinglab.com/backtests/WFVXYEHISQNMRCol
So for now, you need to accept this as a limitation of PTL's backtester. Important facts to realize:
- consolidated prices are problem only if equities are traded on multiple venues and prices are aggregated from all these venues (unfortunately US market is the good example), for Asian and European market there is often no problem
- this whole issue is actually a Signal-to-Noise-Ratio (SNR) problem. The lower the absolute correlation between pairs is, the better the SNR is and therefore the problem is not that significant...you can assume that for pairs with correlation <0.95 (in absolute value) you are always fine, the warning is displayed for pairs with correlation over 0.99 (in absolute value)
More informations in detail:
http://epchan.blogspot.cz/2015/04/beware-of-low-frequency-data.html
http://epchan.blogspot.cz/2016/09/really-beware-of-low-frequency-data.html
As a part of your education, it is good idea to try to run these strategies like UVXY/TVIX in PTL Trader using paper account. You will see for yourself how these pairs really behave in real-time. You will notice there is quite significant difference between z-score ASK and z-score BID, even that bid-ask spread on both legs is $0.01, which is already suspicious. You will not get virtually any entry signals, because the noise in consolidated prices is inflated and entry signals will be mostly not met. You might also notice that if quotes change for UVXY, TVIX quotes will match the change in milliseconds, which is probably HFT traders conducting their stat arb market making.
How reliable are backtest results considering ordinary dividends are not simulated?
When you trade pair strategy, you gain dividends for the long leg and you pay dividends for the short one. So the impact of dividends can be expressed like D = Dgained - Dpaid.
Under most conditions, the D is very close to zero (if both legs have similar dividend gaining performance). In 99% of pairs, the impact of gaining and paying dividends is significantly lower than your profit or even comissions paid.
However, there are some examples where this is not true. Good example is the SPY/VOO pair. This pair exhibits extremely positive correlation (close to 1) - it is too correlated so there is no space left for any profits. You can see the backtest is suspicious at the first sight - trade signals are only triggered on ex-dividend dates (you can see the peaks).
Please mind this when you select your pairs - avoid pairs with extreme correlations with periodical peaks in the Z-Score and equity too nice to be true. Usually these pairs exhibit very low CAGR but very good looking equities and profit distributions.
We will fully support simulating dividends in the future. For now please stay aware of this limitation.
I have pair AAA/BBB in my portfolio. I would like to add pair AAA/CCC, but it won't let me.
You can't have two pairs sharing the same equity in the same portfolio. This is not the limitation of the software solution. The problem is that IB (as an US broker following US regulations) does not (and must not) support hedged positions (you cannot hold long and short position of the same equity at the same time within one single account).
So imagine you are in long pair position of AAA/BBB pair (long AAA, short BBB). Now your AAA/CCC pair would like to go short (short AAA, long BBB). Entering this position would reduce the current position in AAA held by the AAA/BBB strategy. This is the reason why you cannot share equities within the same portfolio. There is nothing to do about it.
What is System Score?
System Score is our proprietary trading system performance measure. It is based on system CAGR and system (logarithmic) equity linearity (R2 measure). The formula is:
System Score = CAGR * Linearity^3 (linearity in <0, 1>)
It is always less or equal to CAGR in absolute value. For systems with perfect linear equity (linearity=1) it is equal to CAGR (positive or negative). For systems with "ugly", non-linear equity full of drawdowns, it is close to zero. Traders prefer systems with System Score as high as possible (this guarantees system with both high yield and nice profit distribution at the same time).
I noticed that my recent pair tests are announced in Recent Analyses and Recent Backtests. I would really prefer to keep my pairs from being disclosed to public.
This is no longer true if you become a Premium Member. All pairs, backtests, studies, portfolios of Premium Members are treated as 100% private.
PTL Trader
My PTL Trader instance did something wrong or it does not work as expected. How should I report the issue and what should I include?
In order to report any issue with PTL Trader, please create a ticket in Helpdesk. You need to register first. Please do not use e-mail to report issues.
You can also ask the community for support in the Forum.
With any issue reported, please attach:
- screenshot demonstrating the issue (if applicable)
- PTL Trader log file (see the next Q&A)
Please note that PTL Trader software is provided "as it is" and support is not guaranteed (not even to Premium users). We will introduce special guaranteed paid support programs in the future.
We especially don't provide support where IB API is to blame which is unfortunately in many cases.
Note for macOS users - unfortunately no developer from our team has any access to macOS system, so builds for this platform are completely untested and support tickets will be ignored. Sorry, better ask in the forum.
Where do I find PTL Trader log files?
Log files can be found in this folder:
- under Windows: in
<your user directory>\AppData\Roaming\PTLTrader
(where <your user directory>
is usually something like C:\Users\<your username>
)
- under Linux and macOS: in
~/Application Data/PTLTrader
Log files are named according to your PTL Trader instance name. For the primary instance it is default.log
. Under Windows you may need to enable displaying hidden files and folders to access the AppData
folder.
What market data subscriptions do I need to trade US equities?
If you are Non-Pro user, please subscribe for:
- US Securities Snapshot and Futures Value Bundle ($10 / month, waived for activity)
- US Equity and Options Add-On Streaming Bundle ($4.50 / month)
You need both!
If you are Pro user (and options above are therefore not available to you), please consult what packages you need with Interactive Brokers. In general you need:
- historical data for equities you are about to trade
- real-time (streaming) market data for equities you are about to trade
Useful info: Interactive Brokers' Market Data Documentation.
Does PTL Trader support portfolio margin?
PTL Trader does support portfolio margin, but you must setup the margin requirement for each leg correctly and manually.
Does PTL Trader support Contracts for Difference (CFDs)? How can I trade CFDs?
Since PTL Trader v1.5.0, our clients may trade pairs based on Contract for Difference (CFD) instruments. The main advantage is lower margin requirements (it permits them to trade more strategies on their accounts).
Please read about IB CFDs here: IB CFDs Overview & FAQ, IB CFD Interests, IB CFD Commissions, IB CFD Margin Requirements and make sure you understand everything.
Unfortunately CFDs are not available for trading to residents of US, Canada, Hong Kong, Australia, New Zealand and Israel. Additional limitations apply for residents of Japan and Singapore. These limitations are enforced by regulations Interactive Brokers has to follow, do not ask us anything related to these limitations, we won't be able to help you!
Important remarks:
- CFDs are not available for any symbol; please consult with IB's CFD Product List first if your desired stock/ETF is also tradeable as a CFD; if you attempt to trade an non-existing CFD the PTL Trader won't trade the pair strategy and will end up with an error
- only CFDs listed in USD currency are supported for now
- you need to set the correct margin for your CFD instrument manually and correctly yourself (it should be 10% in most cases), see IB CFD Margin Requirements
- the CFD setting is effective for PTL Trader only; the setting is ignored by the backtester (but the margin is simulated correctly)
- you can technically trade pairs where one leg is CFD and the other is Stock or ETF, but it does not make much sense
- you may not enable/disable CFD trading for portfolios that already bound to an IB account; you need to close all positions and then unbind the portfolio first (you can add new CFD strategies to active portfolios though!)
- use the extra leverage gained from using CFDs to trade more strategies at the same time rather than boosting the leverage for the average portfolio; if you dedicate your whole account to pairs trading using 10% margin CFDs only (leverage 1:10 per leg), trade at least 50 pair strategies in your portfolio in order to diversify!
How to trade your portfolio using CFDs:
- for each pair strategy please verify if both legs are available as CFDs using the IB's CFD Product List
- for each verified pair please set the Trade as to CFD in Portfolio Manager for each leg
- set the margin for each leg to appropriate value using the IB CFD Margin Requirements, usually it will be 10 (10% maintenance margin)
- load your portfolio to PTL Trader (v1.5.0 or newer) and bind it to your IB account
- ...
- PROFIT
I would like to trade pairs based on non-US equities.
Unfortunately for now PTL Trader only supports US equities denominated in USD only. In future we will lift this limitation.
My account is set up to have different base currency than USD. PTL Trader refuses to work.
Unfortunately for now PTL Trader only supports USD as the base currency. In the future we will lift this limitation.
There are no positions indicated in PTL Trader (I am sure there are some).
Positions in the Pair Legs tab are displayed per strategy. So you need to click on any strategy first to see positions related to it.
How should I setup my strategy so it trades at the end-of-the-day only?
Setting up a strategy to trade at the end of the day only means to restrict the time the strategy is allowed to trade. For instance, set the trade hours for the strategy to something like 15:50 - 15:59 to trade last 9 minutes of the trading session. It is good to leave one minute after the interval to slow fills in order to avoid you positions not being completely filled before trade session stops (like in the example).
What execution algos does PTL Trader offer? How much can I trade without moving the market?
PTL Trader only supports simple market order executions at this moment. We plan to support more sophisticated algos in the near future. Market orders are still sufficient for trading accounts of hundreds of thousands USD as long you trade liquid equities only.
If this is not enough for you and you really would need better execution algos right now, we can help you by providing advanced execution solution from our partner (contact us in case of such interest).
PTL Trader is stuck in “entry: waiting for hist data” state and my log file is full of errors.
PTL Trader is indicating Z-Score above the entry threshold but it won't enter the position!
There can be multiple causes to this. The key is to check the "engine status" indicator, which will usually provides an useful hint about what prevents PTL Trader to enter the position. Common cases:
- you have enabled the Min Price constraint and equity price is below threshold
- you have enabled the Min Profit Potential constraint and the profit potential is not provided by the model or it is lower
- there is a Max Score set for the model and the current Z-Score is above
- you are looking on a wrong Z-Score (there is separate Z-Score BID and Z-score ASK since PTL Trader v1.3.0)
- you have restricted trading hours of your strategy (and you are outside of the period)
- exchange is closed because of holidays (engine status: no exchange activity detected)
- you use uptick or downtick entry mode (and there was no uptick or downtick detected)
- bid-ask prices are not being streamed in, bid-ask quotes are not from the same day, there is no last trade, the last trade is more than 5% off the bid/ask quotes (engine status: suspicious market data)
Will PTL Trader continue managing my portfolio gracefully if ...
- I will shut it down and start again: yes
- it will lose the connection to TWS/IB gateway temporarily: yes
- it loses connection to PTL backend: yes (it can operate without connection to PTL backend for very long times after it starts up)
- I reduce some position in TWS: yes
- I will close the pair position manually in TWS: yes
- I will close one of the leg manually in TWS: no (it will report the pair and stop auto-trading)
- I will unbind the portfolio and bind it again: yes (with changes applied)
- Split or reverse split occurs on an existing position: yes in most cases (if the automated system fails, it will report the pair and stop auto-trading)
- Long leg is filled but the short one is not: yes (it will close the long leg after predefined amount of time or immediately if IB API reports that short position cannot be opened)
PTL Trader is not indicating equity availability for shorting correctly (stocks are indicated as easy-to-borrow in TWS, but hard-to-borrow in PTL Trader).
There is a known bug in IB API causing this. Please restart both TWS (or IB Gateway) and PTL Trader to fix it. As a workaround, whenever do you need to restart either TWS/ IB Gateway or PTL Trader, always restart both of them.
PTL Trader is indicating incorrect bid-ask data for equities and therefore calculating Z-Score incorrectly.
There is a known bug in IB API causing this. Please restart both TWS (or IB Gateway) and PTL Trader to fix it. As a workaround, whenever do you need to restart either TWS/ IB Gateway or PTL Trader, always restart both of them.
PTL Trader is calculating Z-Score wrong! I calculated it myself using my algorithm and data and it is completely different!
Algorithms in PTL Trader are well tested and proven. It is very unlikely there is any bug in Z-Score calculation or model implementation. The only possible causes to incorrect Z-Score calculations are these:
- IB provides incorrect historical data to PTL Trader, which causes model stats to be calculated incorrectly
- IB provides wrong bid-ask prices to PTL Trader, which causes Z-Score to be calculated from wrong prices and therefore incorrect
Please check bid-ask quotes coming from IB and IB historical prices against another sources (like Google Finance) to see if there is any discrepancy. The issue with historical data often happens after split or reverse split (where IB forgets to make the adjustment in their historical data in time).
To check the historical data used for model calculations, you can check PTL Trader log file (it lists last 15 prices for each symbol).
If you confirm there is a problem in IB data, please contact IB support and report the issue.
I have setup monitoring of my PTL Trader instance, but I keep getting many warnings of my instance not responding, but I am sure it works fine. What is wrong?
Please make sure your VPS system time and timezone are both correct.
I have a special IB account (Friends & Family / Family Office / SBA / Advisor / MM). I am not able to bind desired portfolio to an account of my choice.
The common symptom is that you have one of those special group accounts and when you want to bind PTL Portfolio to one of the IB (sub)accounts you manage, your account code is not displayed in the account select next to "Bind to Account" button.
PTL Trader does not fully support these special IB accounts but in most cases you can still make it working just fine by pasting your desired account code to FA Account field in Settings -> Interactive Brokers API just before you connect to IB API. Then this account should become available to use for binding.
I am getting a different performance and trades in live trading when compared to the backtest. What is wrong?