WEBVTT

00:00.200 --> 00:03.520
And now we move on to our trader.

00:03.960 --> 00:08.360
So our trader we're going to give our trader a strategy.

00:08.360 --> 00:15.400
So that I'm going to name our traders by the standard cryptocurrency names that they give things beginning

00:15.400 --> 00:16.200
with A, B and C.

00:16.240 --> 00:20.200
So Alice is our first trader and uh, yeah.

00:20.200 --> 00:24.440
So, so, um, we begin by giving Alice a trading strategy.

00:24.480 --> 00:30.200
You are a day trader that aggressively buys and sells shares based on news and market conditions.

00:30.720 --> 00:34.360
And we're going to use account get Alice.

00:34.400 --> 00:41.880
And we're going to call a method reset on account that resets Alice's strategy to this strategy here.

00:41.880 --> 00:48.000
And it also takes her money to exactly 10,000 to a starting position.

00:48.000 --> 00:49.920
So this gets us to our starting point.

00:49.920 --> 00:52.120
And obviously we're calling the account code directly.

00:52.120 --> 00:55.120
There's no point in using an MCP tool for this.

00:55.120 --> 00:59.520
This is just us getting things ready, getting our environment prepared okay.

00:59.560 --> 01:02.880
And then once we've done that I will use MCP to show you.

01:02.920 --> 01:06.000
We will use it to call reading the resources.

01:06.000 --> 01:07.720
And there are actually two resources.

01:07.720 --> 01:14.440
There's one for looking at Alice's account, and there's one for looking at her investment strategy

01:14.440 --> 01:15.960
that we've hopefully just set.

01:16.000 --> 01:19.720
When we call these, it will be it'll be in the account codes.

01:19.720 --> 01:20.760
It will be in here.

01:21.080 --> 01:30.320
Uh, when we call reset, it's going to uh it's going to both um, uh, create Alice's, uh, account

01:30.320 --> 01:35.160
and set it up, but it's also going to then save it in into to the database.

01:35.160 --> 01:39.560
So if we look at the reset method right here, it sets the balance to the initial balance.

01:39.560 --> 01:46.000
That's the strategy to the strategy wipes out the holdings and the time series and then saves and save

01:46.040 --> 01:52.800
is going to save uh everything down to our SQL, our SQLite database.

01:53.320 --> 01:56.880
So let's run this and see if it all works.

01:58.240 --> 02:00.120
Well it did and it was very fast.

02:00.120 --> 02:07.400
So we've got a trader called Alice who's got 10,000 in the bank, no holdings, no transactions and

02:07.400 --> 02:09.160
a total portfolio value of 10,000.

02:09.200 --> 02:11.320
And that is Alice's investment strategy.

02:11.360 --> 02:14.040
A day trader aggressively buys and sells.

02:14.040 --> 02:16.080
So, so far, so good.

02:16.280 --> 02:19.520
And now time to create our trader agent.

02:19.680 --> 02:20.800
Okay, so this is it.

02:20.800 --> 02:23.280
This is the agent for for Alice.

02:23.480 --> 02:28.720
So the account details is that we are going to read that from the resource.

02:28.720 --> 02:29.640
Same for the strategy.

02:29.680 --> 02:31.320
We put together some instructions.

02:31.320 --> 02:32.440
The system prompt.

02:32.480 --> 02:35.160
You're a trader that manages a portfolio of shares.

02:35.200 --> 02:36.560
Your name is Alice.

02:36.600 --> 02:38.400
Your account is under the name Alice.

02:38.800 --> 02:44.520
You have access to tools to search the internet, to check stock prices, to buy and sell shares.

02:44.680 --> 02:50.720
Your investment strategy is this and your account holdings and balances this your tools.

02:50.720 --> 02:59.000
To do this, we should also say we should add in here you have tools to, uh, save.

03:00.050 --> 03:01.530
a memory.

03:03.610 --> 03:06.370
Of companies.

03:07.610 --> 03:12.290
Research and thinking.

03:12.890 --> 03:14.010
So far.

03:14.170 --> 03:20.610
So we'll give Alice some knowledge of the fact that Alice has the the persistent tools as well.

03:20.850 --> 03:23.010
Use your tools to make decisions about the market.

03:23.010 --> 03:23.650
Investigate.

03:23.650 --> 03:27.930
Make your decision, make the trades and respond with a summary of your actions.

03:28.210 --> 03:29.010
That's great.

03:29.050 --> 03:31.890
Let's just see that printed out now with with the stuff in it.

03:31.930 --> 03:36.530
And what you'll see is that the current holdings and the balance have been written in there.

03:36.770 --> 03:41.370
And you'll see that the strategy is in here as well.

03:41.610 --> 03:42.610
There it is.

03:42.850 --> 03:45.490
So it's all clearly laid out.

03:45.770 --> 03:48.970
And now it's time for us to run our trader.

03:49.810 --> 03:54.850
So this here is going to connect with all of our servers.

03:54.850 --> 03:56.490
And actually we can just write that simply.

03:56.530 --> 04:02.650
We can make that for server in MCP servers await server connect.

04:02.650 --> 04:07.250
So that will just connect all of our servers so that they should all be ready to go.

04:08.330 --> 04:15.890
And we will now call the to get the researcher tool passing in the researcher servers.

04:16.530 --> 04:23.410
And then we are going to create a trader called called called Alice.

04:23.970 --> 04:28.050
Going to pass in that system prompt those instructions for the tools.

04:28.050 --> 04:35.770
We're going to pass in the trader tools, which is either an empty list or it's a list of the free tools

04:35.770 --> 04:36.730
for market.

04:36.770 --> 04:39.130
If you if you're going with the free approach.

04:39.530 --> 04:42.490
And then we're going to add in our researcher tool right here.

