Straddle - TraderPlan/wiki GitHub Wiki

What is a Straddle Strategy?

The straddle strategy is primarily used for risk management, where you set the amount of your portfolio that will be invested in a given market (i.e. currency pair), with the amount varying based on where the market price is within a given price range (Lower Target Price and Upper Target Price).

Let's use the market ZEC-BTC as an example (assume no scaling is applied). If the market price of ZEC-BTC increases towards the upper range (e.g. the upper 10%), then the bot will sell until the BTC value of ZEC that you hold is 10% of your max allocation.

This strategy also has a secondary purpose, which is to profit from short-term price fluctuations. Let's say you set a Pivot Margin of 10%, If the price decreases to a level that results in a 10% difference between the Base Allocation % and the Current Target %, then you'll be in Allocation Mode, which means you will buy enough ZEC so that you go into Neutral Mode, where there is no longer a difference between the two percentages. Conversely, when the price increases so that your Base Allocation % is 10% higher than your Current Target %, you'll sell an amount ZEC so that you are back to neutral (or zero difference).

Straddle Profile

Definitions

Here are the definitions for each field that is calculated by the strategy (when no scaling is applied):

The Base Allocation % is your base allocation (converted into your counter value) as a percentage of your Maximum Allocation. If your Maximum Allocation is 1.00 BTC and your Base Allocation is 20 ZEC which is equivalent to 0.86 BTC, then your Base Allocation % is equal to 0.86 / 1.00 * 100 = 86.

basePercent = baseAllocationValue / maxAllocation * 100

The Current Target is the position of the market price relative to a given price range (upperPrice and lowerPrice). If no scaling is applied, then 50% means the price is at the midpoint of your range. The more aggressive your scale, then lower the percentage. The Current Target is used as the percentage that you want your Base Allocation % to become.

targetPercent = (upperPrice - currentPrice) / (upperPrice - lowerPrice)

When do you buy or sell? You buy when your Base Allocation % is less than your Current Target Percent % by more than your Pivot Margin %, assuming your Pivot Mode is set to RANGE. A similar logic applies when you sell.

isTimeToBuy = basePercent + rangePivotMargin < targetPercent
isTimeToSell =  basePercent - rangePivotMargin > targetPercent

Straddle setup

Create Straddle

Description: Using this command will create a new straddle.

To create a straddle you use the following commands:

  • [pre]addstraddle [Base] [Counter]
  • [pre]as [Base] [Counter]

Example: [pre]as BTC USDT

The example shows a user creating a new BTC/USDT straddle. The new straddle strategy is created with a 50%/50% balance and is turned off by default.

Remove Straddle

Description: This feature allows the user to remove an existing straddle. The command will remove the straddle entirely. Once removed, a straddle pair would have to be added again and reconfigured.

To remove a straddle you use the following commands:

  • [pre]removestraddle [Base] [Counter]
  • [pre]rs [Base] [Counter]

Example: [pre]rs BTC USDT

The example shows a user completely removing their BTC/USDT straddle. If the user wanted to add it back, they would need to recreate it using [pre]addstraddle

Copy/Clone Straddle

Description: This feature allows for the user to import previous straddle settings into a new market/pair. The command creates a new straddle that has the exact settings of another straddle that the user chooses.

To copy a straddle you use the following commands:

  • [pre]clonestraddle [BaseOriginal] [CounterOriginal] [BaseClone] [CounterClone]
  • [pre]cs [BaseOriginal] [CounterOriginal] [BaseClone] [CounterClone]

Example: [pre]cs BTC USDT DASH USDT

The example shows a user creating a new DASH/USDT straddle. The new straddle will use the settings from their pre-existing original BTC/USDT straddle.

View Straddle Report

Description: Using this command will display all Straddle Pairs that you have added to your Straddle Editor

To view your straddle/s you use the following commands:

  • [pre]straddlereport
  • [pre]sr

Example: [pre]sr

The above entry will open a list of all saved pivots

Edit Straddle

