rusty_common/websocket/exchanges/
upbit.rs1use crate::types::Exchange;
6use crate::websocket::{CompressionConfig, WebSocketConfig};
7use std::time::Duration;
8
9pub fn default_config(url: String) -> WebSocketConfig {
11 WebSocketConfig::builder(Exchange::Upbit, url)
12 .connect_timeout(Duration::from_secs(10))
13 .timeout(Duration::from_secs(30))
14 .ping_interval(Duration::from_secs(120)) .pong_timeout(Duration::from_secs(10))
16 .max_frame_size(65536) .max_message_size(10 * 1024 * 1024) .compression(CompressionConfig::default())
20 .build()
21}
22
23pub mod urls {
25 pub const PUBLIC: &str = "wss://api.upbit.com/websocket/v1";
27
28 pub const PRIVATE: &str = "wss://api.upbit.com/websocket/v1";
30}
31
32pub fn create_subscription(
34 ticket: &str,
35 types: Vec<String>,
36 codes: Vec<String>,
37 is_only_snapshot: bool,
38 is_only_realtime: bool,
39) -> Vec<simd_json::OwnedValue> {
40 vec![
41 simd_json::json!({
43 "ticket": ticket
44 }),
45 simd_json::json!({
47 "type": types.join(","),
48 "codes": codes,
49 "isOnlySnapshot": is_only_snapshot,
50 "isOnlyRealtime": is_only_realtime
51 }),
52 ]
53}
54
55pub fn create_simple_subscription(ticket: &str, format: &str) -> Vec<simd_json::OwnedValue> {
57 vec![
58 simd_json::json!({
59 "ticket": ticket
60 }),
61 simd_json::json!({
62 "format": format
63 }),
64 ]
65}