WEBVTT

00:00.120 --> 00:03.440
Well, we are now on the final home stretch.

00:03.440 --> 00:07.960
This is the penultimate episode, the penultimate lesson.

00:08.280 --> 00:15.840
It is week six, day four, the beginning, the beginning of our capstone project.

00:15.840 --> 00:18.480
Although really we've been doing the capstone project all week.

00:18.480 --> 00:26.320
But this is the conclusion of the project, a a project which is going to bring together OpenAI agents

00:26.320 --> 00:36.200
SDK and MCP into a commercial project that I'm calling autonomous Alpha agents, because this is a project

00:36.200 --> 00:40.000
applied to financial markets, as you have no doubt guessed.

00:40.200 --> 00:45.360
And the idea is that in this project, we're going to do something that is commercial.

00:45.360 --> 00:49.320
It is first and foremost going to be something that we can apply in business.

00:49.640 --> 00:54.920
And most of our projects so far have been somewhat generic in that there have been things like a sidekick,

00:55.240 --> 00:57.840
uh, and something that builds code.

00:57.920 --> 01:03.920
And I wanted to do something which could apply to a business vertical and use some kind of a setup that

01:03.920 --> 01:07.120
you could imagine applying to many other business verticals.

01:07.240 --> 01:14.040
And so we're applying it to financial markets, and we'll be trying to build something that is exciting

01:14.040 --> 01:18.800
from a commercial business point of view, as well as from a technical agents point of view.

01:19.200 --> 01:25.080
There's going to be five different MCP servers that we'll be using, uh, with tools and resources from

01:25.080 --> 01:25.440
them.

01:25.640 --> 01:28.120
There's going to be interactions between agents.

01:28.120 --> 01:31.400
Of course, it's going to be fully autonomous.

01:31.400 --> 01:33.000
You wouldn't have it any other way.

01:33.360 --> 01:38.760
And I need to tell you, do not under any condition, under any circumstances, use this for your own

01:38.760 --> 01:40.440
trading decisions.

01:40.440 --> 01:47.040
This is educational and for learning and applying agents to understanding how to use them for business,

01:47.040 --> 01:50.040
but not actually to use them for trading decisions.

01:50.400 --> 01:55.880
And now for our capstone project we go to the week six folder.

01:55.880 --> 01:58.570
We go to lab number four for.

01:58.970 --> 02:04.490
And welcome to the lab introducing you to our project Autonomous Alpha agents.

02:04.730 --> 02:06.450
Our equity simulator.

02:06.730 --> 02:09.290
And let me tell you all about what we're going to do.

02:09.330 --> 02:15.370
We're going to build an equity trading simulation with three traders and a researcher agent, powered

02:15.370 --> 02:19.850
by an army of MCP servers with tools and resources.

02:19.970 --> 02:21.090
There's five of them.

02:21.330 --> 02:28.890
The homemade accounts, MCP server that we built based on the work of our own engineering team of agents

02:28.890 --> 02:29.810
from week three.

02:30.290 --> 02:31.010
Fetch.

02:31.450 --> 02:35.690
We're using to get web pages via a headless browser that will be running locally.

02:35.890 --> 02:37.250
Memory will use.

02:37.250 --> 02:42.570
In case our agents or traders wish to save their thoughts, they'll be able to share them too.

02:42.610 --> 02:47.970
So this will allow our trading floor to have a kind of shared memory state as they learn about markets,

02:48.810 --> 02:55.450
search via the brave API and then financial data, either the free version or the paid version.

02:55.450 --> 02:58.770
If you wish to Were entertain yourself as I have done.

02:58.770 --> 02:59.890
It's great fun.

03:00.130 --> 03:05.650
I say it's worth 20 bucks, but I realize that everyone's appetite for this will be different.

03:05.930 --> 03:15.490
Um, so look, the goal of today's part of the capstone project is to build a Python module, and that

03:15.490 --> 03:22.050
Python module will be called traders and will contain a trader class, which will be an independent

03:22.050 --> 03:23.370
autonomous agent.

03:23.970 --> 03:29.730
But the way I like to do this is I like to start in a lab in a notebook, because you can iterate over

03:29.730 --> 03:32.610
things and explore and work on it there.

03:32.770 --> 03:38.530
And then over time, we will migrate to a Python module when we're ready to do so.

03:38.690 --> 03:40.970
That is the that's how I like to work.

03:40.970 --> 03:44.090
And so we'll start in the lab and then move to the module in a bit.

03:44.370 --> 03:50.890
But of course I have to mention one more time yet again this warning that you should not use this for

03:50.890 --> 03:53.970
actual trading decisions, just in case I haven't said that enough.

03:54.010 --> 03:55.450
If you're fed up of me saying it.

03:55.810 --> 03:59.890
All right, so there's a bunch of imports to get us started.

03:59.970 --> 04:01.210
You'd expect nothing less.

04:01.410 --> 04:03.010
And a load dot env.