04:42.770 --> 04:45.170
We're going to pass in our MCP servers.

04:45.410 --> 04:49.610
And we're going to then uh runner dot run.

04:49.610 --> 04:55.890
That is of course the way that we kick off the entire run, including delegating to the tool to call

04:55.890 --> 05:00.890
the researcher and putting all of the results back in the variable result.

05:00.930 --> 05:02.610
Okay, let's see what happens.

05:03.730 --> 05:04.650
Off it goes.

05:06.490 --> 05:07.970
It's going to think about that.

05:08.570 --> 05:11.090
While it's doing that I might just set.

05:11.130 --> 05:16.210
Maybe we should uh right after this we would want to print the, um.

05:16.250 --> 05:16.610
Oh, sorry.

05:16.610 --> 05:17.290
I've got that already.

05:17.290 --> 05:18.210
We're displaying it right here.

05:18.210 --> 05:23.890
Well, then maybe right afterwards we'll want to go and have a look at our, uh, at our, um, trace.

05:29.010 --> 05:34.650
I'll do that while it's thinking, which is a platform dot OpenAI.

05:39.530 --> 05:41.050
Okay, well, here we go.

05:41.090 --> 05:43.850
It completed, uh, market overview.

05:43.850 --> 05:49.010
The market is experiencing significant downturns, with major indices declining due to tariffs, uh,

05:49.290 --> 05:50.730
which is happening right now.

05:50.930 --> 05:52.850
Here are some stock price movements.

05:52.930 --> 05:55.050
And so it's made some trading activities.

05:55.050 --> 06:02.130
It claims that it has uh Purchased ten shares of Netflix tried to sell ten shares of Apple.

06:02.210 --> 06:03.410
Well, that seems a bit silly.

06:03.450 --> 06:08.570
It says it didn't hold any shares, so no doubt it's no surprise that it complained.

06:08.570 --> 06:10.050
Maybe it was trying to go short.

06:10.330 --> 06:13.930
Uh, maybe we should say that you're not allowed to sell shares you don't have.

06:14.210 --> 06:15.690
Um, and, um.

06:15.730 --> 06:16.290
There we go.

06:16.330 --> 06:18.450
Then this is the summary at the end.

06:18.810 --> 06:21.770
So let's, uh, first of all, see if we agree with that.

06:21.770 --> 06:24.490
Let's read the accounts resource and see what's happened.

06:24.650 --> 06:29.730
So it does indeed at this time hold ten Netflix shares.

06:29.730 --> 06:31.410
So the trading decision worked.

06:31.410 --> 06:34.970
It did buy ten shares of Netflix just as it thought it did.

06:35.330 --> 06:39.250
And those are the transactions that it's that it's made right there.

06:39.690 --> 06:46.370
And uh, it's got the rationale in here that it's written against that and the portfolio value and the

06:46.370 --> 06:53.090
trading loss, a tiny trading loss because of the trading fees, the the bid offer spread.

06:53.370 --> 06:54.810
Um, and so there we go.

06:54.850 --> 07:02.420
We've just seen a successful trading run decisions made and we've seen many MCP tools being used.

07:02.420 --> 07:05.180
It's used the tools to search the web.

07:05.180 --> 07:09.220
It's used the financial tools to look up share prices and financial news.

07:09.220 --> 07:13.100
And then it's used our tools to actually make the trade.

07:13.100 --> 07:16.900
So let's go and look at the trace now in OpenAI.

07:17.620 --> 07:19.180
So here it is Alice.

07:19.820 --> 07:20.700
Because we did that.

07:20.740 --> 07:22.420
The 13 different tools.

07:22.820 --> 07:23.980
Uh wow.

07:24.020 --> 07:25.220
Let's take a look at what happened.

07:25.220 --> 07:26.900
So there's a lot of lists that went on.

07:26.900 --> 07:32.060
So first of all the researcher was called the researcher, which was in there as a tool.

07:32.060 --> 07:33.740
It was collaborating as a tool.

07:33.940 --> 07:40.060
And the researcher also, of course, listed its tools, and it did a total of three brave searches.

07:40.340 --> 07:44.700
It looked for the current market top performing stocks.

07:44.700 --> 07:46.180
It did as that's great.

07:46.700 --> 07:50.180
Current Market Trends Stocks April 2025.

07:50.340 --> 07:55.980
So it did a bunch of of, uh, of web search queries to gather that information.

07:56.300 --> 08:02.020
Um, and you can see that it's it's definitely it's taking the brave search in favor of just trying

08:02.020 --> 08:04.180
to retrieve web pages itself.

08:04.540 --> 08:09.540
Um, and you can see there's we have to press load more to get more so we can see that.

08:09.540 --> 08:12.740
Then the trading agent went and got lots of stock prices.

08:12.780 --> 08:18.540
Amazon, Apple, Microsoft, Tesla, Google and Netflix.

08:18.540 --> 08:19.940
It got all of those.

08:20.180 --> 08:23.300
And then it decided to buy some shares.

08:23.300 --> 08:25.460
It bought Netflix shares.

08:25.500 --> 08:28.340
And then just as it said it tried to sell Apple.

08:28.340 --> 08:33.620
And it got the error back and it tried to sell Tesla and got the error back, and then it crafted its

08:33.620 --> 08:35.100
response back to us.

08:35.300 --> 08:39.300
So the trace is where we can go and see everything that happened.

08:39.340 --> 08:46.420
See all of the activities that our trader, uh, carried out and see it's sort of inner thoughts as

08:46.420 --> 08:47.180
it did it.

08:47.340 --> 08:53.460
And so this is a super useful to see what's going on behind the scenes and to confirm that our trader

08:53.460 --> 08:57.620
and researcher are collaborating and working exactly as we planned.
