1
00:00:00,280 --> 00:00:05,320
So first we take a look at some code and then we go and run our trading floor.

2
00:00:05,480 --> 00:00:10,240
So I wanted to point out that there are a few settings in the EMV file that you can control.

3
00:00:10,400 --> 00:00:13,640
You need to put these in there to make sure that things work properly.

4
00:00:13,840 --> 00:00:17,240
Run every N minutes just literally like that.

5
00:00:17,280 --> 00:00:22,320
Equals 60 will make sure that it that it runs every 60 minutes.

6
00:00:22,360 --> 00:00:25,600
Actually if you if you don't include it in your M file it will default to 60.

7
00:00:25,640 --> 00:00:32,920
Anyway, run even when market is closed, is how you can make sure that it doesn't start trading all

8
00:00:32,920 --> 00:00:35,160
night overnight every every hour.

9
00:00:35,560 --> 00:00:36,720
And now I currently have this.

10
00:00:36,720 --> 00:00:38,320
True because it is Sunday right now.

11
00:00:38,320 --> 00:00:42,160
And I want to I want it to be trading and use many models.

12
00:00:42,320 --> 00:00:45,080
If it's false, it just uses Gpt4 mini.

13
00:00:45,120 --> 00:00:49,680
If it's true, it uses the models that we just saw in the user interface.

14
00:00:49,720 --> 00:00:51,920
And so obviously I have it as true.

15
00:00:52,480 --> 00:00:53,120
All right.

16
00:00:53,160 --> 00:00:56,760
And now I need to show you the class that brings it all together.

17
00:00:56,760 --> 00:01:02,670
That is wonderfully simple and is a fitting conclusion to the other material that we've covered.

18
00:01:02,990 --> 00:01:07,510
So we collect the variables that I just mentioned from the env file.

19
00:01:07,510 --> 00:01:11,070
These are the names of our agents.

20
00:01:11,390 --> 00:01:14,470
And then we simply look how short this is.

21
00:01:14,670 --> 00:01:17,150
We create our traders.

22
00:01:17,390 --> 00:01:22,590
Uh, so we create a collection of traders for each of these different traders.

23
00:01:22,950 --> 00:01:27,710
And then here is the run every n minutes function.

24
00:01:27,710 --> 00:01:29,470
This is the one that that does everything.

25
00:01:29,470 --> 00:01:30,630
It all happens here.

26
00:01:30,790 --> 00:01:33,910
We start by adding this trace.

27
00:01:33,910 --> 00:01:42,230
This is where we register that we want OpenAI agents SDK to record any traces using that log tracer

28
00:01:42,230 --> 00:01:44,910
that I created that I showed you a moment ago.

29
00:01:45,270 --> 00:01:47,710
We then create our traders as done here.

30
00:01:48,030 --> 00:01:51,470
And then there's a nice little whiletrue, uh, thing here.

31
00:01:51,470 --> 00:01:52,870
So this will keep going forever.

32
00:01:53,190 --> 00:01:59,930
Um, it will then call async gather, which you remember means that all these async methods will happen

33
00:01:59,930 --> 00:02:00,970
at the same time.

34
00:02:01,290 --> 00:02:09,050
Trader run for each of our traders so all four traders will be kicked off at the same time, and async

35
00:02:09,050 --> 00:02:12,970
IO will make sure that they all run as if as if it's multithreaded.

36
00:02:12,970 --> 00:02:18,770
But of course, what's going on is that anytime one of them is is locked on, IO is waiting for something

37
00:02:18,770 --> 00:02:22,850
to come back, another one will run that will allow them all to run.

38
00:02:23,170 --> 00:02:30,530
Uh, and uh, at the end of that, it will then sleep for the number of minutes that we specify.

39
00:02:30,970 --> 00:02:34,690
And finally there's this if name is main.

40
00:02:34,690 --> 00:02:37,810
And that's where we kick off this whole thing.

41
00:02:38,250 --> 00:02:42,130
So all that remains now is for me to actually kick this off.

42
00:02:42,290 --> 00:02:43,210
Let's do it.

43
00:02:43,210 --> 00:02:46,210
And so the time has come now to launch our trading floor.

44
00:02:46,250 --> 00:02:51,970
See these agents in action and see in particular this while true loop running.

45
00:02:52,250 --> 00:02:54,890
So I'm going to bring up a terminal.

