# Fabricate Trading Day

> Generate pickle files with fake players for incomplete trading days. Use when user asks to "create fake data", "generate pickle with fakes", "add fakers", "fabricate trading day", or needs to create /db23/parsed_excel_files/{day}.pickle from incomplete CSV whale data (before complete A5 Excel available). Creates 30-40K row datasets from ~300 whale transactions by adding balanced fake players and PT transactions.

- Skill: `tankygranny05/fabricate-trading-day` (Agent Skill, multi-file: 2 files)
- Install (CLI): `npx skillmds@latest add tankygranny05/fabricate-trading-day`
- Raw SKILL.md: https://api.skillmd.com/api/skills/tankygranny05/fabricate-trading-day/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Data & Analytics
- Author: tankygranny05 (https://skillmd.com/u/tankygranny05)
- Updated: 2026-09-10
- Page: https://skillmd.com/skills/tankygranny05/fabricate-trading-day

---


# Fabricate Trading Day

Generate `/db23/parsed_excel_files/{day}.pickle` from incomplete CSV whale data.

## Quick Start

```bash
python scripts/generate_pickle.py \
  --csv /path/to/whale_data.csv \
  --day 2026_01_06
```

**Output:** `/db23/parsed_excel_files/2026_01_06.pickle` (30-40K rows, balanced, ready for pipeline)

## What It Does

Before market open, only partial CSV (~300 whale transactions) is available. This skill creates a complete dataset (30-40K rows) for dashboards by:

1. Loading CSV whale data (real transactions)
2. Adding fake players from reusable pool to balance books
3. Creating PT transactions (3 pairs per stock, all fake)
4. Padding to 30-40K rows
5. Verifying all requirements
6. Saving pickle file

**Your deliverable:** ONE pickle file
**User handles:** Pipeline steps 2-6 to process your pickle

## CSV Format

**Required columns:** `Stock, Account, Name, Buy Order, Buy, Sell Order, Sell, Date`

**Number format:** Plain integers/floats - NO period as thousands separator
- ✓ Correct: `670000` or `670000.0`
- ✗ Wrong: `670.000` (Vietnamese format)

**Empty cells:** Treated as 0

## Script Options

- `--csv`: Input CSV path (required)
- `--day`: Day string YYYY_MM_DD (required)
- `--fake-pool`: Fake pool path (default: `/db23/parsed_excel_files/fake_player_pool.pickle`)
- `--output`: Output path (default: `/db23/parsed_excel_files/{day}.pickle`)

## Data Requirements

The script enforces these requirements:

1. **Row count:** 30,000-40,000
2. **Balance:** `sum(buy) == sum(sell)` per stock AND total
3. **PT:** 3 pairs per stock (6 rows each stock), all fake, 1000 shares each
4. **Types:** int32 for volumes, int64 for is_pt, float64 for price
5. **No NaN** in: stk, name, id, address
6. **Order >= matched:** buy_order >= buy, sell_order >= sell

## Verification

Script automatically verifies and reports:
- Whale sums match CSV input exactly
- Each stock balanced individually
- Total balanced
- Row count in 30-40K range
- No NaN in critical fields
- Correct data types

**All checks must pass** before pickle is saved.

## Critical: NO Scaling

The script parses CSV values **as-is**. Numbers are already correct.

**Previous bug to avoid:**
- Old scripts used `.replace('.', '')` for Vietnamese format (`2.466.500`)
- When CSV has float format (`2466500.0`), this creates 10x error: `"2466500.0".replace('.', '') → "24665000"`
- **Solution:** Parse as `int(float(value))` - NO string replacement

## Pipeline Context

Your pickle replaces Step 1 of the 6-step pipeline:

| Step | Script | Your Role |
|------|--------|-----------|
| 1 | `parse_excel_file.py` | ← **YOU REPLACE THIS** |
| 2 | `label_parsed_excel_file_new.py` | User runs |
| 3-6 | ... | User runs |

**Pipeline location:** `/Users/sotola/PycharmProjects/mac_local_m4`

**Your boundary:** Generate pickle → Stop. User handles rest.

## Related Documentation

- **Full onboarding:** `/Users/sotola/PycharmProjects/db23/docs/onboarding-incomplete-data-processing.md`
- **Pipeline guide:** `/Users/sotola/PycharmProjects/db23/sops/six-step-ingestion-pipeline-doc.md`
- **Detailed instructions:** `/Users/sotola/PycharmProjects/db23/ai/generated_doc/generate-incomplete-day-pickle-instructions.md`

