bybit-api 0.1.2

A Rust SDK for the Bybit V5 API - async, type-safe, zero-panic
Documentation
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
//! Market data models.

use rust_decimal::Decimal;
use serde::{Deserialize, Serialize};

/// Server time response.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ServerTime {
    /// Server time in seconds
    pub time_second: String,
    /// Server time in nanoseconds
    pub time_nano: String,
}

/// Instruments info response.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct InstrumentsInfo {
    /// Category
    pub category: String,
    /// List of instruments
    pub list: Vec<InstrumentInfo>,
    /// Next page cursor
    #[serde(default)]
    pub next_page_cursor: String,
}

/// Single instrument info.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct InstrumentInfo {
    /// Symbol name
    pub symbol: String,
    /// Contract type
    #[serde(default)]
    pub contract_type: String,
    /// Trading status
    pub status: String,
    /// Base coin
    #[serde(default)]
    pub base_coin: String,
    /// Quote coin
    #[serde(default)]
    pub quote_coin: String,
    /// Settle coin
    #[serde(default)]
    pub settle_coin: String,
    /// Launch time
    #[serde(default)]
    pub launch_time: String,
    /// Delivery time
    #[serde(default)]
    pub delivery_time: String,
    /// Delivery fee rate
    #[serde(default)]
    pub delivery_fee_rate: String,
    /// Price scale
    #[serde(default)]
    pub price_scale: String,
    /// Leverage filter
    #[serde(default)]
    pub leverage_filter: Option<LeverageFilter>,
    /// Price filter
    #[serde(default)]
    pub price_filter: Option<PriceFilter>,
    /// Lot size filter
    #[serde(default)]
    pub lot_size_filter: Option<LotSizeFilter>,
}

/// Leverage filter.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct LeverageFilter {
    /// Min leverage
    pub min_leverage: String,
    /// Max leverage
    pub max_leverage: String,
    /// Leverage step
    pub leverage_step: String,
}

/// Price filter.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct PriceFilter {
    /// Min price
    pub min_price: String,
    /// Max price
    pub max_price: String,
    /// Tick size
    pub tick_size: String,
}

/// Lot size filter.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct LotSizeFilter {
    /// Max order qty
    #[serde(default)]
    pub max_order_qty: String,
    /// Min order qty
    #[serde(default)]
    pub min_order_qty: String,
    /// Qty step
    #[serde(default)]
    pub qty_step: String,
    /// Post only max order qty
    #[serde(default)]
    pub post_only_max_order_qty: String,
    /// Base precision
    #[serde(default)]
    pub base_precision: String,
    /// Quote precision
    #[serde(default)]
    pub quote_precision: String,
    /// Min order amt
    #[serde(default)]
    pub min_order_amt: String,
    /// Max order amt
    #[serde(default)]
    pub max_order_amt: String,
}

/// Orderbook response.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Orderbook {
    /// Symbol
    pub s: String,
    /// Bids [price, size]
    pub b: Vec<[String; 2]>,
    /// Asks [price, size]
    pub a: Vec<[String; 2]>,
    /// Timestamp
    pub ts: u64,
    /// Update ID
    pub u: u64,
}

/// Tickers response.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Tickers {
    /// Category
    pub category: String,
    /// List of tickers
    pub list: Vec<Ticker>,
}

/// Single ticker.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Ticker {
    /// Symbol
    pub symbol: String,
    /// Last price
    #[serde(default)]
    pub last_price: String,
    /// Index price
    #[serde(default)]
    pub index_price: String,
    /// Mark price
    #[serde(default)]
    pub mark_price: String,
    /// Previous 24h price
    #[serde(default)]
    pub prev_price_24h: String,
    /// Price change 24h percentage
    #[serde(default)]
    pub price_24h_pcnt: String,
    /// High price 24h
    #[serde(default)]
    pub high_price_24h: String,
    /// Low price 24h
    #[serde(default)]
    pub low_price_24h: String,
    /// Previous 1h price
    #[serde(default)]
    pub prev_price_1h: String,
    /// Open interest
    #[serde(default)]
    pub open_interest: String,
    /// Open interest value
    #[serde(default)]
    pub open_interest_value: String,
    /// Turnover 24h
    #[serde(default)]
    pub turnover_24h: String,
    /// Volume 24h
    #[serde(default)]
    pub volume_24h: String,
    /// Funding rate
    #[serde(default)]
    pub funding_rate: String,
    /// Next funding time
    #[serde(default)]
    pub next_funding_time: String,
    /// Bid price
    #[serde(default)]
    pub bid_1_price: String,
    /// Bid size
    #[serde(default)]
    pub bid_1_size: String,
    /// Ask price
    #[serde(default)]
    pub ask_1_price: String,
    /// Ask size
    #[serde(default)]
    pub ask_1_size: String,
}

/// Kline response.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Klines {
    /// Category
    pub category: String,
    /// Symbol
    pub symbol: String,
    /// List of klines [timestamp, open, high, low, close, volume, turnover]
    pub list: Vec<Vec<String>>,
}

