Published on Jun 21, 2018
Selling on a secondary market is technically much more complicated for BeePlus than buying from a primary or secondary market since it needs even more finely-orchestrated ever-running background jobs.
Logic for the end-user is similar with other investing functionalities - when user has created any rule with at least one filter (and BeePlus has been authorized), then that rule is participating in selling loans on Bondora's secondary market.
Also, as for buying, so called background jobs exist which do all the heavy-lifting and are not visible to the user directly. For selling on the secondary market there exists five forever-running jobs - one for sending out sale requests to secondary market, three for updating sale status of loans (one for recent sales, another for longer sale periods and one for special erroneous sale requests) and one for cancelling sales when item does not match rule's filters anymore. Last one allows for nice chainable sale strategies - you can read more about it in blog.
BeePlus fetches user's current investments from Bondora as often as possible to get them with the most updated status. It would do it even more often, but Bondora has set up many different documented and undocumented rate limits. After getting investments, it will cycle through all of them trying to match against secondary market sell rules. Most of the matching is done by comparing rule's filter field value with the item's actual value, but there's also some more complicated algorithms involved when values are choices, ranges or time-based. After any rule with all matching filters has been found, a sale order is sent to Bondora.
Putting a sale order on Bondora's platform is an asynchronous process, which means that BeePlus needs to ask status of all the items to understand if anything has been sold already or not. BeePlus also cancels sales, when loan on sale does not match rule anymore.
While writing this post, everything seems to be quite simple, but it's far from reality. In reality there has been many undocumented API features, throttling rules have been changed during BeePlus's operation, API itself has been changed with very brief notice period (or without any notice), API is technically unstable at times and so on. It's not like a walk in the park even if it seems so from using BeePlus. One of the biggest problems for me as a developer has been working with Bondora's API throttling rules - basically, the more requests I need to perform against their API, the more I will hit against throttling rules. And there's quite many requests to perform to keep everything running for primary and secondary market at all time.
I hope that these inner working posts have given some overview of how BeePlus operates when operating on a primary and secondary market. If you have any other questions regarding BeePlus then do not hesitate to write me.