-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ExchangeBot] Now does what it is supposed to be doing
- Loading branch information
Showing
7 changed files
with
337 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,35 @@ | ||
from grapheneapi.graphenewsprotocol import GrapheneWebsocketProtocol | ||
from grapheneexchange import GrapheneExchange | ||
import time | ||
|
||
|
||
class BotProtocol(GrapheneWebsocketProtocol): | ||
pass | ||
|
||
|
||
class Bot(): | ||
|
||
def __init__(self, config, **kwargs): | ||
botProtocol = BotProtocol | ||
[setattr(botProtocol, key, config.__dict__[key]) for key in config.__dict__.keys()] | ||
|
||
self.config = config | ||
self.dex = GrapheneExchange(config, safe_mode=True) | ||
self.dex = GrapheneExchange(botProtocol, safe_mode=config.safe_mode) | ||
|
||
# Initialize all bots | ||
self.bots = {} | ||
for name in config.bots: | ||
self.bots[name] = config.bots[name]["bot"](config=self.config, | ||
name=name, | ||
dex=self.dex) | ||
for index, name in enumerate(config.bots, 1): | ||
botClass = config.bots[name]["bot"] | ||
self.bots[name] = botClass(config=config, name=name, | ||
dex=self.dex, index=index) | ||
self.bots[name].init() | ||
|
||
def wait_block(self): | ||
time.sleep(6) | ||
|
||
def execute(self): | ||
for name in self.bots: | ||
self.bots[name].cancel_mine() | ||
if self.bots[name].cancel_this_markets() and self.config.safe_mode: | ||
self.wait_block() | ||
self.bots[name].tick() | ||
self.bots[name].store() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.