04:03.250 --> 04:09.890
And now the first stage is to gather all of the parameters for our MCP servers.

04:09.890 --> 04:16.130
So we've defined each of our MCP servers as we've gone with one of these, these dictionaries that store

04:16.130 --> 04:18.930
the parameters for how you launch that server.

04:18.930 --> 04:21.050
And now we're going to gather them all together.

04:21.050 --> 04:26.850
So we're starting with a group called the Trader Server Parameters, which is going to have our account

04:26.850 --> 04:34.810
server where we look up account details and then the server memory where it can maintain its memory.

04:35.170 --> 04:40.770
Uh, and we put that into we also want to have a trader tools that we're going to have as an empty list

04:40.770 --> 04:41.530
to start with.

04:41.890 --> 04:43.650
And then here we've got we've got a choice.

04:43.650 --> 04:48.810
It depends on whether you are using the paid financial services approach.

04:48.970 --> 04:56.090
If so, then we're going to add another MCP server which is the paid financial services with the directory

04:56.130 --> 04:58.690
set to this directory here that you should.

04:58.730 --> 05:02.930
Overwrite with the directory that you're using if you're using the paid.

05:02.970 --> 05:05.210
Financial services API.

05:05.410 --> 05:08.730
If you're using the free one, then we need to get the tools.

05:09.130 --> 05:14.610
From the MCP server using open AI and sorry converting it to open AI tools.

05:14.650 --> 05:18.410
Using the client that I wrote, um, and I might replace that.

05:18.410 --> 05:22.010
You may see the code here might be tidied up if I am able to get it to work.

05:22.010 --> 05:26.530
Just using the the open ai mcp client.

05:27.090 --> 05:27.530
Okay.

05:27.570 --> 05:33.090
So with that we will we will collect together these MCP servers and we will collect them together here

05:33.090 --> 05:33.930
the parameters.

05:34.330 --> 05:38.050
And we will collect one a couple more for the researcher.

05:38.050 --> 05:39.610
We're going to collect fetch.

05:39.890 --> 05:42.370
And we're going to collect the brave search.

05:42.490 --> 05:49.170
So fetch you'll remember that's the one that is going to sort of spawn a headless browser on our computer

05:49.170 --> 05:53.930
that we won't see, but it's going to happen behind the scenes and using playwright, and it will use

05:54.060 --> 05:58.740
that to search the web and bring in web pages and and retrieve their contents.

05:59.060 --> 06:01.700
But the more powerful one is brave.

06:01.740 --> 06:07.900
Brave is where it will call out to the brave search engine, which will run a search and bring back

06:07.900 --> 06:10.220
information relevant to that search.

06:10.500 --> 06:16.460
So these are the two tools, just a web query and a web search, or a fetch and a search.

06:16.740 --> 06:18.740
So let's bring them in as well.

06:18.780 --> 06:21.900
And now we have gathered all of our parameters.

06:21.940 --> 06:22.220
Okay.

06:22.260 --> 06:26.340
Next up we want to actually create the MCP server studio.

06:26.380 --> 06:29.940
The standard input output for each one of our params.

06:30.140 --> 06:33.740
So what we're going to do is we're going to have a list of like let's start with the researcher.

06:33.780 --> 06:35.300
So we're going to have a researcher.

06:37.340 --> 06:39.540
I hate it when cursor fills it all in.

06:39.540 --> 06:41.020
For me that's going to take away the fun.

06:41.180 --> 06:43.340
The researcher MCP servers.

06:43.580 --> 06:46.540
The MCP servers for the researcher is going to be.

06:47.100 --> 06:48.500
And it's got it wrong which is nice.

06:48.540 --> 06:58.380
MCP server standard input Output, um, that we're going to want to create given the params.

06:58.540 --> 06:59.700
And it's got it all right.

06:59.700 --> 07:01.980
Now it's given the parameters.

07:01.980 --> 07:04.620
And we're going to set the cache tools list to true.

07:04.660 --> 07:10.420
We do want to cache them so it doesn't have to create them every time for the parameters in this set

07:10.460 --> 07:10.980
here.

07:10.980 --> 07:13.740
And then we just want to repeat this basically a second time.

07:13.740 --> 07:17.420
But this time we want it to be for the trader parameters.

07:18.020 --> 07:27.140
Um, for those we're going to want to come up with a trader MCP server.

07:27.140 --> 07:34.300
So now we're creating a trader MCP server for every set of parameters in the trader MCP server parameters.

07:34.340 --> 07:34.860
You see what I mean?

07:34.860 --> 07:38.460
We're just iterating through these sets of parameters and creating the servers.

07:38.500 --> 07:38.980
All right.

07:39.020 --> 07:41.660
And then we will just say MCP servers.

07:41.700 --> 07:42.980
Is those two added together.

07:42.980 --> 07:45.420
Those two lists together make all of our servers.

07:45.420 --> 07:52.220
So now we have created our MCP server Stdio for all of these.
