Magpy
Search
K

Triggers

Triggers are events that activate you Bot and set them in motion.
First, the user selects an exchange to obtain market data that will trigger the bot. Then, they choose the type of trigger, asset pair, and relationship (price greater than, less than, equal to, etc.). Finally, they set the gas fee that can be used by this bot.
This settings screen will be used until it is replaced by a prompt in the future.

Some Examples:

  • Price of an asset crosses a certain value
  • Price of an asset moves by a certain percentage in any direction
  • TVL crosses a certain value
  • The MarketCap of an asset moves by a certain value
  • 100-200 EMA Crossover on 4h timeframe, and many more technical analysis triggers

🤖 DEX/AMM

The following triggers can be used in DEX/AMM. Please check the development status as well. For more details, please contact the team.
Function Name
Category
Variable
Explanation
Example
Availability
period_exc()
Periodic Execution
period, unit, n
Triggers to be executed periodically
period_exc(1,hour,2) means buy btc 2 times per hour
🛠
price()
Market Data
marketName, minutes(optional)
Takes a market name as an argument and returns the final price of the asset. When user input n, it returns the price n minute before the asset.
price("ETH/USD",7) returns the price 7 minute before ETH/USD.
🛠
last_trade_price()
Market Data
marketName
Returns the last traded price of the asset.
last_trade_price("LINKBULL/USD") Returns the last trade price for that asset.
🛠
free_collateral
Account Data
-
Returns the amount of collateral not required in U.S. dollars in the Wallet.
free_collateral>500. This rule is triggered when the collateral-free amount in the wallet exceeds $500.
🛠
total_position_size
Account Data
-
Returns the total account position size (in USD) for all futures.
total_position_size<2*total_collateral This rule is triggered when the total position is less than twice the collateral in the account.
🛠
position()
Position Data
marketName
Returns the size of the asset position. Returns a positive value or 0.
position("BTC-USDC") returns the size of the BTC position in spot.
🛠
position_side()
Position Data
marketName
Returns 1 if the position is long, -1 if the position is short, or 0 if the position is neither.
position_side("ETH-USDC")Returns 1 if ETH bought.
🛠
abs()
Math Function
x
Takes a numeric value as an argument and returns its absolute value.
In the case of abs(-2), 2 is returned.
🛠
max()
Math Function
x,y
The two numbers are taken as arguments and return the greater of x and y.
max(3.2, 10) returns 10
🛠
min()
Math Function
x,y
The two numbers are taken as arguments and return the smaller of x and y.
min(1, 5), 1 is returned.
🛠
sqrt()
Math Function
x
Takes a positive number and returns its square root.
sqrt(25) returns 5.
🛠
floor()
Math Function
x
Takes a numeric argument and returns the largest integer less than or equal to x.
floor(2.5) returns 2.
🛠
ceil()
Math Function
x
Takes a numeric argument and returns the smallest integer greater than or equal to x.
ceil(2.5) returns 3.
🛠
sign()
Math Function
x
It takes a numeric argument and returns 1 for positive values and 0 for negative values.
sign(10) returns 1 and sign(-5) returns 0.
🛠
get_variable()
Others
name
It takes a variable name as an argument and returns the value stored in this variable.
When you store 10 in the variable named myVariable. In that case, get_variable('myVariable') returns 10.
🛠
time
Others
Returns the current UNIX time.
🛠
minute
Others
Returns only the minute of the current time.
🛠
hour
Others
Returns only the current Universal Standard Time.
🛠

🤖 Perpetual DEX

