Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QAQIFIAccount 中A股交易的qapos的问题 #2

Open
zhongjyyy opened this issue Jul 5, 2020 · 1 comment
Open

QAQIFIAccount 中A股交易的qapos的问题 #2

zhongjyyy opened this issue Jul 5, 2020 · 1 comment

Comments

@zhongjyyy
Copy link

关于当日买入后, volume_frozen_today , volume_today 值问题

  1. 空仓建仓后应为
assert pos.volume_long_his == 0
assert pos.volume_long == amount
assert pos.volume_long_today == amount  # 此项源码作为结算使用
assert pos.volume_long_frozen_today == 0  # TODO 买入是否需要冻结?
  1. 当日空仓建仓后应无法卖出
r = acc.send_order(code, amount=amount, price=price, towards=ORDER_DIRECTION.BUY).copy()
acc.make_deal(r)
r1 = acc.send_order(code, amount=amount, price=price, towards=ORDER_DIRECTION.SELL).copy()
assert r1 == False  # 此处应为交易前置检查失败
acc.make_deal(r1)
  1. 测试源码
def test_sell():
    # 委托状态:委托全部成交
    code, price, amount = '000001', 10, 1000
    acc: QIFI_Account = QIFI_Account("x4", "x4")
    acc.initial()
    r = acc.send_order(code, amount=amount, price=price, towards=ORDER_DIRECTION.BUY).copy()
    acc.make_deal(r)
    pos: QA_Position = acc.positions.get(code)
    volume_his = pos.volume_long_his
    print("建仓买入", pos.hold_detail)
    assert pos.volume_long_his == 0
    assert pos.volume_long == amount
    assert pos.volume_long_today == amount
    assert pos.volume_long_frozen_today == 0  # TODO 买入是否需要冻结?
    if volume_his == 0:
        r = acc.send_order(code, amount=amount, price=price, towards=ORDER_DIRECTION.SELL).copy()
        print("卖出委托", r)
        assert r == False  # 此处应为交易前置检查失败
        if r:
            acc.make_deal(r)
        # {'volume_long_today': 0, 'volume_long_his': 0, 'volume_long': 1000, 'volume_short_today': 0, 'volume_short_his': 0, 'volume_short': 0, 'volume_long_frozen_today': 1000, 'volume_short_frozen_today': 0}
        print("卖出委托后", pos.hold_detail)
        assert pos.volume_long == amount
        assert pos.volume_long_today == amount
        assert pos.volume_long_frozen_today == 0  # TODO 买入是否需要冻结?
    acc.settle()
    print("结算后", pos.hold_detail)
    assert pos.volume_long == amount
    assert pos.volume_long_his == amount
    assert pos.volume_long_today == 0
    assert pos.volume_long_frozen_today == 0
@yutiansut
Copy link
Owner

already fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants