0bps

Strategy vault / Other

Share Strategies for Grabbing New Spot Products

Python strategy by 盯盘狗 - 策略出租.

PythonOther
Author
盯盘狗 - 策略出租
Complexity
Starter · 41 lines
Parameters
0

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

Source Python

import time

# Initialize strategy parameters
symbol = 'huobip/ht_usdt'
amount = 10
max_price = 1.5
min_price = 0.5
interval = 0.1

# ConnectAPI
exchange = Exchange()
exchange.SetContractType(symbol)

# Main loop
while True:
    # Get current market depth
    depth = exchange.GetDepth()

    # Get the current best bid and ask prices
    buy_price = float(depth['Bids'][0]['Price'])
    sell_price = float(depth['Asks'][0]['Price'])

    # Determine whether conditions are met
    if buy_price <= max_price and sell_price >= min_price:
        # If the conditions are met, execute a buy operation
        buy_amount = amount / buy_price
        exchange.Buy(buy_price, buy_amount)
        print('Buy', buy_amount, 'HT, price', buy_price)

        # Wait for a period of time before executing the sell operation
        time.sleep(interval)
        sell_price = float(depth['Asks'][0]['Price'])
        sell_amount = amount / sell_price
        exchange.Sell(sell_price, sell_amount)
        print('Sell', sell_amount, 'HT, at price', sell_price)

    # Wait for next loop
    time.sleep(1)


#This strategy usesFMZProvided by the platformExchange APIto trade. In the main loop, first get the current market depth, then get the current bid and ask prices. If the buying price is less than or equal to the set maximum price and the selling price is greater than or equal to the set minimum price, a buying operation is performed. Wait for a period of time and then obtain the current selling price to perform the selling operation. Finally wait for the next cycle. It should be noted that there are certain risks in the strategy of grabbing new spot goods, so you need to operate with caution.

Published by 盯盘狗 - 策略出租 on the FMZ strategy square · last modified 2023-04-18. 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/Share-Strategies-for-Grabbing-New-Spot-Products.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