gpt4 book ai didi

C++ : Avoid lot of boolean variable for multiple verification conditions in trading app

转载 作者:太空宇宙 更新时间:2023-11-04 12:21:56 25 4
gpt4 key购买 nike

我是交易应用程序的初级开发人员...我们有一个订单刷新验证单元。它必须验证交易所的订单确认。我们批量发送一堆不同的请求(NEW、MODIFY、CANCEL)来交换……所有订单的每个 T 间隔必须进行最多 N 次验证。如果在 N 重试之前所有订单都验证成功,那么很好..否则我们需要指示验证不成功。我完成了一个非常紧急的基本编码,如下所示

for( N times )
{
for_each ( sent_request_order ) // SENT
{
1) get all the refreshed order from DB or shared mem i.e REFRESHED
2) find current sent order in REFRESHED

if( not_found )
not refreshed from exchange, continue to next order

if( found )

case NEW : //check for new status, mark verification done
case MODIFY : //check for modified status..
//if not mark pending, go to next order,
//revisit the same after T time
case CANCEL : //check for cancelled status..
//if not mark pending, go to next order,
//revisit the same after T time
}

if( all_verified )
exit from verification.

wait ( T sec )

}

order_verification_pending, order_verification_done, order_visited, order_not_visited, all_verified, all_not_verified ... 用于指示的大量 bool 标志..

有没有更好的方法来做到这一点……在各个类之间分配责任……????

我知道这不是一个普遍的问题....但仍然有标志让我处理起来很麻烦......

最佳答案

您的算法看起来可行。实现它。

在代码运行之前不要尝试优化它。一旦你有一个运行的工作版本,不管有多丑,然后你就会寻找优化的方法和手段。很有可能您会找到一种方法来处理给您带来如此多麻烦的标志。

关于C++ : Avoid lot of boolean variable for multiple verification conditions in trading app,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4496790/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com