HomeVideos

Polymarket Stop Loss, Order Book, Order Flow, Order Types & Maker vs Taker

Now Playing

Polymarket Stop Loss, Order Book, Order Flow, Order Types & Maker vs Taker

Transcript

501 segments

0:00

All right. So in this video I will be

0:02

talking about everything related to

0:05

orders on poly market. So I will be

0:07

talking about the order book and I will

0:11

be talking about the spread. I will be

0:12

talking about what is a tick size. I

0:14

will also be talking about stop- losses,

0:16

take profits. I'll be talking about what

0:18

is a mega, what is a taker and generally

0:21

just digging deep into that. So I hope

0:23

you will stick around. This is really

0:24

important information. And I've really

0:26

been researching this for a while now.

0:28

And now I'm going to do a brain dump on

0:30

you so you get a better understanding of

0:32

this. And this will actually enable you

0:34

to perform better with your trading. But

0:36

because it's important to understand

0:38

what happens when you place a trade, how

0:40

can you handle your trades? How can you

0:42

monitor your trades? How can you limit

0:44

risk exposure by implementing uh stop-

0:47

losses and take profits? Because as you

0:49

probably know, Poly Market does not

0:51

support stop- losses. So, it's something

0:53

we have to implement in our bot by

0:55

ourself. And I have an implementation of

0:57

that that I will show you how it works.

0:59

It might not be perfect yet, but as we

1:02

go along, I will improve it and make it

1:04

very robust when Raven is ready to

1:07

launch. So, let's get started. To

1:10

understand stop-losses and take profit,

1:13

we need to understand the order book.

1:14

So, I have uh this market here. The US

1:18

government shutdown Saturday and we have

1:20

the order book. Okay. So the order book

1:23

represents basically everybody all the

1:26

traders that are placing trades. This is

1:29

what you see here is resting orders on

1:32

the order book. The ask side is people

1:35

that are willing to sell which is

1:39

indicated by red and the bit side is

1:41

people willing to buy. So that's on the

1:44

buying side. And then you have a spread

1:47

which is the difference between the asks

1:49

and the bits.

1:51

And this also ties in a little bit with

1:54

what we talked about in the previous

1:55

video about what is a maker and what is

1:57

a taker. So I will be explaining that as

2:00

well because if you remember we have the

2:02

mega rebates program. So you are

2:04

actually able to earn money by becoming

2:08

a maker. And if you are what we define

2:11

as a taker you actually pay money you

2:14

pay trading fees. And this is

2:16

specifically for the 15minute crypto

2:18

markets because these are going crazy.

2:21

But we might actually have these fees

2:23

coming onto other markets that are very

2:25

liquid. So it's important to understand

2:27

well what is a mega and what is a taker.

2:30

So I'm going to try my best to explain

2:32

what that is. There's some confusion

2:34

about what is a mega and what is a

2:36

taker. Some people think that the megas

2:39

is someone that sells and the tears is

2:42

someone that buys because that's kind of

2:43

what your intuition would say, but

2:45

that's actually not what what it is. So

2:48

a mega or taker is defined as who

2:51

provides and who takes liquidity. To

2:54

provide liquidity to a market, you would

2:58

have to place what we call a resting

3:01

order on the order book. So if you let's

3:04

say you place a let's say you want to

3:08

sell but you want to sell as a mega

3:12

what you would have to do is you would

3:13

have to place a order to sell your

3:18

shares

3:19

at 45 not crossing

3:24

the bit not crossing a spread. So you

3:26

can actually place you can see there's a

3:27

spread now of 1 cent.

3:30

So if you play if you place a sell

3:32

order, let's say 45.5,

3:36

you did not cross the spread over to the

3:39

bit side, meaning that it's actually a

3:41

maker order. However, if you place a

3:43

order of let's say 44 to sell at 44,

3:48

that would be a taker. You are removing

3:51

liquidity because you have resting

3:53

orders that has provided liquid

3:55

liquidity

3:57

and um and it would actually be

4:00

taken right away by the people that are

4:04

buying. So the spread is the difference

4:07

between the best asks and the best bits.

4:11

So there's also something called a tick

4:13

size. So the tick size is basically how

4:15