/// Parsed kline data.
#[derive(Debug, Clone)]
pub struct Kline {
    /// Start time in milliseconds
    pub start_time: u64,
    /// Open price
    pub open: Decimal,
    /// High price
    pub high: Decimal,
    /// Low price
    pub low: Decimal,
    /// Close price
    pub close: Decimal,
    /// Volume
    pub volume: Decimal,
    /// Turnover
    pub turnover: Decimal,
}

/// Funding rate history response.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct FundingHistory {
    /// Category
    pub category: String,
    /// List of funding records
    pub list: Vec<FundingRecord>,
}

/// Single funding record.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct FundingRecord {
    /// Symbol
    pub symbol: String,
    /// Funding rate
    pub funding_rate: String,
    /// Funding rate timestamp
    pub funding_rate_timestamp: String,
}

/// Recent trades response.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct RecentTrades {
    /// Category
    pub category: String,
    /// List of trades
    pub list: Vec<Trade>,
}

/// Single trade.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Trade {
    /// Exec ID
    pub exec_id: String,
    /// Symbol
    pub symbol: String,
    /// Price
    pub price: String,
    /// Size
    pub size: String,
    /// Side
    pub side: String,
    /// Time
    pub time: String,
    /// Is block trade
    #[serde(default)]
    pub is_block_trade: bool,
}

/// Open interest response.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct OpenInterest {
    /// Category
    pub category: String,
    /// Symbol
    pub symbol: String,
    /// List of open interest data
    pub list: Vec<OpenInterestRecord>,
    /// Next page cursor
    #[serde(default)]
    pub next_page_cursor: String,
}

/// Single open interest record.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct OpenInterestRecord {
    /// Open interest
    pub open_interest: String,
    /// Timestamp
    pub timestamp: String,
}

/// Risk limit response.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct RiskLimits {
    /// Category
    pub category: String,
    /// List of risk limits
    pub list: Vec<RiskLimit>,
}

/// Single risk limit.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct RiskLimit {
    /// ID
    pub id: i32,
    /// Symbol
    pub symbol: String,
    /// Risk limit value
    pub risk_limit_value: String,
    /// Maintenance margin
    pub maintenance_margin: String,
    /// Initial margin
    pub initial_margin: String,
    /// Max leverage
    pub max_leverage: String,
}

/// ADL alert record.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct AdlAlertRecord {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub coin: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub symbol: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub balance: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub max_balance: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub insurance_pnl_ratio: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub pnl_ratio: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub adl_trigger_threshold: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub adl_stop_ratio: Option<String>,
}

/// ADL alert result wrapper.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct AdlAlertResult {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub updated_time: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub list: Option<Vec<AdlAlertRecord>>,
}

/// Response payload for the get ADL alert endpoint.
pub type GetAdlAlertResponse = AdlAlertResult;

/// Delivery price record.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct DeliveryPriceRecord {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub symbol: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub delivery_price: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub delivery_time: Option<String>,
}

/// Delivery price result wrapper.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct DeliveryPriceResult {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub category: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub next_page_cursor: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub list: Option<Vec<DeliveryPriceRecord>>,
}

/// Response payload for the get delivery price endpoint.
pub type GetDeliveryPriceResponse = DeliveryPriceResult;

/// Fee rate level record.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct FeeRateLevel {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub level: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub taker_fee_rate: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub maker_fee_rate: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub maker_rebate: Option<String>,
}

/// Fee group record.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct FeeGroup {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub group_name: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub weighting_factor: Option<i32>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub symbols_numbers: Option<i32>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub symbols: Option<Vec<String>>,
    /// List of taker/maker fee rates by level. Wired to the already-defined
    /// `FeeRateLevel` inner type.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub fee_rates: Option<Vec<FeeRateLevel>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub update_time: Option<String>,
}

/// Fee group info result wrapper.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct FeeGroupInfoResult {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub list: Option<Vec<FeeGroup>>,
}

/// Response payload for the get fee group info endpoint.
pub type GetFeeGroupInfoResponse = FeeGroupInfoResult;

/// Historical volatility record.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct VolatilityRecord {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub period: Option<i32>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub value: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub time: Option<String>,
}

/// Response payload for the get historical volatility endpoint.
///
/// Bybit V5 returns the inner result as a flat list of volatility records.
/// `client.rs` already unwraps the envelope, so this is just the inner body.
pub type GetHistoricalVolatilityResponse = Vec<VolatilityRecord>;

/// Index component item.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct IndexComponentItem {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub exchange: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub symbol: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub price: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub weight: Option<String>,
}

/// Index components result wrapper.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct IndexComponentsResult {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub index_name: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub index_price: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub timestamp: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub components: Option<Vec<IndexComponentItem>>,
}

