HIP - Move the Pure Market Strategy from cython to Pure Python

Author: [0x8…6] (Snapshot)

Original Post Date: 2 Aug 2022 - Aug, 2, 2022

[Snapshot Proposal Link](not yet)

Category:
Dev Grants

Summary:

  1. Refactor Pure Market Strategy into pure python implementation - 40k

Linked HGP:
https://snapshot.org/#/hbot.eth/proposal/0xd0c5b54badfd631d7433da0f76795a9dc0d82fc66596d547cda2f3537f903e3f

Description:

  1. Refactor Pure Market Strategy into pure python implementation
    Pure Python implementation will make it much simple to improve, debug and test

HBOT amount:

  1. 40k to @MementoMori (self ;P)
3 Likes

I support this initiative, I think that it’s a very good way to start making our project more accessible to other developers!

How will this make it simpler?
On a scale of 1 to 10 how much simpler is it going to be after removing cython?
Are there any tradeoffs from removing cython such as speed will suffer greatly?

I would also estimate the work at closer to 5000 HBOT.
I also think it’s a bad idea and not thought through properly - most people use PMM and just turning it off for everyone rather than using a feature switch isn’t user friendly. Adding a cdef section and adding entries in a pdx doesn’t suddenly muddy the waters making it difficult to debug and test things.

  • From a medium-level developer standpoint, it’ll be a 8. The cython modules do not seem to be debuggable with PyCharm-Pro and the methods are not Mockable for testing

  • Speed does not seem to be a necessity for PMM. The cdefs are oddly set:

    cdef c_apply_price_band(self, proposal):
        if self._price_ceiling > 0 and self.get_price() >= self._price_ceiling:
            proposal.buys = []
        if self._price_floor > 0 and self.get_price() <= self._price_floor:
            proposal.sells = []

However, cProfile will be used to evaluate the speed degradation from the proposal and will be a criteria in assessing its benefit

The HBOT estimate was simply copied from a similar HIP, 20 USDT for a couple days of work seems reasonable

There is no mention of turning PMM off in this proposal. cdef are not muddying the waters, but so far no one in discord pointed out a way to debug in PyCharm, having to put a litany of print() and remembering to remove them is cumbersome

Sorry, I just don’t see the need - as someone who has rewritten the entire hummingbot for personal use my advice would be to just strip out the fat you don’t need. I’ve never had a problem using self.logger to quickly get to the bottom of issues. The major pain is creating a new global variable…takes a long time to write into all the different files such as template, config, pyx, pdx

Agreed that this proposal has few benefits for experienced/seasoned developers, who may be using gdb and have better coding discipline. From my experience as a beginner, who wants to contribute, cython is a hurdle.

The proposal changed a bit to reflect the possibility to implement ‘Augmented Pure Python’ mode. This requires more research and work. Currently moving from cython to Pure Python replaces completely the cython compiled code, the ‘Augmented Pure Python’ provides both version concurrently, which means that there will be some collision to resolve between the 2 different mode of cythonizing the code.

As an example, Simple Pure Python translation of PMM takes just a few days, was done and fully tested already - Augmented Pure Python had to be put on halt after a few days of work with some good progress but not completely successful

If we lose speed of execution, then I am against

If the execution is at the same speed, then I am for
As a beginner, python is + accessible to me.

But if it is to lose 1ms+ of execution, then no