you know how much you can increment your

4:17

prices with. Let's say you have a tick

4:19

size of 0.1. That means you can place um

4:22

you know orders at 45.1, 45.2 and so on

4:26

and so forth. So let's say the tick

4:28

price is 0.1. Then you could place a

4:31

mega order on the ask side at 45.9 and

4:35

it would it will still be a mega order.

4:40

And the same goes for the bit side.

4:42

Let's say that you want to buy as a

4:46

taker. That means you would have to take

4:48

liquidity from the ask side. You would

4:50

have to place a buy order at 45. So that

4:54

means place a order at the best ask then

4:58

you would be almost guaranteed that your

5:01

order would be filled right away unless

5:03

the market moves away from you which

5:05

actually happened for me a few times and

5:07

I'm I'm going to show you exactly what

5:09

happened there. So in that case you

5:11

would become at a at taker. If you want

5:12

to be a mega as a buyer you would have

5:15

to place your buyer orders within the

5:18

spread not crossing over to ask. You

5:20

could do it at 44. You could do it at

5:23

45, 44.5, 44.6 and so on depending on

5:27

the tick size. The text size we can get

5:30

from the API, but I'm not going to show

5:33

this in this video. So if we look at

5:35

this examples of a buyer limit buy below

5:40

best ask, it rests on the order book and

5:43

then it becomes a mega. If you do a

5:45

limit buy at or above the best ask, it

5:48

then fails and you become a taker. And

5:50

if you do it on the cell examples, a

5:53

limit cell above best bit, then it rests

5:56

and you are maker limit cell at or below

6:00

best bit, it fills and then you are

6:01

taker. I hope that makes sense. It all

6:04

depends on if you are crossing the

6:06

spread over to the other side. That's

6:08

what defines if you're mega or a taker.

6:10

And this is kind of I mean it's not this

6:12

is very important when you are

6:14

implementing your stop-loss and take

6:17

profit which is very relevant when doing

6:19

trading bots. So when implementing a

6:22

stop-loss we also want to understand the

6:24

different order types. So if we look at

6:27

poly markets documentation there's

6:29

different order types. You have an order

6:30

type called fill or kill order which is

6:33

a market order to buy in dollars or sell

6:38

in shares.

6:40

shares that must be executed immediately

6:43

in its entirety otherwise the entire

6:46

order will be cancelled. Now we have to

6:49

keep in mind here poly market doesn't

6:52

have market orders. So the definition

6:54

here of a market order is what we also

6:58

could call a taker order. So it's a

7:01

order you place on the best bit or as

7:04

depending on if you are a seller or

7:06

buyer. So if you want to do a market

7:08

order as a buyer, then you would have to

7:11

look at the order book. You would have

7:12

to say, okay, as a buyer, I need to

7:15

cross the spread over to the ask side.

7:17

What is the best ask? It's 46.

7:20

So if you place a order to buy at 46,

7:25

you could be almost guaranteed that they

7:28

fill if there's enough liquidity. So in

7:32

this case, let's say that I place an

7:35

order to buy at 46,

7:38

let's say 6,000 shares. The order would

7:41

be cancelled if it's a fill or kill

7:44

because it has to be executed first of

7:47

all immediately and also in its entirety

7:50

otherwise the entire order will be

7:52

cancelled. So if there's not enough

7:54

liquidity, if it's if there's not enough

7:56

shares, it's going to be cancelled. But

7:58

there's another one that we call or that

8:00

they call fill and kill order which is a

8:04

similar order. It's a market order to

8:05

buy in dollars or sell in shares that

8:10

will be executed

8:12

immediately for as many shares as are

8:14

available.

8:16

Any portion not filled at once is

8:18

canled.

8:20

So I actually haven't tried this one uh

8:22

myself. I have tried to fill or kill but

8:24

the way I understand this one is that

8:27

let's say that you place a buy order

8:31

at let's say now it's 6,000 let's say

8:33

you place it at 7,000

8:35

at 46 then you would get these 6 thou 6

8:38

6,100

8:41

but then the remaining shares you will

8:44

not get

8:46

and the same goes if you are selling

8:48

let's say that you are selling

8:51

um and there was Now there's 300,

8:53

