forked from Polymarket/real-time-data-client
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathquick-connection.ts
More file actions
86 lines (76 loc) · 2.38 KB
/
Copy pathquick-connection.ts
File metadata and controls
86 lines (76 loc) · 2.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
import { RealTimeDataClient } from "../src/client";
import { Message } from "../src/model";
const onMessage = (_: RealTimeDataClient, message: Message): void => {
console.log(
message.topic,
message.type,
message.timestamp,
message.connection_id,
message.payload,
);
};
const onConnect = (client: RealTimeDataClient): void => {
// Subscribe to a topic
client.subscribe({
subscriptions: [
// comments
{
topic: "comments",
type: "*", // "*"" can be used to connect to all the types of the topic
//filters: `{"parentEntityID":20200,"parentEntityType":"Event"}`,
},
// activity
{
topic: "activity",
type: "*",
//filters: `{"event_slug":"slug"}`, // filters: `{"market_slug":"slug"}
},
// crypto_prices
{
topic: "crypto_prices",
type: "*",
filters: "", // filters: `{"symbol":"btCUSDt"}`,
},
// crypto_prices_chainlink
{
topic: "crypto_prices_chainlink",
type: "*",
filters: "", // filters: `{"symbol":"eth/usd"}`,
},
// equity_prices
{
topic: "equity_prices",
type: "*",
filters: "", // filters: `{"symbol":"AAPL"}`,
},
// clob_market
{
topic: "clob_market",
type: "*",
// filters: `["71321045679252212594626385532706912750332728571942532289631379312455583992563"]`,
},
// clob_user
{
topic: "clob_user",
type: "*",
clob_auth: {
key: "xxxxxx-xxxx-xxxx-xxxx-xxxxxx",
secret: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
passphrase: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
},
},
],
});
/*
// Unsubscribe from a topic
client.subscribe({
subscriptions: [
{
topic: "activity",
type: "trades",
},
],
});
*/
};
new RealTimeDataClient({ onConnect, onMessage }).connect();