Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add logs for orders in json format #552

Merged
merged 1 commit into from
Nov 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions models/BotConfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ def __init__(self, *args, **kwargs):
self.smart_switch = 1
self.telegram = False
self.telegramdatafolder = ""
self.logbuysellinjson = False
self.buypercent = 100
self.sellpercent = 100
self.last_action = None
Expand Down Expand Up @@ -516,6 +517,7 @@ def _parse_arguments(self):
help="Enable Machine Learning E.g. seasonal ARIMA model for predictions",
)
parser.add_argument("--websocket", action="store_true", help="Enable websocket")
parser.add_argument("--logbuysellinjson", action="store_true", help="Enable logging orders in json format")

# pylint: disable=unused-variable
args, unknown = parser.parse_known_args()
Expand Down
7 changes: 7 additions & 0 deletions models/PyCryptoBot.py
Original file line number Diff line number Diff line change
Expand Up @@ -803,6 +803,9 @@ def enableML(self) -> bool:
def enableWebsocket(self) -> bool:
return self.websocket

def enabledLogBuySellInJson(self) -> bool:
return self.logbuysellinjson

def setGranularity(self, granularity: int):
if granularity in [60, 300, 900, 3600, 21600, 86400]:
self.granularity = granularity
Expand Down Expand Up @@ -1352,6 +1355,10 @@ def _generate_banner(self) -> None:
str(self.enableinsufficientfundslogging)
+ " --enableinsufficientfundslogging",
)
text_box.line(
"Log Buy and Sell orders in JSON",
str(self.logbuysellinjson) + " --logbuysellinjson"
)

if self.getBuyMaxSize():
text_box.line(
Expand Down
7 changes: 7 additions & 0 deletions models/config/default_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -461,3 +461,10 @@ def defaultConfigParse(app, config):
app.buymaxsize = config["buymaxsize"]
else:
raise TypeError("buymaxsize must be of type int or float")

if "logbuysellinjson" in config:
if isinstance(config["logbuysellinjson"], int):
if bool(config["logbuysellinjson"]):
app.logbuysellinjson = True
else:
raise TypeError("logbuysellinjson must be of type int")
6 changes: 6 additions & 0 deletions pycryptobot.py
Original file line number Diff line number Diff line change
Expand Up @@ -1392,6 +1392,11 @@ def executeJob(

_state.last_df_index = str(df_last.index.format()[0])

if _app.enabledLogBuySellInJson() == True \
and _state.action in ["BUY", "SELL"] \
and len(_app.trade_tracker) > 0:
Logger.info( _app.trade_tracker.loc[len(_app.trade_tracker)-1].to_json())
byymster marked this conversation as resolved.
Show resolved Hide resolved

if not _app.isLive() and _state.iterations == len(df):
simulation = {
"config": {},
Expand Down Expand Up @@ -1674,6 +1679,7 @@ def executeJob(

def main():
try:
_websocket = None
whittlem marked this conversation as resolved.
Show resolved Hide resolved
message = "Starting "
if app.getExchange() == "coinbasepro":
message += "Coinbase Pro bot"
Expand Down