Skip to content

Commit 70a58fe

Browse files
committed
v2.0
1 parent f4d5b13 commit 70a58fe

File tree

9 files changed

+768
-118
lines changed

9 files changed

+768
-118
lines changed

.github/workflows/docker-image.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
uses: docker/build-push-action@v2
3232
with:
3333
context: .
34-
platforms: linux/amd64
34+
platforms: linux/amd64,linux/arm/v7
3535
file: ./Dockerfile.cryptopump
3636
push: true
3737
tags: ${{ secrets.DOCKER_HUB_USERNAME }}/cryptopump:latest
@@ -45,5 +45,14 @@ jobs:
4545
push: true
4646
tags: ${{ secrets.DOCKER_HUB_USERNAME }}/cryptopump_db:latest
4747

48+
- name: Build and push
49+
uses: docker/build-push-action@v2
50+
with:
51+
context: .
52+
platforms: linux/arm/v7
53+
file: ./Dockerfile.mariadb
54+
push: true
55+
tags: ${{ secrets.DOCKER_HUB_USERNAME }}/cryptopump_mariadb:latest
56+
4857
- name: Image digest
4958
run: echo ${{ steps.docker_build.outputs.digest }}

Dockerfile.mariadb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
FROM yobasystems/alpine-mariadb:10.4.17-armhf
2+
COPY /mysql/cryptopump-mariadb.sql /docker-entrypoint-initdb.d/init.sql

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ CryptoPump is a cryptocurrency trading tool that focuses on extremely high speed
1313
Do not risk money which you are afraid to lose. USE THE SOFTWARE AT YOUR OWN RISK. THE AUTHORS AND ALL AFFILIATES ASSUME NO RESPONSIBILITY FOR YOUR TRADING RESULTS.
1414

1515
Always start by running a this trading tool in Dry-run or TestNet and do not engage money before you understand how it works and what profit/loss you should expect.
16-
#### - CryptoPump is now available as a self-contained Docker container set. Check it out at https://hub.docker.com/repository/docker/andreleibovici/cryptopump
16+
#### - CryptoPump is now available as a self-contained Docker container set for linux/amd64 and linux/arm/v7 (Raspberry Pi). Check it out at https://hub.docker.com/repository/docker/andreleibovici/cryptopump
1717

1818
- CryptoPump is a cryptocurrency trading tool that focuses on extremely high speed and flexibility. The algorithms utilize Go Language and the exchange WebSockets to react in real-time to market movements based on Bollinger statistical analysis and pre-defined profit margins.
1919

algorithms/algorithms.go

Lines changed: 45 additions & 109 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ package algorithms
33
import (
44
"encoding/json"
55
"errors"
6-
"fmt"
7-
"strings"
86
"sync"
97
"time"
108

@@ -578,50 +576,33 @@ func WsUserDataServe(
578576
LogLevel: "DebugLevel",
579577
}.Do()
580578

581-
switch {
582-
case strings.Contains(err.Error(), "1001"):
583-
/* -1001 DISCONNECTED Internal error; unable to process your request. Please try again. */
584-
585-
exchange.GetClient(configData, sessionData) /* Reconnect exchange client */
586-
587-
case strings.Contains(err.Error(), "1006"):
588-
/* -1006 UNEXPECTED_RESP An unexpected response was received from the message bus. Execution status unknown. */
589-
/* Error Codes for Binance https://github.com/binance/binance-spot-api-docs/blob/master/errors.md */
590-
591-
exchange.GetClient(configData, sessionData) /* Reconnect exchange client */
579+
}
592580

593-
case strings.Contains(err.Error(), "read: operation timed out"):
594-
/* read tcp X.X.X.X:port->X.X.X.X:port: read: operation timed out */
581+
for {
595582

596-
exchange.GetClient(configData, sessionData) /* Reconnect exchange client */
583+
doneC, stopC, err = exchange.WsUserDataServe(configData, sessionData, wsHandler, errHandler) /* Start websocket channel */
597584

598-
case strings.Contains(err.Error(), "read: connection reset by peer"):
599-
/* read tcp X.X.X.X:port->X.X.X.X:port: read: connection reset by peer */
585+
if err != nil { /* If websocket channel is not connected */
600586

601-
exchange.GetClient(configData, sessionData) /* Reconnect exchange client */
587+
panic(err) /* Panic */
602588

603589
}
604590

605-
Channel{}.SetTrue(sessionData) /* Set all goroutine channels to stop */
606-
Channel{
607-
name: "WsUserDataServe",
608-
}.Stop(stopC, wg, configData, sessionData) /* Stop goroutine channel */
609-
610-
/* Retrieve NEW WsUserDataServe listen key for user stream service when there's an error */
611-
sessionData.ListenKey, err = exchange.GetUserStreamServiceListenKey(configData, sessionData)
612-
613-
}
614-
615-
doneC, stopC, err = exchange.WsUserDataServe(configData, sessionData, wsHandler, errHandler)
591+
<-doneC
616592

617-
if err != nil {
593+
logger.LogEntry{ /* Log Entry */
594+
Config: configData,
595+
Market: nil,
596+
Session: sessionData,
597+
Order: &types.Order{},
598+
Message: functions.GetFunctionName() + " - " + "websocket channel disconnected, trying to re-establish",
599+
LogLevel: "DebugLevel",
600+
}.Do()
618601

619-
fmt.Println(err)
602+
time.Sleep(time.Second / 3) /* Sleep for 3 seconds */
620603

621604
}
622605

623-
<-doneC
624-
625606
}
626607