/// Response payload for the index components endpoint.
pub type IndexComponentsResponse = IndexComponentsResult;

/// Insurance pool record.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct InsurancePoolRecord {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub coin: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub balance: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub value: Option<String>,
}

/// Insurance result wrapper.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct InsuranceResult {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub updated_time: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub list: Option<Vec<InsurancePoolRecord>>,
}

/// Response payload for the insurance endpoint.
pub type InsuranceResponse = InsuranceResult;

/// Long/short ratio record.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct LongShortRatioRecord {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub symbol: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub buy_ratio: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub sell_ratio: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub timestamp: Option<String>,
}

/// Long/short ratio result wrapper.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct LongShortRatioResult {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub list: Option<Vec<LongShortRatioRecord>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub next_page_cursor: Option<String>,
}

/// Response payload for the long/short ratio endpoint.
pub type LongShortRatioResponse = LongShortRatioResult;

/// New delivery price record.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct NewDeliveryPriceRecord {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub symbol: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub delivery_price: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub delivery_time: Option<String>,
}

/// New delivery price result wrapper.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct NewDeliveryPriceResult {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub category: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub list: Option<Vec<NewDeliveryPriceRecord>>,
}

/// Response payload for the new delivery price endpoint.
pub type NewDeliveryPriceResponse = NewDeliveryPriceResult;

/// Order price limit result wrapper.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct OrderPriceLimitResult {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub category: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub symbol: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub buy_lmt: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub sell_lmt: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub ts: Option<String>,
}

pub type OrderPriceLimitResponse = OrderPriceLimitResult;

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct RpiOrderbookResult {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub s: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub b: Option<Vec<Vec<String>>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub a: Option<Vec<Vec<String>>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub ts: Option<i64>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub u: Option<i64>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub seq: Option<i64>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub cts: Option<i64>,
}

pub type RpiOrderbookResponse = RpiOrderbookResult;

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct IndexComponent {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub exchange: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub spot_pair: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub equivalent_price: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub multiplier: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub price: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub weight: Option<String>,
}