there's 500. Let's say there's 500

8:56

liquidity and you sell a,000. You're

8:58

trying to sell a,000 at at 45. Then you

9:01

would sell the 561, but the remaining

9:05

400 something you would not sell. So

9:09

this is a very big distinction between

9:12

these two and it's important to

9:14

understand if you're going to implement,

9:16

you know, stop losses because let's say

9:19

that you place a stop-loss. Let's say

9:20

you place a a limit order to sell right

9:23

away because your position has moved

9:25

against you, but it's actually not

9:27

filled.

9:29

You know, what are you going to do? You

9:30

have to have some kind of monitoring in

9:32

place. And I'm also going to explain how

9:34

I have implemented that into Raven.

9:38

You also have good till cancelled. So a

9:40

good to can good till order is a limit

9:43

order that is active until it's

9:45

fulfillled.

9:47

So it kind of you know it's pretty

9:48

typical. you place an order. Let's say

9:50

you place an order here at 45 or 44.

9:54

It's going to just going to stay there

9:55

until it's filled and not do anything.

9:58

And then we have the good till date.

10:00

Order is a type of order that is active

10:02

until it's until it's specified date UTC

10:07

seconds timestamp

10:09

unless it has been fulfilled or

10:12

cancelled.

10:14

There's a security threshold of 1

10:16

minute. If the order needs to expire in

10:18

90 seconds, the correct expiration value

10:21

is now plus 1 minute plus 30 seconds. I

10:26

don't really understand what they mean

10:28

about this. So, there's a security

10:31

threshold of 1 minute. If the order

10:33

needs to expire in 90 seconds, the

10:35

correct expiration value is now plus 1

10:38

minute

10:40

plus 30 seconds. If you if you know what

10:43

they mean about this, leave a comment

10:44

down below because I don't really

10:45

understand what they mean here, but

10:47

that's okay. But I mean, it it kind of

10:49

makes sense. They're good till date. So,

10:51

you want to place a limit order. You

10:53

only want to have that, let's say, in 2

10:54

minutes or 3 minutes. After that, it's

10:56

going to expire. So, when you place an

10:58

order, it goes through different order

11:00

life cycle on Poly Market. You have

11:03

different statuses. And this is taken

11:04

from the documentation. But however

11:06

there's actually more statuses than this

11:09

that I have experienced when doing uh

11:11

trades but I'm going to go through

11:13

these. So we have the status that's

11:15

called match. So you place an order on

11:17

poly market you know it might be resting

11:20

on the order book. So nothing really

11:23

happens before something happens sort of

11:25

saying so when it's matched it means

11:27

that a trade has been matched and sent

11:29

to the executor service by the operator.

11:32

The executor service submits the trade

11:34

as a transaction to the exchange

11:36

contract. So you have to understand Poly

11:38

Market runs on blockchain. So first of

11:41

all you place an order through their

11:44

API. It's it goes to their centralized

11:46

servers on AWS. Now they're looking for,

11:49

you know, traders, sellers or buyers on

11:52

the order book. When they find someone

11:54

matching your order,

11:56

they going it's then matched, right? And

11:58

then it's going to be sent to be mined

12:00

onto the blockchain. Okay. And this is

12:03

when the next status happens. So the

12:04

status is mined. So the trade is

12:07

observed to be mined onto the chain. No

12:09

finality threshold established.

12:12

So it is going to be mined on the

12:15

blockchain. Okay. But before that

12:17

actually happens, it's sort of not

12:19

final. Something can still happen. It

12:21

can still be cancelled. How that's going

12:23

to hap happen, I'm not really sure, but

12:25

it can. And then we have the confirmed

12:28

status. This is where the order is

12:30

terminal. So the trade has achieved

12:32

strong probabilistic finality and was

12:35

successful. So you know on the

12:37

blockchain when you put a transaction on

12:39

the blockchain there's certain

12:40

confirmations that need to happen on the

12:42

blockchain before it's final. And this

12:45

is kind of what they wait for. And when

12:46

you have a certain amount of

12:47

confirmations well then they know that

12:50

it's confirmed. It have a strong

12:52

probabilistic finality and then it's

12:54

done. Okay. So this is what you need to

