Week 09 · Build Your Own Automated Options Trading System

Going live
with one lot.

One lot, one tranche, one day. Watched. Squared off cleanly. The cheapest tuition you will ever pay.

Week 9 of 12
Smallest possible first trade
Broker terminal open the entire time
This week, in one glance

Same five beats. New topic.

1
Idea
One lot live is the cheapest tuition you will ever pay.
2
Outcome
One real order placed, watched, and squared off cleanly. Broker terminal screenshot saved.
3
Vocabulary
live mode flag · simulator · smoke test · dry run · structured logging
4
Hands-on
Run one lot · one tranche · one day. Screenshot the broker terminal at fire time.
5
War story
Cancel-and-replace turned into both orders filling, because nobody asked the broker if the cancel went through.
1 · The idea

The smallest possible real trade. On purpose.

Eight weeks of preparation. Today's job is to find out what your prep missed — at the cheapest possible price.

1 lot
smallest size. Fixed cost of finding bugs.
1 tranche
single decision, single entry, single SL — no orchestration yet
1 day
watch every second. Tomorrow you scale only what worked today.
Going big on day one is paying full tuition for what one lot would have taught you.
Before the bot places one real order

The pre-live checklist.

Must
Live-mode flag is explicit
A single boolean (LIVE = True) gates real orders. Default to False. You flip it on purpose.
Must
Lot size = 1, hard-coded for this run
Even if config says more, force 1. Belt + suspenders.
Must
SL placed in same breath as entry
From Week 8. If SL placement fails, the engine exits the position immediately. No naked windows.
Must
Telegram entry & exit alerts wired
From Week 7. You see the fire fire. You see the exit exit.
Should
Dry-run yesterday, fire today
Run the same script in dry-run mode against yesterday's data. If yesterday's decision looks sane, today's odds are better.
Should
Broker terminal open beside the laptop
When the alert lands on your phone, the broker terminal should show the order within seconds. If not, something's off.
Nice
Squareoff time set 30 min before normal close
Gives you time to handle anything weird. Tomorrow you can extend.
If any "Must" is unchecked, you are not ready to go live today. There's no shame in waiting one week — there is real cost in skipping one.
2 · By the end of this week

One trade. Watched. Squared off clean.

You ran your strategy live for one trading day with LIVE=True and LOTS=1 — nothing more.
A real order fired on the broker terminal. You saw it land on your phone via Telegram within seconds.
An SL was placed in the same breath. Either the SL fired and exited cleanly, or the squareoff time exited cleanly.
You have a screenshot of the broker terminal at the moment of fire. You can show it to anyone and explain every column.
P&L on day one is irrelevant. The product of Week 9 is a working pipeline, not a winning trade.
3 · New vocabulary

Five words. Use them this week.

live mode flag
A single boolean that decides "place real orders or not." Default off. You flip it for the run.
LIVE = True
simulator
A fake broker that accepts your orders and replies with plausible fills — for development without real money.
MockBroker()
smoke test
A quick, end-to-end "does the basic pipe work?" check. Not deep. Just confirms nothing's on fire.
place 1 lot, immediately cancel
dry run
Full strategy execution, but every order call is intercepted and logged — never sent to the broker.
DRY_RUN=True
structured logging
Log lines as key=value pairs (or JSON), not free-form prose. Easy to grep, easy to alert on.
action=ENTRY symbol=NIFTY qty=65
Structured logging is the difference between "I think it placed the order" and grep action=ENTRY today.log.
A day in the life — first live run

Wake up early. Sit beside the terminal.

One full trading day, your first real one

08:30
Wake. Verify broker token refreshed overnight. Confirm funds.py still works from the server.
09:00
Start the strategy. Watch the Telegram channel for "Strategy started · LIVE=True · lots=1" message.
09:15
Market opens. Strategy reads its first tick. Open the broker terminal on a second screen.
09:25 (example)
Entry decision fires. Telegram ping. Broker terminal shows the order. Screenshot it now.
09:25 + 5s
SL order placed. Confirm both on the broker terminal: short position + stop order.
… all day
Do not interfere. Watch only. Touching the order manually is how Week-9 lessons get muddled.
14:45
Squareoff fires (early on purpose). Telegram exit ping. Broker terminal shows position closed. Screenshot.
15:30 +
Sit with the log file for 30 minutes. Read every line. Note anything you didn't expect.
The journal you write tonight is more valuable than the P&L. The journal compounds. The P&L on day one doesn't.
4 · The hands-on bit — your task

One lot. One day. One screenshot.

What to do this week (one trading day, fully present)

  1. Pre-flight, the day before. Walk the pre-live checklist top to bottom. Every "Must" checked. If any are not, postpone.
  2. Force lots=1. Even if your risk-based sizing says 4, hard-code 1 in this run. Belt + suspenders.
  3. Start the strategy at 09:00 from your cloud server. Confirm Telegram says "LIVE=True · lots=1".
  4. Open broker terminal on a second screen at 09:14. Order book + positions view.
  5. When the entry fires: screenshot the broker terminal showing the order row. Screenshot the SL row. Save both to ~/trading/day1/.
  6. Do nothing all day. Watching is the job. No manual edits. No "let me move the SL." That's Week 11.
  7. After squareoff: read the entire log file out loud. Then write 200 words on what surprised you.
If anything goes wrong, hit the kill script for your strategy (per-strategy, never pkill). Then debug calmly tomorrow with the broker terminal still open.
5 · A real-money war story

Cancel-and-replace turned into both orders filling.

A re-price routine wanted to move the entry order from ₹68 to ₹70. It sent a CANCEL on the old order, then immediately a PLACE for the new one. The cancel was in flight when the old order filled at ₹68. The new order also filled at ₹70. Two positions where one was planned.

What the code did

Fire-and-forget cancel. Place the replacement without verifying. Two orders open simultaneously for a moment — and both filled.

# cancel-and-replace, the wrong way
broker.cancel(old_id)        # in-flight
broker.place(new_order)       # placed anyway
# both fill before we know

What the code does now

Cancel-verify pattern (Week 8). Place the replacement only after the broker confirms the old one is dead.

state = cancel_and_verify(old_id)
if state == "already_filled":
    # the price is already ours — don't double
    log.warn("replace skipped — first leg filled")
elif state == "cancelled":
    broker.place(new_order)   # safe now
2x
position size compared to plan
~30ms
window where both orders were live
1
pattern fixes both BUG-100 (Week 8) and this — cancel-verify
The lesson, pinned

Cancel is a question, not a command.

You ask the broker to cancel. The broker may, or may not, succeed. The exchange may, or may not, fill your order before the cancel lands. Until you read the final state of the order from the broker, you don't know what happened. Every action after a cancel must be gated on that final state — never on the optimistic assumption that "the cancel went through."

This is the same lesson as BUG-100 (Week 8), just dressed differently. Cancel-verify is the universal pattern. It costs an extra HTTP call. It saves real-money damage. It is non-negotiable.

A live order that you assume was cancelled is just a live order. The exchange doesn't care about your assumptions.
Week 9 — takeaway

One lot today. Tomorrow you scale only what worked.

The product of Week 9 is not a winning P&L — it's a clean pipeline. Real order. Real fill. Real SL. Real exit. Real screenshots. Real journal. Sit with all of it for an evening before you change one line.

End of Week 9

Next: From script to system.

source: cowork/Course_Outline_12_Weeks · Week 9
← → navigate · F fullscreen · click to advance
1 / 12