Description:This feature allows the user to customize their straddle settings. This allows the user to take complete control of their straddle strategies on the fly.

To edit your straddles you use the following commands:

  • [pre]se [Base] [Counter]
  • [pre]es [Base] [Counter]
  • [pre]ss [Base] [Counter]

Example: [pre]es BTC/USDT

The example shows a user opening their BTC/USDT straddle for editing.

Settings

1-Base Allocation

Assuming a ZEC-BTC pair, this is the balance of ZEC that the strategy will see in your wallet.

Command Example: 1 disable

The above entry will set the base allocation to always equal your wallet balance. If you manually buy ZEC, it will increase the base allocation and may put the strategy into distribution mode. This means the bot may sell a portion of your ZEC so that the straddle is returns to neutral mode.

Command Example: 1 2

For a ZEC-BTC pair, the above entry will set your base allocation to 2 ZEC, as if you started with a wallet balance of 2 ZEC. If there are deposits and withdrawals in your base wallet that are done manually or by another strategy (e.g. a pivot), it will not affect the base allocation. The base allocation will remain the same unless a buy or a sell is triggered by the straddle strategy.

This prevents the situation where a manual withdrawal from your base wallet will immediately make your strategy go into allocation mode and start buying.

Command Example: 1 enable

This will set your base allocation equal to your wallet balance, but only initially. It's effectively the same as the previous command where you enter 1 <balance> except in this case, the balance will be your wallet balance. This saves you having to copy and paste the wallet balance.

2-Maximum Allocation

Assuming a ZEC-BTC pair, then this is the amount of base (ZEC) measured in counter (BTC) that you will have allocated when the Current Target % is 100%.

Command Example: 2 0.5

_For a ZEC-BTC pair, the above entry will set 0.5 as the maximum BTC (counter) value that you will hold. However, if the price in BTC continues dropping, then your base allocation percentage will also drop. As a result, TraderPlan will buy more ZEC so that the value in your portfolio is maintained at 0.5 BTC. This may cause you to spend more than 0.5 BTC if you do not have 7-Total Spend enabled.

3-Active

This option toggles the straddle to active/inactive (Represented as True/False).

Command Example: 3 true

4-Pivot Margin

This option establishes the % change needed in price relative to market price or straddle range (dependant upon Pivot Mode) to initiate a buy or sell.

Command Example: 4 4

The above entry will set the pivot margin to 4%

5-Pivot Mode

Setting the pivot mode to "PRICE" and a pivot margin to 10% will look for a 10% movement in the actual price to initiate a buy or sell.

Setting the pivot mode to "RANGE" and a pivot margin to 10% will look for a 10% movement of your straddle range (Upper-Lower) to initiate a buy or sell.

Command Example: 5 Range

The above entry will set the pivot mode to Range.

6-Scale Mode

Scaling is set to NONE by default. You may want to increase your scaling if you prefer to allocate more at the lower price points. For example, if the Current Target % of 50% is too high, then increasing your scaling will reduce your Current Target % to say 40%.

With no scaling, you'll be increasing your allocation by the same amount for each dollar decrease in price. With scaling, you'll be increasing your allocation by a higher amount for each dollar decrease in price.

This feature is more profitable when you prefer to wait for the price to drop much before doing most of your allocation. For example, let's assume you set your lower target price to $11,000 and upper target price to $25,000.

When no scale is used, you allocate 75% of your opportunity when the price is $14,500. When you're aggressively scaled, you allocate 75% of your opportunity when the price is $12,000. As you can see, the price needs to be much lower than if you were not scaled. If you know the price is going to drop to $12,000, then using an aggressive scale will be more profitable because you saved yourself from allocating at a higher price under no scaling.

For a more detailed explanation of how scaling works, see Straddle Scaling.

7-Total Spent

This provides an additional restriction on when the bot is allowed to buy. This is not the same as Max Allocation. Max Allocation looks at the BTC value that you're currently holding. Total Spent looks at the BTC that you already paid for.

For example, let's assume that you've enabled Total Spent, and the editor shows the values below:

