HedgeTech 0.0.0__py3-none-any.whl → 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,1921 @@
1
+ # ========================================|======================================== #
2
+ # Imports #
3
+ # ========================================|======================================== #
4
+
5
+ from datetime import datetime
6
+ from typing import (
7
+ List,
8
+ Union,
9
+ Dict,
10
+ Optional,
11
+ TypedDict,
12
+ )
13
+
14
+ # ========================================|======================================== #
15
+ # Class Definitions #
16
+ # ========================================|======================================== #
17
+
18
+ class WebsocketBase_symbolIsin(TypedDict):
19
+ """
20
+ Base structure for websocket messages containing fund or instrument information
21
+ identified by ISIN (International Securities Identification Number).
22
+
23
+ This TypedDict defines the common structure of messages received over a websocket
24
+ where each message is linked to a specific ISIN.
25
+
26
+ Attributes:
27
+ channel (str): The name of the websocket channel through which the message is sent.
28
+ symbolIsin (str): The ISIN code of the instrument or fund.
29
+ timestamp (str): ISO-formatted timestamp indicating when the message was generated.
30
+
31
+ Example:
32
+ >>> message: WebsocketBase_symbolIsin = {
33
+ ... "channel": "fund_live_updates",
34
+ ... "symbolIsin": "IR0001234567",
35
+ ... "timestamp": "2025-11-19T10:30:00Z"
36
+ ... }
37
+ >>> message["symbolIsin"]
38
+ 'IR0001234567'
39
+ """
40
+ channel: str
41
+ symbolIsin: str
42
+ timestamp: str
43
+
44
+
45
+ class WebsocketBase_symbolName(TypedDict):
46
+ """
47
+ Base structure for websocket messages containing fund or instrument information
48
+ identified by symbol name.
49
+
50
+ This TypedDict defines the common structure of messages received over a websocket
51
+ where each message is linked to a specific symbol name.
52
+
53
+ Attributes:
54
+ channel (str): The name of the websocket channel through which the message is sent.
55
+ symbolName (str): The symbol name of the instrument or fund.
56
+ timestamp (str): ISO-formatted timestamp indicating when the message was generated.
57
+
58
+ Example:
59
+ >>> message: WebsocketBase_symbolName = {
60
+ ... "channel": "fund_live_updates",
61
+ ... "symbolName": "ETF001",
62
+ ... "timestamp": "2025-11-19T10:30:00Z"
63
+ ... }
64
+ >>> message["symbolName"]
65
+ 'ETF001'
66
+ """
67
+ channel: str
68
+ symbolName: str
69
+ timestamp: str
70
+
71
+
72
+ class StatusDescription(TypedDict):
73
+ """
74
+ Contains a human-readable description of the server or API status.
75
+
76
+ Attributes:
77
+ fa (str): Description in Farsi (Persian) language.
78
+ en (str): Description in English language.
79
+
80
+ Example:
81
+ >>> desc: StatusDescription = {
82
+ ... "fa": "عملیات موفقیت‌آمیز بود",
83
+ ... "en": "Operation successful"
84
+ ... }
85
+ >>> desc["en"]
86
+ 'Operation successful'
87
+ """
88
+ fa: str
89
+ en: str
90
+
91
+
92
+ class Status(TypedDict):
93
+ """
94
+ Represents the status metadata of a server response or websocket message.
95
+
96
+ This TypedDict provides information about the success of an operation,
97
+ server timestamp, versioning, author info, description, and status code.
98
+
99
+ Attributes:
100
+ State (bool): Indicates whether the operation or request was successful.
101
+ ServerTimeStamp (float): Server timestamp, typically a Unix timestamp.
102
+ Version (str): Version of the API or server sending the message.
103
+ Author (str): Name of the author or owner of the API/server.
104
+ Description (StatusDescription): A human-readable description of the status
105
+ in multiple languages.
106
+ StatusCode (int): Numeric status code returned by the server.
107
+
108
+ Example:
109
+ >>> status: Status = {
110
+ ... "State": True,
111
+ ... "ServerTimeStamp": 1700350200.0,
112
+ ... "Version": "1.2.3",
113
+ ... "Author": "HedgeTech",
114
+ ... "Description": {"fa": "عملیات موفقیت‌آمیز بود", "en": "Operation successful"},
115
+ ... "StatusCode": 200
116
+ ... }
117
+ >>> status["Description"]["en"]
118
+ 'Operation successful'
119
+ """
120
+ State: bool
121
+ ServerTimeStamp: float
122
+ Version: str
123
+ Author: str
124
+ Description: StatusDescription
125
+ StatusCode: int
126
+
127
+ # +--------------------------------------------------------------------------------------+ #
128
+
129
+
130
+ class SecuritiesAndFunds(TypedDict):
131
+ """
132
+ Represents detailed metadata for a security or fund, including trading rules,
133
+ commission rates, limits, and other attributes used in financial operations.
134
+
135
+ This TypedDict is typically used in systems that manage ETFs, stocks, or other
136
+ traded instruments, providing all necessary details for order validation,
137
+ display, and transaction execution.
138
+
139
+ Attributes:
140
+ symbolIsin (str): International Securities Identification Number (ISIN) of the instrument.
141
+ symbolName (str): Trading symbol of the instrument.
142
+ title (str): Human-readable name or title of the security/fund.
143
+
144
+ buyCommission (float): Commission rate applied when buying this security/fund.
145
+ sellCommission (float): Commission rate applied when selling this security/fund.
146
+
147
+ minValidBuyVolume (int): Minimum allowable buy volume per order.
148
+ maxValidBuyVolume (int): Maximum allowable buy volume per order.
149
+ minValidSellVolume (int): Minimum allowable sell volume per order.
150
+ maxValidSellVolume (int): Maximum allowable sell volume per order.
151
+
152
+ canBuy (bool): Indicates whether buying is currently permitted.
153
+ canSell (bool): Indicates whether selling is currently permitted.
154
+
155
+ minAllowedPrice (float): Minimum price allowed for placing an order.
156
+ maxAllowedPrice (float): Maximum price allowed for placing an order.
157
+
158
+ is_ETF (bool): Indicates if the security/fund is an Exchange-Traded Fund (ETF).
159
+ baseVolume (float): The base trading volume unit of the instrument.
160
+ minDealablePrice (float): Minimum price at which a deal can be executed.
161
+ minDealableCount (int): Minimum number of units that can be traded per deal.
162
+
163
+ owner (str): Name of the instrument owner or issuer.
164
+ hidePrice (int): Flag indicating if the price should be hidden in the interface (0 or 1).
165
+ dataClass (str): Classification of the data, e.g., "Equity", "ETF", etc.
166
+
167
+ Example:
168
+ >>> fund: SecuritiesAndFunds = {
169
+ ... "symbolIsin": "IR0001234567",
170
+ ... "symbolName": "ETF001",
171
+ ... "title": "HedgeTech Growth ETF",
172
+ ... "buyCommission": 0.0015,
173
+ ... "sellCommission": 0.0015,
174
+ ... "minValidBuyVolume": 100,
175
+ ... "maxValidBuyVolume": 10000,
176
+ ... "minValidSellVolume": 100,
177
+ ... "maxValidSellVolume": 10000,
178
+ ... "canBuy": True,
179
+ ... "canSell": True,
180
+ ... "minAllowedPrice": 1000.0,
181
+ ... "maxAllowedPrice": 200000.0,
182
+ ... "is_ETF": True,
183
+ ... "baseVolume": 100.0,
184
+ ... "minDealablePrice": 1000.0,
185
+ ... "minDealableCount": 100,
186
+ ... "owner": "HedgeTech",
187
+ ... "hidePrice": 0,
188
+ ... "dataClass": "ETF"
189
+ ... }
190
+ >>> fund["symbolName"]
191
+ 'ETF001'
192
+ >>> fund["canBuy"]
193
+ True
194
+ >>> fund["minValidBuyVolume"]
195
+ 100
196
+ """
197
+ symbolIsin: str
198
+ symbolName: str
199
+ title: str
200
+
201
+ buyCommission: float
202
+ sellCommission: float
203
+
204
+ minValidBuyVolume: int
205
+ maxValidBuyVolume: int
206
+ minValidSellVolume: int
207
+ maxValidSellVolume: int
208
+
209
+ canBuy: bool
210
+ canSell: bool
211
+
212
+ minAllowedPrice: float
213
+ maxAllowedPrice: float
214
+
215
+ is_ETF: bool
216
+ baseVolume: float
217
+ minDealablePrice: float
218
+ minDealableCount: int
219
+
220
+ owner: str
221
+ hidePrice: int
222
+ dataClass: str
223
+
224
+ # +--------------------------------------------------------------------------------------+ #
225
+
226
+
227
+ class StockFutures(TypedDict):
228
+ """
229
+ Represents detailed metadata for a stock futures contract, including trading rules,
230
+ margin requirements, underlying assets, commissions, limits, and other attributes
231
+ needed for trading and risk management.
232
+
233
+ This TypedDict is typically used in systems that manage futures contracts for equities,
234
+ ETFs, or other underlying instruments, providing all necessary details for order
235
+ validation, execution, and reporting.
236
+
237
+ Attributes:
238
+ symbolIsin (str): ISIN code of the futures contract.
239
+ title (str): Human-readable name or title of the futures contract.
240
+ symbolName (str): Trading symbol of the futures contract.
241
+
242
+ csize (int): Contract size (number of underlying units per futures contract).
243
+ firstMargin (float): Initial margin required to open a position.
244
+ minimumMargin (float): Minimum maintenance margin required.
245
+
246
+ UnderlyingAssets_symbolIsin (str): ISIN of the underlying asset.
247
+ UnderlyingAssets_title (str): Title or name of the underlying asset.
248
+ UnderlyingAssets_symbolName (str): Trading symbol of the underlying asset.
249
+ UnderlyingAssets_is_ETF (bool): Whether the underlying asset is an ETF.
250
+
251
+ roundFactor (int): Price rounding factor used for the futures contract.
252
+ ExpirationDate (str): Expiration date of the contract in ISO format (YYYY-MM-DD).
253
+ DaysToExpiration (int): Number of days remaining until the contract expires.
254
+
255
+ buyCommission (float): Commission rate applied when buying the contract.
256
+ sellCommission (float): Commission rate applied when selling the contract.
257
+
258
+ minValidBuyVolume (int): Minimum valid buy volume per order.
259
+ maxValidBuyVolume (int): Maximum valid buy volume per order.
260
+ minValidSellVolume (int): Minimum valid sell volume per order.
261
+ maxValidSellVolume (int): Maximum valid sell volume per order.
262
+
263
+ canBuy (bool): Indicates whether buying is currently allowed.
264
+ canSell (bool): Indicates whether selling is currently allowed.
265
+
266
+ minAllowedPrice (float): Minimum price allowed for placing an order.
267
+ maxAllowedPrice (float): Maximum price allowed for placing an order.
268
+
269
+ minDealableCount (int): Minimum number of contracts per deal.
270
+ minDealablePrice (float): Minimum price at which a deal can be executed.
271
+
272
+ owner (str): Name of the contract owner or issuing entity.
273
+
274
+ ExerciseFeePhysical (float): Fee charged for physical settlement of the contract.
275
+ ExerciseFeeCash (float): Fee charged for cash settlement of the contract.
276
+ ExerciseSellTax (float): Tax applied when exercising or selling the contract.
277
+
278
+ OpenPositionLimitInstitution (int): Maximum open positions allowed for institutions.
279
+ OpenPositionLimitIndividual (int): Maximum open positions allowed for individuals.
280
+ OpenPositionLimitMarket (int): Maximum open positions allowed for the entire market.
281
+
282
+ dataClass (str): Classification of the data, e.g., "Futures", "ETF Futures", etc.
283
+
284
+ Example:
285
+ >>> future: StockFutures = {
286
+ ... "symbolIsin": "IRFUT123456",
287
+ ... "title": "HedgeTech Equity Futures",
288
+ ... "symbolName": "FUT001",
289
+ ... "csize": 100,
290
+ ... "firstMargin": 5000.0,
291
+ ... "minimumMargin": 2500.0,
292
+ ... "UnderlyingAssets_symbolIsin": "IR0001234567",
293
+ ... "UnderlyingAssets_title": "HedgeTech Growth ETF",
294
+ ... "UnderlyingAssets_symbolName": "ETF001",
295
+ ... "UnderlyingAssets_is_ETF": True,
296
+ ... "roundFactor": 10,
297
+ ... "ExpirationDate": "2025-12-31",
298
+ ... "DaysToExpiration": 42,
299
+ ... "buyCommission": 0.001,
300
+ ... "sellCommission": 0.001,
301
+ ... "minValidBuyVolume": 1,
302
+ ... "maxValidBuyVolume": 100,
303
+ ... "minValidSellVolume": 1,
304
+ ... "maxValidSellVolume": 100,
305
+ ... "canBuy": True,
306
+ ... "canSell": True,
307
+ ... "minAllowedPrice": 1000.0,
308
+ ... "maxAllowedPrice": 200000.0,
309
+ ... "minDealableCount": 1,
310
+ ... "minDealablePrice": 1000.0,
311
+ ... "owner": "HedgeTech",
312
+ ... "ExerciseFeePhysical": 50.0,
313
+ ... "ExerciseFeeCash": 25.0,
314
+ ... "ExerciseSellTax": 5.0,
315
+ ... "OpenPositionLimitInstitution": 1000,
316
+ ... "OpenPositionLimitIndividual": 100,
317
+ ... "OpenPositionLimitMarket": 5000,
318
+ ... "dataClass": "Futures"
319
+ ... }
320
+ >>> future["symbolName"]
321
+ 'FUT001'
322
+ >>> future["UnderlyingAssets_is_ETF"]
323
+ True
324
+ >>> future["DaysToExpiration"]
325
+ 42
326
+ """
327
+ symbolIsin: str
328
+ title: str
329
+ symbolName: str
330
+
331
+ csize: int
332
+ firstMargin: float
333
+ minimumMargin: float
334
+
335
+ UnderlyingAssets_symbolIsin: str
336
+ UnderlyingAssets_title: str
337
+ UnderlyingAssets_symbolName: str
338
+ UnderlyingAssets_is_ETF: bool
339
+
340
+ roundFactor: int
341
+ ExpirationDate: str
342
+ DaysToExpiration: int
343
+
344
+ buyCommission: float
345
+ sellCommission: float
346
+
347
+ minValidBuyVolume: int
348
+ maxValidBuyVolume: int
349
+ minValidSellVolume: int
350
+ maxValidSellVolume: int
351
+
352
+ canBuy: bool
353
+ canSell: bool
354
+
355
+ minAllowedPrice: float
356
+ maxAllowedPrice: float
357
+
358
+ minDealableCount: int
359
+ minDealablePrice: float
360
+
361
+ owner: str
362
+
363
+ ExerciseFeePhysical: float
364
+ ExerciseFeeCash: float
365
+ ExerciseSellTax: float
366
+
367
+ OpenPositionLimitInstitution: int
368
+ OpenPositionLimitIndividual: int
369
+ OpenPositionLimitMarket: int
370
+
371
+ dataClass: str
372
+
373
+ # +--------------------------------------------------------------------------------------+ #
374
+
375
+
376
+ class StockOptions(TypedDict):
377
+ """
378
+ Represents detailed metadata for a stock options contract, including trading rules,
379
+ commissions, volume limits, underlying assets, exercise fees, position limits, and
380
+ other attributes required for trading and risk management.
381
+
382
+ This TypedDict is typically used in systems that handle equity options, providing
383
+ all necessary details for order validation, execution, reporting, and margin calculations.
384
+
385
+ Attributes:
386
+ symbolIsin (str): ISIN code of the options contract.
387
+ symbolName (str): Trading symbol of the options contract.
388
+ title (str): Human-readable name or title of the options contract.
389
+
390
+ buyCommission (float): Commission rate applied when buying the option.
391
+ sellCommission (float): Commission rate applied when selling the option.
392
+
393
+ minValidBuyVolume (int): Minimum valid buy volume per order.
394
+ maxValidBuyVolume (int): Maximum valid buy volume per order.
395
+ minValidSellVolume (int): Minimum valid sell volume per order.
396
+ maxValidSellVolume (int): Maximum valid sell volume per order.
397
+
398
+ canBuy (bool): Indicates whether buying is currently allowed.
399
+ canSell (bool): Indicates whether selling is currently allowed.
400
+
401
+ minAllowedPrice (float): Minimum price allowed for placing an order.
402
+ maxAllowedPrice (float): Maximum price allowed for placing an order.
403
+
404
+ minDealablePrice (float): Minimum price at which a deal can be executed.
405
+ minDealableCount (int): Minimum number of contracts per deal.
406
+
407
+ owner (str): Name of the contract owner or issuing entity.
408
+
409
+ strikePrice (float): Strike price of the option.
410
+ csize (int): Contract size (number of underlying units per option contract).
411
+ optionType (str): Type of the option, e.g., "Call" or "Put".
412
+ ExpirationDate (str): Expiration date of the option in ISO format (YYYY-MM-DD).
413
+ DaysToExpiration (int): Number of days remaining until expiration.
414
+
415
+ UnderlyingAssets_symbolIsin (str): ISIN of the underlying asset.
416
+ UnderlyingAssets_title (str): Title or name of the underlying asset.
417
+ UnderlyingAssets_symbolName (str): Trading symbol of the underlying asset.
418
+ UnderlyingAssets_is_ETF (bool): Indicates whether the underlying asset is an ETF.
419
+
420
+ ExerciseFeePhysical (float): Fee for physical settlement of the option.
421
+ ExerciseFeeCash (float): Fee for cash settlement of the option.
422
+ ExerciseSellTax (float): Tax applied when exercising or selling the option.
423
+
424
+ OpenPositionLimitInstitution (int): Maximum open positions allowed for institutions.
425
+ OpenPositionLimitIndividual (int): Maximum open positions allowed for individuals.
426
+ OpenPositionLimitMarket (int): Maximum open positions allowed for the entire market.
427
+
428
+ dataClass (str): Classification of the data, e.g., "Options", "ETF Options", etc.
429
+
430
+ Example:
431
+ >>> option: StockOptions = {
432
+ ... "symbolIsin": "IROPT123456",
433
+ ... "symbolName": "OPT001",
434
+ ... "title": "HedgeTech Call Option",
435
+ ... "buyCommission": 0.001,
436
+ ... "sellCommission": 0.001,
437
+ ... "minValidBuyVolume": 1,
438
+ ... "maxValidBuyVolume": 50,
439
+ ... "minValidSellVolume": 1,
440
+ ... "maxValidSellVolume": 50,
441
+ ... "canBuy": True,
442
+ ... "canSell": True,
443
+ ... "minAllowedPrice": 1000.0,
444
+ ... "maxAllowedPrice": 200000.0,
445
+ ... "minDealablePrice": 1000.0,
446
+ ... "minDealableCount": 1,
447
+ ... "owner": "HedgeTech",
448
+ ... "strikePrice": 1200.0,
449
+ ... "csize": 100,
450
+ ... "optionType": "Call",
451
+ ... "ExpirationDate": "2025-12-31",
452
+ ... "DaysToExpiration": 42,
453
+ ... "UnderlyingAssets_symbolIsin": "IR0001234567",
454
+ ... "UnderlyingAssets_title": "HedgeTech Growth ETF",
455
+ ... "UnderlyingAssets_symbolName": "ETF001",
456
+ ... "UnderlyingAssets_is_ETF": True,
457
+ ... "ExerciseFeePhysical": 50.0,
458
+ ... "ExerciseFeeCash": 25.0,
459
+ ... "ExerciseSellTax": 5.0,
460
+ ... "OpenPositionLimitInstitution": 1000,
461
+ ... "OpenPositionLimitIndividual": 100,
462
+ ... "OpenPositionLimitMarket": 5000,
463
+ ... "dataClass": "Options"
464
+ ... }
465
+ >>> option["symbolName"]
466
+ 'OPT001'
467
+ >>> option["optionType"]
468
+ 'Call'
469
+ >>> option["DaysToExpiration"]
470
+ 42
471
+ """
472
+ symbolIsin: str
473
+ symbolName: str
474
+ title: str
475
+
476
+ buyCommission: float
477
+ sellCommission: float
478
+
479
+ minValidBuyVolume: int
480
+ maxValidBuyVolume: int
481
+ minValidSellVolume: int
482
+ maxValidSellVolume: int
483
+
484
+ canBuy: bool
485
+ canSell: bool
486
+
487
+ minAllowedPrice: float
488
+ maxAllowedPrice: float
489
+
490
+ minDealablePrice: float
491
+ minDealableCount: int
492
+
493
+ owner: str
494
+
495
+ strikePrice: float
496
+ csize: int
497
+ optionType: str
498
+ ExpirationDate: str
499
+ DaysToExpiration: int
500
+
501
+ UnderlyingAssets_symbolIsin: str
502
+ UnderlyingAssets_title: str
503
+ UnderlyingAssets_symbolName: str
504
+ UnderlyingAssets_is_ETF: bool
505
+
506
+ ExerciseFeePhysical: float
507
+ ExerciseFeeCash: float
508
+ ExerciseSellTax: float
509
+
510
+ OpenPositionLimitInstitution: int
511
+ OpenPositionLimitIndividual: int
512
+ OpenPositionLimitMarket: int
513
+
514
+ dataClass: str
515
+
516
+ # +--------------------------------------------------------------------------------------+ #
517
+
518
+
519
+ class TreasuryBonds(TypedDict):
520
+ """
521
+ Represents detailed metadata for a treasury bond or government-issued debt instrument,
522
+ including trading rules, commissions, limits, settlement, and other attributes needed
523
+ for trading and portfolio management.
524
+
525
+ This TypedDict is typically used in financial systems that handle treasury bonds,
526
+ ETFs, or similar instruments, providing all necessary details for order validation,
527
+ execution, reporting, and risk management.
528
+
529
+ Attributes:
530
+ symbolIsin (str): ISIN code of the treasury bond.
531
+ symbolName (str): Trading symbol of the bond.
532
+ title (str): Human-readable name or title of the bond.
533
+
534
+ buyCommission (float): Commission rate applied when buying the bond.
535
+ sellCommission (float): Commission rate applied when selling the bond.
536
+
537
+ minValidBuyVolume (int): Minimum valid buy volume per order.
538
+ maxValidBuyVolume (int): Maximum valid buy volume per order.
539
+ minValidSellVolume (int): Minimum valid sell volume per order.
540
+ maxValidSellVolume (int): Maximum valid sell volume per order.
541
+
542
+ canBuy (bool): Indicates whether buying is currently allowed.
543
+ canSell (bool): Indicates whether selling is currently allowed.
544
+
545
+ minAllowedPrice (float): Minimum price allowed for placing an order.
546
+ maxAllowedPrice (float): Maximum price allowed for placing an order.
547
+
548
+ baseVol (float): Base trading volume unit of the bond.
549
+ minDealablePrice (float): Minimum price at which a deal can be executed.
550
+ minDealableCount (int): Minimum number of bonds per deal.
551
+
552
+ owner (str): Name of the bond issuer or owner.
553
+ hidePrice (int): Flag indicating if the price should be hidden in the interface (0 or 1).
554
+ is_ETF (bool): Indicates whether the instrument is an ETF.
555
+
556
+ ExpirationDate (str): Expiration date or maturity date of the bond in ISO format (YYYY-MM-DD).
557
+ DaysToExpiration (int): Number of days remaining until expiration or maturity.
558
+
559
+ dataClass (str): Classification of the data, e.g., "TreasuryBond", "ETF Bond", etc.
560
+
561
+ Example:
562
+ >>> bond: TreasuryBonds = {
563
+ ... "symbolIsin": "IRTB1234567",
564
+ ... "symbolName": "TB001",
565
+ ... "title": "HedgeTech Treasury Bond",
566
+ ... "buyCommission": 0.001,
567
+ ... "sellCommission": 0.001,
568
+ ... "minValidBuyVolume": 1,
569
+ ... "maxValidBuyVolume": 1000,
570
+ ... "minValidSellVolume": 1,
571
+ ... "maxValidSellVolume": 1000,
572
+ ... "canBuy": True,
573
+ ... "canSell": True,
574
+ ... "minAllowedPrice": 1000.0,
575
+ ... "maxAllowedPrice": 200000.0,
576
+ ... "baseVol": 1.0,
577
+ ... "minDealablePrice": 1000.0,
578
+ ... "minDealableCount": 1,
579
+ ... "owner": "HedgeTech",
580
+ ... "hidePrice": 0,
581
+ ... "is_ETF": False,
582
+ ... "ExpirationDate": "2030-12-31",
583
+ ... "DaysToExpiration": 1800,
584
+ ... "dataClass": "TreasuryBond"
585
+ ... }
586
+ >>> bond["symbolName"]
587
+ 'TB001'
588
+ >>> bond["is_ETF"]
589
+ False
590
+ >>> bond["DaysToExpiration"]
591
+ 1800
592
+ """
593
+ symbolIsin: str
594
+ symbolName: str
595
+ title: str
596
+
597
+ buyCommission: float
598
+ sellCommission: float
599
+
600
+ minValidBuyVolume: int
601
+ maxValidBuyVolume: int
602
+ minValidSellVolume: int
603
+ maxValidSellVolume: int
604
+
605
+ canBuy: bool
606
+ canSell: bool
607
+
608
+ minAllowedPrice: float
609
+ maxAllowedPrice: float
610
+
611
+ baseVol: float
612
+ minDealablePrice: float
613
+ minDealableCount: int
614
+
615
+ owner: str
616
+ hidePrice: int
617
+ is_ETF: bool
618
+
619
+ ExpirationDate: str
620
+ DaysToExpiration: int
621
+
622
+ dataClass: str
623
+
624
+ # +--------------------------------------------------------------------------------------+ #
625
+
626
+
627
+ class Instruments(TypedDict):
628
+ """
629
+ Represents a complete response containing a list of various financial instruments
630
+ along with the server status metadata.
631
+
632
+ This TypedDict is commonly used to fetch or store all instruments data from an API,
633
+ including equities, ETFs, stock futures, stock options, and treasury bonds. Each
634
+ instrument in the `Data` list can be one of several TypedDict types, providing
635
+ a unified structure for heterogeneous financial instruments.
636
+
637
+ Attributes:
638
+ Data (List[Union[SecuritiesAndFunds, StockFutures, StockOptions, TreasuryBonds, None]]):
639
+ A list containing individual instrument data. Each item can be:
640
+ - SecuritiesAndFunds: For standard securities and ETFs
641
+ - StockFutures: For futures contracts on equities or ETFs
642
+ - StockOptions: For options contracts
643
+ - TreasuryBonds: For government-issued debt instruments
644
+ - None: In case of missing or unavailable data
645
+
646
+ Status (Status): Metadata about the server response, including success state,
647
+ timestamp, version, author, description, and status code.
648
+
649
+ Example:
650
+ >>> instruments: Instruments = {
651
+ ... "Data": [
652
+ ... {
653
+ ... "symbolIsin": "IR0001234567",
654
+ ... "symbolName": "ETF001",
655
+ ... "title": "HedgeTech Growth ETF",
656
+ ... "buyCommission": 0.0015,
657
+ ... "sellCommission": 0.0015,
658
+ ... "minValidBuyVolume": 100,
659
+ ... "maxValidBuyVolume": 10000,
660
+ ... "minValidSellVolume": 100,
661
+ ... "maxValidSellVolume": 10000,
662
+ ... "canBuy": True,
663
+ ... "canSell": True,
664
+ ... "minAllowedPrice": 1000.0,
665
+ ... "maxAllowedPrice": 200000.0,
666
+ ... "is_ETF": True,
667
+ ... "baseVolume": 100.0,
668
+ ... "minDealablePrice": 1000.0,
669
+ ... "minDealableCount": 100,
670
+ ... "owner": "HedgeTech",
671
+ ... "hidePrice": 0,
672
+ ... "dataClass": "ETF"
673
+ ... },
674
+ ... {
675
+ ... "symbolIsin": "IRFUT123456",
676
+ ... "symbolName": "FUT001",
677
+ ... "title": "HedgeTech Equity Futures",
678
+ ... "csize": 100,
679
+ ... "firstMargin": 5000.0,
680
+ ... "minimumMargin": 2500.0,
681
+ ... "UnderlyingAssets_symbolIsin": "IR0001234567",
682
+ ... "UnderlyingAssets_title": "HedgeTech Growth ETF",
683
+ ... "UnderlyingAssets_symbolName": "ETF001",
684
+ ... "UnderlyingAssets_is_ETF": True,
685
+ ... "roundFactor": 10,
686
+ ... "ExpirationDate": "2025-12-31",
687
+ ... "DaysToExpiration": 42,
688
+ ... "buyCommission": 0.001,
689
+ ... "sellCommission": 0.001,
690
+ ... "minValidBuyVolume": 1,
691
+ ... "maxValidBuyVolume": 100,
692
+ ... "minValidSellVolume": 1,
693
+ ... "maxValidSellVolume": 100,
694
+ ... "canBuy": True,
695
+ ... "canSell": True,
696
+ ... "minAllowedPrice": 1000.0,
697
+ ... "maxAllowedPrice": 200000.0,
698
+ ... "minDealableCount": 1,
699
+ ... "minDealablePrice": 1000.0,
700
+ ... "owner": "HedgeTech",
701
+ ... "ExerciseFeePhysical": 50.0,
702
+ ... "ExerciseFeeCash": 25.0,
703
+ ... "ExerciseSellTax": 5.0,
704
+ ... "OpenPositionLimitInstitution": 1000,
705
+ ... "OpenPositionLimitIndividual": 100,
706
+ ... "OpenPositionLimitMarket": 5000,
707
+ ... "dataClass": "Futures"
708
+ ... }
709
+ ... ],
710
+ ... "Status": {
711
+ ... "State": True,
712
+ ... "ServerTimeStamp": 1700350200.0,
713
+ ... "Version": "1.2.3",
714
+ ... "Author": "HedgeTech",
715
+ ... "Description": {"fa": "عملیات موفقیت‌آمیز بود", "en": "Operation successful"},
716
+ ... "StatusCode": 200
717
+ ... }
718
+ ... }
719
+ >>> instruments["Data"][0]["symbolName"]
720
+ 'ETF001'
721
+ >>> instruments["Status"]["State"]
722
+ True
723
+ """
724
+ Data: List[
725
+ Union[
726
+ SecuritiesAndFunds,
727
+ StockFutures,
728
+ StockOptions,
729
+ TreasuryBonds,
730
+ None
731
+ ]
732
+ ]
733
+ Status: Status
734
+
735
+ # +--------------------------------------------------------------------------------------+ #
736
+
737
+
738
+ class BestLimitItem(TypedDict):
739
+ """
740
+ Represents the best limit order information at a given price level for a financial instrument.
741
+
742
+ Attributes:
743
+ buy_order_count (int): Number of active buy orders at this price level.
744
+ buy_quantity (int): Total quantity available for buying at this price level.
745
+ buy_price (int): Price level for buy orders.
746
+ sell_order_count (int): Number of active sell orders at this price level.
747
+ sell_quantity (int): Total quantity available for selling at this price level.
748
+ sell_price (int): Price level for sell orders.
749
+
750
+ Example:
751
+ >>> item: BestLimitItem = {
752
+ ... "buy_order_count": 5,
753
+ ... "buy_quantity": 1000,
754
+ ... "buy_price": 12000,
755
+ ... "sell_order_count": 3,
756
+ ... "sell_quantity": 800,
757
+ ... "sell_price": 12100
758
+ ... }
759
+ >>> item["buy_price"]
760
+ 12000
761
+ """
762
+ buy_order_count: int
763
+ buy_quantity: int
764
+ buy_price: int
765
+ sell_order_count: int
766
+ sell_quantity: int
767
+ sell_price: int
768
+
769
+
770
+ class BestLimit(TypedDict):
771
+ """
772
+ Represents the aggregated best limit orders for multiple instruments.
773
+
774
+ The structure is a nested dictionary where the first key is typically a symbol
775
+ identifier (ISIN or symbolName) and the second key represents the order level or priority.
776
+
777
+ Attributes:
778
+ items (Dict[str, Dict[str, BestLimitItem]]): Nested dictionary of BestLimitItem objects.
779
+ - Outer key: Instrument identifier (e.g., ISIN or symbolName)
780
+ - Inner key: Price level or order priority
781
+ - Value: BestLimitItem for that level
782
+
783
+ Example:
784
+ >>> best_limit: BestLimit = {
785
+ ... "ETF001": {
786
+ ... "1": {
787
+ ... "buy_order_count": 5,
788
+ ... "buy_quantity": 1000,
789
+ ... "buy_price": 12000,
790
+ ... "sell_order_count": 3,
791
+ ... "sell_quantity": 800,
792
+ ... "sell_price": 12100
793
+ ... }
794
+ ... }
795
+ ... }
796
+ >>> best_limit["ETF001"]["1"]["sell_quantity"]
797
+ 800
798
+ """
799
+ items: Dict[str, Dict[str, BestLimitItem]]
800
+
801
+
802
+ class BestLimitResponse(TypedDict):
803
+ """
804
+ Response structure for best limit orders from a REST API call.
805
+
806
+ Attributes:
807
+ Data (BestLimit): Aggregated best limit order data.
808
+ Status (Status): Metadata about the server response, including success state,
809
+ timestamp, version, author, description, and status code.
810
+
811
+ Example:
812
+ >>> response: BestLimitResponse = {
813
+ ... "Data": best_limit,
814
+ ... "Status": {
815
+ ... "State": True,
816
+ ... "ServerTimeStamp": 1700350200.0,
817
+ ... "Version": "1.2.3",
818
+ ... "Author": "HedgeTech",
819
+ ... "Description": {"fa": "عملیات موفقیت‌آمیز بود", "en": "Operation successful"},
820
+ ... "StatusCode": 200
821
+ ... }
822
+ ... }
823
+ >>> response["Data"]["ETF001"]["1"]["buy_quantity"]
824
+ 1000
825
+ >>> response["Status"]["State"]
826
+ True
827
+ """
828
+ Data: BestLimit
829
+ Status: Status
830
+
831
+
832
+ class BestLimit_WS_symbolIsin(WebsocketBase_symbolIsin):
833
+ """
834
+ Websocket message structure for best limit orders identified by ISIN.
835
+
836
+ This TypedDict extends `WebsocketBase_symbolIsin` and represents real-time best
837
+ limit order updates for a specific instrument identified by its ISIN.
838
+
839
+ Attributes:
840
+ data (Dict[str, BestLimitItem]): Dictionary mapping price levels or order priorities
841
+ to BestLimitItem objects for the instrument.
842
+
843
+ Example:
844
+ >>> ws_data: BestLimit_WS_symbolIsin = {
845
+ ... "channel": "best_limit_updates",
846
+ ... "symbolIsin": "IR0001234567",
847
+ ... "timestamp": "2025-11-19T10:30:00Z",
848
+ ... "data": {
849
+ ... "1": {
850
+ ... "buy_order_count": 5,
851
+ ... "buy_quantity": 1000,
852
+ ... "buy_price": 12000,
853
+ ... "sell_order_count": 3,
854
+ ... "sell_quantity": 800,
855
+ ... "sell_price": 12100
856
+ ... },
857
+ ... "2": {
858
+ ... "buy_order_count": 4,
859
+ ... "buy_quantity": 500,
860
+ ... "buy_price": 11950,
861
+ ... "sell_order_count": 2,
862
+ ... "sell_quantity": 600,
863
+ ... "sell_price": 12150
864
+ ... }
865
+ ... }
866
+ ... }
867
+ >>> ws_data["data"]["1"]["sell_price"]
868
+ 12100
869
+ """
870
+ data: Dict[str, BestLimitItem]
871
+
872
+
873
+ class BestLimit_WS_symbolName(WebsocketBase_symbolName):
874
+ """
875
+ Websocket message structure for best limit orders identified by symbol name.
876
+
877
+ This TypedDict extends `WebsocketBase_symbolName` and represents real-time best
878
+ limit order updates for a specific instrument identified by its trading symbol.
879
+
880
+ Attributes:
881
+ data (Dict[str, BestLimitItem]): Dictionary mapping price levels or order priorities
882
+ to BestLimitItem objects for the instrument.
883
+
884
+ Example:
885
+ >>> ws_data: BestLimit_WS_symbolName = {
886
+ ... "channel": "best_limit_updates",
887
+ ... "symbolName": "ETF001",
888
+ ... "timestamp": "2025-11-19T10:30:00Z",
889
+ ... "data": {
890
+ ... "1": {
891
+ ... "buy_order_count": 5,
892
+ ... "buy_quantity": 1000,
893
+ ... "buy_price": 12000,
894
+ ... "sell_order_count": 3,
895
+ ... "sell_quantity": 800,
896
+ ... "sell_price": 12100
897
+ ... },
898
+ ... "2": {
899
+ ... "buy_order_count": 4,
900
+ ... "buy_quantity": 500,
901
+ ... "buy_price": 11950,
902
+ ... "sell_order_count": 2,
903
+ ... "sell_quantity": 600,
904
+ ... "sell_price": 12150
905
+ ... }
906
+ ... }
907
+ ... }
908
+ >>> ws_data["data"]["2"]["buy_price"]
909
+ 11950
910
+ """
911
+ data: Dict[str, BestLimitItem]
912
+
913
+ # +--------------------------------------------------------------------------------------+ #
914
+
915
+
916
+ class OrderItem(TypedDict):
917
+ """
918
+ Represents a single order entry in the order book.
919
+
920
+ Attributes:
921
+ price (float): Price level of the order.
922
+ quantity (int): Total quantity available at this price level.
923
+ count (int): Number of orders at this price level.
924
+
925
+ Example:
926
+ >>> order: OrderItem = {
927
+ ... "price": 12000.0,
928
+ ... "quantity": 500,
929
+ ... "count": 3
930
+ ... }
931
+ >>> order["price"]
932
+ 12000.0
933
+ """
934
+ price: float
935
+ quantity: int
936
+ count: int
937
+
938
+
939
+ class OrderBook(TypedDict):
940
+ """
941
+ Represents the full order book for a single financial instrument.
942
+
943
+ Attributes:
944
+ Buy (List[OrderItem]): List of buy orders, usually sorted by descending price.
945
+ Sell (List[OrderItem]): List of sell orders, usually sorted by ascending price.
946
+
947
+ Example:
948
+ >>> book: OrderBook = {
949
+ ... "Buy": [{"price": 12000.0, "quantity": 500, "count": 3}],
950
+ ... "Sell": [{"price": 12100.0, "quantity": 400, "count": 2}]
951
+ ... }
952
+ >>> book["Sell"][0]["quantity"]
953
+ 400
954
+ """
955
+ Buy: List[OrderItem]
956
+ Sell: List[OrderItem]
957
+
958
+
959
+ class OrderBookResponse(TypedDict):
960
+ """
961
+ Response structure for order book data from a REST API call.
962
+
963
+ Attributes:
964
+ Data (Dict[str, OrderBook]): Dictionary mapping instrument identifiers (ISIN or symbolName)
965
+ to their respective order book.
966
+ Status (Status): Metadata about the server response, including success state,
967
+ timestamp, version, author, description, and status code.
968
+
969
+ Example:
970
+ >>> response: OrderBookResponse = {
971
+ ... "Data": {
972
+ ... "IR0001234567": {
973
+ ... "Buy": [{"price": 12000.0, "quantity": 500, "count": 3}],
974
+ ... "Sell": [{"price": 12100.0, "quantity": 400, "count": 2}]
975
+ ... }
976
+ ... },
977
+ ... "Status": {
978
+ ... "State": True,
979
+ ... "ServerTimeStamp": 1700350200.0,
980
+ ... "Version": "1.2.3",
981
+ ... "Author": "HedgeTech",
982
+ ... "Description": {"fa": "عملیات موفقیت‌آمیز بود", "en": "Operation successful"},
983
+ ... "StatusCode": 200
984
+ ... }
985
+ ... }
986
+ >>> response["Data"]["IR0001234567"]["Buy"][0]["price"]
987
+ 12000.0
988
+ >>> response["Status"]["State"]
989
+ True
990
+ """
991
+ Data: Dict[str, OrderBook]
992
+ Status: Status
993
+
994
+
995
+ class OrderBook_WS_symbolIsin(WebsocketBase_symbolIsin):
996
+ """
997
+ Websocket message structure for order book updates identified by ISIN.
998
+
999
+ Attributes:
1000
+ data (OrderBook): Real-time order book for the specified instrument.
1001
+
1002
+ Example:
1003
+ >>> ws_data: OrderBook_WS_symbolIsin = {
1004
+ ... "channel": "order_book_updates",
1005
+ ... "symbolIsin": "IR0001234567",
1006
+ ... "timestamp": "2025-11-19T10:30:00Z",
1007
+ ... "data": {
1008
+ ... "Buy": [{"price": 12000.0, "quantity": 500, "count": 3}],
1009
+ ... "Sell": [{"price": 12100.0, "quantity": 400, "count": 2}]
1010
+ ... }
1011
+ ... }
1012
+ >>> ws_data["data"]["Buy"][0]["price"]
1013
+ 12000.0
1014
+ """
1015
+ data: OrderBook
1016
+
1017
+
1018
+ class OrderBook_WS_symbolName(WebsocketBase_symbolName):
1019
+ """
1020
+ Websocket message structure for order book updates identified by symbol name.
1021
+
1022
+ Attributes:
1023
+ data (OrderBook): Real-time order book for the specified instrument.
1024
+
1025
+ Example:
1026
+ >>> ws_data: OrderBook_WS_symbolName = {
1027
+ ... "channel": "order_book_updates",
1028
+ ... "symbolName": "ETF001",
1029
+ ... "timestamp": "2025-11-19T10:30:00Z",
1030
+ ... "data": {
1031
+ ... "Buy": [{"price": 12000.0, "quantity": 500, "count": 3}],
1032
+ ... "Sell": [{"price": 12100.0, "quantity": 400, "count": 2}]
1033
+ ... }
1034
+ ... }
1035
+ >>> ws_data["data"]["Sell"][0]["quantity"]
1036
+ 400
1037
+ """
1038
+ data: OrderBook
1039
+
1040
+ # +--------------------------------------------------------------------------------------+ #
1041
+
1042
+
1043
+
1044
+ class Aggregate(TypedDict):
1045
+ """
1046
+ Represents aggregated market data for a single financial instrument over a given period.
1047
+
1048
+ This includes trade statistics, volume, value, and price information.
1049
+
1050
+ Attributes:
1051
+ date (str): Date of the aggregation in ISO format (YYYY-MM-DD).
1052
+ time (str): Time of the aggregation in HH:MM:SS format.
1053
+ trade_count (int): Number of trades executed during this period.
1054
+ total_volume (int): Total traded volume.
1055
+ total_value (int): Total traded value (sum of price * quantity).
1056
+ closing_price (float): Closing price at the end of the period.
1057
+ last_price (float): Last traded price.
1058
+ low_price (float): Lowest price during the period.
1059
+ high_price (float): Highest price during the period.
1060
+ open_price (float): Opening price at the start of the period.
1061
+ previous_close (float): Closing price from the previous trading period.
1062
+
1063
+ Example:
1064
+ >>> agg: Aggregate = {
1065
+ ... "date": "2025-11-19",
1066
+ ... "time": "10:30:00",
1067
+ ... "trade_count": 120,
1068
+ ... "total_volume": 5000,
1069
+ ... "total_value": 60000000,
1070
+ ... "closing_price": 12000.0,
1071
+ ... "last_price": 12100.0,
1072
+ ... "low_price": 11950.0,
1073
+ ... "high_price": 12150.0,
1074
+ ... "open_price": 12050.0,
1075
+ ... "previous_close": 11980.0
1076
+ ... }
1077
+ >>> agg["closing_price"]
1078
+ 12000.0
1079
+ """
1080
+ date: str
1081
+ time: str
1082
+ trade_count: int
1083
+ total_volume: int
1084
+ total_value: int
1085
+ closing_price: float
1086
+ last_price: float
1087
+ low_price: float
1088
+ high_price: float
1089
+ open_price: float
1090
+ previous_close: float
1091
+
1092
+
1093
+ class AggregateResponse(TypedDict):
1094
+ """
1095
+ Response structure for aggregated market data from a REST API call.
1096
+
1097
+ Attributes:
1098
+ Data (Dict[str, Aggregate]): Dictionary mapping instrument identifiers (ISIN or symbolName)
1099
+ to their corresponding aggregated data.
1100
+ Status (Status): Metadata about the server response, including success state,
1101
+ timestamp, version, author, description, and status code.
1102
+
1103
+ Example:
1104
+ >>> response: AggregateResponse = {
1105
+ ... "Data": {
1106
+ ... "IR0001234567": agg
1107
+ ... },
1108
+ ... "Status": {
1109
+ ... "State": True,
1110
+ ... "ServerTimeStamp": 1700350200.0,
1111
+ ... "Version": "1.2.3",
1112
+ ... "Author": "HedgeTech",
1113
+ ... "Description": {"fa": "عملیات موفقیت‌آمیز بود", "en": "Operation successful"},
1114
+ ... "StatusCode": 200
1115
+ ... }
1116
+ ... }
1117
+ >>> response["Data"]["IR0001234567"]["last_price"]
1118
+ 12100.0
1119
+ >>> response["Status"]["State"]
1120
+ True
1121
+ """
1122
+ Data: Dict[str, Aggregate]
1123
+ Status: Status
1124
+
1125
+
1126
+ class Aggregate_WS_symbolIsin(WebsocketBase_symbolIsin):
1127
+ """
1128
+ Websocket message structure for aggregated market data identified by ISIN.
1129
+
1130
+ Attributes:
1131
+ data (Aggregate): Real-time aggregated data for the specified instrument.
1132
+
1133
+ Example:
1134
+ >>> ws_data: Aggregate_WS_symbolIsin = {
1135
+ ... "channel": "aggregate_updates",
1136
+ ... "symbolIsin": "IR0001234567",
1137
+ ... "timestamp": "2025-11-19T10:30:00Z",
1138
+ ... "data": agg
1139
+ ... }
1140
+ >>> ws_data["data"]["high_price"]
1141
+ 12150.0
1142
+ """
1143
+ data: Aggregate
1144
+
1145
+
1146
+ class Aggregate_WS_symbolName(WebsocketBase_symbolName):
1147
+ """
1148
+ Websocket message structure for aggregated market data identified by symbol name.
1149
+
1150
+ Attributes:
1151
+ data (Aggregate): Real-time aggregated data for the specified instrument.
1152
+
1153
+ Example:
1154
+ >>> ws_data: Aggregate_WS_symbolName = {
1155
+ ... "channel": "aggregate_updates",
1156
+ ... "symbolName": "ETF001",
1157
+ ... "timestamp": "2025-11-19T10:30:00Z",
1158
+ ... "data": agg
1159
+ ... }
1160
+ >>> ws_data["data"]["total_volume"]
1161
+ 5000
1162
+ """
1163
+ data: Aggregate
1164
+
1165
+ # +--------------------------------------------------------------------------------------+ #
1166
+
1167
+
1168
+ class institutional_vs_individual(TypedDict):
1169
+ """
1170
+ Represents the breakdown of buy and sell activity between individual and institutional traders
1171
+ for a specific financial instrument.
1172
+
1173
+ Attributes:
1174
+ buy_count_individual (int): Number of buy orders placed by individual traders.
1175
+ buy_volume_individual (int): Total volume bought by individual traders.
1176
+ buy_count_institution (int): Number of buy orders placed by institutional traders.
1177
+ buy_volume_institution (int): Total volume bought by institutional traders.
1178
+ sell_count_individual (int): Number of sell orders placed by individual traders.
1179
+ sell_volume_individual (int): Total volume sold by individual traders.
1180
+ sell_count_institution (int): Number of sell orders placed by institutional traders.
1181
+ sell_volume_institution (int): Total volume sold by institutional traders.
1182
+
1183
+ Example:
1184
+ >>> trades: institutional_vs_individual = {
1185
+ ... "buy_count_individual": 120,
1186
+ ... "buy_volume_individual": 5000,
1187
+ ... "buy_count_institution": 45,
1188
+ ... "buy_volume_institution": 10000,
1189
+ ... "sell_count_individual": 100,
1190
+ ... "sell_volume_individual": 4000,
1191
+ ... "sell_count_institution": 50,
1192
+ ... "sell_volume_institution": 9000
1193
+ ... }
1194
+ >>> trades["buy_volume_institution"]
1195
+ 10000
1196
+ """
1197
+ buy_count_individual: int
1198
+ buy_volume_individual: int
1199
+ buy_count_institution: int
1200
+ buy_volume_institution: int
1201
+ sell_count_individual: int
1202
+ sell_volume_individual: int
1203
+ sell_count_institution: int
1204
+ sell_volume_institution: int
1205
+
1206
+
1207
+ class Institutional_vs_IndividualItemResponse(TypedDict):
1208
+ """
1209
+ Response structure for institutional vs individual trading data from a REST API call.
1210
+
1211
+ Attributes:
1212
+ Data (Dict[str, institutional_vs_individual]): Dictionary mapping instrument identifiers
1213
+ (ISIN or symbolName) to their corresponding buy/sell breakdown.
1214
+ Status (Status): Metadata about the server response, including success state,
1215
+ timestamp, version, author, description, and status code.
1216
+
1217
+ Example:
1218
+ >>> response: Institutional_vs_IndividualItemResponse = {
1219
+ ... "Data": {"IR0001234567": trades},
1220
+ ... "Status": {
1221
+ ... "State": True,
1222
+ ... "ServerTimeStamp": 1700350200.0,
1223
+ ... "Version": "1.2.3",
1224
+ ... "Author": "HedgeTech",
1225
+ ... "Description": {"fa": "عملیات موفقیت‌آمیز بود", "en": "Operation successful"},
1226
+ ... "StatusCode": 200
1227
+ ... }
1228
+ ... }
1229
+ >>> response["Data"]["IR0001234567"]["sell_volume_individual"]
1230
+ 4000
1231
+ >>> response["Status"]["State"]
1232
+ True
1233
+ """
1234
+ Data: Dict[str, institutional_vs_individual]
1235
+ Status: Status
1236
+
1237
+
1238
+ class institutional_vs_individual_WS_symbolIsin(WebsocketBase_symbolIsin):
1239
+ """
1240
+ Websocket message structure for institutional vs individual trading data identified by ISIN.
1241
+
1242
+ Attributes:
1243
+ data (institutional_vs_individual): Real-time breakdown of buy/sell activity for
1244
+ individual and institutional traders.
1245
+
1246
+ Example:
1247
+ >>> ws_data: institutional_vs_individual_WS_symbolIsin = {
1248
+ ... "channel": "inst_vs_ind_updates",
1249
+ ... "symbolIsin": "IR0001234567",
1250
+ ... "timestamp": "2025-11-19T10:30:00Z",
1251
+ ... "data": trades
1252
+ ... }
1253
+ >>> ws_data["data"]["buy_count_individual"]
1254
+ 120
1255
+ """
1256
+ data: institutional_vs_individual
1257
+
1258
+
1259
+ class institutional_vs_individual_WS_symbolName(WebsocketBase_symbolName):
1260
+ """
1261
+ Websocket message structure for institutional vs individual trading data identified by symbol name.
1262
+
1263
+ Attributes:
1264
+ data (institutional_vs_individual): Real-time breakdown of buy/sell activity for
1265
+ individual and institutional traders.
1266
+
1267
+ Example:
1268
+ >>> ws_data: institutional_vs_individual_WS_symbolName = {
1269
+ ... "channel": "inst_vs_ind_updates",
1270
+ ... "symbolName": "ETF001",
1271
+ ... "timestamp": "2025-11-19T10:30:00Z",
1272
+ ... "data": trades
1273
+ ... }
1274
+ >>> ws_data["data"]["sell_count_institution"]
1275
+ 50
1276
+ """
1277
+ data: institutional_vs_individual
1278
+
1279
+ # +--------------------------------------------------------------------------------------+ #
1280
+
1281
+
1282
+ class ContractInfo(TypedDict):
1283
+ """
1284
+ Represents key contract information for derivatives, including open interest and margin requirements.
1285
+
1286
+ Attributes:
1287
+ open_interest (int): Total number of outstanding contracts that have not been settled.
1288
+ initial_margin (int): Margin required to open a new position.
1289
+ required_margin (int): Margin required to maintain an existing position.
1290
+
1291
+ Example:
1292
+ >>> contract: ContractInfo = {
1293
+ ... "open_interest": 1200,
1294
+ ... "initial_margin": 5000,
1295
+ ... "required_margin": 4500
1296
+ ... }
1297
+ >>> contract["open_interest"]
1298
+ 1200
1299
+ """
1300
+ open_interest: int
1301
+ initial_margin: int
1302
+ required_margin: int
1303
+
1304
+
1305
+ class ContractInfoResponse(TypedDict):
1306
+ """
1307
+ Response structure for contract information from a REST API call.
1308
+
1309
+ Attributes:
1310
+ Data (Dict[str, ContractInfo]): Dictionary mapping instrument identifiers (ISIN or symbolName)
1311
+ to their corresponding contract information.
1312
+ Status (Status): Metadata about the server response, including success state,
1313
+ timestamp, version, author, description, and status code.
1314
+
1315
+ Example:
1316
+ >>> response: ContractInfoResponse = {
1317
+ ... "Data": {"IRFUT123456": contract},
1318
+ ... "Status": {
1319
+ ... "State": True,
1320
+ ... "ServerTimeStamp": 1700350200.0,
1321
+ ... "Version": "1.2.3",
1322
+ ... "Author": "HedgeTech",
1323
+ ... "Description": {"fa": "عملیات موفقیت‌آمیز بود", "en": "Operation successful"},
1324
+ ... "StatusCode": 200
1325
+ ... }
1326
+ ... }
1327
+ >>> response["Data"]["IRFUT123456"]["initial_margin"]
1328
+ 5000
1329
+ >>> response["Status"]["State"]
1330
+ True
1331
+ """
1332
+ Data: Dict[str, ContractInfo]
1333
+ Status: Status
1334
+
1335
+
1336
+ class ContractInfo_WS_symbolIsin(WebsocketBase_symbolIsin):
1337
+ """
1338
+ Websocket message structure for contract information updates identified by ISIN.
1339
+
1340
+ Attributes:
1341
+ data (ContractInfo): Real-time contract information for the specified instrument.
1342
+
1343
+ Example:
1344
+ >>> ws_data: ContractInfo_WS_symbolIsin = {
1345
+ ... "channel": "contract_info_updates",
1346
+ ... "symbolIsin": "IRFUT123456",
1347
+ ... "timestamp": "2025-11-19T10:30:00Z",
1348
+ ... "data": contract
1349
+ ... }
1350
+ >>> ws_data["data"]["required_margin"]
1351
+ 4500
1352
+ """
1353
+ data: ContractInfo
1354
+
1355
+
1356
+ class ContractInfo_WS_symbolName(WebsocketBase_symbolName):
1357
+ """
1358
+ Websocket message structure for contract information updates identified by symbol name.
1359
+
1360
+ Attributes:
1361
+ data (ContractInfo): Real-time contract information for the specified instrument.
1362
+
1363
+ Example:
1364
+ >>> ws_data: ContractInfo_WS_symbolName = {
1365
+ ... "channel": "contract_info_updates",
1366
+ ... "symbolName": "FUT001",
1367
+ ... "timestamp": "2025-11-19T10:30:00Z",
1368
+ ... "data": contract
1369
+ ... }
1370
+ >>> ws_data["data"]["open_interest"]
1371
+ 1200
1372
+ """
1373
+ data: ContractInfo
1374
+
1375
+ # +--------------------------------------------------------------------------------------+ #
1376
+
1377
+
1378
+ class FundInfo(TypedDict):
1379
+ """
1380
+ Represents key information about a fund, including its net asset value, total units,
1381
+ market capitalization, and the timestamp of the data.
1382
+
1383
+ Attributes:
1384
+ nav (float): Net Asset Value of the fund per unit.
1385
+ units (int): Total number of fund units outstanding.
1386
+ marketCap (int): Total market capitalization of the fund.
1387
+ as_of (datetime): Timestamp indicating when the data was recorded.
1388
+
1389
+ Example:
1390
+ >>> fund: FundInfo = {
1391
+ ... "nav": 12500.0,
1392
+ ... "units": 100000,
1393
+ ... "marketCap": 1250000000,
1394
+ ... "as_of": datetime(2025, 11, 19, 10, 30)
1395
+ ... }
1396
+ >>> fund["nav"]
1397
+ 12500.0
1398
+ """
1399
+ nav: float
1400
+ units: int
1401
+ marketCap: int
1402
+ as_of: datetime
1403
+
1404
+
1405
+ class FundInfoResponse(TypedDict):
1406
+ """
1407
+ Response structure for fund information from a REST API call.
1408
+
1409
+ Attributes:
1410
+ Data (Dict[str, FundInfo]): Dictionary mapping fund identifiers (ISIN or symbolName)
1411
+ to their corresponding FundInfo.
1412
+ Status (Status): Metadata about the server response, including success state,
1413
+ timestamp, version, author, description, and status code.
1414
+
1415
+ Example:
1416
+ >>> response: FundInfoResponse = {
1417
+ ... "Data": {"IRFND123456": fund},
1418
+ ... "Status": {
1419
+ ... "State": True,
1420
+ ... "ServerTimeStamp": 1700350200.0,
1421
+ ... "Version": "1.2.3",
1422
+ ... "Author": "HedgeTech",
1423
+ ... "Description": {"fa": "عملیات موفقیت‌آمیز بود", "en": "Operation successful"},
1424
+ ... "StatusCode": 200
1425
+ ... }
1426
+ ... }
1427
+ >>> response["Data"]["IRFND123456"]["marketCap"]
1428
+ 1250000000
1429
+ >>> response["Status"]["State"]
1430
+ True
1431
+ """
1432
+ Data: Dict[str, FundInfo]
1433
+ Status: Status
1434
+
1435
+
1436
+ class FundInfo_WS_symbolIsin(WebsocketBase_symbolIsin):
1437
+ """
1438
+ Websocket message structure for fund information updates identified by ISIN.
1439
+
1440
+ Attributes:
1441
+ data (FundInfo): Real-time fund information for the specified fund.
1442
+
1443
+ Example:
1444
+ >>> ws_data: FundInfo_WS_symbolIsin = {
1445
+ ... "channel": "fund_info_updates",
1446
+ ... "symbolIsin": "IRFND123456",
1447
+ ... "timestamp": "2025-11-19T10:30:00Z",
1448
+ ... "data": fund
1449
+ ... }
1450
+ >>> ws_data["data"]["units"]
1451
+ 100000
1452
+ """
1453
+ data: FundInfo
1454
+
1455
+
1456
+ class FundInfo_WS_symbolName(WebsocketBase_symbolName):
1457
+ """
1458
+ Websocket message structure for fund information updates identified by symbol name.
1459
+
1460
+ Attributes:
1461
+ data (FundInfo): Real-time fund information for the specified fund.
1462
+
1463
+ Example:
1464
+ >>> ws_data: FundInfo_WS_symbolName = {
1465
+ ... "channel": "fund_info_updates",
1466
+ ... "symbolName": "FND001",
1467
+ ... "timestamp": "2025-11-19T10:30:00Z",
1468
+ ... "data": fund
1469
+ ... }
1470
+ >>> ws_data["data"]["nav"]
1471
+ 12500.0
1472
+ """
1473
+ data: FundInfo
1474
+
1475
+ # +--------------------------------------------------------------------------------------+ #
1476
+
1477
+
1478
+ class OHLCV_live(TypedDict):
1479
+ """
1480
+ Represents live OHLCV (Open, High, Low, Close, Volume) data for a financial instrument.
1481
+
1482
+ Attributes:
1483
+ open (float): Opening price of the instrument for the current interval.
1484
+ high (float): Highest price reached during the interval.
1485
+ low (float): Lowest price reached during the interval.
1486
+ close (float): Last traded price (closing price) during the interval.
1487
+ volume (int): Total traded volume during the interval.
1488
+
1489
+ Example:
1490
+ >>> ohlcv: OHLCV_live = {
1491
+ ... "open": 12000.0,
1492
+ ... "high": 12150.0,
1493
+ ... "low": 11950.0,
1494
+ ... "close": 12100.0,
1495
+ ... "volume": 5000
1496
+ ... }
1497
+ >>> ohlcv["high"]
1498
+ 12150.0
1499
+ """
1500
+ open: float
1501
+ high: float
1502
+ low: float
1503
+ close: float
1504
+ volume: int
1505
+
1506
+
1507
+ class OHLCVLast1mResponse(TypedDict):
1508
+ """
1509
+ Response structure for the latest 1-minute OHLCV data from a REST API call.
1510
+
1511
+ Attributes:
1512
+ Data (Dict[str, OHLCV_live]): Dictionary mapping instrument identifiers (ISIN or symbolName)
1513
+ to their corresponding OHLCV_live data.
1514
+ Status (Status): Metadata about the server response, including success state,
1515
+ timestamp, version, author, description, and status code.
1516
+
1517
+ Example:
1518
+ >>> response: OHLCVLast1mResponse = {
1519
+ ... "Data": {"IR0001234567": ohlcv},
1520
+ ... "Status": {
1521
+ ... "State": True,
1522
+ ... "ServerTimeStamp": 1700350200.0,
1523
+ ... "Version": "1.2.3",
1524
+ ... "Author": "HedgeTech",
1525
+ ... "Description": {"fa": "عملیات موفقیت‌آمیز بود", "en": "Operation successful"},
1526
+ ... "StatusCode": 200
1527
+ ... }
1528
+ ... }
1529
+ >>> response["Data"]["IR0001234567"]["volume"]
1530
+ 5000
1531
+ >>> response["Status"]["State"]
1532
+ True
1533
+ """
1534
+ Data: Dict[str, OHLCV_live]
1535
+ Status: Status
1536
+
1537
+
1538
+ class OHLCV_WS_symbolIsin(WebsocketBase_symbolIsin):
1539
+ """
1540
+ Websocket message structure for live OHLCV updates identified by ISIN.
1541
+
1542
+ Attributes:
1543
+ data (OHLCV_live): Real-time OHLCV data for the specified instrument.
1544
+
1545
+ Example:
1546
+ >>> ws_data: OHLCV_WS_symbolIsin = {
1547
+ ... "channel": "ohlcv_updates",
1548
+ ... "symbolIsin": "IR0001234567",
1549
+ ... "timestamp": "2025-11-19T10:30:00Z",
1550
+ ... "data": ohlcv
1551
+ ... }
1552
+ >>> ws_data["data"]["close"]
1553
+ 12100.0
1554
+ """
1555
+ data: OHLCV_live
1556
+
1557
+
1558
+ class OHLCV_WS_symbolName(WebsocketBase_symbolName):
1559
+ """
1560
+ Websocket message structure for live OHLCV updates identified by symbol name.
1561
+
1562
+ Attributes:
1563
+ data (OHLCV_live): Real-time OHLCV data for the specified instrument.
1564
+
1565
+ Example:
1566
+ >>> ws_data: OHLCV_WS_symbolName = {
1567
+ ... "channel": "ohlcv_updates",
1568
+ ... "symbolName": "ETF001",
1569
+ ... "timestamp": "2025-11-19T10:30:00Z",
1570
+ ... "data": ohlcv
1571
+ ... }
1572
+ >>> ws_data["data"]["low"]
1573
+ 11950.0
1574
+ """
1575
+ data: OHLCV_live
1576
+
1577
+
1578
+ # +--------------------------------------------------------------------------------------+ #
1579
+
1580
+
1581
+ class OverviewSecuritiesAndFunds(SecuritiesAndFunds):
1582
+ """
1583
+ Overview of a security or fund instrument including best limit orders, aggregated market data,
1584
+ trading breakdown by individual vs institutional investors, fund info, and contract info.
1585
+
1586
+ Inherits from `SecuritiesAndFunds` and extends it with additional real-time and aggregated metrics.
1587
+
1588
+ Attributes:
1589
+ BestLimit (Dict[str, BestLimitItem]): Best limit orders for this instrument by price level.
1590
+ Aggregate (Aggregate): Aggregated trading statistics for this instrument.
1591
+ institutional_vs_individual (institutional_vs_individual): Buy/sell activity breakdown
1592
+ between individual and institutional traders.
1593
+ FundInfo (FundInfo): Net asset value, total units, and market capitalization.
1594
+ ContractInfo (ContractInfo): Derivatives contract data (if applicable).
1595
+
1596
+ Example:
1597
+ >>> overview: OverviewSecuritiesAndFunds = {
1598
+ ... "symbolIsin": "IR0001234567",
1599
+ ... "symbolName": "ETF001",
1600
+ ... "title": "Example ETF",
1601
+ ... "buyCommission": 0.001,
1602
+ ... "sellCommission": 0.001,
1603
+ ... "minValidBuyVolume": 1,
1604
+ ... "maxValidBuyVolume": 1000,
1605
+ ... "minValidSellVolume": 1,
1606
+ ... "maxValidSellVolume": 1000,
1607
+ ... "canBuy": True,
1608
+ ... "canSell": True,
1609
+ ... "minAllowedPrice": 10000,
1610
+ ... "maxAllowedPrice": 20000,
1611
+ ... "is_ETF": True,
1612
+ ... "baseVolume": 1,
1613
+ ... "minDealablePrice": 10000,
1614
+ ... "minDealableCount": 1,
1615
+ ... "owner": "Market",
1616
+ ... "hidePrice": 0,
1617
+ ... "dataClass": "SecuritiesAndFunds",
1618
+ ... "BestLimit": {"1": {"buy_order_count": 5, "buy_quantity": 1000, "buy_price": 12000, "sell_order_count": 3, "sell_quantity": 800, "sell_price": 12100}},
1619
+ ... "Aggregate": {"date": "2025-11-19", "time": "10:30:00", "trade_count": 120, "total_volume": 5000, "total_value": 60000000, "closing_price": 12000.0, "last_price": 12100.0, "low_price": 11950.0, "high_price": 12150.0, "open_price": 12050.0, "previous_close": 11980.0},
1620
+ ... "institutional_vs_individual": {"buy_count_individual": 120, "buy_volume_individual": 5000, "buy_count_institution": 45, "buy_volume_institution": 10000, "sell_count_individual": 100, "sell_volume_individual": 4000, "sell_count_institution": 50, "sell_volume_institution": 9000},
1621
+ ... "FundInfo": {"nav": 12500.0, "units": 100000, "marketCap": 1250000000, "as_of": datetime(2025,11,19,10,30)},
1622
+ ... "ContractInfo": {"open_interest": 1200, "initial_margin": 5000, "required_margin": 4500}
1623
+ ... }
1624
+ >>> overview["BestLimit"]["1"]["buy_price"]
1625
+ 12000
1626
+ >>> overview["Aggregate"]["high_price"]
1627
+ 12150
1628
+ >>> overview["FundInfo"]["nav"]
1629
+ 12500.0
1630
+ """
1631
+ BestLimit: Dict[str, BestLimitItem]
1632
+ Aggregate: Aggregate
1633
+ institutional_vs_individual: institutional_vs_individual
1634
+ FundInfo: FundInfo
1635
+ ContractInfo: ContractInfo
1636
+
1637
+
1638
+ class OverviewTreasuryBonds(TreasuryBonds):
1639
+ """
1640
+ Overview of a treasury bond instrument including best limit orders, aggregated market data,
1641
+ trading breakdown, fund info, and contract info.
1642
+
1643
+ Inherits from `TreasuryBonds` and extends it with additional metrics.
1644
+
1645
+ Attributes:
1646
+ BestLimit (Dict[str, BestLimitItem])
1647
+ Aggregate (Aggregate)
1648
+ institutional_vs_individual (institutional_vs_individual)
1649
+ FundInfo (FundInfo)
1650
+ ContractInfo (ContractInfo)
1651
+ """
1652
+ BestLimit: Dict[str, BestLimitItem]
1653
+ Aggregate: Aggregate
1654
+ institutional_vs_individual: institutional_vs_individual
1655
+ FundInfo: FundInfo
1656
+ ContractInfo: ContractInfo
1657
+
1658
+
1659
+ class OverviewStockOptions(StockOptions):
1660
+ """
1661
+ Overview of a stock option instrument including best limit orders, aggregated market data,
1662
+ trading breakdown, fund info, and contract info.
1663
+
1664
+ Inherits from `StockOptions` and extends it with additional metrics.
1665
+
1666
+ Attributes:
1667
+ BestLimit (Dict[str, BestLimitItem])
1668
+ Aggregate (Aggregate)
1669
+ institutional_vs_individual (institutional_vs_individual)
1670
+ FundInfo (FundInfo)
1671
+ ContractInfo (ContractInfo)
1672
+ """
1673
+ BestLimit: Dict[str, BestLimitItem]
1674
+ Aggregate: Aggregate
1675
+ institutional_vs_individual: institutional_vs_individual
1676
+ FundInfo: FundInfo
1677
+ ContractInfo: ContractInfo
1678
+
1679
+
1680
+ class OverviewStockFuturess(StockFutures):
1681
+ """
1682
+ Overview of a stock futures instrument including best limit orders, aggregated market data,
1683
+ trading breakdown, fund info, and contract info.
1684
+
1685
+ Inherits from `StockFutures` and extends it with additional metrics.
1686
+
1687
+ Attributes:
1688
+ BestLimit (Dict[str, BestLimitItem])
1689
+ Aggregate (Aggregate)
1690
+ institutional_vs_individual (institutional_vs_individual)
1691
+ FundInfo (FundInfo)
1692
+ ContractInfo (ContractInfo)
1693
+ """
1694
+ BestLimit: Dict[str, BestLimitItem]
1695
+ Aggregate: Aggregate
1696
+ institutional_vs_individual: institutional_vs_individual
1697
+ FundInfo: FundInfo
1698
+ ContractInfo: ContractInfo
1699
+
1700
+
1701
+ class OverviewResponse:
1702
+ """
1703
+ Response structure for the comprehensive overview of multiple financial instruments.
1704
+
1705
+ Attributes:
1706
+ Data (Dict[str, Optional[Union[OverviewSecuritiesAndFunds, OverviewTreasuryBonds,
1707
+ OverviewStockOptions, OverviewStockFuturess]]]): Dictionary mapping instrument
1708
+ identifiers (ISIN or symbolName) to their corresponding overview data.
1709
+ Some entries may be None if data is unavailable.
1710
+ Status (Status): Metadata about the server response, including success state, timestamp,
1711
+ version, author, description, and status code.
1712
+
1713
+ Example:
1714
+ >>> overview_response: OverviewResponse = {
1715
+ ... "Data": {"IR0001234567": overview},
1716
+ ... "Status": {
1717
+ ... "State": True,
1718
+ ... "ServerTimeStamp": 1700350200.0,
1719
+ ... "Version": "1.2.3",
1720
+ ... "Author": "HedgeTech",
1721
+ ... "Description": {"fa": "عملیات موفقیت‌آمیز بود", "en": "Operation successful"},
1722
+ ... "StatusCode": 200
1723
+ ... }
1724
+ ... }
1725
+ >>> overview_response["Data"]["IR0001234567"]["BestLimit"]["1"]["sell_price"]
1726
+ 12100
1727
+ >>> overview_response["Status"]["State"]
1728
+ True
1729
+ """
1730
+ Data : Dict[
1731
+ str,Optional[
1732
+ Union[
1733
+ OverviewSecuritiesAndFunds,
1734
+ OverviewTreasuryBonds,
1735
+ OverviewStockOptions,
1736
+ OverviewStockFuturess
1737
+ ]
1738
+ ]
1739
+ ]
1740
+ Status: Status
1741
+
1742
+ # +--------------------------------------------------------------------------------------+ #
1743
+
1744
+
1745
+ class OHLCV_historical(TypedDict):
1746
+ """
1747
+ Represents historical OHLCV (Open, High, Low, Close, Volume) data for a financial instrument
1748
+ over multiple timestamps.
1749
+
1750
+ Attributes:
1751
+ Date_timestamp (List[int]): List of timestamps (in UNIX epoch format) for each OHLCV record.
1752
+ Open (List[Union[float, int]]): Opening prices corresponding to each timestamp.
1753
+ High (List[Union[float, int]]): Highest prices for each timestamp.
1754
+ Low (List[Union[float, int]]): Lowest prices for each timestamp.
1755
+ Close (List[Union[float, int]]): Closing prices for each timestamp.
1756
+ Volume (List[int]): Traded volume for each timestamp.
1757
+ symbolName (str): Symbol name of the instrument.
1758
+ symbolIsin (str): ISIN identifier of the instrument.
1759
+
1760
+ Example:
1761
+ >>> ohlcv_hist: OHLCV_historical = {
1762
+ ... "Date_timestamp": [1700000000, 1700000600],
1763
+ ... "Open": [12000.0, 12100.0],
1764
+ ... "High": [12150.0, 12200.0],
1765
+ ... "Low": [11950.0, 12050.0],
1766
+ ... "Close": [12100.0, 12150.0],
1767
+ ... "Volume": [5000, 6000],
1768
+ ... "symbolName": "ETF001",
1769
+ ... "symbolIsin": "IR0001234567"
1770
+ ... }
1771
+ >>> ohlcv_hist["Close"][1]
1772
+ 12150.0
1773
+ >>> ohlcv_hist["Volume"][0]
1774
+ 5000
1775
+ """
1776
+ Date_timestamp: List[int]
1777
+ Open: List[Union[float, int]]
1778
+ High: List[Union[float, int]]
1779
+ Low: List[Union[float, int]]
1780
+ Close: List[Union[float, int]]
1781
+ Volume: List[int]
1782
+ symbolName: str
1783
+ symbolIsin: str
1784
+
1785
+
1786
+
1787
+ class OHLCVResponse(TypedDict):
1788
+ """
1789
+ Response structure for historical OHLCV data from a REST API call.
1790
+
1791
+ Attributes:
1792
+ Data (OHLCV_historical): Historical OHLCV data for the specified instrument.
1793
+ Status (Status): Metadata about the server response, including success state, timestamp,
1794
+ version, author, description, and status code.
1795
+
1796
+ Example:
1797
+ >>> response: OHLCVResponse = {
1798
+ ... "Data": ohlcv_hist,
1799
+ ... "Status": {
1800
+ ... "State": True,
1801
+ ... "ServerTimeStamp": 1700350200.0,
1802
+ ... "Version": "1.2.3",
1803
+ ... "Author": "HedgeTech",
1804
+ ... "Description": {"fa": "عملیات موفقیت‌آمیز بود", "en": "Operation successful"},
1805
+ ... "StatusCode": 200
1806
+ ... }
1807
+ ... }
1808
+ >>> response["Data"]["symbolName"]
1809
+ 'ETF001'
1810
+ >>> response["Data"]["High"][0]
1811
+ 12150.0
1812
+ >>> response["Status"]["State"]
1813
+ True
1814
+ """
1815
+ Data: OHLCV_historical
1816
+ Status: Status
1817
+
1818
+ # +--------------------------------------------------------------------------------------+ #
1819
+
1820
+ class DividendAction(TypedDict):
1821
+ """
1822
+ Represents a dividend distribution action for a financial instrument.
1823
+
1824
+ Attributes:
1825
+ Date_timestamp (int): Timestamp of the dividend action in UNIX epoch format.
1826
+ corporateAction (str): Type of corporate action (e.g., "Dividend").
1827
+ symbolName (str): Symbol name of the instrument.
1828
+ symbolIsin (str): ISIN identifier of the instrument.
1829
+ سود_تقسیم_شده (Optional[str]): Distributed dividend amount (may be None if not available).
1830
+ تاریخ (str): Human-readable date of the dividend action.
1831
+
1832
+ Example:
1833
+ >>> dividend: DividendAction = {
1834
+ ... "Date_timestamp": 1700350200,
1835
+ ... "corporateAction": "Dividend",
1836
+ ... "symbolName": "ETF001",
1837
+ ... "symbolIsin": "IR0001234567",
1838
+ ... "سود_تقسیم_شده": "1500",
1839
+ ... "تاریخ": "2025-11-19"
1840
+ ... }
1841
+ >>> dividend["سود_تقسیم_شده"]
1842
+ '1500'
1843
+ """
1844
+ Date_timestamp: int
1845
+ corporateAction: str
1846
+ symbolName: str
1847
+ symbolIsin: str
1848
+ سود_تقسیم_شده: Optional[str]
1849
+ تاریخ: str
1850
+
1851
+
1852
+ class CapitalIncreaseAction(TypedDict):
1853
+ """
1854
+ Represents a capital increase action for a financial instrument.
1855
+
1856
+ Attributes:
1857
+ Date_timestamp (int): Timestamp of the capital increase action in UNIX epoch format.
1858
+ corporateAction (str): Type of corporate action (e.g., "Capital Increase").
1859
+ symbolName (str): Symbol name of the instrument.
1860
+ symbolIsin (str): ISIN identifier of the instrument.
1861
+ سرمایه_قبلی (Optional[str]): Previous capital amount (may be None if not available).
1862
+ سرمایه_جدید (Optional[str]): New capital amount after increase (may be None if not available).
1863
+ درصد_افزایش (Optional[str]): Percentage of capital increase (may be None if not available).
1864
+ تاریخ (str): Human-readable date of the capital increase action.
1865
+
1866
+ Example:
1867
+ >>> capital_inc: CapitalIncreaseAction = {
1868
+ ... "Date_timestamp": 1700350200,
1869
+ ... "corporateAction": "Capital Increase",
1870
+ ... "symbolName": "ETF002",
1871
+ ... "symbolIsin": "IR0009876543",
1872
+ ... "سرمایه_قبلی": "1000000",
1873
+ ... "سرمایه_جدید": "1200000",
1874
+ ... "درصد_افزایش": "20%",
1875
+ ... "تاریخ": "2025-11-19"
1876
+ ... }
1877
+ >>> capital_inc["درصد_افزایش"]
1878
+ '20%'
1879
+ """
1880
+ Date_timestamp: int
1881
+ corporateAction: str
1882
+ symbolName: str
1883
+ symbolIsin: str
1884
+ سرمایه_قبلی: Optional[str]
1885
+ سرمایه_جدید: Optional[str]
1886
+ درصد_افزایش: Optional[str]
1887
+ تاریخ: str
1888
+
1889
+
1890
+
1891
+ class CorporateActionResponse(TypedDict):
1892
+ """
1893
+ Response structure for corporate actions (dividends and capital increases) from a REST API call.
1894
+
1895
+ Attributes:
1896
+ Data (List[Union[DividendAction, CapitalIncreaseAction, None]]): List of corporate action records.
1897
+ Each item may represent a dividend action, a capital increase action, or None if unavailable.
1898
+ Status (Status): Metadata about the server response, including success state, timestamp,
1899
+ version, author, description, and status code.
1900
+
1901
+ Example:
1902
+ >>> response: CorporateActionResponse = {
1903
+ ... "Data": [dividend, capital_inc, None],
1904
+ ... "Status": {
1905
+ ... "State": True,
1906
+ ... "ServerTimeStamp": 1700350200.0,
1907
+ ... "Version": "1.2.3",
1908
+ ... "Author": "HedgeTech",
1909
+ ... "Description": {"fa": "عملیات موفقیت‌آمیز بود", "en": "Operation successful"},
1910
+ ... "StatusCode": 200
1911
+ ... }
1912
+ ... }
1913
+ >>> response["Data"][0]["سود_تقسیم_شده"]
1914
+ '1500'
1915
+ >>> response["Data"][1]["سرمایه_جدید"]
1916
+ '1200000'
1917
+ >>> response["Status"]["State"]
1918
+ True
1919
+ """
1920
+ Data: List[Union[DividendAction, CapitalIncreaseAction, None]]
1921
+ Status: Status