WEBVTT

00:00.200 --> 00:05.760
Well, it seems almost impossible to believe this, but somehow, somehow I do believe this is day five

00:05.760 --> 00:06.720
of week six.

00:06.760 --> 00:09.920
This is the finale, the conclusion, the ending.

00:10.160 --> 00:11.640
And it better be a good one.

00:11.640 --> 00:12.440
Let's see.

00:12.800 --> 00:13.640
This is it.

00:13.880 --> 00:18.280
Finally, coloring in the top right square on this enormous chart.

00:18.440 --> 00:24.880
And what we're doing today, of course, is nothing short of finishing our capstone project, Autonomous

00:24.920 --> 00:32.960
Alpha Agents, a commercial, a gigantic project which has different agents trading in a simulated trading

00:32.960 --> 00:33.880
environment.

00:34.160 --> 00:37.720
And, uh, wow, we've got a couple of details to add to the mix.

00:37.920 --> 00:39.640
We want to add push notifications.

00:39.680 --> 00:40.280
I mean, come on.

00:40.280 --> 00:42.360
We've been doing that the whole the whole course long.

00:42.520 --> 00:48.760
Of course, we want to have a push notification when a trading decision happens, when trades are made,

00:48.760 --> 00:50.080
we want to know about it.

00:50.320 --> 00:55.600
Uh, so we'll add that with a quick MCP server because why not the trading floor.

00:55.600 --> 00:58.360
We're going to bring in a bunch of, uh, traders to the mix.

00:58.360 --> 01:03.480
We're going to have three, but you could have as many as you want and giving it a bull for for Wall

01:03.480 --> 01:03.880
Street.

01:03.880 --> 01:04.240
There.

01:05.140 --> 01:11.700
We're going to add autonomy, just just with a couple of lines so that if agents wish, they can choose

01:11.700 --> 01:18.980
to evolve their trading strategy in whatever direction they want to, so that this really can be autonomous,

01:18.980 --> 01:21.820
because we don't want to necessarily fence them in.

01:21.820 --> 01:27.420
We want to give them an objective, but let them change their objective and see what they make of it.

01:28.020 --> 01:29.700
And we want to add more models.

01:29.700 --> 01:31.900
So we already laid the foundation for that.

01:31.940 --> 01:35.460
We'll throw deep Sikh into the mix because you know, why not?

01:36.180 --> 01:40.860
And we want to have a user interface because it's not much fun looking at command line stuff when we've

01:40.860 --> 01:42.220
got a whole trading floor.

01:42.900 --> 01:43.700
All right.

01:44.220 --> 01:46.140
With that, are you ready?

01:46.260 --> 01:48.860
Let's go for our very last lab.

01:48.900 --> 01:53.100
And for the final time, we get to cursor for the week six folder.

01:53.220 --> 01:57.620
And I would say that I'm sad that it's the last time that we'll be here, but I'm not, because it's

01:57.620 --> 01:59.700
not going to be the last time I'm here for sure.

01:59.700 --> 02:02.500
I'm going to keep working on these projects, as I'm sure you'll see.

02:02.500 --> 02:07.020
You'll see all the extra things that I've done to it since I record this video, and I'm hoping that

02:07.020 --> 02:08.400
you will, too.

02:08.680 --> 02:11.360
There's there's so much opportunity to extend this.

02:11.360 --> 02:15.720
And I'm hoping that you'll make changes, put them in the community contributions folders that I'll

02:15.720 --> 02:21.640
leave around and send a submit a PR so that I can bring it into the repo and share it with everyone

02:21.640 --> 02:22.680
else taking the course.

02:22.720 --> 02:25.800
In my other course, there's been hundreds of contributions.

02:25.800 --> 02:28.000
I've been blown away, and they've been really cool.

02:28.000 --> 02:34.080
There's been some super innovative things, but but there was nothing like the power that we have right

02:34.080 --> 02:36.560
now with with all of the functionality in this repo.

02:36.560 --> 02:40.480
So I'm hoping that that, that we'll take it even further together.

02:40.480 --> 02:42.520
And you should look for the changes that I make.

02:42.920 --> 02:50.080
Anyway, going into the sixth folder one more time into lab five, this is our final lab, and it's

02:50.080 --> 02:53.280
quite a short one because most of our changes are to Python modules.

02:53.320 --> 02:57.960
Now it's the grand finale of our autonomous Alpha agents projects.

