Possible Functions with Definitions

browse

Disclaimers

  1. None of this is investment advice.
  2. Users should use the Quant Zone at their own risk.
  3. 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.
  4. 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 Telegramhttps://t.me/FTX_Quant_Zone

Note: see here for some examples of Quant Zone Rules.

 

 

Market data

 

  • price("BTC-PERP")

    • price(“marketName”)

    • This function takes a market name as argument and returns the last price of the asset 
      • Example:  price(‘BTC-PERP’) returns the price of BTC-PERP
  • price("BTC-PERP", 1)

    • price(“marketName”,1)

    • This function returns the price of the asset 1 minute ago
      • Example: price(“BTC-PERP”,1) returns the price of BTC-PERP one minute ago. 

 

  • price("BTC-PERP", n)

    • price(“marketName”, n)

    • This function returns the price of the asset “n” minutes ago.
      • Example: price(“ETH/USD”, 7) returns the price of ETH/USD 7 minutes ago.

 

  • bid_price("BTC-PERP")

    • bid_price(“marketName”)

    • This function returns the best bid price of the asset
      • Example: bid_price(“ETH-PERP”) returns the best bid price of ETH/USD.



  • offer_price("BTC-PERP")

    • offer_price(“marketName”)

    • This function returns the best offer price of the asset.
      • Example: offer_price(“XRP-PERP”) returns the best offer price of XRP-PERP. 

 

  • last_trade_price("BTC-PERP")

    • last_trade_price(“marketName”)

    • This function returns the last trade price of the asset.
      • Example: last_trade_price(“LINKBULL/USD”) returns the last traded price of the asset.



  • index_price("BTC-PERP")

    • index_price(“marketName”)

    • This function returns the index price of the asset.
      • Example: index_price(“EOS-PERP”) returns the index price of EOS-PERP.



  • index_price("BTC-PERP", n)

    • index_price(“marketName”, n)

    • This function returns the index price of the asset n minutes ago.
      • Example: index_price(“LINK-PERP”, 33) returns the index price of LINK-PERP 33 minutes ago.



  • premium("BTC-PERP")

    • premium(“marketName”)

    • This function returns the futures premium of the asset (mark price divided by index price).
      • Example: premium(“ETH-PERP”) returns the premium of ETH-PERP. 



Account Data:

This section is dedicated to the functions used to retrieve data from your wallet.

  • collateral
    • This function does not take any argument and returns the total amount of collateral in USD of your wallet. 
    • Example: collateral>500
      This rule will be triggered if the amount of total collateral in your wallet is greater than $500

 

  • free_collateral
    • This function does not take any argument and returns the amount of free collateral in USD of your wallet. 
    • Example: free_collateral>500

This rule will be triggered if the amount of free collateral in your wallet is greater than $500

 

  • total_position_size
    • This function does not take any argument and returns the total account position size across all futures (in USD)
    • Example: total_position_size<2*total_collateral

This rule will be triggered if the total position is inferior to two times the total collateral of the account

 

  • margin_fraction
    • This function does not take any argument and returns the account margin fraction i.e the ratio between account total position size and collateral
    • Example: margin_fraction>1 

 

  • open_margin_fraction
    • This function does not take any argument and returns the open margin fraction i.e the margin fraction including the open orders
    • Example open_margin_fraction>1

 

  • leverage
    • This function does not take any argument and returns the approximate account leverage i.e ratio between account collateral and total position size.
    • Example: leverage<10 will be triggered if the leverage is inferior to 10

 

  • initial_mfr:
    • This function does not take any argument and returns the initial margin fraction requirement

 

  • Maintenance_mfr:
    • This function does not take any argument and returns the account maintenance margin fraction requirement

 

  • Liquidation_distance:
    • This function does not take any argument and returns the approximate liquidation distance in USD of your account.



Position Data:

 

  • position(“BTC-PERP”)

    • position(“marketName”)

    • This function returns the size of the asset position. It returns either a positive value or zero. 
      • Example: position(“BTC-PERP”) returns the size of your BTC-PERP position in BTC. 


  • position(“BTC-PERP”, “buy”) 

    • position(“marketName”, “buy”) 

    • This function returns the size of the asset position if long. Zero if short. 
      • Example: position(“ALGO-PERP”. “buy”) returns the size of your ALGO-PERP long.
  • position(“BTC-PERP”, “sell”)

    • position(“marketName”,”sell”)

    • This function returns the size of the asset position if short. Zero if long. 
      • Example: position(“BSV-PERP”,”sell”) returns the size of your BSV-PERP if short.


  • position_side(“BTC-PERP”)

    • position_side(“marketName”)

    • This function returns 1 if position is long, -1 if position is short, 0 otherwise.
      • Example: position_side(“ETH-PERP”) returns 1 if you have an ETH-PERP long. 


  • position_net(“BTC-PERP”)

    • position_net("marketName") 

    • This function returns the net size of your position. Positive if long and negative if short. 
      • Example: position_net(“BTC-PERP”) returns the net size of your BTC-PERP position. 

 

  • position_leverage(“BTC-PERP”)

    • position_leverage("marketName")

    • This function returns the approximate leverage of your position. 
      • Example: position_leverage(“EOS-PERP”) returns an approximate of your leverage in your EOS-PERP position. 


  • position_notional(“BTC-PERP”)

    • position_notional("marketName") 

    • This function returns the notional size of your position in USD for risk purposes.
      • Example: position_notional(“ALT-PERP”) returns the USD notional size of your ALT-PERP position. 



