forked from gateio/gateapi-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathposition.py
More file actions
703 lines (532 loc) · 19 KB
/
position.py
File metadata and controls
703 lines (532 loc) · 19 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
# coding: utf-8
"""
Gate API v4
APIv4 provides spot, margin and futures trading operations. There are public APIs to retrieve the real-time market statistics, and private APIs which needs authentication to trade on user's behalf. # noqa: E501
Contact: support@mail.gate.io
Generated by: https://openapi-generator.tech
"""
import pprint
import re # noqa: F401
import six
from gate_api.configuration import Configuration
class Position(object):
"""NOTE: This class is auto generated by OpenAPI Generator.
Ref: https://openapi-generator.tech
Do not edit the class manually.
"""
"""
Attributes:
openapi_types (dict): The key is attribute name
and the value is attribute type.
attribute_map (dict): The key is attribute name
and the value is json key in definition.
"""
openapi_types = {
'user': 'int',
'contract': 'str',
'size': 'int',
'leverage': 'str',
'risk_limit': 'str',
'leverage_max': 'str',
'maintenance_rate': 'str',
'value': 'str',
'margin': 'str',
'entry_price': 'str',
'liq_price': 'str',
'mark_price': 'str',
'unrealised_pnl': 'str',
'realised_pnl': 'str',
'history_pnl': 'str',
'last_close_pnl': 'str',
'realised_point': 'str',
'history_point': 'str',
'adl_ranking': 'int',
'pending_orders': 'int',
'close_order': 'PositionCloseOrder',
}
attribute_map = {
'user': 'user',
'contract': 'contract',
'size': 'size',
'leverage': 'leverage',
'risk_limit': 'risk_limit',
'leverage_max': 'leverage_max',
'maintenance_rate': 'maintenance_rate',
'value': 'value',
'margin': 'margin',
'entry_price': 'entry_price',
'liq_price': 'liq_price',
'mark_price': 'mark_price',
'unrealised_pnl': 'unrealised_pnl',
'realised_pnl': 'realised_pnl',
'history_pnl': 'history_pnl',
'last_close_pnl': 'last_close_pnl',
'realised_point': 'realised_point',
'history_point': 'history_point',
'adl_ranking': 'adl_ranking',
'pending_orders': 'pending_orders',
'close_order': 'close_order',
}
def __init__(
self,
user=None,
contract=None,
size=None,
leverage=None,
risk_limit=None,
leverage_max=None,
maintenance_rate=None,
value=None,
margin=None,
entry_price=None,
liq_price=None,
mark_price=None,
unrealised_pnl=None,
realised_pnl=None,
history_pnl=None,
last_close_pnl=None,
realised_point=None,
history_point=None,
adl_ranking=None,
pending_orders=None,
close_order=None,
local_vars_configuration=None,
): # noqa: E501
# type: (int, str, int, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, int, int, PositionCloseOrder, Configuration) -> None
"""Position - a model defined in OpenAPI""" # noqa: E501
if local_vars_configuration is None:
local_vars_configuration = Configuration()
self.local_vars_configuration = local_vars_configuration
self._user = None
self._contract = None
self._size = None
self._leverage = None
self._risk_limit = None
self._leverage_max = None
self._maintenance_rate = None
self._value = None
self._margin = None
self._entry_price = None
self._liq_price = None
self._mark_price = None
self._unrealised_pnl = None
self._realised_pnl = None
self._history_pnl = None
self._last_close_pnl = None
self._realised_point = None
self._history_point = None
self._adl_ranking = None
self._pending_orders = None
self._close_order = None
self.discriminator = None
if user is not None:
self.user = user
if contract is not None:
self.contract = contract
if size is not None:
self.size = size
if leverage is not None:
self.leverage = leverage
if risk_limit is not None:
self.risk_limit = risk_limit
if leverage_max is not None:
self.leverage_max = leverage_max
if maintenance_rate is not None:
self.maintenance_rate = maintenance_rate
if value is not None:
self.value = value
if margin is not None:
self.margin = margin
if entry_price is not None:
self.entry_price = entry_price
if liq_price is not None:
self.liq_price = liq_price
if mark_price is not None:
self.mark_price = mark_price
if unrealised_pnl is not None:
self.unrealised_pnl = unrealised_pnl
if realised_pnl is not None:
self.realised_pnl = realised_pnl
if history_pnl is not None:
self.history_pnl = history_pnl
if last_close_pnl is not None:
self.last_close_pnl = last_close_pnl
if realised_point is not None:
self.realised_point = realised_point
if history_point is not None:
self.history_point = history_point
if adl_ranking is not None:
self.adl_ranking = adl_ranking
if pending_orders is not None:
self.pending_orders = pending_orders
if close_order is not None:
self.close_order = close_order
@property
def user(self):
"""Gets the user of this Position. # noqa: E501
User ID # noqa: E501
:return: The user of this Position. # noqa: E501
:rtype: int
"""
return self._user
@user.setter
def user(self, user):
"""Sets the user of this Position.
User ID # noqa: E501
:param user: The user of this Position. # noqa: E501
:type: int
"""
self._user = user
@property
def contract(self):
"""Gets the contract of this Position. # noqa: E501
Futures contract # noqa: E501
:return: The contract of this Position. # noqa: E501
:rtype: str
"""
return self._contract
@contract.setter
def contract(self, contract):
"""Sets the contract of this Position.
Futures contract # noqa: E501
:param contract: The contract of this Position. # noqa: E501
:type: str
"""
self._contract = contract
@property
def size(self):
"""Gets the size of this Position. # noqa: E501
Position size # noqa: E501
:return: The size of this Position. # noqa: E501
:rtype: int
"""
return self._size
@size.setter
def size(self, size):
"""Sets the size of this Position.
Position size # noqa: E501
:param size: The size of this Position. # noqa: E501
:type: int
"""
self._size = size
@property
def leverage(self):
"""Gets the leverage of this Position. # noqa: E501
Position leverage. 0 means cross margin; positive number means isolated margin # noqa: E501
:return: The leverage of this Position. # noqa: E501
:rtype: str
"""
return self._leverage
@leverage.setter
def leverage(self, leverage):
"""Sets the leverage of this Position.
Position leverage. 0 means cross margin; positive number means isolated margin # noqa: E501
:param leverage: The leverage of this Position. # noqa: E501
:type: str
"""
self._leverage = leverage
@property
def risk_limit(self):
"""Gets the risk_limit of this Position. # noqa: E501
Position risk limit # noqa: E501
:return: The risk_limit of this Position. # noqa: E501
:rtype: str
"""
return self._risk_limit
@risk_limit.setter
def risk_limit(self, risk_limit):
"""Sets the risk_limit of this Position.
Position risk limit # noqa: E501
:param risk_limit: The risk_limit of this Position. # noqa: E501
:type: str
"""
self._risk_limit = risk_limit
@property
def leverage_max(self):
"""Gets the leverage_max of this Position. # noqa: E501
Maximum leverage under current risk limit # noqa: E501
:return: The leverage_max of this Position. # noqa: E501
:rtype: str
"""
return self._leverage_max
@leverage_max.setter
def leverage_max(self, leverage_max):
"""Sets the leverage_max of this Position.
Maximum leverage under current risk limit # noqa: E501
:param leverage_max: The leverage_max of this Position. # noqa: E501
:type: str
"""
self._leverage_max = leverage_max
@property
def maintenance_rate(self):
"""Gets the maintenance_rate of this Position. # noqa: E501
Maintenance rate under current risk limit # noqa: E501
:return: The maintenance_rate of this Position. # noqa: E501
:rtype: str
"""
return self._maintenance_rate
@maintenance_rate.setter
def maintenance_rate(self, maintenance_rate):
"""Sets the maintenance_rate of this Position.
Maintenance rate under current risk limit # noqa: E501
:param maintenance_rate: The maintenance_rate of this Position. # noqa: E501
:type: str
"""
self._maintenance_rate = maintenance_rate
@property
def value(self):
"""Gets the value of this Position. # noqa: E501
Position value calculated in settlement currency # noqa: E501
:return: The value of this Position. # noqa: E501
:rtype: str
"""
return self._value
@value.setter
def value(self, value):
"""Sets the value of this Position.
Position value calculated in settlement currency # noqa: E501
:param value: The value of this Position. # noqa: E501
:type: str
"""
self._value = value
@property
def margin(self):
"""Gets the margin of this Position. # noqa: E501
Position margin # noqa: E501
:return: The margin of this Position. # noqa: E501
:rtype: str
"""
return self._margin
@margin.setter
def margin(self, margin):
"""Sets the margin of this Position.
Position margin # noqa: E501
:param margin: The margin of this Position. # noqa: E501
:type: str
"""
self._margin = margin
@property
def entry_price(self):
"""Gets the entry_price of this Position. # noqa: E501
Entry price # noqa: E501
:return: The entry_price of this Position. # noqa: E501
:rtype: str
"""
return self._entry_price
@entry_price.setter
def entry_price(self, entry_price):
"""Sets the entry_price of this Position.
Entry price # noqa: E501
:param entry_price: The entry_price of this Position. # noqa: E501
:type: str
"""
self._entry_price = entry_price
@property
def liq_price(self):
"""Gets the liq_price of this Position. # noqa: E501
Liquidation price # noqa: E501
:return: The liq_price of this Position. # noqa: E501
:rtype: str
"""
return self._liq_price
@liq_price.setter
def liq_price(self, liq_price):
"""Sets the liq_price of this Position.
Liquidation price # noqa: E501
:param liq_price: The liq_price of this Position. # noqa: E501
:type: str
"""
self._liq_price = liq_price
@property
def mark_price(self):
"""Gets the mark_price of this Position. # noqa: E501
Current mark price # noqa: E501
:return: The mark_price of this Position. # noqa: E501
:rtype: str
"""
return self._mark_price
@mark_price.setter
def mark_price(self, mark_price):
"""Sets the mark_price of this Position.
Current mark price # noqa: E501
:param mark_price: The mark_price of this Position. # noqa: E501
:type: str
"""
self._mark_price = mark_price
@property
def unrealised_pnl(self):
"""Gets the unrealised_pnl of this Position. # noqa: E501
Unrealized PNL # noqa: E501
:return: The unrealised_pnl of this Position. # noqa: E501
:rtype: str
"""
return self._unrealised_pnl
@unrealised_pnl.setter
def unrealised_pnl(self, unrealised_pnl):
"""Sets the unrealised_pnl of this Position.
Unrealized PNL # noqa: E501
:param unrealised_pnl: The unrealised_pnl of this Position. # noqa: E501
:type: str
"""
self._unrealised_pnl = unrealised_pnl
@property
def realised_pnl(self):
"""Gets the realised_pnl of this Position. # noqa: E501
Realized PNL # noqa: E501
:return: The realised_pnl of this Position. # noqa: E501
:rtype: str
"""
return self._realised_pnl
@realised_pnl.setter
def realised_pnl(self, realised_pnl):
"""Sets the realised_pnl of this Position.
Realized PNL # noqa: E501
:param realised_pnl: The realised_pnl of this Position. # noqa: E501
:type: str
"""
self._realised_pnl = realised_pnl
@property
def history_pnl(self):
"""Gets the history_pnl of this Position. # noqa: E501
History realized PNL # noqa: E501
:return: The history_pnl of this Position. # noqa: E501
:rtype: str
"""
return self._history_pnl
@history_pnl.setter
def history_pnl(self, history_pnl):
"""Sets the history_pnl of this Position.
History realized PNL # noqa: E501
:param history_pnl: The history_pnl of this Position. # noqa: E501
:type: str
"""
self._history_pnl = history_pnl
@property
def last_close_pnl(self):
"""Gets the last_close_pnl of this Position. # noqa: E501
PNL of last position close # noqa: E501
:return: The last_close_pnl of this Position. # noqa: E501
:rtype: str
"""
return self._last_close_pnl
@last_close_pnl.setter
def last_close_pnl(self, last_close_pnl):
"""Sets the last_close_pnl of this Position.
PNL of last position close # noqa: E501
:param last_close_pnl: The last_close_pnl of this Position. # noqa: E501
:type: str
"""
self._last_close_pnl = last_close_pnl
@property
def realised_point(self):
"""Gets the realised_point of this Position. # noqa: E501
Realized POINT PNL # noqa: E501
:return: The realised_point of this Position. # noqa: E501
:rtype: str
"""
return self._realised_point
@realised_point.setter
def realised_point(self, realised_point):
"""Sets the realised_point of this Position.
Realized POINT PNL # noqa: E501
:param realised_point: The realised_point of this Position. # noqa: E501
:type: str
"""
self._realised_point = realised_point
@property
def history_point(self):
"""Gets the history_point of this Position. # noqa: E501
History realized POINT PNL # noqa: E501
:return: The history_point of this Position. # noqa: E501
:rtype: str
"""
return self._history_point
@history_point.setter
def history_point(self, history_point):
"""Sets the history_point of this Position.
History realized POINT PNL # noqa: E501
:param history_point: The history_point of this Position. # noqa: E501
:type: str
"""
self._history_point = history_point
@property
def adl_ranking(self):
"""Gets the adl_ranking of this Position. # noqa: E501
ADL ranking, range from 1 to 5 # noqa: E501
:return: The adl_ranking of this Position. # noqa: E501
:rtype: int
"""
return self._adl_ranking
@adl_ranking.setter
def adl_ranking(self, adl_ranking):
"""Sets the adl_ranking of this Position.
ADL ranking, range from 1 to 5 # noqa: E501
:param adl_ranking: The adl_ranking of this Position. # noqa: E501
:type: int
"""
self._adl_ranking = adl_ranking
@property
def pending_orders(self):
"""Gets the pending_orders of this Position. # noqa: E501
Current open orders # noqa: E501
:return: The pending_orders of this Position. # noqa: E501
:rtype: int
"""
return self._pending_orders
@pending_orders.setter
def pending_orders(self, pending_orders):
"""Sets the pending_orders of this Position.
Current open orders # noqa: E501
:param pending_orders: The pending_orders of this Position. # noqa: E501
:type: int
"""
self._pending_orders = pending_orders
@property
def close_order(self):
"""Gets the close_order of this Position. # noqa: E501
:return: The close_order of this Position. # noqa: E501
:rtype: PositionCloseOrder
"""
return self._close_order
@close_order.setter
def close_order(self, close_order):
"""Sets the close_order of this Position.
:param close_order: The close_order of this Position. # noqa: E501
:type: PositionCloseOrder
"""
self._close_order = close_order
def to_dict(self):
"""Returns the model properties as a dict"""
result = {}
for attr, _ in six.iteritems(self.openapi_types):
value = getattr(self, attr)
if isinstance(value, list):
result[attr] = list(map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value))
elif hasattr(value, "to_dict"):
result[attr] = value.to_dict()
elif isinstance(value, dict):
result[attr] = dict(
map(
lambda item: (item[0], item[1].to_dict()) if hasattr(item[1], "to_dict") else item,
value.items(),
)
)
else:
result[attr] = value
return result
def to_str(self):
"""Returns the string representation of the model"""
return pprint.pformat(self.to_dict())
def __repr__(self):
"""For `print` and `pprint`"""
return self.to_str()
def __eq__(self, other):
"""Returns true if both objects are equal"""
if not isinstance(other, Position):
return False
return self.to_dict() == other.to_dict()
def __ne__(self, other):
"""Returns true if both objects are not equal"""
if not isinstance(other, Position):
return True
return self.to_dict() != other.to_dict()