跳转到内容
View in the app

A better way to browse. Learn more.

彼岸论坛

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.
欢迎抵达彼岸 彼岸花开 此处谁在 -彼岸论坛

[程序员] 请教技术方案, 2 个机子根据对方的状态 相互通信

发表于
参加:2 个不同个人局域网的 PC ,运行一套 python 程序,基于 a 股的量化交易。

现在要求 a ,b 两个机子根据对方的成交与否,觉得另一方的下一步。

比如 a 成交了,b 就融券卖出,如果 a 没有成交,b 就卖出,诸如此类。

目前方法是 走 redis ,把 a ,b 的状态放到 redis ,同步双方的状态,

目前遇到的问题是 同步一次的需要 2-3 秒的时间,主要的耗时:

1. 获取 a 是否成交,这个通过循环获取订单状态,感觉这一步没法优化,因为读取状态需要时间,也是走网络,渠道券商柜台。

2. a 把状态放入 redis ,b 读取,这个一个流程里面大概会有 6 次 redis key 的读取,感觉这里的速度有点慢了。

试过判读 key 是否存在,还有 blpop 设置 0.5 秒超时,设置时间短了,如果 a 来不及获取到成交状态并推送到 redis ,
会误判没有成交,实际 a 端已经成交了。

感觉用 rabbitmq zeromq 这种消息队列会不会好一些?


或者有没有成熟的技术方案?

先谢过各位老师大佬

Featured Replies

No posts to show

创建帐户或登录来提出意见

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.