Wait, did you spot that intentional little hiccup there? 等等，你发现那里故意打嗝了吗？
I was it was just after I stopped recording. 我是在我停止录音之后。
I was thinking, and I'm like, hang on a second, hang on a second. 我在想，我想，等一下，等一下。
We saw that that, uh, in the traces that it bought Tesla stock and it didn't report that it bought 我们看到，呃，在它购买特斯拉股票的痕迹中，但它没有报告它购买了
Tesla stock. 特斯拉股票。
And we didn't see that in our holdings at the end. 我们最终没有在我们的持股中看到这一点。
So let's go back and see what happened there. 那么让我们回去看看那里发生了什么。
So I went back into the trace and I took a look and I scrolled down load more. 所以我回到跟踪中看了一下，然后向下滚动加载更多内容。
Uh, and uh uh, sure enough, if we get down to the bottom here, you will see that there were indeed 呃呃呃呃,果然,如果我们深入到这里的话,你会发现确实有
these two buying shares. 这两次购买股票。
First of all, it bought 50 Disney shares. 首先，它购买了50股迪士尼股票。
And then as I remember it, bought 30 Tesla shares. 然后我记得，我买了 30 股特斯拉股票。
What's going on? 这是怎么回事？
Well, then I scrolled down and saw that it got an error back from this error executing tool. 好吧，然后我向下滚动，发现这个错误执行工具返回了一个错误。
Insufficient funds to buy shares. 资金不足，无法购买股票。
And what's kind of brilliant about this is that that error message is an error message that was written 这个错误消息的精彩之处在于该错误消息是被写入的错误消息
by our crew agents in week three. 由我们的机组人员在第三周进行。
We asked it one of our business requirements is that it should put something in there that prevents 我们要求它的业务要求之一是它应该放一些东西来防止
the person from buying more shares than they can afford. 该人购买的股票超出了他们的承受能力。
And so that error message. 错误信息也是如此。
Insufficient funds to buy shares was written by those crew agents. 资金不足买股是那些船员经纪人写的。
That's what's been surfaced back here. 这就是这里出现的情况。
And that is why those shares weren't bought. 这就是为什么这些股票没有被购买的原因。
And that's why it didn't include that on its summary. 这就是为什么它没有将其包含在摘要中。
And indeed why why, although it does mention that it should be monitored in the next steps. 确实为什么为什么，尽管它确实提到应该在接下来的步骤中对其进行监控。
And that's why, of course, it isn't in the holdings at the bottom. 当然，这就是为什么它不在底部的持仓中。
So there's a great explanation. 所以有一个很好的解释。
And it's everything is working perfectly. 一切都运转良好。
So we're now going to go and look at some Python modules, some Python code. 所以我们现在要去看看一些 Python 模块，一些 Python 代码。
And this really brings again this very important point that a great way to work with building a genetic 这确实再次提出了这一非常重要的观点，即构建遗传基因的好方法
framework. 框架。
So building a genetic solutions to business problems is to start in the lab. 因此，构建商业问题的基因解决方案要从实验室开始。
Start in a notebook like this experimenting with prompts and different agent configurations. 从这样的笔记本开始尝试提示和不同的代理配置。
And don't move to Python modules until you've done your experiments. 在完成实验之前，不要转向 Python 模块。
I do get a lot of people asking me, how am I going to go about building this agent solution to the 确实有很多人问我，我该如何构建这个代理解决方案？
following commercial problem. 以下商业问题。
And they want to dive straight into code and building lots of agents, and they want to build a diagram 他们想要直接深入代码并构建大量代理，并且他们想要构建一个图表
that shows boxes with agents all talking to each other. 这显示了盒子里的代理都在互相交谈。
And I say to them, look, it's super important to begin by experimenting where that data science hat 我对他们说，看，从实验数据科学帽子的位置开始是非常重要的
start in the lab, start by experimenting with prompts, understand what are the capabilities that you 从实验室开始，从尝试提示开始，了解您可以使用哪些功能
can give an agent, that it can stay coherent and it can follow instructions. 可以让代理保持连贯性并且可以遵循指令。
And how can you give the right balance between autonomy and coherence and these kinds of decisions? 如何在自主性和一致性以及此类决策之间取得适当的平衡？
They come through practice, and it doesn't come from designing a big picture and then coding for a 他们是通过实践得来的，而不是来自设计一个大局然后编码
long time, and then kicking it off and then complaining when it doesn't do what you want it to do because 很长一段时间，然后把它踢掉，然后在它没有做你想做的事情时抱怨，因为
it won't the first time if you do it that way. 如果你这样做的话，这将不是第一次。
And that's why the right way to approach this is little by little, starting small in the lab. 这就是为什么解决这个问题的正确方法是一点一点地、从实验室的小规模开始。
So that's what we've done here. 这就是我们在这里所做的。
We've done that. 我们已经做到了。
We've been in the lab, we've built something, and it's now time for us to turn this into code. 我们已经在实验室中构建了一些东西，现在是时候将其转化为代码了。
And we're going to do that. 我们将会这么做。
And I'm going to show you, piece by piece, three different files MCP servers, templates and traders. 我将逐步向您展示三个不同的文件 MCP 服务器、模板和交易者。
So first of all MCP servers is where we define our MCP servers. 首先，MCP 服务器是我们定义 MCP 服务器的地方。
So here we go. 那么我们开始吧。
We're looking for. 我们正在寻找。
It's actually sorry. 其实是很遗憾。
It's it says MCP servers. 它说的是 MCP 服务器。
It's MCP params dot pi. 它是 MCP 参数点 pi。
Change that right now MCP params dot pi is where the MCP servers are specified. 现在更改 MCP 参数点 pi 是指定 MCP 服务器的位置。
So here we go. 那么我们开始吧。
We're in MCP params dot pi. 我们位于 MCP 参数 dot pi 中。
Now you don't need to have your MCP parameters specified in a python module separate to your other code, 现在，您不需要在与其他代码分开的 python 模块中指定 MCP 参数，
but I think this is an organized, tidy way of doing it to keep things nicely. 但我认为这是一种有组织、整洁的方式，可以让事情保持良好状态。
The right concerns in the right file. 正确的关注点存在于正确的文件中。
So in this file, I'm setting up my different MCP parameters that I'll use later when I'm creating the 因此，在这个文件中，我设置了不同的 MCP 参数，稍后在创建
MCP servers. MCP 服务器。
So first of all, for market data I choose to either use the official polygon MCP server or I use the 因此，首先，对于市场数据，我选择使用官方的 Polygon MCP 服务器，或者使用
little sneaky one that we made market servers that caches results and makes sure that you can use free 我们制作了一个小鬼祟的市场服务器来缓存结果并确保您可以免费使用
polygon IO without exceeding your limits. 多边形 IO 不会超出您的限制。
So we pick one or the other depending on how your EMV is set up. 因此，我们根据您的 EMV 设置方式选择其中之一。
Okay. 好的。
And then the full set of MCP servers for our trader is the accounts server, our homegrown MCP server 然后我们交易者的全套MCP服务器就是账户服务器，我们自己开发的MCP服务器
for accounts, the push server, another little homegrown server sending push notifications because 对于帐户，推送服务器，另一个发送推送通知的本土小型服务器，因为
you know I love them. 你知道我爱他们。
And then the server for the market data. 然后是市场数据的服务器。
Okay. 好的。
And now we've got a separate set of MCP servers for our researcher. 现在我们为我们的研究人员提供了一组单独的 MCP 服务器。
There are three of them. 他们一共有三个。
First of all fetch the ability to fetch a page using playwright browser behind the scenes. 首先，获取在幕后使用剧作家浏览器获取页面的能力。
Then we're using the brave search again, our free brave search API for web searches. 然后我们再次使用brave search，我们的免费brave search API 用于网络搜索。
And then this the return of the memory. 然后这就是记忆的回归。
We're using our memory. 我们正在使用我们的记忆。
We're using the SQL based memory. 我们正在使用基于 SQL 的内存。
And you can see I'm actually going to try and have a separate memory file for each trader based on its 你可以看到我实际上会尝试根据每个交易者的交易情况建立一个单独的内存文件
name. 姓名。
So the name will be passed in. 所以名字会被传入。
And that's what we will use here as the, the name of the of the memory file, so that every trader, 这就是我们在这里使用的内存文件的名称，以便每个交易者，
every researcher has a separate set of memory. 每个研究人员都有一套单独的记忆。
Okay. 好的。
That is the MCP params module. 那是 MCP 参数模块。
So the second module I wanted to show you is called templates. 所以我想向您展示的第二个模块称为模板。
And here's the thing templates.py is just where I have put any function which is returning like a prompt 这就是 templates.py ，我放置了像提示一样返回的任何函数
instruction or a string or something like that. 指令或字符串或类似的东西。
And I've done this to be organized so that I don't have tons of text coded within the body of my functionality. 我这样做是为了进行组织，这样我就不会在我的功能体内编码大量文本。
And again, this is just a nice, good practice. 再说一次，这只是一个很好的做法。
It's good to separate concerns this way. 以这种方式分离关注点是很好的。
It means that if I need to edit my prompts, I've got one place to go and do it. 这意味着如果我需要编辑提示，我可以去一个地方进行编辑。
I've got effectively my my prompt templates. 我已经有效地获得了我的提示模板。
Uh, in many ways, if you if you think of some of the more opinionated frameworks like Lang chain or 呃，在很多方面，如果你想到一些比较固执己见的框架，比如 Lang chain 或
like crew I for for an agent framework, they sort of force you to separate stuff like this? 就像我为代理框架工作的人员一样，他们有点强迫你将这样的东西分开？
Uh, well, they don't force you. 呃，好吧，他们不会强迫你。
But there are ways around it. 但有一些方法可以解决这个问题。
But but, uh, crew, for example, of course, has the YAML files, which, uh, specifically takes 但是，呃，例如，船员，当然有 YAML 文件，其中，呃，专门采用
away takes to one side your text. 离开将您的文字移至一侧。
But we're not we're not using those kinds of frameworks, but there's nothing stopping us from, uh, 但我们并不是不使用这类框架，但是没有什么可以阻止我们，呃，
putting us through the discipline of putting all of our texts like this into a separate module. 让我们经历将所有像这样的文本放入一个单独的模块的纪律。
And that's why I've got it here. 这就是我把它放在这里的原因。
So I've got, uh, my researcher instructions, my research tool definitions, my trader instructions, 所以我有，呃，我的研究人员指示，我的研究工具定义，我的交易者指示，
and my prompts all here in these different functions. 我的提示都在这些不同的功能中。
And you'll see I do things like inserting the current date in the prompts, which I said before was 你会看到我做了一些事情，比如在提示中插入当前日期，我之前说过
a was a very good practice, uh, to avoid having to equip it with the tool that it needs to call. a 是一个非常好的实践，呃，可以避免为其配备需要调用的工具。
Just put the date in the prompt, and you'll also see how I'm putting the strategy and the account details 只需在提示中输入日期，您还将看到我如何设置策略和帐户详细信息
straight in there in the prompt. 直接在提示中输入。
So that's templates.py that separates out our uh text into its own module. 这就是 templates.py 将我们的 uh 文本分离到它自己的模块中。