627608
// WsKline The Kline/Candlestick Stream push updates to the current klines/candlestick every second.
@@ -696,52 +677,33 @@ func WsKline(
696677
LogLevel: "DebugLevel",
697678
}.Do()
698679

699-
switch {
700-
case strings.Contains(err.Error(), "1006"):
701-
/* -1006 UNEXPECTED_RESP An unexpected response was received from the message bus. Execution status unknown. */
702-
/* Error Codes for Binance https://github.com/binance/binance-spot-api-docs/blob/master/errors.md */
703-
704-
exchange.GetClient(configData, sessionData) /* Reconnect exchange client */
705-
706-
case strings.Contains(err.Error(), "EOF"):
707-
/* -unexpected EOF An unexpected response was received from the message bus. Execution status unknown. */
708-
709-
return
710-
711-
case strings.Contains(err.Error(), "1001"):
712-
/* -1001 DISCONNECTED Internal error; unable to process your request. Please try again. */
713-
714-
exchange.GetClient(configData, sessionData) /* Reconnect exchange client */
680+
}
715681

716-
case strings.Contains(err.Error(), "read: operation timed out"):
717-
/* read tcp X.X.X.X:port->X.X.X.X:port: read: operation timed out */
682+
for {
718683

719-
exchange.GetClient(configData, sessionData) /* Reconnect exchange client */
684+
doneC, stopC, err = exchange.WsKlineServe(configData, sessionData, wsHandler, errHandler) /* Start websocket channel */
720685

721-
case strings.Contains(err.Error(), "read: connection reset by peer"):
722-
/* read tcp X.X.X.X:port->X.X.X.X:port: read: connection reset by peer */
686+
if err != nil { /* If websocket channel is not connected */
723687

724-
exchange.GetClient(configData, sessionData) /* Reconnect exchange client */
688+
panic(err) /* Panic */
725689

726690
}
727691

728-
Channel{}.SetTrue(sessionData) /* Set all goroutine channels to stop */
729-
Channel{
730-
name: "WsKline",
731-
}.Stop(stopC, wg, configData, sessionData) /* Stop goroutine channel */
732-
733-
}
734-
735-
doneC, stopC, err = exchange.WsKlineServe(configData, sessionData, wsHandler, errHandler)
692+
<-doneC
736693

737-
if err != nil {
694+
logger.LogEntry{ /* Log Entry */
695+
Config: configData,
696+
Market: marketData,
697+
Session: sessionData,
698+
Order: &types.Order{},
699+
Message: functions.GetFunctionName() + " - " + "websocket channel disconnected, trying to re-establish",
700+
LogLevel: "DebugLevel",
701+
}.Do()
738702

739-
fmt.Println(err)
703+
time.Sleep(time.Second / 3) /* Sleep for 3 seconds */
740704

741705
}
742706

743-
<-doneC
744-
745707
}
746708

747709
// WsBookTicker Pushes any update to the best bid or asks price or quantity in real-time for a specified symbol
@@ -854,59 +816,33 @@ func WsBookTicker(
854816
LogLevel: "DebugLevel",
855817
}.Do()
856818

857-
switch {
858-
case strings.Contains(err.Error(), "1006"):
859-
/* -1006 UNEXPECTED_RESP An unexpected response was received from the message bus. Execution status unknown. */
860-
/* Error Codes for Binance https://github.com/binance/binance-spot-api-docs/blob/master/errors.md */
861-
862-
exchange.GetClient(configData, sessionData) /* Reconnect exchange client */
863-
864-
case strings.Contains(err.Error(), "1008"):
865-
/* websocket: close 1008 (policy violation): Pong timeout */
866-
/* 1008 indicates that an endpoint is terminating the connection
867-
because it has received a message that violates its policy. This
868-
is a generic status code that can be returned when there is no
869-
other more suitable status code (e.g., 1003 or 1009) or if there
870-
is a need to hide specific details about the policy. */
871-
872-
exchange.GetClient(configData, sessionData) /* Reconnect exchange client */
873-
874-
return
875-
876-
case strings.Contains(err.Error(), "EOF"):
877-
/* -unexpected EOF An unexpected response was received from the message bus. Execution status unknown. */
878-
879-
return
819+
}
880820