46
00:02:54,890 --> 00:02:56,520
This is our running user interface.

47
00:02:56,520 --> 00:02:59,240
I'm going to open a new terminal window to run.

48
00:02:59,240 --> 00:03:05,320
At the same time, I'm going to change to the sixth directory and I'm going to do you've run Trading

49
00:03:05,360 --> 00:03:07,240
Floor dot Pi.

50
00:03:07,280 --> 00:03:14,800
And this is now kicking off our agent process and running our various agents.

51
00:03:14,800 --> 00:03:18,000
So it's running for different traders and their researchers.

52
00:03:18,000 --> 00:03:25,680
And right away you can see I hope that the information in these panels has started flying by.

53
00:03:25,880 --> 00:03:31,960
And this of course is our user interface tracking the traces that we have intercepted and written ourselves

54
00:03:31,960 --> 00:03:34,040
so that we can be managing the logs.

55
00:03:34,040 --> 00:03:38,600
It's being stored to a database and and showing here visibly on the user interface.

56
00:03:38,600 --> 00:03:43,200
And it is terrific fun to watch this and see autonomy in action.

57
00:03:43,240 --> 00:03:47,400
You'll see the different colors representing things like calling different MCP servers actually using

58
00:03:47,440 --> 00:03:48,240
tools.

59
00:03:48,240 --> 00:03:54,580
The red when you see it is when it's actually calling our accounts business logic, our own home grown

60
00:03:54,580 --> 00:04:00,380
MCP server and that noise, if I don't know if it comes through on this mic, but it just made a notification

61
00:04:00,380 --> 00:04:06,380
noise that one of our four traders of Warren or George or Ray or Cathy just made a trading decision

62
00:04:06,380 --> 00:04:11,780
and I got alerted about it, and they will now be off and running.

63
00:04:11,820 --> 00:04:13,540
It typically takes them a few minutes.

64
00:04:13,900 --> 00:04:20,180
Uh, thanks to the joys of async coding, they can run in parallel like this as they do their thinking.

65
00:04:20,420 --> 00:04:25,780
They will go through managing their portfolio, and down below you can see things like their current

66
00:04:25,780 --> 00:04:27,740
holdings and their recent transactions.

67
00:04:27,740 --> 00:04:30,180
So you can keep keep stock on what they're doing.

68
00:04:30,340 --> 00:04:34,220
Uh, and uh, yeah, as I say, it's uh, it's it's terrific.

69
00:04:34,260 --> 00:04:35,820
Terrific fun to see this.

70
00:04:35,820 --> 00:04:36,220
Here we go.

71
00:04:36,220 --> 00:04:36,980
We can just see here.

72
00:04:37,020 --> 00:04:43,980
Sold five AMD shares, retrieving account details and then sold three Qualcomm and bought four Nvidia

73
00:04:44,020 --> 00:04:45,540
shares as Warren.

74
00:04:45,820 --> 00:04:47,420
Uh, they do tend to love Nvidia.

75
00:04:47,620 --> 00:04:53,930
Uh, so um, which must be something to do with the researcher and some other share activity going on,

76
00:04:54,130 --> 00:04:57,930
and an update there to our to the values of the portfolios.

77
00:04:57,970 --> 00:05:03,770
Oh, and another text message I just got, which is and another one which is trading going on AMD trade

78
00:05:03,770 --> 00:05:04,530
apparently.

79
00:05:04,690 --> 00:05:08,770
Uh, and yeah, as I say, this is super addictive.

80
00:05:09,050 --> 00:05:10,890
I absolutely love watching this.

81
00:05:11,170 --> 00:05:18,250
Obviously the learning point here is to really get this very visual, very real, tangible sense of

82
00:05:18,250 --> 00:05:26,090
what it's like to have multiple agents working, uh, calling other agents and using a bunch of different

83
00:05:26,090 --> 00:05:29,050
MCP servers to achieve a commercial objective.

84
00:05:29,250 --> 00:05:35,410
Uh, and being able to use this as a way of inspecting what's going on and understanding the LM activity

85
00:05:35,410 --> 00:05:40,410
that's happening behind the scenes to allow for this trading activity.

86
00:05:40,570 --> 00:05:46,610
So hopefully when you run this yourself and get this sense, uh, you'll find it, uh, highly, highly

87
00:05:46,610 --> 00:05:50,690
educational and insightful as well as being quite a lot of fun.