pub type GetIndexPriceComponentsResponse = IndexComponentsResult;

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct IndexKlineEntry {
    pub item: Vec<String>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct IndexPriceKlineResult {
    pub category: String,
    pub symbol: String,
    pub list: Vec<IndexKlineEntry>,
}

pub type IndexPriceKlineResponse = IndexPriceKlineResult;

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct LotSizeFilterLinear {
    pub max_order_qty: String,
    pub min_order_qty: String,
    pub qty_step: String,
    pub post_only_max_order_qty: String,
    pub max_mkt_order_qty: String,
    pub min_notional_value: String,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct LotSizeFilterSpot {
    pub base_precision: String,
    pub quote_precision: String,
    pub min_order_amt: String,
    pub max_order_amt: String,
    pub max_limit_order_qty: String,
    pub max_market_order_qty: String,
    pub post_only_max_limit_order_size: String,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct RiskParameters {
    pub price_limit_ratio_x: String,
    pub price_limit_ratio_y: String,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct InstrumentLinearInverse {
    pub symbol: String,
    pub contract_type: String,
    pub status: String,
    pub base_coin: String,
    pub quote_coin: String,
    pub launch_time: String,
    pub delivery_time: String,
    pub delivery_fee_rate: String,
    pub price_scale: String,
    pub leverage_filter: serde_json::Value,
    pub price_filter: serde_json::Value,
    pub lot_size_filter: LotSizeFilterLinear,
    pub unified_margin_trade: bool,
    pub funding_interval: i32,
    pub settle_coin: String,
    pub copy_trading: String,
    pub upper_funding_rate: String,
    pub lower_funding_rate: String,
    pub is_pre_listing: bool,
    // FIXME(typed-field): falls back to `serde_json::Value` because the Bybit
    // spec did not provide a matching inner type at generation time. Replace
    // with a typed struct in a follow-up PR after consulting the V5 docs.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub pre_listing_info: Option<serde_json::Value>,
    pub risk_parameters: RiskParameters,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct InstrumentSpot {
    pub symbol: String,
    pub base_coin: String,
    pub quote_coin: String,
    pub status: String,
    pub margin_trading: String,
    pub st_tag: String,
    pub lot_size_filter: LotSizeFilterSpot,
    pub price_filter: serde_json::Value,
    pub risk_parameters: RiskParameters,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct InstrumentOption {
    pub symbol: String,
    pub options_type: String,
    pub status: String,
    pub base_coin: String,
    pub quote_coin: String,
    pub settle_coin: String,
    pub launch_time: String,
    pub delivery_time: String,
    pub price_filter: serde_json::Value,
    pub lot_size_filter: serde_json::Value,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct InstrumentsInfoResult {
    pub category: String,
    pub next_page_cursor: String,
    pub list: Vec<serde_json::Value>,
}

pub type InstrumentsInfoResponse = InstrumentsInfoResult;

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct InsuranceRecord {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub coin: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub symbols: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub balance: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub value: Option<String>,
}

pub type GetInsurancePoolResponse = InsuranceResult;

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct KlineEntry {
    pub items: Vec<String>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct KlineResult {
    pub category: String,
    pub symbol: String,
    pub list: Vec<KlineEntry>,
}

pub type KlineResponse = KlineResult;

pub type GetLongShortRatioResponse = LongShortRatioResult;

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct MarkKlineEntry {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub items: Option<Vec<String>>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct MarkPriceKlineResult {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub category: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub symbol: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub list: Option<Vec<MarkKlineEntry>>,
}

pub type MarkPriceKlineResponse = MarkPriceKlineResult;

pub type GetNewDeliveryPriceResponse = NewDeliveryPriceResult;

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct OpenInterestResult {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub category: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub symbol: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub list: Option<Vec<OpenInterestRecord>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub next_page_cursor: Option<String>,
}

pub type OpenInterestResponse = OpenInterestResult;

pub type GetOrderPriceLimitResponse = OrderPriceLimitResult;

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct OrderbookLevel {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub items: Option<Vec<String>>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct OrderbookResult {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub s: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub b: Option<Vec<OrderbookLevel>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub a: Option<Vec<OrderbookLevel>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub ts: Option<i64>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub u: Option<i64>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub seq: Option<i64>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub cts: Option<i64>,
}

pub type OrderbookResponse = OrderbookResult;

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct PremiumIndexKlineEntry {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub items: Option<Vec<String>>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct PremiumIndexKlineResult {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub category: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub symbol: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub list: Option<Vec<PremiumIndexKlineEntry>>,
}

pub type PremiumIndexKlineResponse = PremiumIndexKlineResult;

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct TradeRecord {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub exec_id: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub symbol: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub price: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub size: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub side: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub time: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub is_block_trade: Option<bool>,
    #[serde(rename = "isRPITrade", skip_serializing_if = "Option::is_none")]
    pub is_rpi_trade: Option<bool>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub seq: Option<String>,
    #[serde(rename = "mP", skip_serializing_if = "Option::is_none")]
    pub m_p: Option<String>,
    #[serde(rename = "iP", skip_serializing_if = "Option::is_none")]
    pub i_p: Option<String>,
    #[serde(rename = "mIv", skip_serializing_if = "Option::is_none")]
    pub m_iv: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub iv: Option<String>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct RecentTradeResult {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub category: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub list: Option<Vec<TradeRecord>>,
}

pub type RecentTradeResponse = RecentTradeResult;

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct RiskLimitTier {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub id: Option<i32>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub symbol: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub risk_limit_value: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub maintenance_margin: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub initial_margin: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub is_lowest_risk: Option<i32>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub max_leverage: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub mm_deduction: Option<String>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct RiskLimitResult {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub category: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub list: Option<Vec<RiskLimitTier>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub next_page_cursor: Option<String>,
}

pub type RiskLimitResponse = RiskLimitResult;

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct RpiOrderbookLevel {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub items: Option<Vec<String>>,
}

pub type GetRpiOrderbookResponse = RpiOrderbookResult;

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct TickerLinearInverse {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub symbol: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub last_price: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub index_price: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub mark_price: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub prev_price_24h: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub price_24h_pcnt: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub high_price_24h: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub low_price_24h: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub prev_price_1h: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub open_interest: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub open_interest_value: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub turnover_24h: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub volume_24h: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub funding_rate: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub next_funding_time: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub bid1_price: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub bid1_size: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub ask1_price: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub ask1_size: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub funding_interval_hour: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub funding_cap: Option<String>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct TickerSpot {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub symbol: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub bid1_price: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub bid1_size: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub ask1_price: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub ask1_size: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub last_price: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub prev_price_24h: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub price_24h_pcnt: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub high_price_24h: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub low_price_24h: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub turnover_24h: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub volume_24h: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub usd_index_price: Option<String>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct TickerOption {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub symbol: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub bid1_price: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub bid1_size: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub bid1_iv: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub ask1_price: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub ask1_size: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub ask1_iv: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub last_price: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub high_price_24h: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub low_price_24h: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub mark_price: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub index_price: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub mark_iv: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub open_interest: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub turnover_24h: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub volume_24h: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub delta: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub gamma: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub vega: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub theta: Option<String>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct TickersResult {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub category: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub list: Option<Vec<serde_json::Value>>,
}

pub type TickersResponse = serde_json::Value;

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ServerTimeResult {
    pub time_second: String,
    pub time_nano: String,
}

pub type ServerTimeResponse = ServerTimeResult;