881-
case strings.Contains(err.Error(), "read: operation timed out"):
882-
/* read tcp X.X.X.X:port->X.X.X.X:port: read: operation timed out */
821+
for {
883822

884-
exchange.GetClient(configData, sessionData) /* Reconnect exchange client */
823+
doneC, stopC, err = exchange.WsBookTickerServe(configData, sessionData, wsHandler, errHandler) /* Start websocket channel */
885824

886-
case strings.Contains(err.Error(), "read: connection reset by peer"):
887-
/* read tcp X.X.X.X:port->X.X.X.X:port: read: connection reset by peer */
825+
if err != nil { /* If websocket channel is not connected */
888826

889-
exchange.GetClient(configData, sessionData) /* Reconnect exchange client */
827+
panic(err) /* Panic */
890828

891829
}
892830

893-
Channel{}.SetTrue(sessionData) /* Set all goroutine channels to stop */
894-
Channel{
895-
name: "WsBookTicker",
896-
}.Stop(stopC, wg, configData, sessionData) /* Stop goroutine channel */
897-
898-
}
831+
<-doneC
899832

900-
doneC, stopC, err = exchange.WsBookTickerServe(configData, sessionData, wsHandler, errHandler)
901-
902-
if err != nil {
833+
logger.LogEntry{ /* Log Entry */
834+
Config: configData,
835+
Market: marketData,
836+
Session: sessionData,
837+
Order: &types.Order{},
838+
Message: functions.GetFunctionName() + " - " + "websocket channel disconnected, trying to re-establish",
839+
LogLevel: "DebugLevel",
840+
}.Do()
903841

904-
fmt.Println(err)
842+
time.Sleep(time.Second / 3) /* Sleep for 3 seconds */
905843

906844
}
907845

908-
<-doneC
909-
910846
}
911847

912848
// BuyDecisionTree BUY decision routine

documentation/HowToInstall.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
## HOW TO INSTALL
22

3-
Cryptopump can be used on Windows and Linux (with a MYSQL database is present and usable) or in a self-contained Docker environment.
3+
Cryptopump can be used on Windows or Linux (with a MySQL or MariaDB database) or in a self-contained Docker environment.
44

55
### DOCKER:
66

7+
#### - CryptoPump is now available as a self-contained Docker container set for linux/amd64 and linux/arm/v7 (Raspberry Pi). Check it out at https://hub.docker.com/repository/docker/andreleibovici/cryptopump
8+
79
This is the easiest way to get CryptoPump up and running. The Docker Compose file provides all the necessary components to run the system.
810

911
1 - Create a directory for the project.
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
version: '3.6'
2+
3+
services:
4+
5+
cryptopump_db:
6+
image: andreleibovici/cryptopump_mariadb:latest
7+
container_name: cryptopump_db
8+
environment:
9+
MYSQL_ROOT_PASSWORD: password # change this
10+
ports:
11+
- "3306:3306"
12+
tty: true
13+
cap_add:
14+
- SYS_NICE # CAP_SYS_NICE
15+
volumes:
16+
- db_data:/var/lib/mysql # database files
17+
- /etc/localtime:/etc/localtime:ro # timezone
18+
networks:
19+
- backend
20+
21+
cryptopump_app:
22+
image: andreleibovici/cryptopump:latest
23+
container_name: cryptopump_app
24+
restart: always
25+
environment:
26+
- DB_USER=root
27+
- DB_PASS=password # change this
28+
- DB_TCP_HOST=cryptopump_db
29+
- DB_PORT=3306
30+
- DB_NAME=cryptopump
31+
ports:
32+
- "8080-8090:8080-8090"
33+
tty: true
34+
volumes:
35+
- config_data:/go/src/cryptopump/config # config files
36+
- /etc/localtime:/etc/localtime:ro # timezone
37+
networks:
38+
- backend
39+
depends_on:
40+
- cryptopump_db
41+
42+
networks:
43+
backend:
44+
45+
volumes:
46+
db_data:
47+
config_data:

exchange/binance.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,8 @@ func binanceMapExchangeInfo(sessionData *types.Session, from *binance.ExchangeIn
158158
func binanceGetClient(
159159
configData *types.Config) *binance.Client {
160160

161-
binance.WebsocketKeepalive = false
162-
binance.WebsocketTimeout = time.Second * 30
161+
binance.WebsocketKeepalive = false /* Disable websocket keepalive */
162+
binance.WebsocketTimeout = time.Second * 100 /* Set websocket timeout */
163163

164164
/* If the -test.v flag is set, the testnet API is used */
165165
if flag.Lookup("test.v") != nil {

0 commit comments

Comments
 (0)