02:58.280 --> 03:01.600
Uh, and uh, we're going to be adding some more MCP servers.

03:01.600 --> 03:05.000
We're going to be adding a user interface and adding the trading floor.

03:05.360 --> 03:09.400
And I've also added a utility that I'll show you called Reset Traders.

03:09.400 --> 03:14.580
That puts all of the traders back to the beginning should you want to, to reset the state of affairs.

03:14.580 --> 03:18.580
So to quickly show you the reset traders thing, it's right here.

03:18.580 --> 03:20.620
The Reset Traders is perfectly simple.

03:20.820 --> 03:24.580
It sets a beginning strategy for Alice, Bob and Carol.

03:24.860 --> 03:29.900
Alice is an aggressive day trader that buys and sells regularly to maximize profits.

03:30.140 --> 03:36.380
Bob looks for long term value, looks for companies that are undervalued and have a strong fundamentals

03:36.420 --> 03:37.780
or strong business model.

03:38.220 --> 03:45.500
And Carol is a technical investor that looks for technical indicators to find trading opportunities

03:45.500 --> 03:47.300
and uses them to do so.

03:47.420 --> 03:53.780
So those are three stereotypical trading thesis trading strategies that these three have.

03:54.060 --> 03:55.580
And that is the starting position.

03:55.580 --> 03:58.060
You can see that Reset traders calls.

03:58.140 --> 04:01.100
It just uses the standard account code.

04:01.100 --> 04:07.540
There's no no MCP servers here since we'll only use it once it calls account get for each of these three

04:07.700 --> 04:08.740
and it resets them.

04:08.740 --> 04:14.820
And that means in our database accounts DB in our SQLite database they will all be restored.

04:14.820 --> 04:17.960
And let me show you where I made a couple of other changes.

04:17.960 --> 04:19.880
So one of them is that traders.

04:19.880 --> 04:26.320
So now they have this ability to change their own strategy, to decide to go in a different course.

04:26.320 --> 04:31.240
The strategy is associated with the account because you could have multiple accounts of different strategies.

04:31.240 --> 04:32.760
So that's that's where I put it.

04:32.760 --> 04:34.600
So it's a field on the account.

04:34.600 --> 04:40.760
So if we if we go to accounts dot pi you'll see that uh strategy is is one of the fields.

04:40.760 --> 04:42.520
That's, that's part of an account.

04:42.560 --> 04:44.040
An account has a strategy.

04:44.320 --> 04:48.000
And if we go down to the end, you'll see that you can both get the strategy.

04:48.000 --> 04:51.200
And you can also change the strategy at your discretion.

04:51.200 --> 04:55.480
If you choose to call this to change your investment strategy for the future.

04:55.920 --> 05:04.400
And if we go into our MCP server accounts server, you'll see that there is a new service here, uh,

05:04.560 --> 05:11.920
change strategy, a new MCP tool called Change Strategy, which says at your discretion, if you choose

05:11.920 --> 05:17.200
to call this to change your investment strategy for the future, I see it's rather ugly.

05:17.200 --> 05:22.550
I put that in between buy and sell, which is not very nice layout, so I will just move it down here

05:22.550 --> 05:24.070
and hopefully won't break anything.

05:25.270 --> 05:28.750
And the old rule that anytime you change anything, you're likely to break something.

05:28.750 --> 05:31.150
But I don't think that is a harmless change.

05:31.190 --> 05:31.910
Buy shares.

05:31.950 --> 05:32.830
Sell shares.

05:32.870 --> 05:39.470
And then change strategy which of course calls account get name change strategy.

05:39.670 --> 05:41.550
And that would immediately expose it.

05:41.590 --> 05:47.030
This will just just just because we've got this this here with this decorator, it will instantly be

05:47.030 --> 05:49.750
available to our agents to call it whenever they want.

05:49.790 --> 05:54.430
And while our trader has access to those account tools and so can change it whenever they want.

05:54.470 --> 06:02.190
I did also add in a little hint to try and encourage that behaviour, should it wish to in the rebalance

06:02.430 --> 06:03.150
prompt.

06:03.390 --> 06:06.950
You can think of this like a crude air task in this task.

06:07.190 --> 06:10.430
I've I've included in with this.

06:10.790 --> 06:15.230
Um, you also have a tool to change your strategy if you wish.

06:15.350 --> 06:20.430
You can decide at any time that you would like to evolve or even switch your strategy.

