Algorithm 价格/时间优先级算法是如何工作的?
我试图编写一个简单的FIFO(价格/时间优先级)订单匹配程序,但我不太确定逻辑是否正确: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
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个买入和卖出订单的模拟上运行了这个程序,但是说实话,我没有一个参考来检查它是否与订单匹配正确-并且尝试手动运行交易将非常耗时。有人能确认我说的对吗?您需要首先完整地描述问题,然后再描述您的解决方案。您立即开始使用解决方案。如果您没有任何单元测试,那么您有一个错误:-)您的算法是用于购买还是出售的?看起来你两个都想做。