In this joint webinar by FXCM & QuantInsti®, you’ll get to learn about the FX market data, trading strategies, backtesting & optimization techniques along with new nextgen tools & platforms.
SESSION OUTLINE:
- Spot Currency Markets Overview
- Related Markets, Macro Drivers (Funding - Repo+xccy Swaps, Forwards and Short term IR)
- Accessing FX Data & Overview of Strategies
- Optimizing & Backtesting
- FX Styles: Carry, Momentum, Value and Defensive
Alpha Strategies
Useful Links:
Quantra: https://quantra.quantinsti.com/
Quantra Blueshift: https://quantra-blueshift.quantinsti.com/
Momentum Trading in Forex: https://quantra.quantinsti.com/course/momentum-trading-forex
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
Forex Trading Strategies and Backtesting Techniques using Quantra Blueshift - Presentation
1. quantra-blueshift.quantinsti.com
CONFIDENTIAL. NOT TO BE SHARED OUTSIDE WITHOUT WRITTEN CONSENT.
Getting Started with FX
Introduction to Quantra Blueshift Platform
Font: Calibri (headings)
Size: 44
Color: White
Font: Calibri (Body)
Size: 20
Color: Green (R:148, G:201, B:81)
2. quantra-blueshift.quantinsti.com
CONFIDENTIAL. NOT TO BE SHARED OUTSIDE WITHOUT WRITTEN CONSENT.
What is Blueshift
Heading Font: Calibri (Headings)
Size: 36
Color: White
Systematic Trading Strategies – For Everyone!
IP protection
Financial datasets
On the cloud Back-testing
Strategy research
Learning and community
3. quantra-blueshift.quantinsti.com
CONFIDENTIAL. NOT TO BE SHARED OUTSIDE WITHOUT WRITTEN CONSENT.
Foreign Exchange Market
A very brief overview
“Successful investing is anticipating the anticipations
of others.”
John Maynard Keynes (Economist)
4. quantra-blueshift.quantinsti.com
CONFIDENTIAL. NOT TO BE SHARED OUTSIDE WITHOUT WRITTEN CONSENT.
FX Market Overview
1. Source: BIS Triennial Central Bank Survey 2016 2. BIS quarterly
review
One of the largest, most liquid, decentralized
global financial markets. Daily volume $5.0T,
daily retail volume $280B (74% of non-
financial volumes)1.
Spot FX market is tightly linked to 1) GC repo/
OIS market for liquidity 2) STIR markets
(Eurodollar/ Euriobor, Short Sterling etc.) for
directionality and 3) Forward and Cross
currency swaps market for longer term
dynamics.
Highly automated (70%2) – One of the first
markets to introduce automated trading!
major differences with equity market: 1) higher
leverage 2) easier shorting (and no short
squeeze) 3) very different volatility 4) More
efficient is probably a myth.
5. quantra-blueshift.quantinsti.com
CONFIDENTIAL. NOT TO BE SHARED OUTSIDE WITHOUT WRITTEN CONSENT.
What Drives the FX Markets
Balance of Payments: Improved balance strengthens the currency.
Rates and Inflation: Rate hikes by the central bank or its
expectation build-up strengthens the currency in the short term.
Economic Growth: A strong economy will drive the currency higher
as it attracts foreign investments.
Fiscal Policy: can impact exchange rate either way (depending on
factors like the government financing positions, economy etc.).
Corporate Flows: Flows driven by business (non-macro) can be
sizable to impact the exchange rate in the short term.
Bond Issuance + Money Trasfers: Hedging by arranger/ market-
makers can impact the exchange rate market. Systematic flows can
persist.
Spillovers: From other markets can move exchange rate, e.g. strong
equity performance in emerging markets my push up the FX.
Macro Factors
Significant events: Sudden political change, geo-political
development or un-pegging of currency by central banks can impact
FX markets strongly
Money Flow
Events
6. quantra-blueshift.quantinsti.com
CONFIDENTIAL. NOT TO BE SHARED OUTSIDE WITHOUT WRITTEN CONSENT.
Reach or Cheap: FX Valuation
Purchase Power Parity: Basket of similar goods should cost same
everywhere, roughly speaking.
Real Effective Exchange Rate: Trade-weighted and inflation
adjusted measure of exchange rate, assumed mean-reverting
(possibly true after some adjustments)
Fundamental Equilibrium Exchange Rate1: REER that equates to
a sustainable balance of payments over long-term. Another
alternative form (BEER) adjusts for other economic variables.
Auto-regressive Forecast Models: Time-series based (ARIMA)
models that are primarily empirical from historical data
Other Data-driven Models: Non-linear time-series models, Neural
Networks (LSTM) and similar.
“Cynic: A man who knows the price of everything, and the value of nothing ”
- Oscar Wilde
1. Exchange Rates and Economic Fundamentals (link)
Econometric Models
Data-driven Models
7. quantra-blueshift.quantinsti.com
CONFIDENTIAL. NOT TO BE SHARED OUTSIDE WITHOUT WRITTEN CONSENT.
Systematic Trading in FX
The Blueshift Platform
“Unfortunately for the case of sanity, that (momentum
investing) seems to be true.”
Cliff Asness (AQR Capital)
8. quantra-blueshift.quantinsti.com
CONFIDENTIAL. NOT TO BE SHARED OUTSIDE WITHOUT WRITTEN CONSENT.
Forex Data-set on Blueshift
10 currency pairs - AUD/USD, EUR/CHF, EUR/JPY, EUR/USD, GBP/JPY,
GBP/USD, NZD/USD, USD/CAD, USD/CHF, USD/JPY. Minute-level data
since 2008. Updated once every day from FXCM.
This is augmented by Macro data on 8 underlying economies (real GDP, Y-
o-Y core inflation rate, short term (3-month) and long term (10-year)
interest rates.
Currencies modelled as non-funded (leveraged). Leverage, account
currency settings and roll-over cost calculation is NOT automatic.
Price Data from the `data` argument passed. Two methods available –
data.current() and data.history(). Macro data can be imported as python
module, and have same functions (with slightly different arguments).
How to read data on Blueshift: Example as follows
9. quantra-blueshift.quantinsti.com
CONFIDENTIAL. NOT TO BE SHARED OUTSIDE WITHOUT WRITTEN CONSENT.
Work-Flow on Blueshift
initialize()
handle_data()
before_trading_start()
Called once at the start of the algorithm
Place to set up algorithm parameters and initialize them
Arguments: context – a dictionary object to store all user parameters
and variables and available to all other functions
Called once at the start of the trading session (i.e. once a day)
Place to set up daily pre-open stuff
Arguments: context – as above, and data – a object with current
date-time, can be queried for current or historical data on symbols
Called once at every bar (every minute)
Place to set up logic on how to respond to market data
Arguments: context – as above, and data – as above
schedule_function()
date_rules()
time_rules()
Other Useful
API Functions
order_percent_target()
get_open_orders()
cancel_order()
set_commission()
set_slippage()
set_account_currency()
Schedule any user-
defined functions
at a given time and
frequency
Functions to place,
and cancel orders
Functions to set
trading and other
parameters
10. quantra-blueshift.quantinsti.com
CONFIDENTIAL. NOT TO BE SHARED OUTSIDE WITHOUT WRITTEN CONSENT.
Blueshift Environment
Data contains everything needed to feed data: current(), history(), as well
as current_dt
Context contains everything else: Portfolio (context.portfolio), account
(context.account), calendar (trading_calendar)
See here for more details
Context
trading_calendar
tz(), open_time()
etc.
account leverage, etc.
portfolio positions
asset, amount
etc.
11. quantra-blueshift.quantinsti.com
CONFIDENTIAL. NOT TO BE SHARED OUTSIDE WITHOUT WRITTEN CONSENT.
Blueshift Workflow Demo
1. Signing up and Platform Tour
2. Creating Strategy
3. Running Back-test with a template
4. Creating our own template
5. Adding imports, initialize()
6. Adding some supporting functions - a) cancel_all_open_orders, b)
square_off c) get_positions, d) get_portfolio_details
7. Add the rollover computation - compute_rollovers
8. Define a generic rebalance method
9. A few technical indicators
10. Let’s run and see
12. quantra-blueshift.quantinsti.com
CONFIDENTIAL. NOT TO BE SHARED OUTSIDE WITHOUT WRITTEN CONSENT.
Systematic Trading in FX
FX Styles and Alpha Strategies
“A rising market and a long position is a sure sign of
investment genius”
John Kenneth Galbraith (Economist)
13. quantra-blueshift.quantinsti.com
CONFIDENTIAL. NOT TO BE SHARED OUTSIDE WITHOUT WRITTEN CONSENT.
The Fundamental Beta in FX
Value: “cheap” currencies will go up in value, and reverse for
“expensive” ones. Measure of richness/ cheapness requires
economic or empirical models (like purchase power parity,
REER or statistical regression-based etc.)
Momentum: Past returns are persistent. Rank currencies on
past returns, long the top ones, short the bottom ones(cross-
sectional momentum). Alternatively, long if past returns are
positive (above threshold) and short if the reverse (time-series
momentum)
Carry: Positioning to profit if nothing changes in the universe
except passage of time. Long currencies with higher yields
(interest rates) and funded by ones with low yields.
Defensive: Low risk currencies (better sovereign ratings)
produces better risk-adjusted returns. Long currencies with
higher sovereign ratings and short the bottom ones.
14. quantra-blueshift.quantinsti.com
CONFIDENTIAL. NOT TO BE SHARED OUTSIDE WITHOUT WRITTEN CONSENT.
Creating A Carry Strategy
1. A bit more on the logic
2. Which one we should buy and which ones to sell
3. Coding the strategy – Starting from the template
4. Adding the momentum logic
5. Adjusting the re-balance function
6. Running the back-test
15. quantra-blueshift.quantinsti.com
CONFIDENTIAL. NOT TO BE SHARED OUTSIDE WITHOUT WRITTEN CONSENT.
Creating Other Factor Strategies
1. Pick up from where we left
2. Which one we should buy and which ones to sell
3. Coding the strategy – Starting from the template
4. Running the back-test
16. quantra-blueshift.quantinsti.com
CONFIDENTIAL. NOT TO BE SHARED OUTSIDE WITHOUT WRITTEN CONSENT.
Creating A Factor Basket
1. Pick up from where we left
2. Simple allocation of 1/3 in to each of carry, value and momentum
3. Combining the strategies
4. Running the back-test
17. quantra-blueshift.quantinsti.com
CONFIDENTIAL. NOT TO BE SHARED OUTSIDE WITHOUT WRITTEN CONSENT.
Strategy Development
Developing strategies on Blueshift
“Past performance is the best predictor of success”
Jim Simons (Renaissance Technologies)
19. quantra-blueshift.quantinsti.com
CONFIDENTIAL. NOT TO BE SHARED OUTSIDE WITHOUT WRITTEN CONSENT.
Systematic Strategy Design Cycle
Universe
Selection
Signal
Generation
Target
Portfolio
Rebalance
Improve
Can be static or dynamic
with filtering
Can be independent
of/ Dependent on
the rest
Based on signals +
positions rules
Execution rules/
strategies go here
Research and
refinement process
20. quantra-blueshift.quantinsti.com
CONFIDENTIAL. NOT TO BE SHARED OUTSIDE WITHOUT WRITTEN CONSENT.
Systematic Strategy Development
Inputs: Input to the strategies can come in many flavours1 like
Price/ returns and it’s transformation. Most of the common technical indicators are transformation of price returns2
Positioning information – volumes and open interest data and participant-wise positioning data if available
Fundamental information –macro-economic information (e.g. interest rates or yield curve slopes)
Non-market information: Example twitter sentiments, analysts ratings of sovereigns etc.
Trading Rules/ Logic: Can be either based on trader’s hypothesis or inferred (learned) from
data
Form hypothesis (e.g. moving average cross-over signals change in trends) and test
Feed data to infer rules (e.g. supervised learning of a random forest or other machine learning models)
Back-testing and Forward-testing: A crucial step and often over-looked step.
A good platform to guard against biases : data-mining bias, survivorship bias, market-impact modeling, look-ahead bias
Should be flexible, event-driven (to avoid look-ahead bias) and with built-in analytics
Portfolio Creation/ Optimization - Ensemble Strategies: Never go all-in with a single strategy
Two strategies better than two – if they are uncorrelated (in terms of signals and/ or performance)
Various methods exists – Bagging/ Boosting (voting), Stacking
Various methods of risk capital allocation – e.g. Kelly criterion, equal-weighted, momentum-weighted, many more
1. Ideally sources should be disparate, uncorrelated and relevant.
2. For further technical details see here.
21. quantra-blueshift.quantinsti.com
CONFIDENTIAL. NOT TO BE SHARED OUTSIDE WITHOUT WRITTEN CONSENT.
A BBands Breakout Strategy
1. A bit more on the logic
2. Coding the strategy – start with the template
3. Checking the code
4. Running the back-test
5. Good look at the results
Examples: Some Other Types
1. Another Technical (RSI)
2. Statistical (Correlation based)
3. A Daily Routine
4. Other possibilities – Time-series (ARMA) models, Data-driven (AI/
Machine learning) [ Not in demo]
5. Ensemble Methods – Ensemble in terms of signal generation, ensemble
in terms of profit-and-loss. They are equivalent in case the signal
aggregation method is ‘average’ and capital allocation is equal [Not in
demo]
22. quantra-blueshift.quantinsti.com
CONFIDENTIAL. NOT TO BE SHARED OUTSIDE WITHOUT WRITTEN CONSENT.
Back-testing: Optimize?
Scientific way of developing a strategy: The way most of us end up with:
optimize
evaluate
ideate
deploy
ideate
hypothesize
evaluate
works
doesn’t
deploy start over
Back-tests are useful for hypothesis testing
Not a data-fitting tool
We do not want to optimize our backtest
performance. We want to optimize expected live
performance.
23. quantra-blueshift.quantinsti.com
CONFIDENTIAL. NOT TO BE SHARED OUTSIDE WITHOUT WRITTEN CONSENT.
Problems with Optimization
Alternative to Optimization
1. Adaptive Strategies: Example Change Point Analysis
2. Stable Factor research: With economic/ behavioural justification
3. Ensemble Strategies: Works best with diverse strategies [not in demo]
4. Validation – cross validation or paper-trading
-1.50
-1.00
-0.50
0.00
0.50
1.00
1.50
2.00
2.50
3.00
3.50
4.00
0 0.5 1 1.5 2 2.5 3 3.5 4
AdjustedSharpe
Measured Sharpe
Sharpe Ratio Adjustment
10 test
100 test
1000 test
base
24. quantra-blueshift.quantinsti.com
CONFIDENTIAL. NOT TO BE SHARED OUTSIDE WITHOUT WRITTEN CONSENT.
What It Is Not
Black-box: A systematic strategy should NOT be a black-box.
We should ALWAYS be able to explain why we buy what we
buy (and sell); and why does it make money.
Risk-free Profit: No systematic strategy (or any strategy!) is
risk free, and will never make money all the time, every time.
Risk management is very important.
Fire-and-Forget: A systematic strategy is an evolving one. It
must pass through the constant cycle of performance measure,
tuning and re-risking.
Man vs. Machine: Systematic strategies are not about man vs.
machine, but man and machine. Human brain is far better
evolved to develop hypotheses. Machines are far better at
testing and executing them.
25. quantra-blueshift.quantinsti.com
CONFIDENTIAL. NOT TO BE SHARED OUTSIDE WITHOUT WRITTEN CONSENT.
Strategy Development - Recommendations
Always save all your strategy variables in the `context` environment
- helps tracking variables and re-starts
Use schedule_function if your algo does not need to respond to every bars
- will run faster
Good practice to check account leverage to make sure the algo is running as
intended
Do not over-fit – build a hypothesis and test. Data-mining (p-hacking)
generates good performance in the past and bad going forward
Check the stats in the backtest results. A strategy with low Sharpe,
concentrated wins (low stability), large downside risks (negative skew),
and large drawdowns and high beta are not one you can actually invest in
26. quantra-blueshift.quantinsti.com
CONFIDENTIAL. NOT TO BE SHARED OUTSIDE WITHOUT WRITTEN CONSENT.
List of Demo Strategies
1. Strategy Template
2. Value Strategy
3. Carry Strategy
4. Time-series momentum strategy
5. Cross-sectional momentum strategy
6. Factors basket strategy
7. Bollinger band based break-out strategy
8. RSI based mean-reversion strategy
9. Correlation based statistical strategy
10. FX daily computation template
11. Change point based regime switching strategy
Find them at: https://github.com/QuantInsti/blueshift-demo-strategies
27. quantra-blueshift.quantinsti.com
CONFIDENTIAL. NOT TO BE SHARED OUTSIDE WITHOUT WRITTEN CONSENT.
Next Steps
Are you new to FX trading and
want to start from Basic?
Enjoy FX trading basics course on
Quantra.
Enroll for Free!
Are you a FX Trader and want to
backtest you strategies?
Benefit from the Quantra
Blueshift early access.
Start exploring!