06:20.790 --> 06:25.130
I put that right after saying what the strategy is so it can choose to do that.

06:25.370 --> 06:32.290
And, uh, I've, uh, um, made sure that that that also gets reflected in the, in the system prompt

06:32.290 --> 06:36.850
as well, that it mentions that you can change your strategy if you wish.

06:37.970 --> 06:39.690
Um, okay.

06:40.170 --> 06:44.930
So with that, the next thing I want to show you is the push notification.

06:45.330 --> 06:47.930
So the push notification is pretty simple.

06:47.930 --> 06:52.530
And I want to show it to you because I want to show how quick and easy it is to put something through

06:52.530 --> 06:54.930
as a new as a new MPP server.

06:54.970 --> 06:57.610
Obviously it's super quick to put something in as a tool as well.

06:57.610 --> 07:02.250
But the great thing about this is that once we put it there, anyone that uses our server would be able

07:02.250 --> 07:04.290
to have access to this functionality too.

07:04.330 --> 07:10.890
And this is an example of one where it's just in one Python server file, both the business logic and

07:10.890 --> 07:13.370
the MCP server, because it's pretty simple.

07:13.610 --> 07:14.530
Uh, this is it.

07:14.810 --> 07:21.290
Uh, there's the this is the usual constants to to get the token and the user id and the, the URL we

07:21.290 --> 07:22.850
import fast MCP.

07:23.290 --> 07:26.270
We say MCP is fast MCP push server.

07:26.710 --> 07:29.310
And then this is the method.

07:29.310 --> 07:36.430
This is the the MCP server itself with the with the with the decorator to say that this is an MCP tool.

07:36.710 --> 07:38.470
And then here it is push.

07:38.670 --> 07:40.750
And as always it's just requests.

07:40.750 --> 07:45.310
Dot push pushes to the URL and pushes the message.

07:45.590 --> 07:50.070
And the one thing I've done here, which is consistent with the way that we did it, if you remember,

07:50.070 --> 07:57.790
with with one of the prior examples, is that we've got a pedantic definition of the arguments.

07:57.910 --> 08:01.590
So this is says that the arguments that come in are called push model args.

08:01.750 --> 08:04.470
And here I've made a pedantic subclass.

08:04.470 --> 08:09.430
And that's given me the opportunity to say that the field is a brief message to push.

08:09.430 --> 08:10.550
And this is a best practice.

08:10.550 --> 08:14.910
That means that we that we clearly explain the purpose of every field.

08:14.950 --> 08:17.950
I didn't do that in the in the prior example.

08:17.950 --> 08:23.030
I just I just left it to the to the docstring, to the description to cover everything that's being

08:23.030 --> 08:23.630
passed in.

08:23.630 --> 08:27.990
And that typically seems to work fine, but this is the very thorough way to do it that you, that you

08:28.070 --> 08:29.730
probably should do in all cases.

08:30.290 --> 08:32.450
So that's another good example for you.

08:32.450 --> 08:34.690
But this is all it is just doing this.

08:34.690 --> 08:36.850
And we've got ourselves another MCP server.

08:36.850 --> 08:44.170
And so if we now go into the traders you'll see that I just added that to the list of MCP servers.

08:45.450 --> 08:48.370
Let's find that where are the MCP servers are right up at the top.

08:48.410 --> 08:49.330
And here it is.

08:49.490 --> 08:51.010
I've given it to the trader.

08:51.010 --> 08:56.650
And you'll see in the instructions that I ask the trader to send a push notification with its trading

08:56.650 --> 08:57.450
decisions.

08:57.810 --> 09:01.490
Uh, as you would expect, the other I made a few other small things.

09:01.490 --> 09:02.370
I've been playing with it.

09:02.370 --> 09:07.410
I stopped the traders from having access to the memory because they didn't seem to be using it, and

09:07.410 --> 09:08.690
it made it too complicated.

09:08.690 --> 09:13.970
And I gave it to the researcher, and I doubled down on telling the researcher in the instructions to

09:14.010 --> 09:20.770
be taking advantage of the, uh, knowledge graph, to store and recall information and to retrieve

09:20.770 --> 09:22.810
information you worked on previously.

09:22.970 --> 09:26.650
And I will see how that how that works and whether that builds up knowledge over time.

09:26.650 --> 09:28.650
And this is something that I might well experiment with.

09:28.650 --> 09:34.090
So when you look at this, the prompts may look different because it's constantly subject to experimentation.
