shadowk29 / BinanceBalance

Simple graphical interface to facilitate balancing of user-defined cryptocurrency portfolio on Binance. This is in no way affiliated with Binance.
MIT License
8 stars 5 forks source link

great project #3

Open thes3cr3t1 opened 5 years ago

thes3cr3t1 commented 5 years ago

This is a great project, do you think you will ever continue development?

I have been playing with the program. Could you describe a better way to handle the websocket message queue. It seems the more coins that are added to the portfolio the GUI updates become slower and the backlog of unprocessed messages builds up. What does this limitation depend on is it CPU or Ram? would running on a server increase performance or is there a better way to process the message queue? Threads? Multiprocessing?

A cool feature would be a way of adding new coins to the portfolio and automatically skimming a certain percentage from each coin to allow for the new coin at a certain percentage.

Portfolio change, gains would be another good feature. Asset holdings increases stats would be good too (Accumulation).

Overall a great project which seems some hard work went into but development stopped? What were your goals for this project?

Cheers!

shadowk29 commented 5 years ago

Thanks for your interest!

It's true that the message queue starts to get too slow past some number of coins. CPU speed would determine that cutoff. The reason for this is because currently every message processed updates all the relevant fields in the GUI. A faster procedure would be to only update internal variables with new messages, and then call updates to the GUI periodically instead. This would limit the graphical changes needed, which would in turn greatly speed up message handling.

Alternatively, you could use multithreading, giving each coin its own thread and message handler, and have a master thread that reads information from the individual coin threads to update the GUI. Would require a complete rewrite to do that way, but it would certainly solve the speed issue.

Adding new coins could be implemented relatively easily, I think. Gains and losses wouldn't be too hard, either. I will do both once I get some time to spend on it again.

Development hasn't stopped, it's just that this is a side project for me which only gets worked on as time permits, which it has not lately. My goal for the project was to create a rebalancer that did not require me to give my API keys to a third party. In that I've succeeded, I think, it does the job. But there is certainly room for improvement. If you are interested in collaborating, feel free to submit a pull request.

thes3cr3t1 commented 5 years ago

Thanks for the quick response, a lot of effort has gone into this. I have made a few changes I could submit. I have immplemented USD portfolio total balance and also auto-rebalance after certain "imbalance" threshold is breached.

I'm a hobby/novice coder, this is the first time I have played with Python though! This project is actually a great project for learning through 'doing'. I'd be happy to upload my changes, although they may need some tweaking.

The message queue build up with a large portfolio is quiet an interesting problem, it's almost mesmerizing watching the GUI update in real time as it does. I'll research this issue further based on your comments.

Thanks

shadowk29 commented 5 years ago

USD balance would be nice to have. I implemented it in the other branch but got side tracked. Feel free to submit pull requests as you like, I am happy to review your code.

thes3cr3t1 commented 5 years ago

Perfect! Ill endeavor to make a solid contribution. It's very kind of you to share your code and make this opensource, most would have kept this private for personal gain or other similar reasons.

Having used your program freely, it makes me feel compelled to follow your example.

I look forward to contributing.

Cheers.

thes3cr3t1 commented 5 years ago

Hi, I edited the program to include multiprocessing for receiving Websocket data and entering it into the message queue. I have also added threading capability to process the queue much faster and update GUI.

It'd be great if you could look over the code to see if you can make any improvements since I am really new to Python.

Next, id like to add trading with BTC as the base currency so that we can rebalance a percentage of the portfolio into a stable coin such as USDT.

Cheers!

shadowk29 commented 5 years ago

Please submit a pull request whenever you're ready.

shadowk29 commented 5 years ago

I merged your pull request into the "multithreading" branch - please target future pull requests to that branch. I have started testing, so far it appears to work, but on windows the GUI is a bit less responsive overall than the single-threaded version and I occasionally get crashes with TimeOut errors from binance. I will spend some time learning about multithreading and make some suggestions once I have a better handle on things.

shadowk29 commented 5 years ago

Actually we have another problem: pandas is not threadsafe (not even read-only operations are threadsafe) so the ultithreaded version is not safe to use as-is without changing the underlying data structure. This will require some careful planning.