Partial take profit algorithm development

We design and develop full-cycle blockchain solutions: from smart contract architecture to launching DeFi protocols, NFT marketplaces and crypto exchanges. Security audits, tokenomics, integration with existing infrastructure.
Showing 1 of 1 servicesAll 1306 services
Partial take profit algorithm development
Simple
from 1 business day to 3 business days
FAQ
Blockchain Development Services
Blockchain Development Stages
Latest works
  • image_website-b2b-advance_0.png
    B2B ADVANCE company website development
    1218
  • image_web-applications_feedme_466_0.webp
    Development of a web application for FEEDME
    1161
  • image_websites_belfingroup_462_0.webp
    Website development for BELFINGROUP
    853
  • image_ecommerce_furnoro_435_0.webp
    Development of an online store for the company FURNORO
    1047
  • image_logo-advance_0.png
    B2B Advance company logo design
    561
  • image_crm_enviok_479_0.webp
    Development of a web application for Enviok
    823

Partial Take Profit Algorithm Development

Partial position closing (partial take profit) lets you lock part of profit as targets hit, leaving remaining position for further growth. Compromise between "sell all early" and "hold to end".

Partial Take Profit Logic

Instead of one target — multiple profit lock levels:

Entry: 1 BTC at $40,000
TP1 (25% position): $42,000 → sell 0.25 BTC, profit $500
TP2 (50% remaining): $44,000 → sell 0.375 BTC, profit $1,500
TP3 (remainder): trailing stop from $44k → sell 0.375 BTC on trigger

After TP1 move stop-loss to break-even. After TP2 — trailing stop.

Calculating Take Profit Levels

Fibonacci-based: levels at 127.2%, 161.8%, 261.8% of initial move.

R:R based: if stop $500 (1R), then TP1 = 1R ($500), TP2 = 2R ($1000), TP3 = 3R ($1500).

ATR-based: TP1 = entry + 1.5 × ATR, TP2 = entry + 3 × ATR, TP3 = trailing.

Implementation

class PartialTakeProfit:
    def __init__(self, total_qty, take_profit_levels):
        """
        take_profit_levels: [(price, pct_of_current), ...]
        """
        self.remaining_qty = total_qty
        self.levels = take_profit_levels
        self.completed_levels = set()
    
    def check_levels(self, current_price):
        actions = []
        for i, (tp_price, pct) in enumerate(self.levels):
            if i not in self.completed_levels and current_price >= tp_price:
                sell_qty = self.remaining_qty * pct
                self.remaining_qty -= sell_qty
                self.completed_levels.add(i)
                actions.append({'action': 'partial_close', 'qty': sell_qty})
        return actions

Break-even stop after first TP: on TP1 fill, move stop-loss to entry price. Remaining position — "free ride".

Develop partial take profit module with customizable levels, auto stop-loss move to break-even, optional trailing stop for final position part.