forked from DeviaVir/zenbot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
132 lines (101 loc) · 2.83 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
# Check if this is Windows
ifneq (,$(findstring WINDOWS,$(PATH)))
WINDOWS := True
endif
# Set shell to cmd on windows
ifdef WINDOWS
SHELL := C:/Windows/System32/cmd.exe
endif
# Don't use sudo on windows
SUDO := "sudo"
ifdef WINDOWS
SUDO :=
endif
# set home dir to user's home on windows running MINGW
ifdef MSYSTEM
HOME := $(subst \,/,$(HOME))
endif
# Get the root dir of this file
ROOT_DIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
# Define the full path to this file
THIS_FILE := $(lastword $(MAKEFILE_LIST))
# Set docker-compose file selector for windows
ifneq (,$(findstring WINDOWS,$(PATH)))
DC_CONFIG=$(ROOT_DIR)/docker-compose-windows.yml
else
DC_CONFIG=$(ROOT_DIR)/docker-compose.yml
endif
# Find or create a home for sensitive environment variables
# Check my secret place
CREDS=$(HOME)/.bash/.credentials
ifneq ("$(wildcard $(CREDS))","")
CREDENTIALS := $(CREDS)
else
# Check a normal place
CREDS=$(HOME)/.credentials
ifneq ("$(wildcard $(CREDS))","")
CREDENTIALS := $(CREDS)
else
$(info $(shell "mkdir" $(CREDS)))
endif
endif
# To use arguments with make execute: make -- <command> <args>
ARGS = $(filter-out $@,$(MAKECMDGOALS))
MAKEFLAGS += --silent
list:
sh -c "echo; $(MAKE) -p no_targets__ | awk -F':' '/^[a-zA-Z0-9][^\$$#\/\\t=]*:([^=]|$$)/ {split(\$$1,A,/ /);for(i in A)print A[i]}' | grep -v '__\$$' | grep -v 'Makefile'| sort"
#############################
# ZENBOT
#############################
list-strategies:
docker-compose exec server zenbot list-strategies $(ARGS)
list-selectors:
docker-compose exec server zenbot list-selectors $(ARGS)
backfill:
docker-compose exec server zenbot backfill $(ARGS)
sim:
docker-compose exec server zenbot sim $(ARGS)
trade:
docker-compose exec server zenbot trade $(ARGS)
paper:
docker-compose exec server zenbot trade --paper $(ARGS)
balance:
docker-compose exec server zenbot balance $(ARGS)
buy:
docker-compose exec server zenbot buy $(ARGS)
sell:
docker-compose exec server zenbot sell $(ARGS)
zenbot:
docker-compose exec server zenbot $(ARGS)
#############################
# Docker machine states
#############################
time-sync:
docker run --rm --privileged alpine hwclock -s
up:
$(SUDO) docker-compose --file=$(DC_CONFIG) up
start:
docker-compose start
stop:
docker-compose stop
state:
docker-compose ps
rebuild:
$(SUDO) docker-compose stop
$(SUDO) docker-compose pull
$(SUDO) docker-compose rm --force server
$(SUDO) docker-compose rm --force mongodb
-$(SUDO) docker-compose rm --force adminmongo
$(SUDO) docker-compose build --no-cache
$(SUDO) docker-compose --file=$(DC_CONFIG) up -d --force-recreate
shell:
docker-compose exec server /bin/sh
shellw:
docker exec -it -u root $$(docker-compose ps -q server) /bin/sh
logs:
docker-compose logs $(ARGS)
#############################
# Argument fix workaround
#############################
%:
@: