xdusongwei / HODL

通过对多头仓位做T的方式来提升赌场存活率的自动化交易系统🎰
MIT License
3 stars 1 forks source link

hodl.exception_tools.PrepareError #7

Open xinmans opened 3 days ago

xinmans commented 3 days ago

11-19 00:13:25.442|WARNING:流程异常: 11-19 00:13:31.613|ERROR:更新收工状态/持仓/现金/行情时出现错误: Traceback (most recent call last): File "/home/xinmans/mydev/HODL/hodl/store_hodl.py", line 375, in on_current self.prepare_chip()


  File "/home/xinmans/mydev/HODL/hodl/store_hodl.py", line 165, in prepare_chip
    chip_count = self.current_chip()
  File "/home/xinmans/mydev/HODL/hodl/trade_mixin.py", line 93, in current_chip
    return self.broker_proxy.query_chips()
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/xinmans/mydev/HODL/hodl/proxy/broker_proxy.py", line 63, in query_chips
    assert isinstance(chips, int)
           ~~~~~~~~~~^^^^^^^^^^^^
AssertionError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/xinmans/mydev/HODL/hodl/store_hodl.py", line 381, in on_current
    raise error
hodl.exception_tools.PrepareError
11-19 00:13:31.614|WARNING:流程异常:
xdusongwei commented 3 days ago

是有非整数碎股么

xinmans commented 3 days ago

是有非整数碎股么

美股不区分碎股吧 港股有14股赠送的狗东碎股

xinmans commented 3 days ago

盘后和夜盘不能支持吗? 现在美股全天候24小时都可以交易。

xdusongwei commented 3 days ago

非RTH时段交易目前在美股市场不具备广泛性

xinmans commented 2 days ago

可以支持下模拟盘成交下单吗? 实盘担心大亏损

xdusongwei commented 2 days ago

参考券商模拟盘配置说明填充配置文件吧

xinmans commented 1 day ago

脆股都卖了,但是还是报错

11-20 23:28:32.186|WARNING:流程异常: 11-20 23:28:38.399|ERROR:更新收工状态/持仓/现金/行情时出现错误: Traceback (most recent call last): File "/home/xinmans/mydev/HODL/hodl/store_hodl.py", line 368, in on_current self.prepare_chip()


  File "/home/xinmans/mydev/HODL/hodl/store_hodl.py", line 166, in prepare_chip
    chip_count = self.current_chip()
  File "/home/xinmans/mydev/HODL/hodl/trade_mixin.py", line 96, in current_chip
    return self.broker_proxy.query_chips()
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/xinmans/mydev/HODL/hodl/proxy/broker_proxy.py", line 63, in query_chips
    assert isinstance(chips, int)
           ~~~~~~~~~~^^^^^^^^^^^^
AssertionError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/xinmans/mydev/HODL/hodl/store_hodl.py", line 374, in on_current
    raise error
hodl.exception_tools.PrepareError
11-20 23:28:38.401|WARNING:流程异常: 
xdusongwei commented 1 day ago

虽然你没提供出配置文件, 没有指出具体所管理的持仓是哪个, 我猜你可能填写的symbol代码并不能在持仓接口中正确对应到你期望的结果.

xinmans commented 22 hours ago

虽然你没提供出配置文件, 没有指出具体所管理的持仓是哪个, 我猜你可能填写的symbol代码并不能在持仓接口中正确对应到你期望的结果.

配置如下,所以意思是symbol = "AAPL"要修改成longport支持的symbol ?

每个持仓的部分在 StoreConfig 中定义

[store.AAPL_longport] region = "US" currency = "USD" broker = "longport" symbol = "AAPL" trade_strategy = "hodl" trade_type = "stock" name = "apple" enable = true visible = true max_shares = 12345 state_file_path = "./state-{broker}-{symbol}-stage{stage}.json" state_archive_folder = "./hodl/archive-{broker}-{symbol}" buy_spread_rate = 0.0 sell_spread_rate = 0.004 buy_order_rate = 0.002 sell_order_rate = 0.002 precision = 2 shares_per_unit = 1 booting_check = true base_price_last_buy = true base_price_last_buy_days = 21 base_price_day_low = true base_price_tumble_protect = true base_price_using_broker = true tumble_protect_day_range = 7 tumble_protect_rsi = true tumble_protect_rsi_unlock_limit = 75 tumble_protect_rsi_warning_limit = 25 lock_position = true price_rate = 1.0 rework_level = 1 market_price_rate = 0.005 sleep_mode = true

xdusongwei commented 12 hours ago

持仓设置看起来没问题, 可能是broker节的设定关系 你可以直接在根目录 debug broker 对象, 了解连接环境:

from hodl.tools import *
from hodl.broker import *
v = VariableTools('/your/config/toml/path')
bc = v.broker_config_dict('longport')
broker = LongPortApi(
    broker_config=bc,
    symbol='AAPL',
    name='',
)
broker.on_init()

print("cash:", broker.query_cash())
print("AAPL chips:", broker.query_chips())