12:56

look for. There's also retrying and

12:58

failed and this kind of you know that

13:00

makes sense. So if you place let's say

13:02

you make a system in your trading bot to

13:05

place a stop-loss you have to monitor

13:07

your your positions to check if it's

13:09

actually confirmed or not. And u and

13:12

this is very important. It's something

13:13

that I have been working on implementing

13:15

into Raven. So the flow that I have been

13:18

working on is when we do the placement

13:20

and this is actually a different status

13:23

that they don't have in uh in this

13:26

overview here. So the placement is

13:28

basically just you place an order on the

13:30

on the order book and that's it. It's

13:32

now it's waiting to get matched. So the

13:34

placement when that happens I listen for

13:38

the user events. when we get the

13:40

placement, that's when uh we place the

13:43

order into what I call the pending order

13:45

tracker. Okay? And the pending order

13:49

tracker then just monitors for these

13:53

statuses over here that I just showed

13:54

you. And then when we get the matched,

13:57

that's when we take the order from the

13:59

pending order tracker over to the

14:01

position track. And now we actually have

14:02

a live position that we need to monitor.

14:05

And this is also where I implement the

14:07

stop loss. So with the the position

14:09

tracker uh tracks the position but it

14:12

also tracks the stop-loss. Okay. And it

14:15

tracks the the the order life cycle from

14:18

match to update mind confirmed and so

14:20

on.

14:22

And um so when it's confirmed you know

14:25

then we actually have an order live and

14:28

we need to monitor it. We need to track

14:30

it and that's when the stop loss is

14:33

actually activated. So I will just

14:37

quickly brief you on the position

14:40

monitor. We have different methods. So

14:41

for example, when we have the position

14:44

monitor, we have a start,

14:47

we have a start monitoring method that

14:49

basically just starts the the monitor,

14:52

right? And then we have a handle price

14:55

change. So the position monitor is

14:59

subscribing to certain events from the

15:02

event bus. Okay, so that's the events we

15:04

get from the user events. You can see

15:06

how it takes a processed event. If you

15:09

don't know what I'm talking about now,

15:10

watch some of my previous videos because

15:12

I've explained this in previous videos

15:14

and kind of explain the architecture of

15:16

this trading bot. And then you can see

15:18

here we have the check position P&L and

15:21

this again it just checks what is the

15:23

P&L of the position and we need this to

15:26

take profit. We need this to stop the

15:29

loss, stop loss, right? And then we

15:32

basically just checks this and uh we

15:33

have then a um a generate a generate

15:37

exit action over here. So we just check

15:41

if we have a stop loss and if that is

15:43

within the threshold that we are looking

15:45

for. We generate the exit action. Okay.

15:49

And that's then going to be published to

15:51

our executing layer. Currently I have

15:54

hardcoded the filler kill order type but

15:57

I will be changing this in Raven. So you

16:00

can choose how you want the bot to

16:02

behave, you know, fine grain things,

16:04

experiment and and stuff like that. But

16:06

for now, what I've done is to use the

16:09

fill or kill. And um I will show you

16:11

what happens in

16:15

here. So you can see here, this is a

16:18

real trade I did. So I've been doing

16:20

real trades, you know, not actually to

16:22

try to make money, but just to see

16:25

how the stop-loss works that I've

16:27

implemented.

16:29

So what I do is I did a mega order

16:32

first. Doesn't really matter if it's a

16:34

mega or take in this case. So I buy five

16:36

at 0.55.

16:39

And then the position monitor monitors

16:43

the position and looks for the P&L. If

16:46

the P&L is less than the threshold, I

16:49

think this it was 10% in this case, it's

16:52

uh going to execute a sell order. And I

16:58

did the fill or kill. And uh what

17:00

actually happened was it got killed

17:03

because you can see here from the time

17:07

the order is placed

17:10

on poly market the market already moved

17:13

against it and this is the risk that we

17:15

need to uh think about. So it was

17:18

actually killed even though I placed the

17:20

order on the best bit. So placing it on

17:23

the best bit should have made it a

17:26

market order but since you know the

17:30

market move you can see how rapidly it

17:33

moved down in this case. I think at the

17:36

time there was just no um orders at that

17:40

time and then was simply just killed and

17:42

then my system then it didn't the system

17:45

then keeps monitoring if the if the

17:47

order go through or not and in this case

17:49

it was killed so it placed another one.

17:54

So it it did a filler kill number two

17:56

here at uh 0.4378 4378 and then it was

18:01

actually filled but but uh I think um

18:07

here it was like 10% already and then it

18:09

when it was uh when it was finally

18:11

filled the second time you know it was

18:13

like down 20% or something. Um so yeah

18:16

that was uh not the best trade. Um but

18:21

you know we live and we learn and so I'm

18:23

I'm I'm tweaking this as I go along. And

18:27

of course in Raven which is you know the

18:31

the framework that I'm working on we

18:33

will be able to set the uh the you know

18:37

the different metrics do you want to

18:38

fill or kill and so on and so forth. So

18:41

yeah if you haven't seen already you

18:44

probably have maybe I'm building Raven

18:46

which is kind of still the project name

18:48

which is what I'm building here in

18:50

public. It's not just a trading bot I

18:52

built for myself, but it's actually a no

18:54

code strategy builder for prediction

18:56

markets. It's something that I'm

18:57

planning to release. And it's a, as I

19:00

said, it's a no code strategy build. You

19:01

can see how you can create these

19:03

different nodes and construct your own

19:06

strategy. So instead of spending, you

19:08

know, too long time on trying to build

19:11

a, you know, a Python bot from the

19:13

ground up, you will actually soon be

19:15

able to use this framework to build and

19:18

test uh your own strategies. Very easy,

19:21

very efficient. And uh now you can join

19:24

the weight list. So I'm still building

19:25

this. I'm building this in public on my

19:28

YouTube channel. So you can click here,

19:30

join the weight list, and then down here

19:32

you can provide your email. And if you

19:35

do that then you will actually be one of

19:37

the first in line to get access because

19:39

I will not be releasing this like you

19:42

know in a grand way. I'm just going to

19:44

be doing it um you know gradually first

19:46

take like you know maybe 10 people then

19:49

20 people then maybe 100 people and so

19:51

on so forth. So if you're on the early

19:53

access you will be getting access

19:55

earlier than everybody else. We also

19:58

have uh Poly Traders which is a free

20:00

discord community for prediction

20:02

markets. We have different channels such

20:05

as you know bot development. We have

20:07

strategy and data. We have predictions

20:10

crypto bite coding and we have a forum

20:13

where people there posting insights. So

20:16

it's a great way to uh meet other you

20:19

know traders, other builders, other

20:21

programmers and so on. And there's a lot

20:23

of nice alpha and insights in here. So I

20:27

really highly highly suggest you to join

20:29

it and it's free to join. Of course,

20:31

it's a free and open community for

20:33

everybody that's interested in

20:35

prediction markets, poly market,

20:37

calcium, and so on so forth. So, I've

20:39

made sure to leave links down below in

20:41

here in the description. You can find

20:43

the link to the weight list, and you can

20:46

find link to Discord. So, with that

20:48

said, I think it's all for now. I hope

20:50

it made sense. And if you have any

20:52

questions or if I said anything that was

20:54

not correct, please, you know, leave

20:56

your comment down below and uh let's

20:59

have a discussion. So, until next time,

21:01

see you and have a good one.

Interactive Summary

This video provides a comprehensive overview of orders on Poly Market, focusing on the order book, spread, tick size, stop-losses, and take-profits. It explains the concepts of 'maker' and 'taker' orders, clarifying that they are defined by providing or taking liquidity, respectively, rather than simply buying or selling. The video details different order types available on Poly Market, including Fill or Kill, Fill and Kill, Good Till Cancelled, and Good Till Date, and discusses their implications, particularly for implementing stop-loss orders, which are not natively supported by Poly Market and must be managed through bots. It also outlines the order lifecycle statuses on the blockchain (Matched, Mined, Confirmed) and the internal tracking system (Placement, Pending Order Tracker, Position Tracker) used in the Raven trading bot. Finally, it touches upon the development of the Raven no-code strategy builder and invites viewers to join the waitlist and the Poly Traders Discord community.

Suggested questions

5 ready-made prompts