Max Allocation = 0.01127
Total Spent = 0.0135

Now, because Total Spent is more than the Max Allocation of 0.01127 BTC, the bot will not buy even if it's in allocation mode.

The editor will show (SPEND CHOKED) in the Current Mode. This tells you the strategy has been prevented from buying any more coins, so that you avoid spending more BTC than your max allocation. If the price rises such that your Max Allocation increases to more than your Total Spent, then the bot will be allowed again to sell if it's in distribution mode.

Command Example: 7 enable

This will enable Total Spend control, which means if the total amount of counter that you spent exceeds your Max Allocation, then the strategy will not buy even if it is in allocation mode.

Command Example 7 disable

This will disable Total Spend control, which means that there's no limit on how much counter that the bot can spend.

Command Example: 7

This will reset Total Spent to equal your baseAllocation multiplied by the current average price.

Command Example: 7 0.0135

This will set your Total Spent to 0.0135.

8-Lowest Target Price

This is used to calculate the Current Target %. The midpoint of your lower and upper price will result in a Current Target % of 50% when no scaling is applied.

If the market price is less than or equal to your Lowest Target Price, then the strategy will buy 100% of your allocation unless you have choke turned on.

Command Example: 8 500

For a USDT-BTC market, the above entry will set the lowest target price in your straddle range at 500 USDT.

9-Allocation Choke % 

You can set your straddle to not initiate a buy at a set target percentage of your allocation.

Command Example: 9 90

The above entry will set TraderPlan to not buy when the Current Target is 90% or above.

10-Maximum Buy price

This option sets the maximum buy price. The straddle will never buy above this price.

Example: 6 8000

For a USDT/BTC market, the above entry sets the maximum buy price of BTC at 8000 USDT

11-Trail Stop Mode (Allocation)

This option toggles trailing buys on and off.

Command Example: 10

The above entry will toggle Trail Stop Mode

12-Trail Stop % (Allocation)

If Trail Stop Mode is toggled on, this will allow the bot to follow momentum of the market beyond the specified pivot margin %.

Example: 12 0.1

The above entry will initiate a 0.1% market price trail, which will continue to follow the market price down. TraderPlan will initiate a buy after a 0.1% increase in market price.

13-Buying Order Mode

This toggles the buy mode to LIMIT/MARKET (applies to exchanges that have these options).

Example: 13 LIMIT

The above entry sets the buying order mode to limit.

14-Maker Taker Mode (Allocation)

This toggles the buy order type to MAKER/TAKER (MAKER will create the lowest bid, TAKER fills from the current lowest bid).

Example: 14 MAKER

The above entry sets Maker/Taker Mode to Maker.

15-Highest Target Price (0%)

This is what you want your straddle to have as the highest market price in your straddle range.

Example: 15 2500

For a USDT market, the above entry will set the lower price in your straddle range at 2500 USDT.

16-Distribution Choke %

You can set your straddle to not initiate a sell at a set target percentage of your allocation.

Example: 16 10

The above entry will set TraderPlan to not sell when the Current Target is 10% or below.

17 Minimum Sell Price

This option sets the minimum sell price. The straddle will never sell below this price.

Example: 16 10000

For a USDT/BTC market, the above entry sets the maximum sell price of BTC at 10000 USDT

18-Trail Stop Mode (Distribution)

This toggles trailing sells on and off.

Example: 18 The above entry will toggle Trail Stop Mode

19-Trail Stop % (Distribution)

If Trail Stop Mode is toggled on, this will allow the bot to follow momentum of the market beyond the specified pivot margin %.

Example: 19 0.1

The above entry will initiate a 0.1% market price trail, which will continue to follow the market price up. TraderPlan will initiate a sell after a 0.1% increase in market price.

20-Selling Order Mode (Distribution)

This toggles the sell mode to LIMIT/MARKET (applies to exchanges that have these options).

Example: 20 LIMIT

The above entry sets the selling order mode to limit.

21-Maker Taker Mode (Distribution)

