仓位查询接口

get_position - 获取持仓对象

rqalpha.api.get_position(order_book_id, direction=POSITION_DIRECTION.LONG)

获取某个标的的持仓对象。

Parameters
  • order_book_id (str) -- 标的编号

  • direction (Optional[POSITION_DIRECTION]) -- 持仓方向

Example

[In] get_position('000001.XSHE', POSITION_DIRECTION.LONG)
[Out]
StockPosition(order_book_id=000001.XSHE, direction=LONG, quantity=268600, market_value=4995960.0, trading_pnl=0.0, position_pnl=0)
Return type

Position

get_positions - 获取全部持仓对象

rqalpha.api.get_positions()

获取所有持仓对象列表。

Example

[In] get_positions()
[Out]
[StockPosition(order_book_id=000001.XSHE, direction=LONG, quantity=1000, market_value=19520.0, trading_pnl=0.0, position_pnl=0),
StockPosition(order_book_id=RB2112, direction=SHORT, quantity=2, market_value=-111580.0, trading_pnl=0.0, position_pnl=0)]
Return type

List[Position]

deposit - 入金(增加账户资金)

rqalpha.api.deposit(account_type, amount)

入金(增加账户资金)

Parameters
  • account_type (str) -- 账户类型

  • amount (float) -- 增加金额

Return type

None

Returns

None

withdraw - 出金(减少账户资金)

rqalpha.api.withdraw(account_type, amount)

出金(减少账户资金)

Parameters
  • account_type (str) -- 账户类型

  • amount (float) -- 减少金额

Return type

None

Returns

None

finance - 融资(增加账户资金,增加负债)

repay - 还款(减少账户资金,减少负债)