天择加密量化开放框架下载
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

823 lines
24 KiB

1 year ago
  1. # coding: utf-8
  2. """
  3. Gate API v4
  4. Welcome to Gate.io API 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
  5. Contact: support@mail.gate.io
  6. Generated by: https://openapi-generator.tech
  7. """
  8. import pprint
  9. import re # noqa: F401
  10. import six
  11. from gate_api.configuration import Configuration
  12. class Position(object):
  13. """NOTE: This class is auto generated by OpenAPI Generator.
  14. Ref: https://openapi-generator.tech
  15. Do not edit the class manually.
  16. """
  17. """
  18. Attributes:
  19. openapi_types (dict): The key is attribute name
  20. and the value is attribute type.
  21. attribute_map (dict): The key is attribute name
  22. and the value is json key in definition.
  23. """
  24. openapi_types = {
  25. 'user': 'int',
  26. 'contract': 'str',
  27. 'size': 'int',
  28. 'leverage': 'str',
  29. 'risk_limit': 'str',
  30. 'leverage_max': 'str',
  31. 'maintenance_rate': 'str',
  32. 'value': 'str',
  33. 'margin': 'str',
  34. 'entry_price': 'str',
  35. 'liq_price': 'str',
  36. 'mark_price': 'str',
  37. 'initial_margin': 'str',
  38. 'maintenance_margin': 'str',
  39. 'unrealised_pnl': 'str',
  40. 'realised_pnl': 'str',
  41. 'history_pnl': 'str',
  42. 'last_close_pnl': 'str',
  43. 'realised_point': 'str',
  44. 'history_point': 'str',
  45. 'adl_ranking': 'int',
  46. 'pending_orders': 'int',
  47. 'close_order': 'PositionCloseOrder',
  48. 'mode': 'str',
  49. 'cross_leverage_limit': 'str',
  50. }
  51. attribute_map = {
  52. 'user': 'user',
  53. 'contract': 'contract',
  54. 'size': 'size',
  55. 'leverage': 'leverage',
  56. 'risk_limit': 'risk_limit',
  57. 'leverage_max': 'leverage_max',
  58. 'maintenance_rate': 'maintenance_rate',
  59. 'value': 'value',
  60. 'margin': 'margin',
  61. 'entry_price': 'entry_price',
  62. 'liq_price': 'liq_price',
  63. 'mark_price': 'mark_price',
  64. 'initial_margin': 'initial_margin',
  65. 'maintenance_margin': 'maintenance_margin',
  66. 'unrealised_pnl': 'unrealised_pnl',
  67. 'realised_pnl': 'realised_pnl',
  68. 'history_pnl': 'history_pnl',
  69. 'last_close_pnl': 'last_close_pnl',
  70. 'realised_point': 'realised_point',
  71. 'history_point': 'history_point',
  72. 'adl_ranking': 'adl_ranking',
  73. 'pending_orders': 'pending_orders',
  74. 'close_order': 'close_order',
  75. 'mode': 'mode',
  76. 'cross_leverage_limit': 'cross_leverage_limit',
  77. }
  78. def __init__(
  79. self,
  80. user=None,
  81. contract=None,
  82. size=None,
  83. leverage=None,
  84. risk_limit=None,
  85. leverage_max=None,
  86. maintenance_rate=None,
  87. value=None,
  88. margin=None,
  89. entry_price=None,
  90. liq_price=None,
  91. mark_price=None,
  92. initial_margin=None,
  93. maintenance_margin=None,
  94. unrealised_pnl=None,
  95. realised_pnl=None,
  96. history_pnl=None,
  97. last_close_pnl=None,
  98. realised_point=None,
  99. history_point=None,
  100. adl_ranking=None,
  101. pending_orders=None,
  102. close_order=None,
  103. mode=None,
  104. cross_leverage_limit=None,
  105. local_vars_configuration=None,
  106. ): # noqa: E501
  107. # type: (int, str, int, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, int, int, PositionCloseOrder, str, str, Configuration) -> None
  108. """Position - a model defined in OpenAPI""" # noqa: E501
  109. if local_vars_configuration is None:
  110. local_vars_configuration = Configuration()
  111. self.local_vars_configuration = local_vars_configuration
  112. self._user = None
  113. self._contract = None
  114. self._size = None
  115. self._leverage = None
  116. self._risk_limit = None
  117. self._leverage_max = None
  118. self._maintenance_rate = None
  119. self._value = None
  120. self._margin = None
  121. self._entry_price = None
  122. self._liq_price = None
  123. self._mark_price = None
  124. self._initial_margin = None
  125. self._maintenance_margin = None
  126. self._unrealised_pnl = None
  127. self._realised_pnl = None
  128. self._history_pnl = None
  129. self._last_close_pnl = None
  130. self._realised_point = None
  131. self._history_point = None
  132. self._adl_ranking = None
  133. self._pending_orders = None
  134. self._close_order = None
  135. self._mode = None
  136. self._cross_leverage_limit = None
  137. self.discriminator = None
  138. if user is not None:
  139. self.user = user
  140. if contract is not None:
  141. self.contract = contract
  142. if size is not None:
  143. self.size = size
  144. if leverage is not None:
  145. self.leverage = leverage
  146. if risk_limit is not None:
  147. self.risk_limit = risk_limit
  148. if leverage_max is not None:
  149. self.leverage_max = leverage_max
  150. if maintenance_rate is not None:
  151. self.maintenance_rate = maintenance_rate
  152. if value is not None:
  153. self.value = value
  154. if margin is not None:
  155. self.margin = margin
  156. if entry_price is not None:
  157. self.entry_price = entry_price
  158. if liq_price is not None:
  159. self.liq_price = liq_price
  160. if mark_price is not None:
  161. self.mark_price = mark_price
  162. if initial_margin is not None:
  163. self.initial_margin = initial_margin
  164. if maintenance_margin is not None:
  165. self.maintenance_margin = maintenance_margin
  166. if unrealised_pnl is not None:
  167. self.unrealised_pnl = unrealised_pnl
  168. if realised_pnl is not None:
  169. self.realised_pnl = realised_pnl
  170. if history_pnl is not None:
  171. self.history_pnl = history_pnl
  172. if last_close_pnl is not None:
  173. self.last_close_pnl = last_close_pnl
  174. if realised_point is not None:
  175. self.realised_point = realised_point
  176. if history_point is not None:
  177. self.history_point = history_point
  178. if adl_ranking is not None:
  179. self.adl_ranking = adl_ranking
  180. if pending_orders is not None:
  181. self.pending_orders = pending_orders
  182. self.close_order = close_order
  183. if mode is not None:
  184. self.mode = mode
  185. if cross_leverage_limit is not None:
  186. self.cross_leverage_limit = cross_leverage_limit
  187. @property
  188. def user(self):
  189. """Gets the user of this Position. # noqa: E501
  190. User ID # noqa: E501
  191. :return: The user of this Position. # noqa: E501
  192. :rtype: int
  193. """
  194. return self._user
  195. @user.setter
  196. def user(self, user):
  197. """Sets the user of this Position.
  198. User ID # noqa: E501
  199. :param user: The user of this Position. # noqa: E501
  200. :type: int
  201. """
  202. self._user = user
  203. @property
  204. def contract(self):
  205. """Gets the contract of this Position. # noqa: E501
  206. Futures contract # noqa: E501
  207. :return: The contract of this Position. # noqa: E501
  208. :rtype: str
  209. """
  210. return self._contract
  211. @contract.setter
  212. def contract(self, contract):
  213. """Sets the contract of this Position.
  214. Futures contract # noqa: E501
  215. :param contract: The contract of this Position. # noqa: E501
  216. :type: str
  217. """
  218. self._contract = contract
  219. @property
  220. def size(self):
  221. """Gets the size of this Position. # noqa: E501
  222. Position size # noqa: E501
  223. :return: The size of this Position. # noqa: E501
  224. :rtype: int
  225. """
  226. return self._size
  227. @size.setter
  228. def size(self, size):
  229. """Sets the size of this Position.
  230. Position size # noqa: E501
  231. :param size: The size of this Position. # noqa: E501
  232. :type: int
  233. """
  234. self._size = size
  235. @property
  236. def leverage(self):
  237. """Gets the leverage of this Position. # noqa: E501
  238. Position leverage. 0 means cross margin; positive number means isolated margin # noqa: E501
  239. :return: The leverage of this Position. # noqa: E501
  240. :rtype: str
  241. """
  242. return self._leverage
  243. @leverage.setter
  244. def leverage(self, leverage):
  245. """Sets the leverage of this Position.
  246. Position leverage. 0 means cross margin; positive number means isolated margin # noqa: E501
  247. :param leverage: The leverage of this Position. # noqa: E501
  248. :type: str
  249. """
  250. self._leverage = leverage
  251. @property
  252. def risk_limit(self):
  253. """Gets the risk_limit of this Position. # noqa: E501
  254. Position risk limit # noqa: E501
  255. :return: The risk_limit of this Position. # noqa: E501
  256. :rtype: str
  257. """
  258. return self._risk_limit
  259. @risk_limit.setter
  260. def risk_limit(self, risk_limit):
  261. """Sets the risk_limit of this Position.
  262. Position risk limit # noqa: E501
  263. :param risk_limit: The risk_limit of this Position. # noqa: E501
  264. :type: str
  265. """
  266. self._risk_limit = risk_limit
  267. @property
  268. def leverage_max(self):
  269. """Gets the leverage_max of this Position. # noqa: E501
  270. Maximum leverage under current risk limit # noqa: E501
  271. :return: The leverage_max of this Position. # noqa: E501
  272. :rtype: str
  273. """
  274. return self._leverage_max
  275. @leverage_max.setter
  276. def leverage_max(self, leverage_max):
  277. """Sets the leverage_max of this Position.
  278. Maximum leverage under current risk limit # noqa: E501
  279. :param leverage_max: The leverage_max of this Position. # noqa: E501
  280. :type: str
  281. """
  282. self._leverage_max = leverage_max
  283. @property
  284. def maintenance_rate(self):
  285. """Gets the maintenance_rate of this Position. # noqa: E501
  286. Maintenance rate under current risk limit # noqa: E501
  287. :return: The maintenance_rate of this Position. # noqa: E501
  288. :rtype: str
  289. """
  290. return self._maintenance_rate
  291. @maintenance_rate.setter
  292. def maintenance_rate(self, maintenance_rate):
  293. """Sets the maintenance_rate of this Position.
  294. Maintenance rate under current risk limit # noqa: E501
  295. :param maintenance_rate: The maintenance_rate of this Position. # noqa: E501
  296. :type: str
  297. """
  298. self._maintenance_rate = maintenance_rate
  299. @property
  300. def value(self):
  301. """Gets the value of this Position. # noqa: E501
  302. Position value calculated in settlement currency # noqa: E501
  303. :return: The value of this Position. # noqa: E501
  304. :rtype: str
  305. """
  306. return self._value
  307. @value.setter
  308. def value(self, value):
  309. """Sets the value of this Position.
  310. Position value calculated in settlement currency # noqa: E501
  311. :param value: The value of this Position. # noqa: E501
  312. :type: str
  313. """
  314. self._value = value
  315. @property
  316. def margin(self):
  317. """Gets the margin of this Position. # noqa: E501
  318. Position margin # noqa: E501
  319. :return: The margin of this Position. # noqa: E501
  320. :rtype: str
  321. """
  322. return self._margin
  323. @margin.setter
  324. def margin(self, margin):
  325. """Sets the margin of this Position.
  326. Position margin # noqa: E501
  327. :param margin: The margin of this Position. # noqa: E501
  328. :type: str
  329. """
  330. self._margin = margin
  331. @property
  332. def entry_price(self):
  333. """Gets the entry_price of this Position. # noqa: E501
  334. Entry price # noqa: E501
  335. :return: The entry_price of this Position. # noqa: E501
  336. :rtype: str
  337. """
  338. return self._entry_price
  339. @entry_price.setter
  340. def entry_price(self, entry_price):
  341. """Sets the entry_price of this Position.
  342. Entry price # noqa: E501
  343. :param entry_price: The entry_price of this Position. # noqa: E501
  344. :type: str
  345. """
  346. self._entry_price = entry_price
  347. @property
  348. def liq_price(self):
  349. """Gets the liq_price of this Position. # noqa: E501
  350. Liquidation price # noqa: E501
  351. :return: The liq_price of this Position. # noqa: E501
  352. :rtype: str
  353. """
  354. return self._liq_price
  355. @liq_price.setter
  356. def liq_price(self, liq_price):
  357. """Sets the liq_price of this Position.
  358. Liquidation price # noqa: E501
  359. :param liq_price: The liq_price of this Position. # noqa: E501
  360. :type: str
  361. """
  362. self._liq_price = liq_price
  363. @property
  364. def mark_price(self):
  365. """Gets the mark_price of this Position. # noqa: E501
  366. Current mark price # noqa: E501
  367. :return: The mark_price of this Position. # noqa: E501
  368. :rtype: str
  369. """
  370. return self._mark_price
  371. @mark_price.setter
  372. def mark_price(self, mark_price):
  373. """Sets the mark_price of this Position.
  374. Current mark price # noqa: E501
  375. :param mark_price: The mark_price of this Position. # noqa: E501
  376. :type: str
  377. """
  378. self._mark_price = mark_price
  379. @property
  380. def initial_margin(self):
  381. """Gets the initial_margin of this Position. # noqa: E501
  382. The initial margin occupied by the position, applicable to the portfolio margin account # noqa: E501
  383. :return: The initial_margin of this Position. # noqa: E501
  384. :rtype: str
  385. """
  386. return self._initial_margin
  387. @initial_margin.setter
  388. def initial_margin(self, initial_margin):
  389. """Sets the initial_margin of this Position.
  390. The initial margin occupied by the position, applicable to the portfolio margin account # noqa: E501
  391. :param initial_margin: The initial_margin of this Position. # noqa: E501
  392. :type: str
  393. """
  394. self._initial_margin = initial_margin
  395. @property
  396. def maintenance_margin(self):
  397. """Gets the maintenance_margin of this Position. # noqa: E501
  398. Maintenance margin required for the position, applicable to portfolio margin account # noqa: E501
  399. :return: The maintenance_margin of this Position. # noqa: E501
  400. :rtype: str
  401. """
  402. return self._maintenance_margin
  403. @maintenance_margin.setter
  404. def maintenance_margin(self, maintenance_margin):
  405. """Sets the maintenance_margin of this Position.
  406. Maintenance margin required for the position, applicable to portfolio margin account # noqa: E501
  407. :param maintenance_margin: The maintenance_margin of this Position. # noqa: E501
  408. :type: str
  409. """
  410. self._maintenance_margin = maintenance_margin
  411. @property
  412. def unrealised_pnl(self):
  413. """Gets the unrealised_pnl of this Position. # noqa: E501
  414. Unrealized PNL # noqa: E501
  415. :return: The unrealised_pnl of this Position. # noqa: E501
  416. :rtype: str
  417. """
  418. return self._unrealised_pnl
  419. @unrealised_pnl.setter
  420. def unrealised_pnl(self, unrealised_pnl):
  421. """Sets the unrealised_pnl of this Position.
  422. Unrealized PNL # noqa: E501
  423. :param unrealised_pnl: The unrealised_pnl of this Position. # noqa: E501
  424. :type: str
  425. """
  426. self._unrealised_pnl = unrealised_pnl
  427. @property
  428. def realised_pnl(self):
  429. """Gets the realised_pnl of this Position. # noqa: E501
  430. Realized PNL # noqa: E501
  431. :return: The realised_pnl of this Position. # noqa: E501
  432. :rtype: str
  433. """
  434. return self._realised_pnl
  435. @realised_pnl.setter
  436. def realised_pnl(self, realised_pnl):
  437. """Sets the realised_pnl of this Position.
  438. Realized PNL # noqa: E501
  439. :param realised_pnl: The realised_pnl of this Position. # noqa: E501
  440. :type: str
  441. """
  442. self._realised_pnl = realised_pnl
  443. @property
  444. def history_pnl(self):
  445. """Gets the history_pnl of this Position. # noqa: E501
  446. History realized PNL # noqa: E501
  447. :return: The history_pnl of this Position. # noqa: E501
  448. :rtype: str
  449. """
  450. return self._history_pnl
  451. @history_pnl.setter
  452. def history_pnl(self, history_pnl):
  453. """Sets the history_pnl of this Position.
  454. History realized PNL # noqa: E501
  455. :param history_pnl: The history_pnl of this Position. # noqa: E501
  456. :type: str
  457. """
  458. self._history_pnl = history_pnl
  459. @property
  460. def last_close_pnl(self):
  461. """Gets the last_close_pnl of this Position. # noqa: E501
  462. PNL of last position close # noqa: E501
  463. :return: The last_close_pnl of this Position. # noqa: E501
  464. :rtype: str
  465. """
  466. return self._last_close_pnl
  467. @last_close_pnl.setter
  468. def last_close_pnl(self, last_close_pnl):
  469. """Sets the last_close_pnl of this Position.
  470. PNL of last position close # noqa: E501
  471. :param last_close_pnl: The last_close_pnl of this Position. # noqa: E501
  472. :type: str
  473. """
  474. self._last_close_pnl = last_close_pnl
  475. @property
  476. def realised_point(self):
  477. """Gets the realised_point of this Position. # noqa: E501
  478. Realized POINT PNL # noqa: E501
  479. :return: The realised_point of this Position. # noqa: E501
  480. :rtype: str
  481. """
  482. return self._realised_point
  483. @realised_point.setter
  484. def realised_point(self, realised_point):
  485. """Sets the realised_point of this Position.
  486. Realized POINT PNL # noqa: E501
  487. :param realised_point: The realised_point of this Position. # noqa: E501
  488. :type: str
  489. """
  490. self._realised_point = realised_point
  491. @property
  492. def history_point(self):
  493. """Gets the history_point of this Position. # noqa: E501
  494. History realized POINT PNL # noqa: E501
  495. :return: The history_point of this Position. # noqa: E501
  496. :rtype: str
  497. """
  498. return self._history_point
  499. @history_point.setter
  500. def history_point(self, history_point):
  501. """Sets the history_point of this Position.
  502. History realized POINT PNL # noqa: E501
  503. :param history_point: The history_point of this Position. # noqa: E501
  504. :type: str
  505. """
  506. self._history_point = history_point
  507. @property
  508. def adl_ranking(self):
  509. """Gets the adl_ranking of this Position. # noqa: E501
  510. Ranking of auto deleveraging, a total of 1-5 grades, `1` is the highest, `5` is the lowest, and `6` is the special case when there is no position held or in liquidation # noqa: E501
  511. :return: The adl_ranking of this Position. # noqa: E501
  512. :rtype: int
  513. """
  514. return self._adl_ranking
  515. @adl_ranking.setter
  516. def adl_ranking(self, adl_ranking):
  517. """Sets the adl_ranking of this Position.
  518. Ranking of auto deleveraging, a total of 1-5 grades, `1` is the highest, `5` is the lowest, and `6` is the special case when there is no position held or in liquidation # noqa: E501
  519. :param adl_ranking: The adl_ranking of this Position. # noqa: E501
  520. :type: int
  521. """
  522. self._adl_ranking = adl_ranking
  523. @property
  524. def pending_orders(self):
  525. """Gets the pending_orders of this Position. # noqa: E501
  526. Current open orders # noqa: E501
  527. :return: The pending_orders of this Position. # noqa: E501
  528. :rtype: int
  529. """
  530. return self._pending_orders
  531. @pending_orders.setter
  532. def pending_orders(self, pending_orders):
  533. """Sets the pending_orders of this Position.
  534. Current open orders # noqa: E501
  535. :param pending_orders: The pending_orders of this Position. # noqa: E501
  536. :type: int
  537. """
  538. self._pending_orders = pending_orders
  539. @property
  540. def close_order(self):
  541. """Gets the close_order of this Position. # noqa: E501
  542. :return: The close_order of this Position. # noqa: E501
  543. :rtype: PositionCloseOrder
  544. """
  545. return self._close_order
  546. @close_order.setter
  547. def close_order(self, close_order):
  548. """Sets the close_order of this Position.
  549. :param close_order: The close_order of this Position. # noqa: E501
  550. :type: PositionCloseOrder
  551. """
  552. self._close_order = close_order
  553. @property
  554. def mode(self):
  555. """Gets the mode of this Position. # noqa: E501
  556. Position mode, including: - `single`: dual mode is not enabled- `dual_long`: long position in dual mode- `dual_short`: short position in dual mode # noqa: E501
  557. :return: The mode of this Position. # noqa: E501
  558. :rtype: str
  559. """
  560. return self._mode
  561. @mode.setter
  562. def mode(self, mode):
  563. """Sets the mode of this Position.
  564. Position mode, including: - `single`: dual mode is not enabled- `dual_long`: long position in dual mode- `dual_short`: short position in dual mode # noqa: E501
  565. :param mode: The mode of this Position. # noqa: E501
  566. :type: str
  567. """
  568. allowed_values = ["single", "dual_long", "dual_short"] # noqa: E501
  569. if self.local_vars_configuration.client_side_validation and mode not in allowed_values: # noqa: E501
  570. raise ValueError(
  571. "Invalid value for `mode` ({0}), must be one of {1}".format(mode, allowed_values) # noqa: E501
  572. )
  573. self._mode = mode
  574. @property
  575. def cross_leverage_limit(self):
  576. """Gets the cross_leverage_limit of this Position. # noqa: E501
  577. Cross margin leverage(valid only when `leverage` is 0) # noqa: E501
  578. :return: The cross_leverage_limit of this Position. # noqa: E501
  579. :rtype: str
  580. """
  581. return self._cross_leverage_limit
  582. @cross_leverage_limit.setter
  583. def cross_leverage_limit(self, cross_leverage_limit):
  584. """Sets the cross_leverage_limit of this Position.
  585. Cross margin leverage(valid only when `leverage` is 0) # noqa: E501
  586. :param cross_leverage_limit: The cross_leverage_limit of this Position. # noqa: E501
  587. :type: str
  588. """
  589. self._cross_leverage_limit = cross_leverage_limit
  590. def to_dict(self):
  591. """Returns the model properties as a dict"""
  592. result = {}
  593. for attr, _ in six.iteritems(self.openapi_types):
  594. value = getattr(self, attr)
  595. if isinstance(value, list):
  596. result[attr] = list(map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value))
  597. elif hasattr(value, "to_dict"):
  598. result[attr] = value.to_dict()
  599. elif isinstance(value, dict):
  600. result[attr] = dict(
  601. map(
  602. lambda item: (item[0], item[1].to_dict()) if hasattr(item[1], "to_dict") else item,
  603. value.items(),
  604. )
  605. )
  606. else:
  607. result[attr] = value
  608. return result
  609. def to_str(self):
  610. """Returns the string representation of the model"""
  611. return pprint.pformat(self.to_dict())
  612. def __repr__(self):
  613. """For `print` and `pprint`"""
  614. return self.to_str()
  615. def __eq__(self, other):
  616. """Returns true if both objects are equal"""
  617. if not isinstance(other, Position):
  618. return False
  619. return self.to_dict() == other.to_dict()
  620. def __ne__(self, other):
  621. """Returns true if both objects are not equal"""
  622. if not isinstance(other, Position):
  623. return True
  624. return self.to_dict() != other.to_dict()