Home /Modules/advantage/README.md

README.md

lib/advantage/learner-vs-professional/courseware/long-medium-averages/README.md · 92 line(s) · markdown

Long-Medium-Averages

An adult courseware entry sitting between a single trade and a long-term hold: medium-term, actively-worked positions — a near-term or short-term window with several buys and a sell, each checked with exact FIFO arithmetic — plus one concrete rule fixed in this session: a trading day admits at most 2,000 actions.

Illustrative only. Coins, tokens, chips and similar invented units stand in for a tradable quantity; no real market, price or order is used. See ../ORGANIZED.md for the full glossary, including which terms from this topic are defined and which are explicitly not (most importantly, "Flat 2" has no definition yet and is not used here).

What "medium" means here

"Medium" is read as covering both near-term and short-term trades: a position built and closed over a short window (days), with more than one action, as opposed to one buy-then-sell pair or a position held for a long threshold of days. It is a point on the same spectrum as the long-term material elsewhere in this library, not a new mechanism.

The classes

SLDailyCapBook is SLLongBook (see ../../../trading-actions-on-verb/SLLongBook.sleela) with one addition: every verb (buy, sell, hold, flatten) calls admitAction(day) before it changes anything. Once a day has recorded 2,000 actions, any further action on that same day is refused with status code 10, and the action count resets to 0 when the day changes. All other status codes (0–8) and the exact-integer bounds are unchanged from SLLongBook.

SLDailyCapShortBook is the short-side mirror, built on SLShortBook: shortSell, cover, hold, coverAll, the same borrow-cost-per-share-day accounting, and the identical 2,000-actions- per-day cap (status code 10). Status codes 0–9 match SLShortBook.

The 20 entries

Entries 1–16 are long-side stories: two buys a few days apart, then a sell, covering 16 invented goods (coins, tokens, chips, blanks, foils and similar). Entry 17 proves the daily cap itself at its boundary. Entries 18–20 are the short-side mirror: two short-sells, then a cover, with borrow cost.

#foldergoodswhat it shows
101-copper-coinscopper coinsbase case: two buys, FIFO sell, exact profit
202-silver-tokenssilver trading tokensa partial sell across two lots
303-gold-chipsgold game chipsa wider day gap between buys and the sell
404-brass-roundsbrass roundsa sell that exactly empties both lots
505-bronze-medalsbronze trading medalsa sell larger than either lot alone
606-nickel-blanksnickel blanksa falling second buy price
707-tin-puckstin pucksequal-sized lots, unequal prices
808-zinc-slugszinc slugslow unit price, large quantity
909-steel-washerssteel washersthe largest quantities in the set
1010-platinum-foilsplatinum foilsthe highest unit price in the set
1111-titanium-tabstitanium tabsa mid-size position with fees
1212-iron-tagsiron tagsa quick two-day turn
1313-quartz-chipsquartz counting chipsa wider window before the sell
1414-obsidian-flakesobsidian trading flakesa loss on the second lot's share
1515-granite-countersgranite countersa rising price path
1616-slate-markersslate markersa falling then rising price path
1717-daily-cap-boundary—the 2000th action is accepted, the 2001st is refused and changes nothing, a new day resets to 0
1818-short-coinsshort-sold trading coinsthe short-side mirror: two short-sells, FIFO cover, borrow cost
1919-short-tokensshort-sold game tokensa short position covered at a higher price (a loss)
2020-short-chipsshort-sold collector chipsa falling cover price across two lots

Assurance

Every entry prints ok/FAIL per check and ends checks passed=N failed=0. Expected values for entries 1–16 and 18–20 were computed by an independent Python model of the same FIFO (and, for 18–20, borrow-cost) rule and compared with what SLeeLa printed; entry 17 was checked by hand against the stated rule (2000 accepted, 2001 refused, reset on day change). Both daily-cap classes were mutation-tested (an off-by-one profit calculation and a cross- check denominator bug were each confirmed caught before being reverted). test-suites/test-long-medium-averages.sh runs all 20 and compares each with its .expected.txt.

bash test-suites/test-long-medium-averages.sh

Honest limits