0bps

Strategy vault / Other

Dry Information Coin Selection System Coin Selection Factors

Python strategy by 陈皮.

PythonOtherATR
Author
陈皮
Complexity
Starter · 59 lines
Parameters
0

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

Source Python

import numpy as np
from scipy.stats import norm
from sklearn import preprocessing
import json

#Calculate Volatility Factor Value
def GetAtrFactorService(records):
    atrlength = 14
    atrs = TA.ATR(records, atrlength)
    acs = sorted(range(len(atrs)), key=lambda k: atrs[k])
    ac = acs[-1]
    arr_mean = np.mean(acs)
    arr_std = np.std(acs,ddof=1)
    p = norm.cdf(x=ac, loc=arr_mean, scale = arr_std)
    #PThe larger the value, the greater the volatility
    atrFactor = _N(p,3)
    return atrFactor 

#Calculate the behavior trace factor value of the organization        
def GetITFactorService(records):
    #Benford's law distribution frequency
    PN = [301, 176, 125, 97, 79, 67, 58, 51, 46]
    FN = [0, 0, 0, 0, 0, 0, 0, 0, 0]
    for i in range(len(records)):
        valume = records[i]['Volume']*10000
        strValume = str(valume)
        num = strValume[0]
        for j in range(len(FN)):
            key = j + 1
            if int(num) == key:
                FN[j] += 1
    if sum(FN) == 0:
        FN = PN
    X = 0
    for i in range(len(PN)):
        X += (FN[i] - PN[i])**2
    ITFactor = X
    #X The larger the value, the greater the deviation of transaction volume data from Benford's ideal distribution, and the more pronounced the traces of institutional behavior.
    return ITFactor

#Calculate the price factor value
def GetPriceFactorService(records):
    record = records[-1]
    price = record["Close"]
    PFactor = 1/price 
    #PFactorThe larger the value, the lower the price 
    return PFactor 

#Standardization   --The calculated factor values need to be standardized due to different magnitudes. Missing values and outliers are not handled for now.
def StandardizedService(factor):
    # Standardization
    factorArray = np.asarray(factor)
    factorArray = preprocessing.scale(factorArray)
    factor = factorArray.tolist()

ext.GetAtrFactorService = GetArtFactorService 
ext.GetITFactorService = GetITFactorService 
ext.GetPriceFactorService = GetPriceFactorService 
ext.StandardizedService = StandardizedService

Published by 陈皮 on the FMZ strategy square · last modified 2022-02-12. 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/Dry-Information-Coin-Selection-System-Coin-Selection-Factors.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