Here’s a problem that’s been bugging me for the last couple of days. Assume you have two equally sized lists of bids and asks which you would like to traverse sequentially for flips.
Now, what would be the optimal way of doing this in a vectorial manner or using adverbs? The performance is acceptable (about 500ms for 500000 items), however I believe there is a proper ‘q-like’ solution.
Thanks,
Zak
This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you are not the named addressee you must not disseminate, distribute or copy this e-mail. Please notify us on regulatory@b2c2.net immediately if you have received this e-mail by mistake and delete this e-mail from your system. If you are not the intended recipient you are notified that disclosing, copying, distributing or taking any action in reliance on the contents of this information is strictly prohibited.
Thanks for helping out. Looks like that won’t work. Actually every time one of the condition is met in the ‘or’ section, we reset the reference prices to the current bid/ask pair and then move on to the next bid/ask pair. So there is some state setting which signum/differ don’t account for…
I’m not sure if this will be any faster, but this is a more usual way of writing your method and it avoids the use of global variables. Global variables are usually avoided unless they are contained within a well defined namespace to avoid any conflicts with variables in different functions sharing the same names.
It performs a recursion passing in an list of the bidref,askref and a boolean for flipped and performs the same logic as yours above. Using scan will output the value of this list for each iteration from which we can grab the last column containing the booleans for flipped and then use ‘where’ to get the indices where this occurs. Finally we can append a 0 and index into each bids and asks list to create the table
I like your solution. Returning the previous state makes sense. Time-wise it takes the same as the original solution. However space wise, I am seeing up to 50x more memory-usage with your solution, which I guess makes sense.