Disclaimers
- None of this is investment advice.
- Users should use the Quant Zone at their own risk.
- The below are rough descriptions of how Quant Zone Rules are designed to work, but they make some approximations and should not be taken to be precise. There are no guarantees that rules or the platform will always be available or execute as intended.
- The Quant Zone, like the rest of FTX, is not being offered to US users.
PLEASE NOTE RULES ARE DESIGNED TO LOOP EVERY 15 SECONDS
FTX Quant Zone Homepage: https://ftx.com/quant-zone
FTX Quant Zone Telegram: https://t.me/FTX_Quant_Zone
Note: users should think carefully before using any Quant Zone rules, including the examples below. Users are responsible for the performance of their Quant Zone rules. This article is not an endorsement of the below rules, just an illustration of how one could construct rules.
Quant Zone Rule Building Competition Winners
These are the winners of the competition. If anyone has a useful rule and wants it to be listed here, feel free to reach out to us. There were enough good submissions we decided to award two winners instead of one!
Tied 1st Place: Supertrend by CheshireCatNick - Wins an HTC EXODUS Smartphone and an FTX swagpack!
Supertrend is a basic yet powerful indicator that can decide whether we are in a bull trend or bear trend.
The author has helpfully put up a description of the strategy here.
Tied 1st Place: MA based BTC buy/sell strategy by 8baller030 - Wins an HTC EXODUS Smartphone and an FTX swagpack!
We have used pyalgo trade to optimise a simple buy strategy for BTC. We have optimised for the difference between the price and moving average along with % of portfolio staked.
8baller has written up their strategy here.
Dynamic RSI Period Reversal Algo by Casper Cheng - Wins 200FTT
Casper wrote a set of rules to implement Dynamic RSI Period Reversal (see here ). He also did a backtest here.
Support/Resistance Trading by Yu-Shiuan Chen - Wins 200FTT
Yu-Shuan’s strategy (see here) uses the price momentum by dynamically developing the BTC-PERP prices resistance and support from 5 Days, 10 Days, 20 Days, and 60 days moving averages.
Converting Collateral by Ankit - Wins 200FTT
The rule finds the ratios of various types of non-USD collaterals in the wallet, & books USD profits in that ratio. For eg. your USD profits are booked equally in BTC & ETH if you have equal $ values of ETH and BTC in your wallet
Note: Ankit has written up his rules here.
Miscellaneous Functions
- Daily Open price
- price("BTC-PERP",minute+60*hour)
- 1 minute halflife EWMA price
- (price("BTC-PERP")+0.5*price("BTC-PERP",1)+0.25*price("BTC-PERP",1)+0.125*price("BTC-PERP",1)+0.0625*price("BTC-PERP",1)+0.03125*price("BTC-PERP",1)+0.015625*price("BTC-PERP",1))/1.984375
- Periodically updating variables
- It might be helpful to have a rule that just cycles every 15s and has lots of Update Variable actions to keep variables up to date
- Only run a rule once
- have as part of the trigger .... and get_variable("v1") == 0
- have as one of the actions Set Variable; v1; 1
- Price X days ago, Y hours + Z minutes into the day:
- price("BTC-PERP",minute+60*hour+X*24*60-Y*60-Z)
EMA
Below is a set of rules for the following bot: "Once per day, if BTC is below its 10 minute EMA, buy 1 BTC; otherwise sell 1 BTC".
Rule 1 -- Variable_loop
Trigger
true
Action 1
Set Variable; BTC_EMA_10; (1*price("BTC-PERP",0)+0.93*price("BTC-PERP",1)+0.87*price("BTC-PERP",2)+0.81*price("BTC-PERP",3)+0.75*price("BTC-PERP",4)+0.70*price("BTC-PERP",5)+0.65*price("BTC-PERP",6)+0.61*price("BTC-PERP",7)+0.57*price("BTC-PERP",8)+0.53*price("BTC-PERP",9)+0.5*price("BTC-PERP",10)+0.46*price("BTC-PERP",11)+0.43*price("BTC-PERP",12)+0.40*price("BTC-PERP",13)+0.37*price("BTC-PERP",14)+0.35*price("BTC-PERP",15))/9.93
Rule 2 -- Buy_rule
Trigger
get_variable("BTC_EMA_10") != 0 and get_variable("BTC_EMA_10") > price("BTC-PERP")
Action 1
Place Custom Order; Market order; Buy; BTC-PERP; 1
Action 2
Pause Rule; Current Rule; 1 Day
Rule 2 -- Sell_rule
Trigger
get_variable("BTC_EMA_10") != 0 and get_variable("BTC_EMA_10") < price("BTC-PERP")
Action 1
Place Custom Order; Market order; Sell; BTC-PERP; 1
Action 2
Pause Rule; Current Rule; 1 Day
SMA Crossover Strategy
I have written a strategy consisting of 3 different rules that form the following bot: “Once per day, if the 3 day SMA is above the 11 SMA long and risk no more than 10% of available balance and close any open short positions, if the 3 days SMA is below the 11 SMA then sell short and risk no more than 10% of available balance and close any open long positions”.
Rule 1: The 11 and 3 SMA Variables
Trigger: true
Action1: (a “Set Variable”) that makes up the 11 Day SMA:
(price("BTC-PERP")+price("BTC-PERP", minute+60*hour)+price("BTC-PERP", minute+60*hour+1440)+price("BTC-PERP", minute+60*hour+2880)+price("BTC-PERP", minute+60*hour+4320)+price("BTC-PERP",minute+60*hour+5760)+price("BTC-PERP",minute+60*hour+7200)+price("BTC-PERP", minute+60*hour+8640)+price("BTC-PERP",minute+60*hour+10080)+price("BTC-PERP",minute+60*hour+11520)+price("BTC-PERP",minute+60*hour+12960))/11
Action 2: (a “Set Variable”) that makes up the 3 Day SMA:
(price("BTC-PERP")+price("BTC-PERP", minute+60*hour)+price("BTC-PERP", minute+60*hour+1440))/3
Rule 2: Buy_Crossover Rule
Trigger: get_variable("11 SMA") != 0 and get_variable("3 SMA") != 0 and get_variable("3 SMA") > get_variable("11 SMA")
Action 1: (a “Close Position”) that closes any open short positions:
Action 2: (a “Place Custom Order”) that opens a long with a market order and risks 10% of available balance:
Action 3: (a “Pause Rule”) pauses this rule for 1 day:
Rule 3: The Sell_Crossunder rule
Trigger: get_variable("11 SMA") != 0 and get_variable("3 SMA") != 0 and get_variable("3 SMA") < get_variable("11 SMA")
Action 1: (a “Close Position”) that closes any open long positions:
Action 2: (a “Place Custom Order”) that opens a long with a market order and risks 10% of available balance:
Action 3: (a “Pause Rule”) pauses this rule for 1 day:
MAX Buy
Below is a set of rules for the following bot: "when BTC trades above its 1 day hourly high, buy".
Rule 1 -- variable_loops
Trigger
true
Action 1
Set Variable. max_px_1.
max(price("BTC-PERP",60),price("BTC-PERP",120),price("BTC-PERP",180),price("BTC-PERP",240),price("BTC-PERP",300),price("BTC-PERP",360),price("BTC-PERP",420),price("BTC-PERP",480),price("BTC-PERP",540),price("BTC-PERP",600),price("BTC-PERP",660),price("BTC-PERP",720))
Action 2
Set Variable. max_px_2.
max(price("BTC-PERP",780),price("BTC-PERP",840),price("BTC-PERP",900),price("BTC-PERP",960),price("BTC-PERP",1020),price("BTC-PERP",1080),price("BTC-PERP",1140),price("BTC-PERP",1200),price("BTC-PERP",1260),price("BTC-PERP",1320),price("BTC-PERP",1380),price("BTC-PERP",1440))
Rule 2 -- buy_max
Trigger
price("BTC-PERP") > get_variable("max_px_1") and price("BTC-PERP") > get_variable("max_px_2")
Action 1
Place Custom Order. Market order; buy; BTC-PERP; 1.
Arbitrage
Below is a set of rules for the following bot: "when perpetual futures are trading above spot, buy spot and sell futures; otherwise, unwind any position you had on".
Rule 1 -- sell_rule
Trigger
premium("BTC-PERP") > 1.001 and (position_leverage("BTC-PERP")*position_side("BTC-PERP") > -0.8 or balance("USD") / collateral > 0.75)
Action 1
Place Custom Order. Market order; Buy; BTC/USD. Order Size: max((balance("USD") / price("BTC/USD") + balance("BTC"))* 0.98 - balance("BTC"),0). IOC. Cancel and place a new order.
Action 2
Place Custom Order. Market order; Sell; BTC-PERP. Order Size: balance("BTC") + position_net("BTC-PERP"). IOC. Cancel and place a new order.
Rule 2 -- buy_rule
Trigger
premium("BTC-PERP") < 1.0002 and (position("BTC-PERP") != 0 or balance("BTC") != 0)
Action 1
Place Custom Order. Market order; Sell; BTC/USD. Order Size: balance("BTC"). IOC. Cancel and place a new order.
Action 2
Close Position. Buy; BTC-PERP. Close the entire position.
Known Flaws:
- The "sell_rule" will buy the BTC spot in one cycle and then sell the BTC-PERP in the next cycle, instead of doing them both at once
- "premium" might be counter-intuitive when markets are moving--what if BTC-PERP has moved but the index data is lagging by a few seconds?
- Doesn't bother checking if you have the right type of assets in your account; you need spot USD to get this started
- Doesn't check your account leverage settings
- Uses non-USD collateral and doesn't think carefully about collateral conversions
- Uses market orders; there might be slippage!
Constant Leverage
Below is a set of rules for the following bot: "every 15 seconds, resets your account leverage to +2x".
Rule 1 -- 2x_leverage_buy
Trigger
leverage < 2
Action 1
Open Position. Buy; BTC-PERP; 2.
Rule 2 -- 2x_leverage_sell
Trigger
leverage > 2
Action 1
Close Position. Sell; BTC-PERP; Reduce position leverage: 2.
Known Flaws:
- Trades a lot
- Doesn't bother checking what type of account collateral you have
- Doesn't check your account leverage settings
- Uses market orders; there might be slippage!
- Can get confused if you start out short BTC-PERP
- Account leverage can be approximate; it depends on the prices of assets at the time the orders are computed
ALT TWAP
Below is a set of rules for the following bot: "each day, buy ALT-PERP TWAP over the first hour if it was up yesterday, and sell if it was down, trading $2000 over the course of the hour".
Rule 1 -- twap_buy
Trigger
hour < 1 and price("ALT-PERP",minute) > price("ALT-PERP",minute + 60*24)
Action 1
Place Custom Order. Market order; Buy; ALT-PERP. Order Size: 2000 * 15 / (60 * 60 * price("ALT-PERP")). IOC. Cancel and place a new order.
Rule 2 -- twap_sell
Trigger
hour < 1 and price("ALT-PERP",minute ) < price("ALT-PERP",minute + 60*24)
Action 1
Place Custom Order. Market order; Sell; ALT-PERP. Order Size: 2000 * 15 / (60 * 60 * price("ALT-PERP")). IOC. Cancel and place a new order.
Known Flaws:
- Doesn't check collateral or liquidation risk
- Doesn't update behavior of ALT-PERP price changes
- Market orders can have slippage
Ping Pong Bot
The Ping Pong Bot works best in ranging markets.
Below are a set of rules for the following bot:
"If BTC goes below 6800, long 1 BTC. If BTC reaches 6900, close long position.”
“If BTC goes above 6900, short 1 BTC. If BTC reaches 6800, close short position.”
“If BTC goes above 7000 or below 6700, close long/short positions.”
Rule 1 -- long_pingPong
Trigger
(price("BTC-PERP") <= 6800) and (position_net("BTC-PERP") == 0)
Action
Place Custom Order; Market order; Buy; BTC-PERP; 1
Rule 2 -- closeLong_pingPong
Trigger
((price("BTC-PERP") >= 6900) or (price("BTC-PERP") <= 6700)) and (position_net("BTC-PERP") > 0)
Action
Close the entire long Position. Sell; BTC-PERP.
Rule 3 -- short_pingPong
Trigger
(price("BTC-PERP") >= 6900) and (position_net("BTC-PERP") == 0)
Action
Place Custom Order; Market order; Sell; BTC-PERP; 1
Rule 4 -- closeShort_pingPong
Trigger
((price("BTC-PERP") <= 6800) or (price("BTC-PERP") >= 7000)) and (position_net("BTC-PERP") < 0)
Action
Close the entire short Position. Buy; BTC-PERP.
Rule 5 -- pause_pingPong
Trigger
((price("BTC-PERP") <= 6700) or (price("BTC-PERP") >= 7000)) and (position_net("BTC-PERP") == 0)
Action
Pause Rule; All Rules; 100 Days
Known Flaws:
- Doesn't check your account leverage settings
- Doesn't bother checking what type of account collateral you have
- Variables could be used instead of hardcoding values in triggers
- Stops could be used in separate rules to pause them temporarily
- Preference to closing existing positions first before opening new positions
- Rules should be paused manually when not required
- Uses market orders; there might be slippage!
________________________________________
FTX Crypto Derivatives Exchange: https://ftx.com
Email: support@ftx.com
FTX Telegram Communities
English - https://t.me/FTX_Official
Chinese - https://t.me/FTX_Chinese_Official
Vietnamese - https://t.me/FTX_Vietnam_Official
Russian - https://t.me/FTX_Russian_Official
Turkish - https://t.me/FTX_Turkey_official
Taiwanese - https://t.me/FTX_Taiwan_Official
French - https://t.me/FTX_France_Officiel
Korea - https://t.me/FTX_Korea_Official
India - https://t.me/FTX_India_Official
Spanish - https://t.me/Ftx_Spanish_Official
Portuguese - https://t.me/Ftx_Portugues_Oficial
Dutch - https://t.me/FTX_Dutch_Official
Africa - https://t.me/FTX_Africa
WeChat - FTX_Official
Blog: https://blog.ftx.com/
Medium:https://medium.com/@ftx
Facebook - https://www.facebook.com/ftx.official/
Twitter- https://twitter.com/FTX_Official
SBF Twitter - https://twitter.com/SBF_Alameda
YouTube - https://www.youtube.com/channel/UC3r0upC_xJ9SvtaCKNUtosA