Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/algorithm/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Algorithm 价格/时间优先级算法是如何工作的?_Algorithm_Finance - Fatal编程技术网

Algorithm 价格/时间优先级算法是如何工作的?

Algorithm 价格/时间优先级算法是如何工作的?,algorithm,finance,Algorithm,Finance,我试图编写一个简单的FIFO(价格/时间优先级)订单匹配程序,但我不太确定逻辑是否正确: for each unfilled buy order (newest first): filter orders by buy price > sell price while buy order not filled: fill best priced sell order if multiple equal cheapest sell orders

我试图编写一个简单的FIFO(价格/时间优先级)订单匹配程序,但我不太确定逻辑是否正确:

for each unfilled buy order (newest first):
    filter orders by buy price > sell price
    while buy order not filled:
        fill best priced sell order
        if multiple equal cheapest sell orders:
            fill oldest
    if remainder of most recently filled sell order is not 0:
        create new sell order for remainder

我已经分别在500个买入和卖出订单的模拟上运行了这个程序,但是说实话,我没有一个参考来检查它是否与订单匹配正确-并且尝试手动运行交易将非常耗时。有人能确认我说的对吗?

您需要首先完整地描述问题,然后再描述您的解决方案。您立即开始使用解决方案。如果您没有任何单元测试,那么您有一个错误:-)您的算法是用于购买还是出售的?看起来你两个都想做。