CyberPunkMetalHead / gateio-crypto-trading-bot-binance-announcements-new-coins

This is a crypto trading bot that scans the Binance Annoucements page for new coins, and places trades on Gateio
MIT License
1.21k stars 303 forks source link

Event driven #63

Closed Triasmus closed 2 years ago

Triasmus commented 2 years ago

This makes the buy and sell blocks event driven, so that we attempt to buy immediately after hearing the announcement, and then sell once we're done buying.

I also made the config values global, since I figured that it makes sense for them to be global and I figured it would be the easiest way to get those values to the buy block.

I decided to leave the sell block in the main thread. It has to keep a sleeper anyway, since it does api requests to learn the current sale price.

This is based on #62 master

The only way I've tested the Threading.Event.Wait() func is through the ctrl-c functionality. I'm confident it will work, based on the buy_ready event triggered log message coming when I expect after hitting ctrl-c, but it has not been tested with a real announcement. It still hasn't been tested with a real announcement, but it works with a fake announcement.

Triasmus commented 2 years ago

I suggest reviewing the changes with just the last two commits: https://github.com/CyberPunkMetalHead/gateio-crypto-trading-bot-binance-announcements-new-coins/pull/63/files/489a9241d861476b9c22ffeead43a9467ee77429..a4d65988dca02f4e5d5cb1f0394a2b18f4f25a94

See https://github.com/CyberPunkMetalHead/gateio-crypto-trading-bot-binance-announcements-new-coins/pull/63#issuecomment-968105406 for suggested review method.

Triasmus commented 2 years ago

I'll update this pull once #59 and #62 get merged into master. updated

Triasmus commented 2 years ago

I've determined that it's not ready, even if you wanted to merge it before #59 for some reason.

I've realized that the buy block expects to have more chances to fulfill the whole order, so I shouldn't clear the Event until it's not going to want to buy any more.

VuzzyM commented 2 years ago

@Triasmus Today was announcements, did you test the functionality together with pr 62?

Triasmus commented 2 years ago

@VuzzyM I did. My internet went out for a bit, which caused some issues (as noted in discord). I restarted the script about 10 minutes after ENS was announced. The script then immediately caught ENS as a new announcement... Besides that, it seems like it's working correctly.

There is a potential bug I thought of yesterday morning that I need to look at before I un-draft this PR

VuzzyM commented 2 years ago

@VuzzyM I did. My internet went out for a bit, which caused some issues (as noted in discord). I restarted the script about 10 minutes after ENS was announced. The script then immediately caught ENS as a new announcement... Besides that, it seems like it's working correctly.

There is a potential bug I thought of yesterday morning that I need to look at before I un-draft this PR

Okey, we are waiting for the solution

Triasmus commented 2 years ago

I'm not planning on doing any updates for this pull until #59 goes in, unless I get told that 59 isn't going to be going in any time soon.

VuzzyM commented 2 years ago

@cryptmjt ?

Triasmus commented 2 years ago

I believe this will work now.

After doing all the work, I made a separate branch and just copy/pasted the buy and sell blocks to their own functions in one commit (https://github.com/CyberPunkMetalHead/gateio-crypto-trading-bot-binance-announcements-new-coins/pull/63/commits/f4791022ba6e0d50369c431cbe38fd130476d840) and then made a separate commit with all the changes I actually made (https://github.com/CyberPunkMetalHead/gateio-crypto-trading-bot-binance-announcements-new-coins/pull/63/commits/c9451393dc52ccac2bc5a39b44cc62e8af015abb).

I suggest reviewing https://github.com/CyberPunkMetalHead/gateio-crypto-trading-bot-binance-announcements-new-coins/pull/63/commits/c9451393dc52ccac2bc5a39b44cc62e8af015abb with whitespace turned off if you want to see the changes I actually made.

Edit: You'll also want to review any commit after this comment.