Function Name
Category
Variable
Explanation
Example
Availability
period_exc()
Periodic Execution
period, unit, n
Triggers to be executed periodically
period_exc(1,hour,2) means buy btc 2 times per hour
🛠
price()
Market Data
marketName, minutes(optional)
Takes a market name as an argument and returns the final price of the asset. When user input n, it returns the price n minute before the asset.
price("ETH-PERP",7) returns the price 7 minute before ETH/USD.
🛠
bid_price()
Market Data
marketName
Returns the highest bid price for the asset.
bid_price("ETH-PERP") returns the highest bid price for ETH/USD.
🛠
offer_price()
Market Data
marketName
Returns the highest offer price for the asset.
offer_price("XRP-PERP") returns the highest offer price for XRP-PERP.
🛠
bid_volume()
Market Data
marketName
Returns the highest bid volume for the asset.
bid_price("ETH-PERP") returns the highest bid volume for ETH/USD.
🛠
offer_volume()
Market Data
marketName
Returns the highest offer volume for the asset.
offer_price("XRP-PERP") returns the highest offer volume for XRP-PERP.
🛠
last_trade_price()
Market Data
marketName
Returns the last traded price of the asset.
last_trade_price("LINKBULL/USD") Returns the last trade price for that asset.
🛠
index_price()
Market Data
marketName, minutes(optional)
Returns the index price "n" minutes ago for that asset.
index_price("LINK-PERP", 33) returns the index price 33 minutes before LINK-PERP.
🛠
premium()
Market Data
marketName
Returns the asset's futures premium (mark price divided by index price).
premium("ETH-PERP") returns the ETH-PERP premium.
🛠
collateral
Account Data
-
Returns the total amount of collateral in U.S. dollars in the wallet.
collateral>500 This rule is triggered when the total amount of collateral in the wallet exceeds $500.
🛠
free_collateral
Account Data
-
Returns the amount of collateral not required in U.S. dollars in the Wallet.
free_collateral>500. This rule is triggered when the collateral-free amount in the wallet exceeds $500.
🛠
total_position_size
Account Data
-
Returns the total account position size (in USD) for all futures.
total_position_size<2*total_collateral This rule is triggered when the total position is less than twice the collateral in the account.
🛠
margin_fraction
Account Data
-
Returns the account margin ratio, i.e., the ratio of the total position size in the account to the collateral.
margin_fraction>1
🛠
open_margin_fraction
Account Data
-
Returns the margin percentage including open orders.
open_margin_fraction>1
🛠
leverage
Account Data
-
Returns the approximate account leverage multiplier, which is the rate of collateral and total position size for the course.
leverage<10 This rule is triggered when leverage is below 10x.
🛠
initial_mfr
Account Data
-
Returns the initial margin requirement.
-
🛠
Maintenance_mfr
Account Data
-
Returns the account maintenance margin percentage requirement.
-
🛠
Liquidation_distance:
Account Data
-
Returns the approximate status of how close your account is to liquidation.
-
🛠
position()
Position Data
marketName,side
Returns the size of the asset position. Returns a positive value or 0.
position("ALGO-PERP". buy") returns the size of the ALGO-PERP long.
🛠
position_side()
Position Data
marketName
Returns 1 if the position is long, -1 if the position is short, or 0 if the position is neither.
position_side("ETH-PERP")Returns 1 if ETH bought.
🛠
position_net()
Position Data
marketName
Returns the net size of the position. Positive for long, negative for short.
position_net("BTC-PERP") returns the net size of BTC-PERP.
🛠
position_leverage()
Position Data
marketName
Returns the approximate leverage of the position.
position_leverage("EOS-PERP") returns the approximate leverage of an EOS-PERP position.
🛠
position_notional()
Position Data
marketName
Return the notional amount of the position in U.S. dollars for risk.
position_notional("ALT-PERP") returns the notional principal of the ALT-PERP position.
🛠
abs()
Math Function
x
Takes a numeric value as an argument and returns its absolute value.
In the case of abs(-2), 2 is returned.
🛠
max()
Math Function
x,y
The two numbers are taken as arguments and return the greater of x and y.
max(3.2, 10) returns 10
🛠
min()
Math Function
x,y
The two numbers are taken as arguments and return the smaller of x and y.
min(1, 5), 1 is returned.
🛠
sqrt()
Math Function
x
Takes a positive number and returns its square root.
sqrt(25) returns 5.
🛠
floor()
Math Function
x
Takes a numeric argument and returns the largest integer less than or equal to x.
floor(2.5) returns 2.
🛠
ceil()
Math Function
x
Takes a numeric argument and returns the smallest integer greater than or equal to x.
ceil(2.5) returns 3.
🛠
sign()
Math Function
x
It takes a numeric argument and returns 1 for positive values and 0 for negative values.
sign(10) returns 1 and sign(-5) returns 0.
🛠
get_variable()
Others
name
It takes a variable name as an argument and returns the value stored in this variable.
When you store 10 in the variable named myVariable. In that case, get_variable('myVariable') returns 10.
🛠
perpetual()
Others
coin
Takes a coin name as an argument and returns the name of the indefinite futures market associated with this coin.
Since perpetual('ETH') returns ETH-PERP, price(perpetual('ETH')) returns the price of ETH-PERP.
🛠
time
Others
Returns the current UNIX time.
🛠
minute
Others
Returns only the minute of the current time.
🛠
hour
Others
Returns only the current Universal Standard Time.
🛠