gocryptotrader
gocryptotrader copied to clipboard
gctscript status "OK" after error had happened and no more processing
New Issue
Context
I'm running several gctscripts scenarios. The problem is that if there is an error happened in the script it stops the processing. However, the status of the script is "OK" and I couldn't find a proper way to restart the script.
-
Operating System: Linux mshogin 5.14.0-1038-oem 42-Ubuntu SMP Thu May 19 05:03:08 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
-
GoCryptoTrader version (
gocryptotrader -version
): GoCryptoTrader v0.1 amd64 go1.17.10 pre-release.
Expected Behavior
It could be helpful to have the status "FAILED".
Current Behavior
After the error had happened the script status is the following
gctcli script status
{
"status": "2 of 10 virtual machines running",
"scripts": [
{
"uuid": "5e7aec45-6722-4e38-9975-0c4b90ef725d",
"name": "alpha.gct",
"next_run": "2022-06-02 22:02:37.761560319 +0200 CEST m=+5005.488771720"
}
]
}
gctcli script query --uuid 5e7aec45-6722-4e38-9975-0c4b90ef725d
{
"status": "ok",
"script": {
"uuid": "5e7aec45-6722-4e38-9975-0c4b90ef725d",
"name": "alpha.gct",
"next_run": "2022-06-02 22:02:37.761560319 +0200 CEST m=+5005.488771720"
},
Steps to Reproduce
Please provide detailed steps for reproducing the issue.
- set the timer="5s"
- exch.ordersubmit(... 'sell' ...)
Failure Logs
[ERROR] | 02/06/2022 22:02:28 | GCT Script: (ACTION) RunCtx Runtime Error: FTX unsuccessful HTTP status code: 400 raw response: {"success":false,"error":"Not enough balances"} at - at - at (main):55:3 at (main):63:1
Notes
Yes, I'm going to add a balance checker to prevent this error in the future, but there could be other errors, and having the script status could help to restart the strategy in a proper way. At the moment, I use the cron job
#!/bin/bash
set -x
set -e
uuid=$(gctcli script status | grep -B1 alpha | grep UUID | head -n 1 | awk -F'"' '{print $4}')
gctcli script execute alpha
gctcli script stop --uuid $uuid
What do you think if we change gctscript modules implementation as the following
instead of
func ExchangeOrderSubmit(args ...objects.Object) (objects.Object, error) {
if len(args) != 9 {
return nil, objects.ErrWrongNumArguments
}
exchangeName, ok := objects.ToString(args[0])
if !ok {
return nil, fmt.Errorf(ErrParameterConvertFailed, exchangeName)
}
.......
we could use something like
func errorResponse(format string, a ...interface{}) (objects.Object, error) {
return &objects.Error{
Value: &objects.String{
Value: fmt.Sprintf(format, a...),
},
}, nil
}
func ExchangeOrderSubmit(args ...objects.Object) (objects.Object, error) {
if len(args) != 9 {
return errorResponse(objects.ErrWrongNumArguments)
}
exchangeName, ok := objects.ToString(args[0])
if !ok {
return errorResponse(ErrParameterConvertFailed, exchangeName)
}
......
and then in gct scripts, we will be able to use is_error as the following
res := exch.ordersubmit(
if is_error(res) {
// do error handling
}
@mshogin Please feel free to test out the new updates and let me know of any further suggestions. Thank you for opening this issue, hopefully, your issues are addressed.