forked from DustinReddit/GME-Swaps
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathschemas.py
More file actions
683 lines (655 loc) · 34 KB
/
schemas.py
File metadata and controls
683 lines (655 loc) · 34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
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
import pyarrow as pa
def make_fields_optional(schema):
return pa.schema(
[pa.field(field.name, field.type, nullable=True) for field in schema]
)
PRE_2023 = make_fields_optional(
pa.schema(
[
pa.field("Dissemination ID", pa.int64()),
pa.field("Original Dissemination ID", pa.int64()),
pa.field("Primary Asset Class", pa.string()),
pa.field("Product ID", pa.string()),
pa.field("Action", pa.string()),
pa.field("Transaction Type", pa.string()),
pa.field("Block Trade Election Indicator", pa.string()),
pa.field("Cleared", pa.string()),
pa.field("Clearing Exception or Exemption Indicator", pa.string()),
pa.field("Day Count Convention", pa.string()),
pa.field("Effective Date", pa.date32()),
pa.field("Embedded Option Type", pa.string()),
pa.field("Event Timestamp", pa.timestamp("s")),
pa.field("Exchange Rate", pa.float64()),
pa.field("Exchange Rate Basis", pa.float64()),
pa.field("Execution Timestamp", pa.timestamp("s")),
pa.field("Expiration Date", pa.date32()),
pa.field("First Exercise Date", pa.date32()),
pa.field("Fixed Rate 1", pa.float64()),
pa.field("Fixed Rate 2", pa.float64()),
pa.field("Fixed Recovery CDS Final Price", pa.float64()),
pa.field("Floating Rate Reset Frequency Period 1", pa.string()),
pa.field("Floating Rate Reset Frequency Period 2", pa.string()),
pa.field("Floating Rate Reset Frequency Period Multiplier 1", pa.int64()),
pa.field("Floating Rate Reset Frequency Period Multiplier 2", pa.int64()),
pa.field("Leg 1 - Commodity Underlyer ID", pa.string()),
pa.field("Leg 2 - Commodity Underlyer ID", pa.string()),
pa.field("Leg 1 - Floating Rate Index", pa.string()),
pa.field("Leg 2 - Floating Rate Index", pa.string()),
pa.field("Non-Standardized Pricing Indicator", pa.string()),
pa.field("Notional Amount 1", pa.string()),
pa.field("Notional Amount 2", pa.string()),
pa.field("Notional Currency 1", pa.string()),
pa.field("Notional Currency 2", pa.string()),
pa.field("Notional Quantity 1", pa.int64()),
pa.field("Notional Quantity 2", pa.int64()),
pa.field("Total Notional Quantity 1", pa.string()),
pa.field("Total Notional Quantity 2", pa.string()),
pa.field("Option Entitlement", pa.int64()),
pa.field("Option Premium Amount", pa.string()),
pa.field("Option Premium Currency", pa.string()),
pa.field("Other Payment Amount", pa.string()),
pa.field("Payment Frequency Period 1", pa.string()),
pa.field("Payment Frequency Period 2", pa.string()),
pa.field("Payment Frequency Period Multiplier 1", pa.int64()),
pa.field("Payment Frequency Period Multiplier 2", pa.int64()),
pa.field("Price 1", pa.string()),
pa.field("Price 2", pa.string()),
pa.field("Price Unit Of Measure 1", pa.string()),
pa.field("Price Unit Of Measure 2", pa.string()),
pa.field("Quantity Frequency", pa.string()),
pa.field("Quantity Unit Of Measure", pa.string()),
pa.field("Settlement Currency 1", pa.string()),
pa.field("Settlement Currency 2", pa.string()),
pa.field("Spread 1", pa.string()),
pa.field("Spread 2", pa.string()),
pa.field("Spread Currency 1", pa.string()),
pa.field("Spread Currency 2", pa.string()),
pa.field("Strike Price", pa.string()),
pa.field("Strike Price Currency", pa.string()),
pa.field("Underlying Asset ID", pa.string()),
pa.field("Underlying Asset ID Type", pa.string()),
pa.field("Underlying Asset Name", pa.string()),
pa.field("Leg 1 - Commodity Instrument ID", pa.string()),
pa.field("Leg 2 - Commodity Instrument ID", pa.string()),
pa.field("Option Type", pa.string()),
pa.field("Option Style", pa.string()),
pa.field("Execution Venue Type", pa.string()),
pa.field("Collateralization Type", pa.string()),
]
)
)
PRE_PHASE_2 = make_fields_optional(
pa.schema(
[
pa.field("Dissemination Identifier", pa.int64()),
pa.field("Original Dissemination Identifier", pa.int64()),
pa.field("Action type", pa.string()),
pa.field("Event type", pa.string()),
pa.field("Event timestamp", pa.timestamp("s", tz="UTC")),
pa.field("Amendment indicator", pa.bool_()),
pa.field("Asset Class", pa.string()),
pa.field("Product name", pa.string()),
pa.field("Cleared", pa.string()),
pa.field("Mandatory clearing indicator", pa.string()),
pa.field("Execution Timestamp", pa.timestamp("s", tz="UTC")),
pa.field("Effective Date", pa.date32()),
pa.field("Expiration Date", pa.date32()),
pa.field("Maturity date of the underlier", pa.date32()),
pa.field("Non-standardized term indicator", pa.string()),
pa.field("Platform identifier", pa.string()),
pa.field("Prime brokerage transaction indicator", pa.string()),
pa.field("Block trade election indicator", pa.string()),
pa.field(
"Large notional off-facility swap election indicator", pa.string()
),
pa.field("Notional amount-Leg 1", pa.string()),
pa.field("Notional amount-Leg 2", pa.string()),
pa.field("Notional currency-Leg 1", pa.string()),
pa.field("Notional currency-Leg 2", pa.string()),
pa.field("Notional quantity-Leg 1", pa.int64()),
pa.field("Notional quantity-Leg 2", pa.int64()),
pa.field("Total notional quantity-Leg 1", pa.int64()),
pa.field("Total notional quantity-Leg 2", pa.int64()),
pa.field("Quantity frequency multiplier-Leg 1", pa.int64()),
pa.field("Quantity frequency multiplier-Leg 2", pa.int64()),
pa.field("Quantity unit of measure-Leg 1", pa.string()),
pa.field("Quantity unit of measure-Leg 2", pa.string()),
pa.field("Quantity frequency-Leg 1", pa.int64()),
pa.field("Quantity frequency-Leg 2", pa.int64()),
pa.field(
"Notional amount in effect on associated effective date-Leg 1",
pa.int64(),
),
pa.field(
"Notional amount in effect on associated effective date-Leg 2",
pa.int64(),
),
pa.field("Effective date of the notional amount-Leg 1", pa.date32()),
pa.field("Effective date of the notional amount-Leg 2", pa.date32()),
pa.field("End date of the notional amount-Leg 1", pa.date32()),
pa.field("End date of the notional amount-Leg 2", pa.date32()),
pa.field("Call amount-Leg 1", pa.float64()),
pa.field("Call amount-Leg 2", pa.float64()),
pa.field("Call currency-Leg 1", pa.string()),
pa.field("Call currency-Leg 2", pa.string()),
pa.field("Put amount-Leg 1", pa.float64()),
pa.field("Put amount-Leg 2", pa.float64()),
pa.field("Put currency-Leg 1", pa.string()),
pa.field("Put currency-Leg 2", pa.string()),
pa.field("Exchange rate", pa.float64()),
pa.field("Exchange rate basis", pa.float64()),
pa.field("First exercise date", pa.date32()),
pa.field("Fixed rate-Leg 1", pa.float64()),
pa.field("Fixed rate-Leg 2", pa.float64()),
pa.field("Option Premium Amount", pa.string()),
pa.field("Option Premium Currency", pa.string()),
pa.field("Price", pa.string()),
pa.field("Price unit of measure", pa.string()),
pa.field("Spread-Leg 1", pa.string()),
pa.field("Spread-Leg 2", pa.string()),
pa.field("Spread currency-Leg 1", pa.string()),
pa.field("Spread currency-Leg 2", pa.string()),
pa.field("Strike Price", pa.float64()),
pa.field("Strike price currency/currency pair", pa.string()),
pa.field("Post-priced swap indicator", pa.bool_()),
pa.field("Price currency", pa.string()),
pa.field("Price notation", pa.int64()),
pa.field("Spread notation-Leg 1", pa.int64()),
pa.field("Spread notation-Leg 2", pa.int64()),
pa.field("Strike price notation", pa.string()),
pa.field("Fixed rate day count convention-leg 1", pa.string()),
pa.field("Fixed rate day count convention-leg 2", pa.string()),
pa.field("Floating rate day count convention-leg 1", pa.string()),
pa.field("Floating rate day count convention-leg 2", pa.string()),
pa.field("Floating rate reset frequency period-leg 1", pa.string()),
pa.field("Floating rate reset frequency period-leg 2", pa.string()),
pa.field(
"Floating rate reset frequency period multiplier-leg 1", pa.int64()
),
pa.field(
"Floating rate reset frequency period multiplier-leg 2", pa.int64()
),
pa.field("Other payment amount", pa.float64()),
pa.field("Fixed rate payment frequency period-Leg 1", pa.string()),
pa.field("Floating rate payment frequency period-Leg 1", pa.string()),
pa.field("Fixed rate payment frequency period-Leg 2", pa.string()),
pa.field("Floating rate payment frequency period-Leg 2", pa.string()),
pa.field(
"Fixed rate payment frequency period multiplier-Leg 1", pa.int64()
),
pa.field(
"Floating rate payment frequency period multiplier-Leg 1", pa.int64()
),
pa.field(
"Fixed rate payment frequency period multiplier-Leg 2", pa.int64()
),
pa.field(
"Floating rate payment frequency period multiplier-Leg 2", pa.int64()
),
pa.field("Other payment type", pa.string()),
pa.field("Other payment currency", pa.string()),
pa.field("Settlement currency-Leg 1", pa.string()),
pa.field("Settlement currency-Leg 2", pa.string()),
pa.field("Settlement location-Leg 1", pa.string()),
pa.field("Settlement location-Leg 2", pa.string()),
pa.field("Collateralisation category", pa.string()),
pa.field("Custom basket indicator", pa.bool_()),
pa.field("Index factor", pa.string()),
pa.field("Underlier ID-Leg 1", pa.string()),
pa.field("Underlier ID-Leg 2", pa.string()),
pa.field("Underlier ID source-Leg 1", pa.string()),
pa.field("Underlying Asset Name", pa.string()),
pa.field(
"Underlying asset subtype or underlying contract subtype-Leg 1",
pa.string(),
),
pa.field(
"Underlying asset subtype or underlying contract subtype-Leg 2",
pa.string(),
),
pa.field("Embedded Option type", pa.string()),
pa.field("Option Type", pa.string()),
pa.field("Option Style", pa.string()),
pa.field("Package indicator", pa.bool_()),
pa.field("Package transaction price", pa.float64()),
pa.field("Package transaction price currency", pa.string()),
pa.field("Package transaction price notation", pa.string()),
pa.field("Package transaction spread", pa.float64()),
pa.field("Package transaction spread currency", pa.string()),
pa.field("Package transaction spread notation", pa.string()),
pa.field("Physical delivery location-Leg 1", pa.string()),
pa.field("Delivery Type", pa.string()),
]
)
)
PHASE_2 = make_fields_optional(
pa.schema(
[
pa.field("Dissemination Identifier", pa.int64()),
pa.field("Original Dissemination Identifier", pa.int64()),
pa.field("Action type", pa.string()),
pa.field("Event type", pa.string()),
pa.field("Event timestamp", pa.timestamp("s", tz="UTC")),
pa.field("Amendment indicator", pa.bool_()),
pa.field("Asset Class", pa.string()),
pa.field("Product name", pa.string()),
pa.field("Cleared", pa.string()),
pa.field("Mandatory clearing indicator", pa.string()),
pa.field("Execution Timestamp", pa.timestamp("s", tz="UTC")),
pa.field("Effective Date", pa.date32()),
pa.field("Expiration Date", pa.date32()),
pa.field("Maturity date of the underlier", pa.date32()),
pa.field("Non-standardized term indicator", pa.string()),
pa.field("Platform identifier", pa.string()),
pa.field("Prime brokerage transaction indicator", pa.string()),
pa.field("Block trade election indicator", pa.string()),
pa.field(
"Large notional off-facility swap election indicator", pa.string()
),
pa.field("Notional amount-Leg 1", pa.string()),
pa.field("Notional amount-Leg 2", pa.string()),
pa.field("Notional currency-Leg 1", pa.string()),
pa.field("Notional currency-Leg 2", pa.string()),
pa.field("Notional quantity-Leg 1", pa.int64()),
pa.field("Notional quantity-Leg 2", pa.int64()),
pa.field("Total notional quantity-Leg 1", pa.string()),
pa.field("Total notional quantity-Leg 2", pa.string()),
pa.field("Quantity frequency multiplier-Leg 1", pa.int64()),
pa.field("Quantity frequency multiplier-Leg 2", pa.int64()),
pa.field("Quantity unit of measure-Leg 1", pa.string()),
pa.field("Quantity unit of measure-Leg 2", pa.string()),
pa.field("Quantity frequency-Leg 1", pa.int64()),
pa.field("Quantity frequency-Leg 2", pa.int64()),
pa.field(
"Notional amount in effect on associated effective date-Leg 1",
pa.string(),
),
pa.field(
"Notional amount in effect on associated effective date-Leg 2",
pa.string(),
),
pa.field("Effective date of the notional amount-Leg 1", pa.date32()),
pa.field("Effective date of the notional amount-Leg 2", pa.date32()),
pa.field("End date of the notional amount-Leg 1", pa.date32()),
pa.field("End date of the notional amount-Leg 2", pa.date32()),
pa.field("Call amount", pa.float64()),
pa.field("Call currency", pa.string()),
pa.field("Put amount", pa.float64()),
pa.field("Put currency", pa.string()),
pa.field("Exchange rate", pa.float64()),
pa.field("Exchange rate basis", pa.float64()),
pa.field("First exercise date", pa.date32()),
pa.field("Fixed rate-Leg 1", pa.float64()),
pa.field("Fixed rate-Leg 2", pa.float64()),
pa.field("Option Premium Amount", pa.string()),
pa.field("Option Premium Currency", pa.string()),
pa.field("Price", pa.string()),
pa.field("Price unit of measure", pa.string()),
pa.field("Spread-Leg 1", pa.string()),
pa.field("Spread-Leg 2", pa.string()), # ??
pa.field("Spread currency-Leg 1", pa.string()),
pa.field("Spread currency-Leg 2", pa.string()),
pa.field("Strike Price", pa.string()),
pa.field("Strike price currency/currency pair", pa.string()),
pa.field("Post-priced swap indicator", pa.bool_()),
pa.field("Price currency", pa.string()),
pa.field("Price notation", pa.int64()),
pa.field("Spread notation-Leg 1", pa.int64()),
pa.field("Spread notation-Leg 2", pa.int64()),
pa.field("Strike price notation", pa.int64()),
pa.field("Fixed rate count convention-leg 1", pa.string()),
pa.field("Fixed rate count convention-leg 2", pa.string()),
pa.field("Floating rate count convention-leg 1", pa.string()),
pa.field("Floating rate count convention-leg 2", pa.string()),
pa.field("Floating rate reset frequency period-leg 1", pa.string()),
pa.field("Floating rate reset frequency period-leg 2", pa.string()),
pa.field(
"Floating rate reset frequency period multiplier-leg 1", pa.int64()
),
pa.field(
"Floating rate reset frequency period multiplier-leg 2", pa.int64()
),
pa.field("Other payment amount", pa.string()),
pa.field("Fixed rate payment frequency period-Leg 1", pa.string()),
pa.field("Floating rate payment frequency period-Leg 1", pa.string()),
pa.field("Fixed rate payment frequency period-Leg 2", pa.string()),
pa.field("Floating rate payment frequency period-Leg 2", pa.string()),
pa.field(
"Fixed rate payment frequency period multiplier-Leg 1", pa.int64()
),
pa.field(
"Floating rate payment frequency period multiplier-Leg 1", pa.int64()
),
pa.field(
"Fixed rate payment frequency period multiplier-Leg 2", pa.int64()
),
pa.field(
"Floating rate payment frequency period multiplier-Leg 2", pa.int64()
),
pa.field("Other payment type", pa.string()),
pa.field("Other payment currency", pa.string()),
pa.field("Settlement currency-Leg 1", pa.string()),
pa.field("Settlement currency-Leg 2", pa.string()),
pa.field("Settlement location", pa.string()),
pa.field("Collateralisation category", pa.string()),
pa.field("Custom basket indicator", pa.bool_()),
pa.field("Index factor", pa.string()),
pa.field("Underlier ID-Leg 1", pa.string()),
pa.field("Underlier ID-Leg 2", pa.string()),
pa.field("Underlier ID source-Leg 1", pa.string()),
pa.field("Underlying Asset Name", pa.string()),
pa.field(
"Underlying asset subtype or underlying contract subtype-Leg 1",
pa.string(),
),
pa.field(
"Underlying asset subtype or underlying contract subtype-Leg 2",
pa.string(),
),
pa.field("Embedded Option type", pa.string()),
pa.field("Option Type", pa.string()),
pa.field("Option Style", pa.string()),
pa.field("Package indicator", pa.bool_()),
pa.field("Package transaction price", pa.string()),
pa.field("Package transaction price currency", pa.string()),
pa.field("Package transaction price notation", pa.int64()),
pa.field("Package transaction spread", pa.float64()),
pa.field("Package transaction spread currency", pa.string()),
pa.field("Package transaction spread notation", pa.string()),
pa.field("Physical delivery location-Leg 1", pa.string()),
pa.field("Delivery Type", pa.string()),
pa.field("Unique Product Identifier", pa.string()),
pa.field("UPI FISN", pa.string()),
pa.field("UPI Underlier Name", pa.string()),
]
)
)
CORRELATED_CUSTOM = make_fields_optional(
pa.schema(
[
pa.field("Dissemination Identifier", pa.int64()),
pa.field("Original Dissemination Identifier", pa.int64()),
pa.field("Progenitor Dissemination Identifier", pa.int64()),
pa.field("Action type", pa.string()),
pa.field("Event type", pa.string()),
pa.field("Event timestamp", pa.timestamp("s", tz="UTC")),
pa.field("Amendment indicator", pa.bool_()),
pa.field("Asset Class", pa.string()),
pa.field("Product name", pa.string()),
pa.field("Cleared", pa.string()),
pa.field("Mandatory clearing indicator", pa.string()),
pa.field("Execution Timestamp", pa.timestamp("s", tz="UTC")),
pa.field("Effective Date", pa.date32()),
pa.field("Expiration Date", pa.date32()),
pa.field("Maturity date of the underlier", pa.date32()),
pa.field("Non-standardized term indicator", pa.string()),
pa.field("Platform identifier", pa.string()),
pa.field("Prime brokerage transaction indicator", pa.string()),
pa.field("Block trade election indicator", pa.string()),
pa.field(
"Large notional off-facility swap election indicator", pa.string()
),
pa.field("Notional amount-Leg 1", pa.string()),
pa.field("Notional amount-Leg 2", pa.string()),
pa.field("Notional currency-Leg 1", pa.string()),
pa.field("Notional currency-Leg 2", pa.string()),
pa.field("Notional quantity-Leg 1", pa.int64()),
pa.field("Notional quantity-Leg 2", pa.int64()),
pa.field("Total notional quantity-Leg 1", pa.string()),
pa.field("Total notional quantity-Leg 2", pa.string()),
pa.field("Quantity frequency multiplier-Leg 1", pa.int64()),
pa.field("Quantity frequency multiplier-Leg 2", pa.int64()),
pa.field("Quantity unit of measure-Leg 1", pa.string()),
pa.field("Quantity unit of measure-Leg 2", pa.string()),
pa.field("Quantity frequency-Leg 1", pa.int64()),
pa.field("Quantity frequency-Leg 2", pa.int64()),
pa.field(
"Notional amount in effect on associated effective date-Leg 1",
pa.string(),
),
pa.field(
"Notional amount in effect on associated effective date-Leg 2",
pa.string(),
),
pa.field("Effective date of the notional amount-Leg 1", pa.date32()),
pa.field("Effective date of the notional amount-Leg 2", pa.date32()),
pa.field("End date of the notional amount-Leg 1", pa.date32()),
pa.field("End date of the notional amount-Leg 2", pa.date32()),
pa.field("Call amount", pa.float64()),
pa.field("Call currency", pa.string()),
pa.field("Put amount", pa.float64()),
pa.field("Put currency", pa.string()),
pa.field("Exchange rate", pa.float64()),
pa.field("Exchange rate basis", pa.float64()),
pa.field("First exercise date", pa.date32()),
pa.field("Fixed rate-Leg 1", pa.float64()),
pa.field("Fixed rate-Leg 2", pa.float64()),
pa.field("Option Premium Amount", pa.string()),
pa.field("Option Premium Currency", pa.string()),
pa.field("Price", pa.string()),
pa.field("Price unit of measure", pa.string()),
pa.field("Spread-Leg 1", pa.string()),
pa.field("Spread-Leg 2", pa.string()), # ??
pa.field("Spread currency-Leg 1", pa.string()),
pa.field("Spread currency-Leg 2", pa.string()),
pa.field("Strike Price", pa.string()),
pa.field("Strike price currency/currency pair", pa.string()),
pa.field("Post-priced swap indicator", pa.bool_()),
pa.field("Price currency", pa.string()),
pa.field("Price notation", pa.int64()),
pa.field("Spread notation-Leg 1", pa.int64()),
pa.field("Spread notation-Leg 2", pa.int64()),
pa.field("Strike price notation", pa.int64()),
pa.field("Fixed rate count convention-leg 1", pa.string()),
pa.field("Fixed rate count convention-leg 2", pa.string()),
pa.field("Floating rate count convention-leg 1", pa.string()),
pa.field("Floating rate count convention-leg 2", pa.string()),
pa.field("Floating rate reset frequency period-leg 1", pa.string()),
pa.field("Floating rate reset frequency period-leg 2", pa.string()),
pa.field(
"Floating rate reset frequency period multiplier-leg 1", pa.int64()
),
pa.field(
"Floating rate reset frequency period multiplier-leg 2", pa.int64()
),
pa.field("Other payment amount", pa.string()),
pa.field("Fixed rate payment frequency period-Leg 1", pa.string()),
pa.field("Floating rate payment frequency period-Leg 1", pa.string()),
pa.field("Fixed rate payment frequency period-Leg 2", pa.string()),
pa.field("Floating rate payment frequency period-Leg 2", pa.string()),
pa.field(
"Fixed rate payment frequency period multiplier-Leg 1", pa.int64()
),
pa.field(
"Floating rate payment frequency period multiplier-Leg 1", pa.int64()
),
pa.field(
"Fixed rate payment frequency period multiplier-Leg 2", pa.int64()
),
pa.field(
"Floating rate payment frequency period multiplier-Leg 2", pa.int64()
),
pa.field("Other payment type", pa.string()),
pa.field("Other payment currency", pa.string()),
pa.field("Settlement currency-Leg 1", pa.string()),
pa.field("Settlement currency-Leg 2", pa.string()),
pa.field("Settlement location", pa.string()),
pa.field("Collateralisation category", pa.string()),
pa.field("Custom basket indicator", pa.bool_()),
pa.field("Index factor", pa.string()),
pa.field("Underlier ID-Leg 1", pa.string()),
pa.field("Underlier ID-Leg 2", pa.string()),
pa.field("Underlier ID source-Leg 1", pa.string()),
pa.field("Underlying Asset Name", pa.string()),
pa.field(
"Underlying asset subtype or underlying contract subtype-Leg 1",
pa.string(),
),
pa.field(
"Underlying asset subtype or underlying contract subtype-Leg 2",
pa.string(),
),
pa.field("Embedded Option type", pa.string()),
pa.field("Option Type", pa.string()),
pa.field("Option Style", pa.string()),
pa.field("Package indicator", pa.bool_()),
pa.field("Package transaction price", pa.string()),
pa.field("Package transaction price currency", pa.string()),
pa.field("Package transaction price notation", pa.int64()),
pa.field("Package transaction spread", pa.float64()),
pa.field("Package transaction spread currency", pa.string()),
pa.field("Package transaction spread notation", pa.string()),
pa.field("Physical delivery location-Leg 1", pa.string()),
pa.field("Delivery Type", pa.string()),
pa.field("Unique Product Identifier", pa.string()),
pa.field("UPI FISN", pa.string()),
pa.field("UPI Underlier Name", pa.string()),
]
)
)
def identify_schema(column_names):
if "Primary Asset Class" in column_names:
return PRE_2023
elif "Call amount-Leg 1" in column_names:
return PRE_PHASE_2
elif "Unique Product Identifier" in column_names:
return PHASE_2
return None
def map_columns(table):
if "Primary Asset Class" in table.column_names:
map = {
name: value
for name, value in PRE_2023_TO_PHASE_2.items()
if value is not None
}
table = table.rename_columns(map)
elif "Call amount-Leg 1" in table.column_names:
map = {
name: value
for name, value in PRE_PHASE_2_TO_PHASE_2.items()
if value is not None
}
table = table.rename_columns(map)
PRE_2023_TO_PHASE_2 = {
"Dissemination ID": "Dissemination Identifier",
"Original Dissemination ID": "Original Dissemination Identifier",
"Action": "Action type",
"Block Trade Election Indicator": "Block trade election indicator",
"Clearing Exception or Exemption Indicator": None, # Is this right?
"Collateralization Type": "Collateralisation category",
"Day Count Convention": None, # ?
"Embedded Option Type": "Embedded Option type",
"Event Timestamp": "Event timestamp",
"Exchange Rate": "Exchange rate",
"Exchange Rate Basis": "Exchange rate basis",
"Execution Venue Type": None, # ?
"First Exercise Date": "First exercise date",
"Fixed Rate 1": "Fixed rate-Leg 1",
"Fixed Rate 2": "Fixed rate-Leg 2",
"Fixed Recovery CDS Final Price": None, # ?
"Floating Rate Reset Frequency Period 1": "Floating rate reset frequency period-leg 1",
"Floating Rate Reset Frequency Period 2": "Floating rate reset frequency period-leg 2",
"Floating Rate Reset Frequency Period Multiplier 1": "Floating rate reset frequency period multiplier-leg 1",
"Floating Rate Reset Frequency Period Multiplier 2": "Floating rate reset frequency period multiplier-leg 2",
"Leg 1 - Commodity Instrument ID": None, # ?
"Leg 2 - Commodity Instrument ID": None, # ?
"Leg 1 - Commodity Underlyer ID": "Underlier ID-Leg 1",
"Leg 2 - Commodity Underlyer ID": "Underlier ID-Leg 2",
"Leg 1 - Floating Rate Index": "Underlier ID source-Leg 1",
"Leg 2 - Floating Rate Index": None, # ?
"Non-Standardized Pricing Indicator": "Non-standardized term indicator",
"Notional Amount 1": "Notional amount-Leg 1",
"Notional Amount 2": "Notional amount-Leg 2",
"Notional Currency 1": "Notional currency-Leg 1",
"Notional Currency 2": "Notional currency-Leg 2",
"Notional Quantity 1": "Notional quantity-Leg 1",
"Notional Quantity 2": "Notional quantity-Leg 2",
"Option Entitlement": None, # ?
"Other Payment Amount": "Other payment amount",
"Payment Frequency Period 1": "Fixed rate payment frequency period-Leg 1",
"Payment Frequency Period 2": "Fixed rate payment frequency period-Leg 2",
"Payment Frequency Period Multiplier 1": "Fixed rate payment frequency period multiplier-Leg 1",
"Payment Frequency Period Multiplier 2": "Fixed rate payment frequency period multiplier-Leg 2",
"Price 1": "Price",
"Price 2": None, # ?
"Price Unit Of Measure 1": "Price unit of measure",
"Price Unit Of Measure 2": None, # ?
"Primary Asset Class": "Asset Class",
"Product ID": "Product name",
"Quantity Frequency": None, # ?
"Quantity Unit Of Measure": None, # ?
"Settlement Currency 1": "Settlement currency-Leg 1",
"Settlement Currency 2": "Settlement currency-Leg 2",
"Spread 1": "Spread-Leg 1",
"Spread 2": "Spread-Leg 2",
"Spread Currency 1": "Spread currency-Leg 1",
"Spread Currency 2": "Spread currency-Leg 2",
"Strike Price Currency": "Strike price currency/currency pair",
"Underlying Asset ID": "Underlier ID-Leg 1",
"Underlying Asset ID Type": "Underlier ID source-Leg 1",
"Total Notional Quantity 1": "Total notional quantity-Leg 1",
"Total Notional Quantity 2": "Total notional quantity-Leg 2",
"Transaction Type": "Event type",
}
PRE_PHASE_2_TO_PHASE_2 = {
"Call amount-Leg 1": "Call amount",
"Call amount-Leg 2": None,
"Call currency-Leg 1": "Call currency",
"Call currency-Leg 2": None,
"Fixed rate day count convention-leg 1": "Fixed rate count convention-leg 1",
"Fixed rate day count convention-leg 2": "Fixed rate count convention-leg 2",
"Floating rate day count convention-leg 1": "Floating rate count convention-leg 1",
"Floating rate day count convention-leg 2": "Floating rate count convention-leg 2",
"Put amount-Leg 1": "Put amount",
"Put amount-Leg 2": None,
"Put currency-Leg 1": "Put currency",
"Put currency-Leg 2": None,
"Settlement location-Leg 1": "Settlement location",
"Settlement location-Leg 2": None,
}
if __name__ == "__main__":
pre_columns = set(PRE_2023.names)
mapped_pre_columns = set(
[PRE_2023_TO_PHASE_2.get(name, name) for name in pre_columns]
)
phase_columns = set(PHASE_2.names)
missing_columns = mapped_pre_columns - phase_columns
missing_columns = sorted([m for m in missing_columns if m is not None])
if len(missing_columns) > 0:
print("Missing columns from PRE_2023 to PHASE_2:")
for column in missing_columns:
print(f" {column}")
else:
print("All columns from PRE_2023 to PHASE_2 are present")
# Verify that the types are the same
for pre_name, phase_name in PRE_2023_TO_PHASE_2.items():
if phase_name is None:
continue
pre_field = PRE_2023.field(pre_name)
phase_field = PHASE_2.field(phase_name)
if pre_field.type != phase_field.type:
print(f"Type mismatch for {pre_name} -> {phase_name}")
print(f" PRE: {pre_field.type}")
print(f" PHASE: {phase_field.type}")
pre_columns = set(PRE_PHASE_2.names)
mapped_pre_columns = set(
[PRE_PHASE_2_TO_PHASE_2.get(name, name) for name in pre_columns]
)
missing_columns = mapped_pre_columns - phase_columns
missing_columns = sorted([m for m in missing_columns if m is not None])
if len(missing_columns) > 0:
print("Missing columns from PRE_PHASE_2 to PHASE_2:")
for column in missing_columns:
print(f" {column}")
else:
print("All columns from PRE_PHASE_2 to PHASE_2 are present")
# Verify that the types are the same
for pre_name, phase_name in PRE_PHASE_2_TO_PHASE_2.items():
if phase_name is None:
continue
pre_field = PRE_PHASE_2.field(pre_name)
phase_field = PHASE_2.field(phase_name)
if pre_field.type != phase_field.type:
print(f"Type mismatch for {pre_name} -> {phase_name}")
print(f" PRE: {pre_field.type}")
print(f" PHASE: {phase_field.type}")