-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy path__init__.py
More file actions
1953 lines (1565 loc) · 67.8 KB
/
Copy path__init__.py
File metadata and controls
1953 lines (1565 loc) · 67.8 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
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# This file was automatically generated by SWIG (http://www.swig.org).
# Version 3.0.12
#
# Do not make changes to this file unless you know what you are doing--modify
# the SWIG interface file instead.
from sys import version_info as _swig_python_version_info
from sys import platform as _swig_python_platform
platform = 'windows'
if _swig_python_platform.startswith('linux'):
platform = 'linux'
elif _swig_python_platform.startswith('darwin'):
platform = 'darwin'
if _swig_python_version_info >= (3, 6) and _swig_python_version_info < (3, 7):
subdir = 'py36'
elif _swig_python_version_info >= (3, 7) and _swig_python_version_info < (3, 8):
subdir = 'py37'
elif _swig_python_version_info >= (3, 8) and _swig_python_version_info < (3, 9):
subdir = 'py38'
elif _swig_python_version_info >= (3, 9) and _swig_python_version_info < (3, 10):
subdir = 'py39'
elif _swig_python_version_info >= (3, 10) and _swig_python_version_info < (3, 11):
subdir = 'py310'
else:
raise Exception('Version of python (' + str(_swig_python_version_info) + ') is not supported')
if _swig_python_version_info >= (3, 7, 0):
def swig_import_helper():
import importlib
mname = '.'.join((__name__, platform, 'x64', subdir, '_tbapi')).lstrip('.')
try:
return importlib.import_module(mname)
except ImportError:
return importlib.import_module('_tbapi')
_tbapi = swig_import_helper()
del swig_import_helper
elif _swig_python_version_info >= (2, 6, 0):
def swig_import_helper():
from os.path import dirname
import imp
fp = None
try:
directory = '/'.join((dirname(__file__), platform, 'x64', subdir))
fp, pathname, description = imp.find_module('_tbapi', [directory])
except ImportError:
import _tbapi
return _tbapi
try:
_mod = imp.load_module('_tbapi', fp, pathname, description)
finally:
if fp is not None:
fp.close()
return _mod
_tbapi = swig_import_helper()
del swig_import_helper
else:
import _tbapi
del _swig_python_version_info
del _swig_python_platform
from os import path
def version():
tbapi_dir = path.dirname(__file__)
if tbapi_dir != '':
tbapi_dir = tbapi_dir + '/project.properties'
with open(tbapi_dir) as file:
lines = file.readlines()
for line in lines:
split_line = line.split('=')
if len(split_line) == 2:
key = split_line[0].strip()
value = split_line[1].strip()
if key.strip() == 'version' and value != None:
return value
return 'UNKNOWN'
try:
_swig_property = property
except NameError:
pass # Python < 2.2 doesn't have 'property'.
try:
import builtins as __builtin__
except ImportError:
import __builtin__
def _swig_setattr_nondynamic(self, class_type, name, value, static=1):
if (name == "thisown"):
return self.this.own(value)
if (name == "this"):
if type(value).__name__ == 'SwigPyObject':
self.__dict__[name] = value
return
method = class_type.__swig_setmethods__.get(name, None)
if method:
return method(self, value)
if (not static):
if _newclass:
object.__setattr__(self, name, value)
else:
self.__dict__[name] = value
else:
raise AttributeError("You cannot add attributes to %s" % self)
def _swig_setattr(self, class_type, name, value):
return _swig_setattr_nondynamic(self, class_type, name, value, 0)
def _swig_getattr(self, class_type, name):
if (name == "thisown"):
return self.this.own()
method = class_type.__swig_getmethods__.get(name, None)
if method:
return method(self)
raise AttributeError("'%s' object has no attribute '%s'" % (class_type.__name__, name))
def _swig_repr(self):
try:
strthis = "proxy of " + self.this.__repr__()
except __builtin__.Exception:
strthis = ""
return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,)
try:
_object = object
_newclass = 1
except __builtin__.Exception:
class _object:
pass
_newclass = 0
try:
import weakref
weakref_proxy = weakref.proxy
except __builtin__.Exception:
weakref_proxy = lambda x: x
class SwigPyIterator(_object):
__swig_setmethods__ = {}
__setattr__ = lambda self, name, value: _swig_setattr(self, SwigPyIterator, name, value)
__swig_getmethods__ = {}
__getattr__ = lambda self, name: _swig_getattr(self, SwigPyIterator, name)
def __init__(self, *args, **kwargs):
raise AttributeError("No constructor defined - class is abstract")
__repr__ = _swig_repr
__swig_destroy__ = _tbapi.delete_SwigPyIterator
__del__ = lambda self: None
def value(self):
return _tbapi.SwigPyIterator_value(self)
def incr(self, n=1):
return _tbapi.SwigPyIterator_incr(self, n)
def decr(self, n=1):
return _tbapi.SwigPyIterator_decr(self, n)
def distance(self, x):
return _tbapi.SwigPyIterator_distance(self, x)
def equal(self, x):
return _tbapi.SwigPyIterator_equal(self, x)
def copy(self):
return _tbapi.SwigPyIterator_copy(self)
def next(self):
return _tbapi.SwigPyIterator_next(self)
def __next__(self):
return _tbapi.SwigPyIterator___next__(self)
def previous(self):
return _tbapi.SwigPyIterator_previous(self)
def advance(self, n):
return _tbapi.SwigPyIterator_advance(self, n)
def __eq__(self, x):
return _tbapi.SwigPyIterator___eq__(self, x)
def __ne__(self, x):
return _tbapi.SwigPyIterator___ne__(self, x)
def __iadd__(self, n):
return _tbapi.SwigPyIterator___iadd__(self, n)
def __isub__(self, n):
return _tbapi.SwigPyIterator___isub__(self, n)
def __add__(self, n):
return _tbapi.SwigPyIterator___add__(self, n)
def __sub__(self, *args):
return _tbapi.SwigPyIterator___sub__(self, *args)
def __iter__(self):
return self
SwigPyIterator_swigregister = _tbapi.SwigPyIterator_swigregister
SwigPyIterator_swigregister(SwigPyIterator)
from contextlib import contextmanager
JAVA_LONG_MIN_VALUE = -9223372036854775808
JAVA_LONG_MAX_VALUE = 9223372036854775807
class InstrumentMessage(object):
def __str__(self):
return str(vars(self))
class StreamScope(_object):
"""
Determines the scope of a stream's durability, if any.
Example:
```
scope = tbapi.StreamScope('TRANSIENT')
```
Possible values:
```
DURABLE,
EXTERNAL_FILE,
TRANSIENT,
RUNTIME
```
"""
__swig_setmethods__ = {}
__setattr__ = lambda self, name, value: _swig_setattr(self, StreamScope, name, value)
__swig_getmethods__ = {}
__getattr__ = lambda self, name: _swig_getattr(self, StreamScope, name)
__repr__ = _swig_repr
DURABLE = _tbapi.StreamScope_DURABLE
EXTERNAL_FILE = _tbapi.StreamScope_EXTERNAL_FILE
TRANSIENT = _tbapi.StreamScope_TRANSIENT
RUNTIME = _tbapi.StreamScope_RUNTIME
def __init__(self, *args):
this = _tbapi.new_StreamScope(*args)
try:
self.this.append(this)
except __builtin__.Exception:
self.this = this
def __int__(self):
return _tbapi.StreamScope___int__(self)
def __str__(self):
return _tbapi.StreamScope___str__(self)
__swig_destroy__ = _tbapi.delete_StreamScope
__del__ = lambda self: None
StreamScope_swigregister = _tbapi.StreamScope_swigregister
StreamScope_swigregister(StreamScope)
class WriteMode(_object):
"""
APPEND: Adds only new data into a stream without truncations.
REPLACE: Adds data into a stream and removes previous data older that first message time
[truncate(first message time + 1)].
REWRITE: Default. Adds data into a stream and removes previous data by truncating using first message time.
[truncate(first message time)].
TRUNCATE: Stream truncated every time when loader writes a messages earlier than last message time.
Example:
```
mode = tbapi.StreamScope('TRUNCATE')
```
Possible values:
```
APPEND,
REPLACE,
REWRITE,
TRUNCATE
```
"""
__swig_setmethods__ = {}
__setattr__ = lambda self, name, value: _swig_setattr(self, WriteMode, name, value)
__swig_getmethods__ = {}
__getattr__ = lambda self, name: _swig_getattr(self, WriteMode, name)
__repr__ = _swig_repr
APPEND = _tbapi.WriteMode_APPEND
REPLACE = _tbapi.WriteMode_REPLACE
REWRITE = _tbapi.WriteMode_REWRITE
TRUNCATE = _tbapi.WriteMode_TRUNCATE
def __init__(self, *args):
this = _tbapi.new_WriteMode(*args)
try:
self.this.append(this)
except __builtin__.Exception:
self.this = this
def __int__(self):
return _tbapi.WriteMode___int__(self)
def __str__(self):
return _tbapi.WriteMode___str__(self)
__swig_destroy__ = _tbapi.delete_WriteMode
__del__ = lambda self: None
WriteMode_swigregister = _tbapi.WriteMode_swigregister
WriteMode_swigregister(WriteMode)
class SelectionOptions(_object):
"""
Options for selecting data from a stream.
Example:
```
so = tbapi.SelectionOptions()
so._from = 0
so.to = 100000
so.useCompression = False
...
```
"""
__swig_setmethods__ = {}
__setattr__ = lambda self, name, value: _swig_setattr(self, SelectionOptions, name, value)
__swig_getmethods__ = {}
__getattr__ = lambda self, name: _swig_getattr(self, SelectionOptions, name)
__repr__ = _swig_repr
def __init__(self):
this = _tbapi.new_SelectionOptions()
try:
self.this.append(this)
except __builtin__.Exception:
self.this = this
__swig_setmethods__["_from"] = _tbapi.SelectionOptions__from_set
__swig_getmethods__["_from"] = _tbapi.SelectionOptions__from_get
if _newclass:
_from = _swig_property(_tbapi.SelectionOptions__from_get, _tbapi.SelectionOptions__from_set)
__swig_setmethods__["to"] = _tbapi.SelectionOptions_to_set
__swig_getmethods__["to"] = _tbapi.SelectionOptions_to_get
if _newclass:
to = _swig_property(_tbapi.SelectionOptions_to_get, _tbapi.SelectionOptions_to_set)
__swig_setmethods__["useCompression"] = _tbapi.SelectionOptions_useCompression_set
__swig_getmethods__["useCompression"] = _tbapi.SelectionOptions_useCompression_get
if _newclass:
useCompression = _swig_property(_tbapi.SelectionOptions_useCompression_get, _tbapi.SelectionOptions_useCompression_set)
__swig_setmethods__["live"] = _tbapi.SelectionOptions_live_set
__swig_getmethods__["live"] = _tbapi.SelectionOptions_live_get
if _newclass:
live = _swig_property(_tbapi.SelectionOptions_live_get, _tbapi.SelectionOptions_live_set)
__swig_setmethods__["reverse"] = _tbapi.SelectionOptions_reverse_set
__swig_getmethods__["reverse"] = _tbapi.SelectionOptions_reverse_get
if _newclass:
reverse = _swig_property(_tbapi.SelectionOptions_reverse_get, _tbapi.SelectionOptions_reverse_set)
__swig_setmethods__["allowLateOutOfOrder"] = _tbapi.SelectionOptions_allowLateOutOfOrder_set
__swig_getmethods__["allowLateOutOfOrder"] = _tbapi.SelectionOptions_allowLateOutOfOrder_get
if _newclass:
allowLateOutOfOrder = _swig_property(_tbapi.SelectionOptions_allowLateOutOfOrder_get, _tbapi.SelectionOptions_allowLateOutOfOrder_set)
__swig_setmethods__["realTimeNotification"] = _tbapi.SelectionOptions_realTimeNotification_set
__swig_getmethods__["realTimeNotification"] = _tbapi.SelectionOptions_realTimeNotification_get
if _newclass:
realTimeNotification = _swig_property(_tbapi.SelectionOptions_realTimeNotification_get, _tbapi.SelectionOptions_realTimeNotification_set)
__swig_setmethods__["minLatency"] = _tbapi.SelectionOptions_minLatency_set
__swig_getmethods__["minLatency"] = _tbapi.SelectionOptions_minLatency_get
if _newclass:
minLatency = _swig_property(_tbapi.SelectionOptions_minLatency_get, _tbapi.SelectionOptions_minLatency_set)
__swig_destroy__ = _tbapi.delete_SelectionOptions
__del__ = lambda self: None
SelectionOptions_swigregister = _tbapi.SelectionOptions_swigregister
SelectionOptions_swigregister(SelectionOptions)
class LoadingOptions(_object):
"""
Options for loading data into a stream.
Example:
```
lo = tbapi.LoadingOptions()
lo.writeMode = tbapi.WriteMode('TRUNCATE')
so.space = 'myspace'
...
```
"""
__swig_setmethods__ = {}
__setattr__ = lambda self, name, value: _swig_setattr(self, LoadingOptions, name, value)
__swig_getmethods__ = {}
__getattr__ = lambda self, name: _swig_getattr(self, LoadingOptions, name)
__repr__ = _swig_repr
__swig_setmethods__["writeMode"] = _tbapi.LoadingOptions_writeMode_set
__swig_getmethods__["writeMode"] = _tbapi.LoadingOptions_writeMode_get
if _newclass:
writeMode = _swig_property(_tbapi.LoadingOptions_writeMode_get, _tbapi.LoadingOptions_writeMode_set)
__swig_setmethods__["minLatency"] = _tbapi.LoadingOptions_minLatency_set
__swig_getmethods__["minLatency"] = _tbapi.LoadingOptions_minLatency_get
if _newclass:
minLatency = _swig_property(_tbapi.LoadingOptions_minLatency_get, _tbapi.LoadingOptions_minLatency_set)
__swig_setmethods__["space"] = _tbapi.LoadingOptions_space_set
__swig_getmethods__["space"] = _tbapi.LoadingOptions_space_get
if _newclass:
space = _swig_property(_tbapi.LoadingOptions_space_get, _tbapi.LoadingOptions_space_set)
def __init__(self):
this = _tbapi.new_LoadingOptions()
try:
self.this.append(this)
except __builtin__.Exception:
self.this = this
__swig_destroy__ = _tbapi.delete_LoadingOptions
__del__ = lambda self: None
LoadingOptions_swigregister = _tbapi.LoadingOptions_swigregister
LoadingOptions_swigregister(LoadingOptions)
class StreamOptions(_object):
"""
Stream definition attributes.
Example:
```
so = tbapi.StreamOptions()
so.name = key
so.description = key
so.scope = tbapi.StreamScope('DURABLE')
so.distributionFactor = 1
so.highAvailability = False
so.polymorphic = False
so.metadata = schema
db.createStream(key, options)
```
"""
__swig_setmethods__ = {}
__setattr__ = lambda self, name, value: _swig_setattr(self, StreamOptions, name, value)
__swig_getmethods__ = {}
__getattr__ = lambda self, name: _swig_getattr(self, StreamOptions, name)
__repr__ = _swig_repr
def name(self, name: str = None) -> None:
'''Optional user-readable name.'''
if name == None:
return self.__getName()
else:
self.__setName(name)
return name
def description(self, description: str = None) -> None:
'''Optional multi-line description.'''
if description == None:
return self.__getDescription()
else:
self.__setDescription(description)
return description
def owner(self, owner: str = None) -> None:
'''Optional owner of stream.
During stream creation it will be set
equals to authenticated user name.
'''
if owner == None:
return self.__getOwner()
else:
self.__setOwner(owner)
return owner
def location(self, location: str = None) -> None:
'''Location of the stream (by default null). When defined this attribute provides alternative stream location (rather than default location under QuantServerHome)'''
if location == None:
return self.__getLocation()
else:
self.__setLocation(location)
return location
def distributionRuleName(self, distributionRuleName: str = None) -> None:
'''Class name of the distribution rule'''
if distributionRuleName == None:
return self.__getDistributionRuleName()
else:
self.__setDistributionRuleName(distributionRuleName)
return distributionRuleName
def metadata(self, metadata: str = None) -> None:
'''Stream metadata in XML format. To build metadata programatically, use tbapi.SchemaDef class.'''
if metadata == None:
return self.__getMetadata()
else:
self.__setMetadata(metadata)
return metadata
__swig_setmethods__["scope"] = _tbapi.StreamOptions_scope_set
__swig_getmethods__["scope"] = _tbapi.StreamOptions_scope_get
if _newclass:
scope = _swig_property(_tbapi.StreamOptions_scope_get, _tbapi.StreamOptions_scope_set)
__swig_setmethods__["distributionFactor"] = _tbapi.StreamOptions_distributionFactor_set
__swig_getmethods__["distributionFactor"] = _tbapi.StreamOptions_distributionFactor_get
if _newclass:
distributionFactor = _swig_property(_tbapi.StreamOptions_distributionFactor_get, _tbapi.StreamOptions_distributionFactor_set)
__swig_setmethods__["duplicatesAllowed"] = _tbapi.StreamOptions_duplicatesAllowed_set
__swig_getmethods__["duplicatesAllowed"] = _tbapi.StreamOptions_duplicatesAllowed_get
if _newclass:
duplicatesAllowed = _swig_property(_tbapi.StreamOptions_duplicatesAllowed_get, _tbapi.StreamOptions_duplicatesAllowed_set)
__swig_setmethods__["highAvailability"] = _tbapi.StreamOptions_highAvailability_set
__swig_getmethods__["highAvailability"] = _tbapi.StreamOptions_highAvailability_get
if _newclass:
highAvailability = _swig_property(_tbapi.StreamOptions_highAvailability_get, _tbapi.StreamOptions_highAvailability_set)
__swig_setmethods__["unique"] = _tbapi.StreamOptions_unique_set
__swig_getmethods__["unique"] = _tbapi.StreamOptions_unique_get
if _newclass:
unique = _swig_property(_tbapi.StreamOptions_unique_get, _tbapi.StreamOptions_unique_set)
__swig_setmethods__["polymorphic"] = _tbapi.StreamOptions_polymorphic_set
__swig_getmethods__["polymorphic"] = _tbapi.StreamOptions_polymorphic_get
if _newclass:
polymorphic = _swig_property(_tbapi.StreamOptions_polymorphic_get, _tbapi.StreamOptions_polymorphic_set)
__swig_setmethods__["periodicity"] = _tbapi.StreamOptions_periodicity_set
__swig_getmethods__["periodicity"] = _tbapi.StreamOptions_periodicity_get
if _newclass:
periodicity = _swig_property(_tbapi.StreamOptions_periodicity_get, _tbapi.StreamOptions_periodicity_set)
def __eq__(self, value):
return _tbapi.StreamOptions___eq__(self, value)
def __init__(self):
this = _tbapi.new_StreamOptions()
try:
self.this.append(this)
except __builtin__.Exception:
self.this = this
def __getName(self):
return _tbapi.StreamOptions___getName(self)
def __setName(self, name):
return _tbapi.StreamOptions___setName(self, name)
def __getDescription(self):
return _tbapi.StreamOptions___getDescription(self)
def __setDescription(self, description):
return _tbapi.StreamOptions___setDescription(self, description)
def __getOwner(self):
return _tbapi.StreamOptions___getOwner(self)
def __setOwner(self, owner):
return _tbapi.StreamOptions___setOwner(self, owner)
def __getLocation(self):
return _tbapi.StreamOptions___getLocation(self)
def __setLocation(self, location):
return _tbapi.StreamOptions___setLocation(self, location)
def __getDistributionRuleName(self):
return _tbapi.StreamOptions___getDistributionRuleName(self)
def __setDistributionRuleName(self, distributionRuleName):
return _tbapi.StreamOptions___setDistributionRuleName(self, distributionRuleName)
def __getMetadata(self):
return _tbapi.StreamOptions___getMetadata(self)
def __setMetadata(self, metadata):
return _tbapi.StreamOptions___setMetadata(self, metadata)
__swig_destroy__ = _tbapi.delete_StreamOptions
__del__ = lambda self: None
StreamOptions_swigregister = _tbapi.StreamOptions_swigregister
StreamOptions_swigregister(StreamOptions)
class QueryParameter(_object):
"""Input parameter definition for a prepared statement."""
__swig_setmethods__ = {}
__setattr__ = lambda self, name, value: _swig_setattr(self, QueryParameter, name, value)
__swig_getmethods__ = {}
__getattr__ = lambda self, name: _swig_getattr(self, QueryParameter, name)
__repr__ = _swig_repr
__swig_setmethods__["name"] = _tbapi.QueryParameter_name_set
__swig_getmethods__["name"] = _tbapi.QueryParameter_name_get
if _newclass:
name = _swig_property(_tbapi.QueryParameter_name_get, _tbapi.QueryParameter_name_set)
__swig_setmethods__["type"] = _tbapi.QueryParameter_type_set
__swig_getmethods__["type"] = _tbapi.QueryParameter_type_get
if _newclass:
type = _swig_property(_tbapi.QueryParameter_type_get, _tbapi.QueryParameter_type_set)
def __init__(self, *args):
this = _tbapi.new_QueryParameter(*args)
try:
self.this.append(this)
except __builtin__.Exception:
self.this = this
def value(self, *args):
return _tbapi.QueryParameter_value(self, *args)
__swig_destroy__ = _tbapi.delete_QueryParameter
__del__ = lambda self: None
QueryParameter_swigregister = _tbapi.QueryParameter_swigregister
QueryParameter_swigregister(QueryParameter)
class TickDb(_object):
"""
The top-level implementation to the methods of the Deltix Tick
Database engine. Instances of this class are created by static method
createFromUrl:
```
db = tbapi.TickDb.createFromUrl('dxtick://localhost:8011')
```
or
```
db = tbapi.TickDb.createFromUrl('dxtick://localhost:8011', 'user', 'password')
```
"""
__swig_setmethods__ = {}
__setattr__ = lambda self, name, value: _swig_setattr(self, TickDb, name, value)
__swig_getmethods__ = {}
__getattr__ = lambda self, name: _swig_getattr(self, TickDb, name)
def __init__(self, *args, **kwargs):
raise AttributeError("No constructor defined")
__repr__ = _swig_repr
@staticmethod
def createFromUrl(url: str, user: str = None, password: str = None) -> "TickDb":
'''Creates a new database instance with the specified root folder, or URL.
Args:
url (str): Connection URL.
user (str): User.
password (str): Password.
Returns:
TickDb: An un-opened TickDB instance.
'''
if user == None:
return _tbapi.TickDb___createFromUrl(url)
else:
return _tbapi.TickDb___createFromUrlWithUser(url, user, password)
@staticmethod
@contextmanager
def openFromUrl(url: str, readonly: bool, user: str = None, password: str = None):
'''Creates a new database instance with the specified root folder, or URL, and opens it.
Args:
url (str): Connection URL.
readonly (bool): Open data store in read-only mode.
user (str): User.
password (str): Password.
Returns:
TickDb: An opened TickDB instance.
'''
db = TickDb.createFromUrl(url, user, password)
try:
db.open(readonly)
yield db
finally:
if db.isOpen():
db.close()
def isReadOnly(self) -> bool:
'''Determines whether the store is open as read-only.'''
return self.__isReadOnly()
def isOpen(self) -> bool:
'''Determines whether the store is open.'''
return self.__isOpen()
def open(self, readOnlyMode: bool) -> bool:
'''Open the data store.
Args:
readOnlyMode (bool): Open data store in read-only mode.
'''
return self.__open(readOnlyMode)
def close(self) -> None:
'''Closes data store.'''
return self.__close()
def format(self) -> bool:
'''Create a new object on disk and format internally.
The data store is left open for read-write at the end of this method.
'''
return self.__format()
def listStreams(self) -> 'list[TickStream]':
'''Enumerates existing streams.
Returns:
list[TickStream]: An array of existing stream objects.
'''
return self.__listStreams()
def getStream(self, key: str) -> 'TickStream':
'''Looks up an existing stream by key.
Args:
key (str): Identifies the stream.
Returns:
TickStream: A stream object, or None if the key was not found.
'''
return self.__getStream(key)
def createStream(self, key: str, options: StreamOptions) -> 'TickStream':
'''Creates a new stream within the database.
Args:
key (str): A required key later used to identify the stream.
options (StreamOptions): Options for creating the stream.
Returns:
TickStream: A new instance of TickStream.
'''
return self.__createStream(key, options)
def createFileStream(self, key: str, dataFile: str) -> 'TickStream':
'''Creates a new stream mount to the given data file.
Args:
key (str): A required key later used to identify the stream.
dataFile (str): Path to the data file (on server side).
Returns:
TickStream: A new instance of TickStream.
'''
return self.__createFileStream(key)
def createCursor(self, stream: 'TickStream', options: SelectionOptions) -> 'TickCursor':
'''Opens an initially empty cursor for reading data from multiple streams,
according to the specified options. The messages
are returned from the cursor strictly ordered by time. Within the same
exact timestamp, the order of messages is undefined and may vary from
call to call, i.e. it is non-deterministic.
The cursor is returned initially empty and must be reset.
The TickCursor class provides
methods for dynamically re-configuring the subscription, or jumping to
a different timestamp.
Args:
stream (TickStream): Stream from which data will be selected.
options (SelectionOptions): Selection options.
Returns:
TickCursor: A cursor used to read messages.
'''
return self.__createCursor(stream, options)
@contextmanager
def tryCursor(self, stream: 'TickStream', options: SelectionOptions) -> 'TickCursor':
'''contextmanager version of createCursor. Usage:
```
with db.newCursor(stream, options) as cursor:
while cursor.next():
message = cursor.getMessage()
```
'''
cursor = None
try:
cursor = self.__createCursor(stream, options)
yield cursor
finally:
cursor.close()
def select(self, timestamp: int, streams: 'list[TickStream]', options: SelectionOptions, types: 'list[str]', entities: 'list[str]') -> 'TickCursor':
'''Opens a cursor for reading data from multiple streams,
according to the specified options. The messages
are returned from the cursor strictly ordered by time. Within the same
exact time stamp, the order of messages is undefined and may vary from
call to call, i.e. it is non-deterministic.
Note that the arguments of this method only determine the initial
configuration of the cursor. The TickCursor clsas provides
methods for dynamically re-configuring the subscription, or jumping to
a different timestamp.
Args:
timestamp (int): The start timestamp in millis.
streams (list[TickStream]): Streams from which data will be selected.
options (SelectionOptions): Selection options.
types (list[str]): Specified message types to be subscribed. If null, then all types will be subscribed.
entities (list[str]): Specified entities to be subscribed. If null, then all entities will be subscribed.
Returns:
TickCursor: A cursor used to read messages.
'''
return self.__select(timestamp, streams, options, types, entities)
@contextmanager
def trySelect(self, timestamp: int, streams: 'list[TickStream]', options: SelectionOptions, types: 'list[str]', entities: 'list[str]') -> 'TickCursor':
'''Contextmanager version of select. Usage:
```
with db.newSelect(timestamp, streams, options, types, entities) as cursor:
while cursor.next():
message = cursor.getMessage()
```
'''
cursor = None
try:
cursor = self.__select(timestamp, streams, options, types, entities)
yield cursor
finally:
cursor.close()
def createLoader(self, stream: 'TickStream', options: LoadingOptions) -> 'TickLoader':
'''Creates a channel for loading data. The loader must be closed
when the loading process is finished.
Args:
stream (TickStream): stream for loading data.
options (SelectionOptions): Loading Options.
Returns:
TickLoader: created loader.
'''
return self.__createLoader(stream, options)
@contextmanager
def tryLoader(self, stream: 'TickStream', options: LoadingOptions) -> 'TickLoader':
'''Contextmanager version of createLoader. Usage:
with db.newLoader(stream, options) as loader:
loader.send(message)
'''
loader = None
try:
loader = self.__createLoader(stream, options)
yield loader
finally:
loader.close()
def executeQuery(self, query: str, options: SelectionOptions = None, timestamp: int = JAVA_LONG_MIN_VALUE, entities: 'list[str]' = None, params: 'list[QueryParameter]' = []) -> 'TickCursor':
'''Execute Query and creates a message source for reading data from it,
according to the specified options. The messages
are returned from the cursor strictly ordered by time. Within the same
exact time stamp, the order of messages is undefined and may vary from
call to call, i.e. it is non-deterministic.
Args:
query (str): Query text element.
options (SelectionOptions): Selection options.
timestamp (int): The start timestamp in millis.
entities (list[str]): Specified entities to be subscribed.
If null, then all entities will be subscribed.
params (list[QueryParameter]): The parameter values of the query.
Returns:
TickCursor: An iterable message source to read messages.
'''
if options == None:
return self.__executeQuery(query)
else:
return self.__executeQueryFull(query, options, timestamp, entities, params);
@contextmanager
def tryExecuteQuery(self, query: str, options: SelectionOptions = None, timestamp: int = JAVA_LONG_MIN_VALUE, entities: 'list[str]' = None, params: 'list[QueryParameter]' = []) -> 'TickCursor':
'''Contextmanager version of executeQuery. Usage:
```
with db.newExecuteQuery('select * from stream') as cursor:
while cursor.next():
message = cursor.getMessage()
```
'''
cursor = None
try:
if options == None:
cursor = self.__executeQuery(query)
else:
cursor = self.__executeQueryFull(query, options, timestamp, entities, params);
yield cursor
finally:
cursor.close()
if _newclass:
__createFromUrl = staticmethod(_tbapi.TickDb___createFromUrl)
else:
__createFromUrl = _tbapi.TickDb___createFromUrl
if _newclass:
__createFromUrlWithUser = staticmethod(_tbapi.TickDb___createFromUrlWithUser)
else:
__createFromUrlWithUser = _tbapi.TickDb___createFromUrlWithUser
def __isReadOnly(self):
return _tbapi.TickDb___isReadOnly(self)
def __isOpen(self):
return _tbapi.TickDb___isOpen(self)
def __open(self, readOnlyMode):
return _tbapi.TickDb___open(self, readOnlyMode)
def __close(self):
return _tbapi.TickDb___close(self)
def __format(self):
return _tbapi.TickDb___format(self)
def __listStreams(self):
return _tbapi.TickDb___listStreams(self)
def __getStream(self, key):
return _tbapi.TickDb___getStream(self, key)
def __createStream(self, key, options):
return _tbapi.TickDb___createStream(self, key, options)
def __createFileStream(self, key, dataFile):
return _tbapi.TickDb___createFileStream(self, key, dataFile)
def __createCursor(self, stream, options):
return _tbapi.TickDb___createCursor(self, stream, options)
def __select(self, time, streams, options, types, entities):
return _tbapi.TickDb___select(self, time, streams, options, types, entities)
def __createLoader(self, stream, options):
return _tbapi.TickDb___createLoader(self, stream, options)
def __executeQueryFull(self, qql, options, time, instruments, params):
return _tbapi.TickDb___executeQueryFull(self, qql, options, time, instruments, params)
__swig_destroy__ = _tbapi.delete_TickDb
__del__ = lambda self: None
def __executeQuery(self, qql):
return _tbapi.TickDb___executeQuery(self, qql)
TickDb_swigregister = _tbapi.TickDb_swigregister
TickDb_swigregister(TickDb)
def TickDb___createFromUrl(url):
return _tbapi.TickDb___createFromUrl(url)
TickDb___createFromUrl = _tbapi.TickDb___createFromUrl
def TickDb___createFromUrlWithUser(url, username, password):
return _tbapi.TickDb___createFromUrlWithUser(url, username, password)
TickDb___createFromUrlWithUser = _tbapi.TickDb___createFromUrlWithUser
class TickStream(_object):
"""
The stream is a time series of messages for a number of
financial instruments ('entities'). Messages can be price bars, trade ticks,
bid/offer ticks, or any of the many more built-in and user-defined types.
In the simplest case, a database will have a single stream of data.
Multiple streams can be used to represent data of different frequencies, or completely
different factors. For instance, separate streams can represent
1-minute price bars and ticks for the same set of entities. Or,
you can have price bars and volatility bars in separate streams.
Get stream:
```
stream = tickdb.getStream('stream_key')
```
List stream:
```
streams = tickdb.listStreams()
```
"""
__swig_setmethods__ = {}
__setattr__ = lambda self, name, value: _swig_setattr(self, TickStream, name, value)
__swig_getmethods__ = {}
__getattr__ = lambda self, name: _swig_getattr(self, TickStream, name)
def __init__(self, *args, **kwargs):
raise AttributeError("No constructor defined")
__repr__ = _swig_repr
def key(self) -> str:
'''Returns the key, which uniquely identifies the stream within its database.'''
return self.__key()
def name(self) -> str:
'''Returns a user-readable short name.'''
return self.__name()
def distributionFactor(self) -> int:
'''Returns the target number of files to be used for storing data.'''
return self.__distributionFactor()
def description(self) -> str:
'''Returns a user-readable multi-line description.'''
return self.__description()
def owner(self) -> str:
'''Returns stream owner.'''
return self.__owner()