Skip to content

Commit

Permalink
更新文档
Browse files Browse the repository at this point in the history
  • Loading branch information
Zhou-JiaJun committed Jul 7, 2023
1 parent 6b214db commit 8f9aaf1
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 4 deletions.
14 changes: 11 additions & 3 deletions docs/source/api/base_api.rst
Expand Up @@ -730,11 +730,19 @@ Account - 账户
:inherited-members:


Position - 持仓
StockPosition - 股票持仓
------------------------------------------------------
.. module:: rqalpha.portfolio.position
.. module:: rqalpha.mod.rqalpha_mod_sys_accounts.position_model

.. autoclass:: Position
.. autoclass:: StockPosition
:members:
:inherited-members:


FuturePosition - 期货持仓
------------------------------------------------------

.. autoclass:: FuturePosition
:members:
:inherited-members:

Expand Down
45 changes: 45 additions & 0 deletions rqalpha/interface.py
Expand Up @@ -132,6 +132,51 @@ def quantity(self):
"""
raise NotImplementedError

@property
@abc.abstractmethod
def avg_price(self):
# type: () -> Union[int, float]
"""
开仓均价
"""
raise NotImplementedError

@property
@abc.abstractmethod
def pnl(self):
# type: () -> float
"""
该持仓的累计盈亏
"""
raise NotImplementedError

@property
@abc.abstractmethod
def equity(self):
# type: () -> float
"""
当前持仓市值
"""
raise NotImplementedError

@property
@abc.abstractmethod
def prev_close(self):
# type: () -> float
"""
昨日收盘价
"""
raise NotImplementedError

@property
@abc.abstractmethod
def last_price(self):
# type: () -> float
"""
当前最新价
"""
raise NotImplementedError


class AbstractStrategyLoader(with_metaclass(abc.ABCMeta)):
"""
Expand Down
1 change: 0 additions & 1 deletion rqalpha/mod/rqalpha_mod_sys_accounts/position_model.py
Expand Up @@ -236,7 +236,6 @@ def equity(self):
@property
def margin(self) -> float:
"""
保证金
保证金 = 持仓量 * 最新价 * 合约乘数 * 保证金率
"""
return self.margin_rate * self.market_value
Expand Down

0 comments on commit 8f9aaf1

Please sign in to comment.