Fund Buying Decision Pro
by @seanmwx
Parameterize and apply a Chinese mutual-fund buy, add, reduce, or hold strategy driven by price drawdown, recurring DCA, cash-pool management, and position l...
clawhub install fund-buying-decisionπ About This Skill
name: fund_buying_decision description: Parameterize and apply a Chinese mutual-fund buy, add, reduce, or hold strategy driven by price drawdown, recurring DCA, cash-pool management, and position limits. Use when Codex needs to maintain the strategy thresholds in SKILL.md, explain or simulate a daily decision, update the bundled Eastmoney-to-SQLite importer, or produce a detailed report for a fund such as 011598.
Fund Buying Decision
Overview
Use this skill to keep a reusable fund trading framework in one place. Prefer changing the parameter block below instead of rewriting numeric rules in prose.
Return one explicit action per decision cycle:
buy_dcabuy_dipsell_take_profitholdskip_data_missingIf multiple actions trigger on the same day, prefer the risk-reducing action and keep the one-trade-per-day rule.
Strategy Parameters
Edit editable first. Keep fixed stable unless the strategy shape really changes.
strategy_parameters:
editable:
capital:
initial_cash: 1000
weekly_dca_amount: 100
monthly_cash_pool_inflow: 1000 scheduling:
weekly_pretrade_reminder:
weekday: monday
time_local: "09:00"
weekly_dca:
weekday: tuesday
weekly_trade_reminder:
weekday: tuesday
time_local: "09:30"
monthly_cash_inflow:
schedule_type: second_to_last_business_day
day_of_month: null
monthly_cash_inflow_reminder:
schedule_type: second_to_last_business_day
day_of_month: null
time_local: "10:00"
price_state:
dip_thresholds_pct: [5, 10, 15]
dip_base_buy_amounts: [100, 150, 200]
take_profit:
profit_thresholds_pct: [10, 20]
profit_sell_ratios_pct: [10, 20]
risk:
max_position_ratio_pct: 80
min_position_ratio_pct: 20
fixed:
universe:
allowed_fund_types:
- index_fund
- equity_fund
disallowed_fund_types:
- bond_fund
- money_market_fund
capital:
fee_rate_source: fund_current_rate
scheduling:
trade_cutoff_local_time: "15:00"
backtest_execution_mode: next_trading_day
max_trades_per_day: 1
price_state:
recent_high_lookback_trading_days: 20
min_trading_days_between_adds: 5
Parameter Groups
Use these two buckets when maintaining the strategy:
editablecapital.initial_cash
capital.weekly_dca_amount
capital.monthly_cash_pool_inflow
scheduling.weekly_pretrade_reminder.weekday
scheduling.weekly_pretrade_reminder.time_local
scheduling.weekly_dca.weekday
scheduling.weekly_trade_reminder.weekday
scheduling.weekly_trade_reminder.time_local
scheduling.monthly_cash_inflow.schedule_type
scheduling.monthly_cash_inflow.day_of_month
scheduling.monthly_cash_inflow_reminder.schedule_type
scheduling.monthly_cash_inflow_reminder.day_of_month
scheduling.monthly_cash_inflow_reminder.time_local
price_state.dip_thresholds_pct
price_state.dip_base_buy_amounts
take_profit.profit_thresholds_pct
take_profit.profit_sell_ratios_pct
risk.max_position_ratio_pct
risk.min_position_ratio_pctfixeduniverse.allowed_fund_types
universe.disallowed_fund_types
capital.fee_rate_source
scheduling.trade_cutoff_local_time
scheduling.backtest_execution_mode
scheduling.max_trades_per_day
price_state.recent_high_lookback_trading_days
price_state.min_trading_days_between_addsState Boundary
Treat SKILL.md as strategy configuration only. Do not store live account state in this file.
SKILL.md is the source of truth for strategy rules, thresholds, schedules, and default initialization values.cash_pool, position_units, avg_cost_price, account_id, and executed trades must live in the database, not in SKILL.md.capital.initial_cash is only the default starting amount used when initializing a new strategy account.python {baseDir}/scripts/manage_strategy_account.py ...
python {baseDir}/scripts/record_strategy_trade.py ...
python {baseDir}/scripts/confirm_strategy_action.py ...
capital.initial_cash in SKILL.md to reflect a new live balance.Required Inputs
Do not invent missing inputs. If a required field is unavailable, return skip_data_missing and explain what is missing.
Required runtime inputs:
fund_codecurrent_pricecost_pricecash_poolposition_valuerecent_hightodaytrade_time_locallast_add_trade_dateis_weekly_dca_dayis_monthly_cash_inflow_dayDerived values:
total_asset = cash_pool + position_valueposition_ratio = position_value / total_assetdrawdown_pct = (recent_high - current_price) / recent_high * 100profit_pct = (current_price - cost_price) / cost_price * 100effective_fee_rate_pct = imported fund current_rate when availableDaily Workflow
1. Refresh or read fund data.
For Eastmoney price data, run python {baseDir}/scripts/import_eastmoney_pingzhongdata.py 011598 or replace 011598 with another fund code.
2. If today and the current local time match the configured weekly_pretrade_reminder, issue the weekly pretrade reminder.
3. If today and the current local time match the configured weekly_trade_reminder, issue the trading reminder and then evaluate the strategy.
4. If today and the current local time match the configured monthly_cash_inflow_reminder, remind the user to add the monthly cash inflow.
5. Record the monthly cash inflow only after it is actually added to cash_pool.
Use python {baseDir}/scripts/record_strategy_trade.py 011598 --trade-type cash_inflow --gross-amount 1000.
6. Update current_price, recent_high, total_asset, and position_ratio.
7. Evaluate take-profit rules first when both buy and sell could trigger on the same day.
8. Evaluate dip-buy rules only if the add-spacing rule is satisfied and cash is available.
9. Evaluate weekly DCA only if no higher-priority trade was selected.
10. Re-check max and min position limits after sizing the candidate trade.
11. Execute at the configured cutoff rule.
For backtests, prefer next_trading_day execution to avoid future leakage.
Scheduling Rules
weekly_pretrade_reminder.weekday and weekly_pretrade_reminder.time_local control the weekly pretrade reminder schedule.weekly_trade_reminder.weekday and weekly_trade_reminder.time_local control the weekly trade reminder schedule.weekly_dca.weekday controls which weekday counts as the DCA trading day.monthly_cash_inflow.schedule_type controls the monthly cash-inflow date used by the strategy state.monthly_cash_inflow_reminder.schedule_type and monthly_cash_inflow_reminder.time_local control the monthly reminder trigger.schedule_type values are:second_to_last_business_day
- last_business_day
- day_of_month
schedule_type = day_of_month, fill day_of_month with an integer such as 15 or 28.Decision Rules
DCA
weekly_dca_amount as the fixed recurring DCA amount.min(weekly_dca_amount, cash_pool).Dip Buy
drawdown_pct from recent_high.dip_thresholds_pct.dip_base_buy_amounts.cash_pool
- remaining room under max_position_ratio_pct
min_trading_days_between_adds.Take Profit
profit_thresholds_pct.profit_sell_ratios_pct.min_position_ratio_pct.cash_pool.Position And Cash Controls
cash_pool.cash_pool.max_position_ratio_pct.min_position_ratio_pct.current_rate in trade sizing when the user requires fees.Fund Detail Reporting
python {baseDir}/scripts/report_fund_details.py 011598 --refresh to fetch and summarize a fund.Drawdown Alerts
python {baseDir}/scripts/check_fund_alert.py 004475 to check drawdown alerts against the configured dip_thresholds_pct tiers in SKILL.md.--threshold-pct, for example:python {baseDir}/scripts/check_fund_alert.py 004475 --threshold-pct 5 --threshold-pct 10 --threshold-pct 15
Strategy Runtime Commands
Default SQLite location:
~/.fund_buying_decision/fund_buying_decision.db--db ~/.fund_buying_decision/.db when you want a separate database file for another account set or experiment.python {baseDir}/scripts/manage_strategy_account.py upsert 011598 --account-id main --cash-pool 1000 --position-units 0 --fund-type equity_fund
python {baseDir}/scripts/record_strategy_trade.py 011598 --account-id main --trade-type cash_inflow --gross-amount 1000
python {baseDir}/scripts/evaluate_strategy.py 011598 --account-id main --refresh
python {baseDir}/scripts/confirm_strategy_action.py 011598 --account-id main --refresh --expected-action buy_dca
python {baseDir}/scripts/check_fund_alert.py 004475References To Load
references/strategy_parameters.mdreferences/data_inputs.md