Wallet Data:

  • balance(“coinName”)
    • This function takes the name of the asset and returns the total balance of this asset in your wallet
    • Example: balance(‘BTC’) returns the amount of BTC in your wallet
  • balance_free(‘coinName’)
    • This function takes the name of the asset and returns the available (unused) balance of this asset in your wallet
    • Example: balance_free(‘ETH’) returns the amount of available ETH in your wallet.

 

Math functions:

  • abs(x)
    • This function takes a number as an argument and returns the absolute value of it.
    • Example: abs(-2) returns 2
  • max(x,y)
    • This function takes two numbers as arguments and returns the larger of x and y
    • Example max(3.2, 10) returns 10
  • min(x,y)
    • This function takes two numbers as arguments and returns the smaller of x and y
    • Example min(1, 5) returns 1
  • sqrt(x)
    • This function takes a positive number and returns the square root of it.
    • Example: sqrt(25) returns 5
  • floor(x)
    • This function takes a number as an argument and returns the largest integer smaller than or equal to x
    • Example: floor(2.5) returns 2
  • ceil(x):
    • This function takes a number as an argument and returns the smallest integer greater than or equal to x
    • Example: ceil(2.5) returns 3
  • sign(x):
    • This function takes a number as an argument and returns 1 if it is positive and 0 if negative.
    • Example: sign(10) returns 1 and sign(-5) returns 0




Miscellaneous functions:

 

  • get_variable(‘name’):
    • This function takes as an argument the name of the variable and returns the value stored in this variable
    • Let’s say you have stored 10 in a variable named myVariable, get_variable(‘myVariable’) returns 10

 

  • perpetual(‘coin’):
    • This function takes as an argument the name of a coin and returns the name of the perpetual futures market associated with this coin
    • Example: perpetual(‘ETH’) returns ‘ETH-PERP’ so price(perpetual(‘ETH’)) returns the price of ‘ETH-PERP’
  • quarterly(‘coin’):
    • This function takes as an argument the name of a coin and returns the name of the current quarterly futures market associated with this coin
    • Example: quarterly(‘ETH’) returns ‘ETH-0626’ so price(quarterly(‘ETH’)) returns the price of ‘ETH-0626’
  • time:
    • This function does not take any argument and returns the current unix time
  • minute:
    • This function does not take any argument and returns the minute component of the current time i.e number of whole minutes since the beginning of the hour.
  • hour:
    • This function does not take any argument and returns the hour component of the current time i.e number of whole hours since midnight UTC.

 

Arithmetic Operators

 

  • x+y:
    • Returns x plus y
  • x-y:
    • Returns x minus y
  • x*y:
    • Returns x multiplied by y
  • x/y:
    • Returns x divided by y
  • x//y:
    • Returns x divided by y rounded down
    • Example: 5//2 returns 2
  • x%y:
    • Returns the remainder of x when divided by y
    • Example: 5%2 returns 1
  • x**y:
    • Returns x raised to the power of y
    • 2**4 returns 16




Logic Operators

 

  • x and y: 
    • Returns True if both x and y are True, false otherwise
    • Example: price(‘BTC-PERP’) > 10000 and balance(‘BTC) > 10 returns True if the price of BTC-PERP is greater than $10,000 and your balance of BTC is greater than 10
  • x or y:
    • Returns True if either x or y (or both) is True, False otherwise
    • Example: price(‘BTC-PERP)>10000 or price(‘ETH-PERP’) > 400 returns True if the price of BTC-PERP is greater than $10,000 or the price of ETH-PERP is greater than $400
  • not x:
    • Return True if x is False and False if x is True
    • Example: not price(‘BTC-PERP’)>10000 returns True if the price of BTC-PERP is less than $10,000 False otherwise
  • x if y else z:
    • Returns x if y is True otherwise z
  • True:
    • Always true
  • False:
    • Always False



Comparison operators

 

  • x == y
    • Returns True if x is equal to y, False otherwise
    • Example: price(‘BTC-PERP’)==100000 returns True if the price of BTC-PERP is equal to $100,000
  • x!=y:
    • Returns True if x is not equal to y, False otherwise
    • Example: leverage!=101 returns True if the leverage of your account is different from 101x
  • x>y:
    • Returns True if x is greater than y, False otherwise
    • Example: price(‘BTC-PERP’)>20000 returns True if the price of BTC-PERP is greater than $20,000
  • x>=y:
    • Returns True if x is greater than or equal to y, False otherwise
    • Example: price(‘BTC-PERP’)>=20000 returns True if the price of BTC-PERP is greater than or equal to $20,000
  • x<y:
    • Returns True if x is less than y, False otherwise
    • Example: balance(‘BTC)<10 returns True if the balance of BTC of your account is inferior to 10
  • x<=y:
    • Returns True if x is less than or equal to y, False otherwise
    • Example: leverage<=50 returns True if the leverage of your account is inferior or equal to 50.

 

 

__________________________________________

 

Previous
Next
360042117811
Didn't find what you were looking for?
Create a support ticket
Community

Was this article helpful?

1 out of 1 found this helpful