This toggles the buy order type to MAKER/TAKER (MAKER will create the lowest bid, TAKER fills from the current lowest bid).

Example: 21 MAKER

The above entry sets Maker/Taker Mode to Maker.

Example

How does the Straddle Strategy work in practice? How does it limit your risk, and how is it profitable even when the market is moving side-ways?

Let's say you added a straddle with the below settings. We set the Pivot Mode to PRICE to ensure that we only trade when the price has moved by 10% or more.

Max Allocation = 1.00000000 BTC
Counter Wallet Balance = 1.00000000 BTC
Pivot Mode = PRICE
Pivot Margin = 10.00%
Scale Mode = NONE
Lower Target Price = 0.02500000
Upper Target Price = 0.15000000
Lower Margin = 100%
Upper Margin = 0%

Starting point

We begin at a neutral state, because we've allocated the same percentage as the current target. Since we've set the Pivot Mode to PRICE, the algorithm will convert the Pivot Margin to the equivalent RANGE of 11.99% so that we only buy or sell when the price exceeds 10% of the target price (i.e. the price in neutral mode).

Current Price = 0.04300000 BTC
Current Mode = NEUTRAL
Current Target = 85.60%
Range Pivot Margin = 11.99%
Next Allocation Level = 0.03856738 BTC
Next Distribution Level = 0.04714235 BTC
Base Allocation = 20 ZEC (86.00% @ 0.86000000 BTC)
Wallet Balance = 1.86000000 BTC

Price decreases to next allocation price

The market price of ZEC decreases to 0.03856738 BTC, putting us in ALLOCATION. The algorithm buys ZEC so we now have a Base Allocation of 23.1142769 ZEC (previously 20 ZEC), which puts us back into NEUTRAL.

Current Price = 0.03856738 BTC
Current Mode = NEUTRAL
Current Target = 89.15%
Range Pivot Margin = 12.00%
Next Allocation Level = 0.03471098 BTC
Next Distribution Level = 0.04242764 BTC
Base Allocation = 23.1142769 ZEC (89.15% @ 0.89145710 BTC)
Wallet Balance = 1.77104733 BTC

Price increases to next distribution level

The market price of ZEC increases to 0.04242764 BTC, putting us in DISTRIBUTION. The algorithm sells ZEC so we now have a Base Allocation of 20.2866518 ZEC (previously 23.1142769 ZEC), which puts us back into NEUTRAL.

Current Price = 0.04242764 BTC
Current Mode = NEUTRAL
Current Target = 86.06%
Range Pivot Margin = 12.01%
Next Allocation Level = 0.03818588 BTC
Next Distribution Level = 0.04666932 BTC
Base Allocation = 20.2866518 ZEC (86.07% @ 0.86071476 BTC)
Wallet Balance = 1.85997453 BTC

Price increases back to starting point

The market price of ZEC increases to where it started, at 0.04300000 BTC. This is only a 1.3% increase, which is not enough to exceed the Next Distribution Level of 0.04666932 BTC. Therefore, we are still in NEUTRAL and no sell will occur.

Current Price = 0.04300000 BTC
Current Mode = NEUTRAL
Current Target = 85.60%
Range Pivot Margin = 12.01%
Next Allocation Level = 0.03818588 BTC
Next Distribution Level = 0.04666932 BTC
Base Allocation = 20.2866518 ZEC (87.23% @ 0.87232603 BTC)
Wallet Balance = 1.87158580 BTC

End result

In a single iteration of the ZEC-BTC price dipping by 10%, we have earned 0.62% profit after commissions of 0.25% per trade. As we know, there are many of these fluctuations every week, so even if the market is moving sideways, you can continually increase your investment. And if the market is trending, you'll automatically take profit when the price moves towards your upper price, or automatically buy the dip, or buy lots when there's a fire sale. In this way, regardless of what the market is doing, you are making profit within your risk tolerance.

Profit % = 0.62289247
Commissions Paid % = 0.03226828
Commissions Paid = 0.00060019
⚠️ **GitHub.com Fallback** ⚠️