LessonThis is a lesson restated in new words. Any figure in it is an example from the source, not this desk's record.
The lecture builds a small Python desktop bot in five layers: a window for symbols and rules, a saved file so the window remembers them, a paper brokerage connection, a buy-the-dip rule with fixed size, and a language model that comments on the book. The model does not invent entries. The rule does. The demonstration account is a paper account. Nothing here is a reason to point the same loop at live capital.
Why it matters
The interesting split is between an order rule and a narrator. The rule is mechanical. For a symbol you choose a number of levels and a drawdown percentage. The bot buys one share at the market when the symbol is switched on, treats the fill as the entry, and parks one-share limit orders at successively lower prices. The language model is handed positions and open orders and asked about concentration, diversification, or what the open limits imply. In the demo, a question about Apple and Johnson & Johnson came back with a remark that the book was concentrated. That is commentary. It is not a signal, and the lecture says you could later let a model trade, which is a different and riskier design than the one that was run.
The idea in plain words
The window is Tkinter. A form takes a symbol, a level count, and a drawdown. A table shows symbol, position, entry, levels, and whether that symbol's system is on. Buttons add, remove, and toggle. A text box sends a question and prints the reply in a read-only field. State lives in a JSON file of equities. On startup the file is loaded, with a missing or broken file treated as an empty book. On close the flag that keeps the refresh thread alive is set false, the file is written, and the window is destroyed. The dip rule is a martingale-style average-down, not a doubled stake. Size stays one share. If the entry is 100 and the drawdown is 10 percent, the lecture describes further buys every additional 10 percent down, one share at each level. The code builds those prices from the entry times one minus the drawdown times the level index, rounded to cents. Levels are stored as keys. A negative key means an order for that level is already working, so a restart does not stack a second order. The lecture's first live-looking test used Apple, five levels, and a 5 percent drawdown.
How to use it
Run it only against a paper endpoint until the order list matches the levels you typed. Check three things the lecture checked: the JSON survives a restart, a toggle off does not leave the bot adding orders, and a second toggle on does not double them. Then ask the model a question you can verify by eye, such as which names are held and whether the limits are below the entries. The prompt in the lecture tells the model it is a portfolio assistant, lists holdings and open orders, and asks it to discuss risk, concentration, and the limits. The lecture used a GPT-4 class model behind that prompt. The reply is not an instruction the bot executes.
The lecture likes the one-share cap because the API will also refuse reckless leverage. That cap limits how fast the position grows. It does not make averaging down safe. Five extra shares, each a fixed percent lower, is still a larger long position in a name that is falling.
What usually goes wrong
Sending the paper code to a live endpoint because the function names match. The lecture's base URL is the paper host for a reason. Storing keys in the source file, which the walkthrough did on screen. Keys belong in a place the repository does not keep. A third failure is trusting the model's risk paragraph. It saw the positions it was given. It did not see a scenario the feed omitted, and it did not place the hedges it might mention. A fourth is forgetting the negative-key trick and resubmitting limits after every five-second wake-up. The lecture hit a key-name bug, cancelled the paper orders, and reran. That recovery is part of the design: the broker is the source of open orders, and the file is a cache that can be wrong until you reconcile it.
Questions people ask
What did the Apple test actually send?
One market buy, then five limit buys at prices stepped down by 5 percent from the fill. The system was off until it was toggled. A later off-on cycle did not add a second set.
Does the language model choose symbols?
No. Symbols, level counts, and drawdowns are typed. The model receives the resulting positions and open orders and answers a question. The lecture's example question was about the risk of holding Apple and Johnson & Johnson together.
Why paper first?
Because the same calls can submit live orders. The lecture says to generate paper keys, use the paper host, and treat a failure on a live host as a funding problem you should not solve by accident.