0bps

Strategy vault / Other

Exchange Wash Trading and Mutual Brushing

Python strategy by apple7474.

PythonOther
Author
apple7474
Complexity
Starter · 64 lines
Parameters
6

The original spec has no written description. Read the source below.

Parameters

NameDefaultWhat it controls
nnum5Quantity
pprice3Price
trade_num5Number of Trades
ButtonDefaultDescription
------------
Start__button__Start volume brushing

Source Python

def main():
    # Set exchange address
    exchanges[0].SetBase("")
    exchanges[1].SetBase("")
    Log("Waiting for instructions")
    while True:
        LogStatus(_D())
        cmd = GetCommand()
        if cmd:
            arr = cmd.split(":")
            # Number of Trades
            for i in range(trade_num):
                Account0 = exchanges[0].GetAccount()
                Account1 = exchanges[1].GetAccount()
                # Log("Account0-usdt", Account0["Balance"], "Account0-DEC", Account0["Stocks"])
                # Log("Account 1-usdt", Account1["Balance"], "Account1-DEC", Account1["Stocks"])
                # Get the coins of A0 and A1
                A0_stocks = Account0["Stocks"]
                A1_stocks = Account1["Stocks"]
                error = 0
                if A0_stocks > A1_stocks:
                    Log("Account0There are coins")
                    # Reset index
                    ex_chang = [exchanges[0], exchanges[1]]
                    if abstest(A0_stocks, A1_stocks) == 1:
                        break
                    else:
                        # Log("Can continue trading")
                        pass
                else:
                    Log("Account1Yesdec")
                    # Reset index
                    ex_chang = [exchanges[1], exchanges[0]]
                    if abstest(A0_stocks, A1_stocks) == 1:
                        break
                    else:
                        # Log("Can continue trading")
                        pass
                # 0Index always sells    
                ex_chang[0].Sell(pprice, nnum)
                # 1Index always sells  
                ex_chang[1].Buy(pprice, nnum)
                Log("Transaction completed",i)
                Sleep(5)
            if abstest(A0_stocks, A1_stocks) == 1:
                break
            else:
                # Log("Can continue trading")
                pass
    Log("Run finished")

def abstest(a, b):
    # Simple judgment
    abs_value = abs(a - b)
    # Log("Currency difference:" + str(abs_value))
    if abs_value == 0:
        Log("Insufficient coins, please check")
        error = 1
    else:
        # Log("Can continue trading")
        error = 0
    return error

Published by apple7474 on the FMZ strategy square · last modified 2021-07-14. Collected in the Quant Trading Vault. Unvalidated research: re-test with your own data and costs before trusting it.

Build this with AgenKit

A spec is not a trading system. Paste this into your coding agent and AgenKit runs a specialist team — architecture, test-first build, risk gates, review — with paper trading on by default.

in Claude Code, Cursor, Codex & 4 more
/agenkit build a production-grade trading bot with a backtest engine, risk controls and paper trading by default from strategies/Exchange-Wash-Trading-and-Mutual-Brushing.md
  1. npx agenkit install engineering-kit in your project
  2. Paste the command into your agent and approve each phase
  3. Get tests, backtest, risk controls and a paper-trading switch

Understand it first

Before you run this, read the lesson behind the idea and how to backtest it honestly. Specs like this one are the survivors of an unknown number of trials; deflate their results accordingly.

Related specs

esc

Try , , or .

↑↓ move↵ open