tickerapp 0.2.1

Unofficial typed async client for the Ticker.app market data API
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
//! Generated types from OpenAPI specification
//!
//! This file contains all the generated types for the API.
//! Do not edit manually - regenerate using the appropriate script.
//! Generated by openapi-to-rust v0.22.0. Source OpenAPI document: specs/tickerapp.openapi.yaml
#![allow(clippy::large_enum_variant)]
#![allow(clippy::format_in_format_args)]
#![allow(clippy::let_unit_value)]
#![allow(unreachable_patterns)]
use serde::{Deserialize, Serialize};
/// Serde normally maps both a missing `Option<T>` field and an
/// explicit JSON null to `None`. Wrapping the decoded value in
/// `Some` retains the field-presence bit for `Option<Option<T>>`.
mod tri_state_serde {
    use serde::{Deserialize, Deserializer};
    pub fn deserialize<'de, D, T>(de: D) -> Result<Option<T>, D::Error>
    where
        D: Deserializer<'de>,
        T: Deserialize<'de>,
    {
        T::deserialize(de).map(Some)
    }
}
///Market statistics response
#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct MarketStatsResponse {
    pub data: Vec<MarketStatsItem>,
    pub meta: MarketStatsResponseMeta,
}
#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct MarketStatsResponseMeta {
    ///Number of items returned
    pub count: i64,
    ///Exchange MIC code (included since XLON is the default if not specified in request)
    #[serde(rename = "exchangeMic")]
    pub exchange_mic: String,
    ///The trading date for which data is returned
    #[serde(rename = "tradingDate")]
    pub trading_date: chrono::NaiveDate,
}
///Single market statistics item
#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct MarketStatsItem {
    pub change: MarketStatsItemChange,
    pub identifier: InstrumentIdentifier,
    ///Company name
    pub name: Option<String>,
    ///Current price
    pub price: f64,
    ///Rank position (1 = top)
    pub rank: i64,
    ///Number of trades executed
    pub trades: i64,
    ///Total value traded (in GBP)
    pub value: f64,
    ///Number of shares traded
    pub volume: i64,
}
#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct MarketStatsItemChange {
    ///Absolute price change from previous close
    pub amount: f64,
    ///Direction of price change
    pub direction: MarketStatsItemChangeDirection,
    ///Percentage change from previous close
    pub percent: f64,
}
///Direction of price change
#[derive(Debug, Clone, PartialEq, Eq, Deserialize, Serialize, Default)]
pub enum MarketStatsItemChangeDirection {
    #[default]
    #[serde(rename = "up")]
    Up,
    #[serde(rename = "down")]
    Down,
}
impl MarketStatsItemChangeDirection {
    pub fn as_str(&self) -> &'static str {
        match self {
            Self::Up => "up",
            Self::Down => "down",
        }
    }
}
impl ::std::fmt::Display for MarketStatsItemChangeDirection {
    fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
        f.write_str(self.as_str())
    }
}
impl AsRef<str> for MarketStatsItemChangeDirection {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}
///Instrument identifier details
#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct InstrumentIdentifier {
    ///ISIN code
    pub isin: String,
    ///Market Identifier Code
    pub mic: String,
    ///Ticker symbol
    pub symbol: String,
}
#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct ListRnsDisclosureItemsResponse {
    pub data: Vec<DisclosureItem>,
    pub meta: Meta,
    /**Optional warnings about the request. For example, if a filter parameter was ignored because it is not available on the current plan, or if both singular and plural array parameter formats were provided.
*/
    #[serde(skip_serializing_if = "Option::is_none")]
    pub warnings: Option<Vec<String>>,
}
#[derive(Debug, Clone, Deserialize, Serialize, Default)]
pub struct ListExchangesResponse {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub data: Option<Vec<ExchangeListItem>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub meta: Option<Meta>,
}
///Exchange summary for list responses
#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct ExchangeListItem {
    ///City name
    #[serde(
        skip_serializing_if = "Option::is_none",
        default,
        deserialize_with = "tri_state_serde::deserialize"
    )]
    pub city: Option<Option<String>>,
    ///Additional comments from ISO registry
    #[serde(
        skip_serializing_if = "Option::is_none",
        default,
        deserialize_with = "tri_state_serde::deserialize"
    )]
    pub comments: Option<Option<String>>,
    ///ISO 3166 country code
    #[serde(
        skip_serializing_if = "Option::is_none",
        default,
        deserialize_with = "tri_state_serde::deserialize"
    )]
    pub country: Option<Option<String>>,
    ///Market Identifier Code (operating MIC)
    pub mic: String,
    ///Exchange name
    #[serde(
        skip_serializing_if = "Option::is_none",
        default,
        deserialize_with = "tri_state_serde::deserialize"
    )]
    pub name: Option<Option<String>>,
    ///MIC status (ACTIVE, UPDATED, EXPIRED)
    #[serde(
        skip_serializing_if = "Option::is_none",
        default,
        deserialize_with = "tri_state_serde::deserialize"
    )]
    pub status: Option<Option<String>>,
}
#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct GetTradesResponse {
    pub data: Vec<TradeItem>,
    pub meta: Meta,
}
///Single trade record
#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct TradeItem {
    ///Trade price
    pub price: f64,
    ///Quote condition code from the exchange
    #[serde(rename = "quoteCondition")]
    pub quote_condition: Option<String>,
    ///Trade side
    pub side: String,
    ///Trade timestamp
    pub timestamp: chrono::DateTime<chrono::Utc>,
    ///Trade venue (Exchange or Off-book)
    pub venue: Option<TradeItemVenue>,
    ///Trade volume
    pub volume: i64,
}
///Trade venue (Exchange or Off-book)
#[derive(Debug, Clone, PartialEq, Eq, Deserialize, Serialize, Default)]
pub enum TradeItemVenue {
    #[default]
    #[serde(rename = "Exchange")]
    Exchange,
    #[serde(rename = "Off-book")]
    OffBook,
}
impl TradeItemVenue {
    pub fn as_str(&self) -> &'static str {
        match self {
            Self::Exchange => "Exchange",
            Self::OffBook => "Off-book",
        }
    }
}
impl ::std::fmt::Display for TradeItemVenue {
    fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
        f.write_str(self.as_str())
    }
}
impl AsRef<str> for TradeItemVenue {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}
#[derive(Debug, Clone, Deserialize, Serialize, Default)]
pub struct GetTimeseriesResponseDataVariant2 {
    /// Additional properties matching the spec's
    /// `additionalProperties` value schema.
    #[serde(flatten)]
    pub additional_properties: std::collections::BTreeMap<String, TimeseriesItemKeyed>,
}
#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct GetTimeseriesResponse {
    pub data: GetTimeseriesResponseData,
    pub meta: Meta,
}
///Single timeseries data point (keyed format, without date)
#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct TimeseriesItemKeyed {
    ///Closing price
    pub close: f64,
    ///High price
    pub high: f64,
    ///Low price
    pub low: f64,
    ///NAV value (only when includeNav=true)
    #[serde(
        skip_serializing_if = "Option::is_none",
        default,
        deserialize_with = "tri_state_serde::deserialize"
    )]
    pub nav: Option<Option<f64>>,
    ///Opening price
    pub open: f64,
    ///Volume traded
    pub volume: i64,
}
///Single timeseries data point
#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct TimeseriesItem {
    ///Closing price
    pub close: f64,
    ///Date of the data point
    pub date: chrono::NaiveDate,
    ///High price
    pub high: f64,
    ///Low price
    pub low: f64,
    ///NAV value (only when includeNav=true)
    #[serde(
        skip_serializing_if = "Option::is_none",
        default,
        deserialize_with = "tri_state_serde::deserialize"
    )]
    pub nav: Option<Option<f64>>,
    ///Opening price
    pub open: f64,
    ///Volume traded
    pub volume: i64,
}
///Response metadata (information about the data, such as pagination)
#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct Meta {
    pub paging: Paging,
}
#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(untagged)]
pub enum GetTimeseriesResponseData {
    TimeseriesArray(Vec<TimeseriesItem>),
    GetTimeseriesResponseDataVariant2(GetTimeseriesResponseDataVariant2),
}
#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct GetRnsDisclosureItemResponse {
    pub data: DisclosureItem,
}
#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct GetNavResponse {
    pub data: Vec<NavItem>,
    pub meta: GetNavResponseMeta,
}
#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct GetNavResponseMeta {
    pub paging: Paging,
}
///Pagination response (format depends on whether pageCursor or pageNumber was used)
#[derive(Debug, Clone)]
pub enum Paging {
    CursorPaging(CursorPaging),
    ClassicPaging(ClassicPaging),
}
impl Serialize for Paging {
    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
    where
        S: serde::Serializer,
    {
        match self {
            Self::CursorPaging(value) => serde::Serialize::serialize(value, serializer),
            Self::ClassicPaging(value) => serde::Serialize::serialize(value, serializer),
        }
    }
}
impl<'de> Deserialize<'de> for Paging {
    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
    where
        D: serde::Deserializer<'de>,
    {
        fn exact_json_integer(number: &serde_json::Number) -> Option<i128> {
            number.as_i64().map(i128::from).or_else(|| number.as_u64().map(i128::from))
        }
        fn json_numbers_have_same_value(
            encoded: &serde_json::Number,
            input: &serde_json::Number,
        ) -> bool {
            match (exact_json_integer(encoded), exact_json_integer(input)) {
                (Some(encoded), Some(input)) => encoded == input,
                (Some(encoded), None) => {
                    input
                        .as_f64()
                        .is_some_and(|input| {
                            input.is_finite() && input.fract() == 0.0
                                && input as i128 == encoded
                        })
                }
                (None, Some(input)) => {
                    encoded
                        .as_f64()
                        .is_some_and(|encoded| {
                            encoded.is_finite() && encoded.fract() == 0.0
                                && encoded as i128 == input
                        })
                }
                (None, None) => encoded.as_f64() == input.as_f64(),
            }
        }
        /// `nulls_may_be_absent` also accepts an input `null` that the
        /// branch omits, as a skipped `None` does. Extra encoded
        /// keys are allowed only by the pre-existing anyOf match.
        fn preserves_complete_json_input(
            encoded: &serde_json::Value,
            input: &serde_json::Value,
            nulls_may_be_absent: bool,
            encoded_keys_may_be_extra: bool,
        ) -> bool {
            match (encoded, input) {
                (
                    serde_json::Value::Object(encoded),
                    serde_json::Value::Object(input),
                ) => {
                    (encoded_keys_may_be_extra
                        || encoded.keys().all(|key| input.contains_key(key)))
                        && input
                            .iter()
                            .all(|(key, value)| match encoded.get(key) {
                                Some(encoded_value) => {
                                    preserves_complete_json_input(
                                        encoded_value,
                                        value,
                                        nulls_may_be_absent,
                                        encoded_keys_may_be_extra,
                                    )
                                }
                                None => nulls_may_be_absent && value.is_null(),
                            })
                }
                (serde_json::Value::Array(encoded), serde_json::Value::Array(input)) => {
                    encoded.len() == input.len()
                        && encoded
                            .iter()
                            .zip(input)
                            .all(|(encoded, input)| {
                                preserves_complete_json_input(
                                    encoded,
                                    input,
                                    nulls_may_be_absent,
                                    encoded_keys_may_be_extra,
                                )
                            })
                }
                (
                    serde_json::Value::Number(encoded),
                    serde_json::Value::Number(input),
                ) => json_numbers_have_same_value(encoded, input),
                _ => encoded == input,
            }
        }
        let input = <serde_json::Value as Deserialize>::deserialize(deserializer)?;
        let mut matched = None;
        let mut equivalent = None;
        let mut equivalent_matches = 0usize;
        if true {
            if let Ok(candidate) = serde_json::from_value::<
                CursorPaging,
            >(input.clone()) {
                match serde_json::to_value(&candidate) {
                    Ok(encoded) if encoded == input => {
                        if matched.is_some() {
                            return Err(
                                serde::de::Error::custom(
                                    concat!(
                                        "ambiguous oneOf value for ", stringify!(Paging),
                                        ": more than one branch preserved the complete input",
                                    ),
                                ),
                            );
                        }
                        matched = Some(Self::CursorPaging(candidate));
                    }
                    Ok(
                        encoded,
                    ) if preserves_complete_json_input(
                        &encoded,
                        &input,
                        true,
                        false,
                    ) => {
                        equivalent_matches += 1;
                        equivalent.get_or_insert(Self::CursorPaging(candidate));
                    }
                    _ => {}
                }
            }
        }
        if true {
            if let Ok(candidate) = serde_json::from_value::<
                ClassicPaging,
            >(input.clone()) {
                match serde_json::to_value(&candidate) {
                    Ok(encoded) if encoded == input => {
                        if matched.is_some() {
                            return Err(
                                serde::de::Error::custom(
                                    concat!(
                                        "ambiguous oneOf value for ", stringify!(Paging),
                                        ": more than one branch preserved the complete input",
                                    ),
                                ),
                            );
                        }
                        matched = Some(Self::ClassicPaging(candidate));
                    }
                    Ok(
                        encoded,
                    ) if preserves_complete_json_input(
                        &encoded,
                        &input,
                        true,
                        false,
                    ) => {
                        equivalent_matches += 1;
                        equivalent.get_or_insert(Self::ClassicPaging(candidate));
                    }
                    _ => {}
                }
            }
        }
        if let Some(matched) = matched {
            return Ok(matched);
        }
        if equivalent_matches > 1 {
            return Err(
                serde::de::Error::custom(
                    concat!(
                        "ambiguous oneOf value for ", stringify!(Paging),
                        ": more than one branch preserved an equivalent input",
                    ),
                ),
            );
        }
        equivalent
            .ok_or_else(|| serde::de::Error::custom(
                concat!(
                    "no oneOf branch for ", stringify!(Paging),
                    " preserved the complete input",
                ),
            ))
    }
}
///Cursor-based pagination response
#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct CursorPaging {
    ///Additional opaque cursor observed in live disclosure pagination on 2026-10-03.
    #[serde(
        rename = "latestCursor",
        skip_serializing_if = "Option::is_none",
        default,
        deserialize_with = "tri_state_serde::deserialize"
    )]
    pub latest_cursor: Option<Option<String>>,
    ///Cursor to request the next page, or null if no more results
    #[serde(rename = "nextCursor")]
    pub next_cursor: Option<String>,
    ///Number of items per page
    #[serde(rename = "pageSize")]
    pub page_size: i64,
}
///Classic page-based pagination response
#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct ClassicPaging {
    ///Total number of items matching the query
    #[serde(rename = "itemTotal")]
    pub item_total: i64,
    ///Current page number (1-indexed)
    #[serde(rename = "pageNumber")]
    pub page_number: i64,
    ///Number of items per page
    #[serde(rename = "pageSize")]
    pub page_size: i64,
    ///Total number of pages
    #[serde(rename = "pageTotal")]
    pub page_total: i64,
}
///Single NAV data point
#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct NavItem {
    ///NAV publication date
    pub date: chrono::NaiveDate,
    pub values: Vec<NavItemValuesItem>,
}
#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct NavItemValuesItem {
    ///Currency code (e.g., GBX, USD)
    pub currency: String,
    ///NAV value
    pub value: f64,
}
#[derive(Debug, Clone, Deserialize, Serialize, Default)]
pub struct GetExchangeResponse {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub data: Option<ExchangeDetail>,
}
#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct GetCurrentPriceResponse {
    pub data: PriceSnapshot,
}
///Current price snapshot for an instrument
#[derive(Debug, Clone, Deserialize, Serialize, Default)]
pub struct PriceSnapshot {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub fundamentals: Option<PriceSnapshotFundamentals>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub identifier: Option<PriceSnapshotIdentifier>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub quote: Option<PriceSnapshotQuote>,
    ///Current trading session data
    #[serde(skip_serializing_if = "Option::is_none")]
    pub session: Option<PriceSnapshotSession>,
    ///52-week statistics
    #[serde(skip_serializing_if = "Option::is_none")]
    pub year: Option<PriceSnapshotYear>,
}
///52-week statistics
#[derive(Debug, Clone, Deserialize, Serialize, Default)]
pub struct PriceSnapshotYear {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub high: Option<PriceSnapshotYearHigh>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub low: Option<PriceSnapshotYearLow>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub performance: Option<PriceSnapshotYearPerformance>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub volatility: Option<f64>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub volume: Option<PriceSnapshotYearVolume>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub vwap: Option<f64>,
}
#[derive(Debug, Clone, Deserialize, Serialize, Default)]
pub struct PriceSnapshotYearVolume {
    ///52-week average daily volume; the live API sends a fraction.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub average: Option<f64>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub total: Option<i64>,
}
#[derive(Debug, Clone, Deserialize, Serialize, Default)]
pub struct PriceSnapshotYearPerformance {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub absolute: Option<f64>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub percent: Option<f64>,
}
#[derive(Debug, Clone, Deserialize, Serialize, Default)]
pub struct PriceSnapshotYearLow {
    ///52-week low date; the live API sends a full timestamp.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub date: Option<chrono::DateTime<chrono::Utc>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub price: Option<f64>,
}
#[derive(Debug, Clone, Deserialize, Serialize, Default)]
pub struct PriceSnapshotYearHigh {
    ///52-week high date; the live API sends a full timestamp.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub date: Option<chrono::DateTime<chrono::Utc>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub price: Option<f64>,
}
///Current trading session data
#[derive(Debug, Clone, Deserialize, Serialize, Default)]
pub struct PriceSnapshotSession {
    ///Current/closing price
    #[serde(skip_serializing_if = "Option::is_none")]
    pub close: Option<f64>,
    ///Session date
    #[serde(skip_serializing_if = "Option::is_none")]
    pub date: Option<chrono::NaiveDate>,
    ///Session high
    #[serde(skip_serializing_if = "Option::is_none")]
    pub high: Option<f64>,
    ///Session low
    #[serde(skip_serializing_if = "Option::is_none")]
    pub low: Option<f64>,
    ///Opening price
    #[serde(skip_serializing_if = "Option::is_none")]
    pub open: Option<f64>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub previous: Option<PriceSnapshotSessionPrevious>,
    ///Number of trades
    #[serde(skip_serializing_if = "Option::is_none")]
    pub trades: Option<i64>,
    ///Volume traded
    #[serde(skip_serializing_if = "Option::is_none")]
    pub volume: Option<i64>,
    ///Volume-weighted average price
    #[serde(skip_serializing_if = "Option::is_none")]
    pub vwap: Option<f64>,
}
#[derive(Debug, Clone, Deserialize, Serialize, Default)]
pub struct PriceSnapshotSessionPrevious {
    ///Previous close price
    #[serde(skip_serializing_if = "Option::is_none")]
    pub close: Option<f64>,
    ///Previous session date
    #[serde(
        skip_serializing_if = "Option::is_none",
        default,
        deserialize_with = "tri_state_serde::deserialize"
    )]
    pub date: Option<Option<chrono::NaiveDate>>,
    ///Previous session volume
    #[serde(
        skip_serializing_if = "Option::is_none",
        default,
        deserialize_with = "tri_state_serde::deserialize"
    )]
    pub volume: Option<Option<i64>>,
}
#[derive(Debug, Clone, Deserialize, Serialize, Default)]
pub struct PriceSnapshotQuote {
    ///Best ask price
    #[serde(skip_serializing_if = "Option::is_none")]
    pub ask: Option<f64>,
    ///Best bid price
    #[serde(skip_serializing_if = "Option::is_none")]
    pub bid: Option<f64>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub change: Option<PriceSnapshotQuoteChange>,
    ///Mid price (average of bid and ask)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub mid: Option<f64>,
    ///Bid-ask spread
    #[serde(skip_serializing_if = "Option::is_none")]
    pub spread: Option<f64>,
    ///Price timestamp
    #[serde(skip_serializing_if = "Option::is_none")]
    pub timestamp: Option<chrono::DateTime<chrono::Utc>>,
    ///Last trade price
    #[serde(skip_serializing_if = "Option::is_none")]
    pub trade: Option<f64>,
}
#[derive(Debug, Clone, Deserialize, Serialize, Default)]
pub struct PriceSnapshotQuoteChange {
    ///Absolute change from previous close
    #[serde(skip_serializing_if = "Option::is_none")]
    pub amount: Option<f64>,
    ///Price used for change calculation
    #[serde(skip_serializing_if = "Option::is_none")]
    pub basis: Option<String>,
    ///Direction of change
    #[serde(skip_serializing_if = "Option::is_none")]
    pub direction: Option<PriceSnapshotQuoteChangeDirection>,
    ///Percentage change from previous close
    #[serde(skip_serializing_if = "Option::is_none")]
    pub percent: Option<f64>,
}
///Direction of change
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum PriceSnapshotQuoteChangeDirection {
    Up,
    Down,
    /// Custom or unknown model identifier
    Custom(String),
}
impl<'de> serde::Deserialize<'de> for PriceSnapshotQuoteChangeDirection {
    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
    where
        D: serde::Deserializer<'de>,
    {
        let value = String::deserialize(deserializer)?;
        match value.as_str() {
            "up" => Ok(PriceSnapshotQuoteChangeDirection::Up),
            "down" => Ok(PriceSnapshotQuoteChangeDirection::Down),
            _ => Ok(PriceSnapshotQuoteChangeDirection::Custom(value)),
        }
    }
}
impl serde::Serialize for PriceSnapshotQuoteChangeDirection {
    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
    where
        S: serde::Serializer,
    {
        serializer.serialize_str(self.as_str())
    }
}
impl PriceSnapshotQuoteChangeDirection {
    pub fn as_str(&self) -> &str {
        match self {
            PriceSnapshotQuoteChangeDirection::Up => "up",
            PriceSnapshotQuoteChangeDirection::Down => "down",
            PriceSnapshotQuoteChangeDirection::Custom(s) => s.as_str(),
        }
    }
}
impl ::std::fmt::Display for PriceSnapshotQuoteChangeDirection {
    fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
        f.write_str(self.as_str())
    }
}
impl AsRef<str> for PriceSnapshotQuoteChangeDirection {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}
#[derive(Debug, Clone, Deserialize, Serialize, Default)]
pub struct PriceSnapshotIdentifier {
    ///ISIN code
    #[serde(skip_serializing_if = "Option::is_none")]
    pub isin: Option<String>,
    ///Market Identifier Code
    #[serde(skip_serializing_if = "Option::is_none")]
    pub mic: Option<String>,
    ///Ticker symbol
    #[serde(skip_serializing_if = "Option::is_none")]
    pub symbol: Option<String>,
}
#[derive(Debug, Clone, Deserialize, Serialize, Default)]
pub struct PriceSnapshotFundamentals {
    ///Market capitalization
    #[serde(
        rename = "marketCap",
        skip_serializing_if = "Option::is_none",
        default,
        deserialize_with = "tri_state_serde::deserialize"
    )]
    pub market_cap: Option<Option<f64>>,
    ///Total shares in issue
    #[serde(
        rename = "sharesInIssue",
        skip_serializing_if = "Option::is_none",
        default,
        deserialize_with = "tri_state_serde::deserialize"
    )]
    pub shares_in_issue: Option<Option<f64>>,
}
///Full exchange details (ISO 10383 MIC data)
#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct ExchangeDetail {
    #[serde(rename = "_links")]
    pub links: ExchangeDetailLinks,
    ///Exchange abbreviation
    #[serde(
        skip_serializing_if = "Option::is_none",
        default,
        deserialize_with = "tri_state_serde::deserialize"
    )]
    pub abbreviation: Option<Option<String>>,
    ///City name
    #[serde(
        skip_serializing_if = "Option::is_none",
        default,
        deserialize_with = "tri_state_serde::deserialize"
    )]
    pub city: Option<Option<String>>,
    ///Additional comments from ISO registry
    #[serde(
        skip_serializing_if = "Option::is_none",
        default,
        deserialize_with = "tri_state_serde::deserialize"
    )]
    pub comments: Option<Option<String>>,
    ///ISO 3166 country code
    #[serde(
        skip_serializing_if = "Option::is_none",
        default,
        deserialize_with = "tri_state_serde::deserialize"
    )]
    pub country: Option<Option<String>>,
    ///ISO date when MIC was created
    #[serde(
        rename = "creationDate",
        skip_serializing_if = "Option::is_none",
        default,
        deserialize_with = "tri_state_serde::deserialize"
    )]
    pub creation_date: Option<Option<String>>,
    ///ISO date when MIC expired (null if active)
    #[serde(
        rename = "expiryDate",
        skip_serializing_if = "Option::is_none",
        default,
        deserialize_with = "tri_state_serde::deserialize"
    )]
    pub expiry_date: Option<Option<String>>,
    ///ISO date when MIC was last updated
    #[serde(
        rename = "lastUpdateDate",
        skip_serializing_if = "Option::is_none",
        default,
        deserialize_with = "tri_state_serde::deserialize"
    )]
    pub last_update_date: Option<Option<String>>,
    ///Market Identifier Code (operating MIC)
    pub mic: String,
    ///Exchange name
    #[serde(
        skip_serializing_if = "Option::is_none",
        default,
        deserialize_with = "tri_state_serde::deserialize"
    )]
    pub name: Option<Option<String>>,
    ///Segment MICs operating under this exchange
    pub segments: Vec<ExchangeSegment>,
    ///MIC status (ACTIVE, UPDATED, EXPIRED)
    #[serde(
        skip_serializing_if = "Option::is_none",
        default,
        deserialize_with = "tri_state_serde::deserialize"
    )]
    pub status: Option<Option<String>>,
    ///Exchange website URL
    #[serde(
        skip_serializing_if = "Option::is_none",
        default,
        deserialize_with = "tri_state_serde::deserialize"
    )]
    pub website: Option<Option<String>>,
}
///A segment MIC within an exchange
#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct ExchangeSegment {
    ///Segment MIC code
    pub mic: String,
    ///Segment name
    #[serde(
        skip_serializing_if = "Option::is_none",
        default,
        deserialize_with = "tri_state_serde::deserialize"
    )]
    pub name: Option<Option<String>>,
    ///Segment status (ACTIVE, UPDATED, EXPIRED)
    #[serde(
        skip_serializing_if = "Option::is_none",
        default,
        deserialize_with = "tri_state_serde::deserialize"
    )]
    pub status: Option<Option<String>>,
}
#[derive(Debug, Clone, Deserialize, Serialize, Default)]
pub struct ExchangeDetailLinks {
    ///Link to this resource
    #[serde(rename = "self", skip_serializing_if = "Option::is_none")]
    pub self_field: Option<String>,
}
///Error response wrapper
#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct ErrorResponse {
    pub error: ErrorDetail,
}
///Error details
#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct ErrorDetail {
    ///Suggestion for resolving the error
    #[serde(skip_serializing_if = "Option::is_none")]
    pub hint: Option<String>,
    ///Human-readable error message
    pub message: String,
}
#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct DisclosureItem {
    ///Categories (Ticker and FCA)
    pub category: Vec<Category>,
    ///Globally unique identifier
    pub guid: String,
    ///Disclosure headline
    pub headline: String,
    pub issuer: Company,
    ///Available document formats
    pub publication: Vec<Publication>,
    ///Related companies mentioned in the disclosure
    #[serde(skip_serializing_if = "Option::is_none")]
    pub related: Option<Vec<Company>>,
    ///If this is a replacement, details of the replaced announcement
    #[serde(skip_serializing_if = "Option::is_none")]
    pub replaces: Option<Replaces>,
    ///Native RNS identifier
    #[serde(rename = "rnsId")]
    pub rns_id: String,
    ///Source code
    pub source: String,
    ///Publication timestamp
    pub timestamp: chrono::DateTime<chrono::Utc>,
    ///Version number (extracted from guid)
    pub version: Option<i64>,
}
#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct Replaces {
    ///GUID of the replaced announcement
    pub guid: String,
    ///Version of the replaced announcement
    pub version: i64,
}
#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct Publication {
    ///MIME type
    pub mime: String,
    ///URL to the document
    pub url: String,
}
#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct Company {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub instrument: Option<Instrument>,
    ///Legal Entity Identifier
    #[serde(skip_serializing_if = "Option::is_none")]
    pub lei: Option<String>,
    ///Company name
    pub name: String,
}
#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct Instrument {
    ///ISIN code
    pub isin: String,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub symbol: Option<Symbol>,
}
#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct Symbol {
    ///Ticker symbol
    pub mnemonic: String,
}
#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct Category {
    ///Category code
    pub code: String,
    ///Category description (FCA only)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub description: Option<String>,
    ///Importance level (FCA only)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub importance: Option<CategoryImportance>,
    ///Category type
    pub kind: CategoryKind,
    ///Category name
    pub name: String,
}
///Category type
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum CategoryKind {
    Ticker,
    Fca,
    Rns,
    /// Custom or unknown model identifier
    Custom(String),
}
impl<'de> serde::Deserialize<'de> for CategoryKind {
    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
    where
        D: serde::Deserializer<'de>,
    {
        let value = String::deserialize(deserializer)?;
        match value.as_str() {
            "Ticker" => Ok(CategoryKind::Ticker),
            "FCA" => Ok(CategoryKind::Fca),
            "RNS" => Ok(CategoryKind::Rns),
            _ => Ok(CategoryKind::Custom(value)),
        }
    }
}
impl serde::Serialize for CategoryKind {
    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
    where
        S: serde::Serializer,
    {
        serializer.serialize_str(self.as_str())
    }
}
impl CategoryKind {
    pub fn as_str(&self) -> &str {
        match self {
            CategoryKind::Ticker => "Ticker",
            CategoryKind::Fca => "FCA",
            CategoryKind::Rns => "RNS",
            CategoryKind::Custom(s) => s.as_str(),
        }
    }
}
impl ::std::fmt::Display for CategoryKind {
    fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
        f.write_str(self.as_str())
    }
}
impl AsRef<str> for CategoryKind {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}
///Importance level (FCA only)
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum CategoryImportance {
    Low,
    Medium,
    High,
    Ultra,
    /// Custom or unknown model identifier
    Custom(String),
}
impl<'de> serde::Deserialize<'de> for CategoryImportance {
    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
    where
        D: serde::Deserializer<'de>,
    {
        let value = String::deserialize(deserializer)?;
        match value.as_str() {
            "low" => Ok(CategoryImportance::Low),
            "medium" => Ok(CategoryImportance::Medium),
            "high" => Ok(CategoryImportance::High),
            "ultra" => Ok(CategoryImportance::Ultra),
            _ => Ok(CategoryImportance::Custom(value)),
        }
    }
}
impl serde::Serialize for CategoryImportance {
    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
    where
        S: serde::Serializer,
    {
        serializer.serialize_str(self.as_str())
    }
}
impl CategoryImportance {
    pub fn as_str(&self) -> &str {
        match self {
            CategoryImportance::Low => "low",
            CategoryImportance::Medium => "medium",
            CategoryImportance::High => "high",
            CategoryImportance::Ultra => "ultra",
            CategoryImportance::Custom(s) => s.as_str(),
        }
    }
}
impl ::std::fmt::Display for CategoryImportance {
    fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
        f.write_str(self.as_str())
    }
}
impl AsRef<str> for CategoryImportance {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}
#[derive(Debug, Clone, Deserialize, Serialize, Default)]
pub struct HealthResponse {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub status: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub timestamp: Option<chrono::DateTime<chrono::Utc>>,
}