Skip to content

Commit a90a148

Browse files
#31 update deploy package
1 parent db55054 commit a90a148

23 files changed

+47
-49
lines changed

deploy/classes/CommonSettings.py renamed to deploy/classes/common_settings.py

+6-5
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ def __init__(self,
1818
db_host=DB_HOST,
1919
db_port=DB_PORT,
2020
db_name=DB_NAME,
21-
exchanges_ids=EXCHANGE.values()
22-
):
21+
exchanges_ids=None):
2322

2423
# Logging
2524

@@ -42,7 +41,10 @@ def __init__(self,
4241
self.db_name = db_name
4342

4443
# Exchanges
45-
self.exchanges = exchanges_ids
44+
if not exchanges_ids:
45+
self.exchanges = EXCHANGE.values()
46+
else:
47+
self.exchanges = exchanges_ids
4648

4749
@classmethod
4850
def from_cfg(cls, file_name):
@@ -62,5 +64,4 @@ def from_cfg(cls, file_name):
6264
config.get("postgres", "db_host"),
6365
config.get("postgres", "db_port"),
6466
config.get("postgres", "db_name"),
65-
exchanges_ids
66-
)
67+
exchanges_ids)

deploy/classes/DeployUnit.py renamed to deploy/classes/deploy_unit.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ class DeployUnit(BaseData):
55
def __init__(self, screen_name, window_name, command):
66
self.screen_name = screen_name
77
self.window_name = window_name
8-
self.command = command
8+
self.command = command

deploy/classes/ExchangeArbitrageSettings.py renamed to deploy/classes/exchange_arbitrage_settings.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ def __init__(self, src_exchange_name, dst_exchange_name, list_of_pairs):
88
self.src_exchange_id = get_exchange_id_by_name(self.src_exchange_name)
99
self.dst_exchange_name = dst_exchange_name
1010
self.dst_exchange_id = get_exchange_id_by_name(self.dst_exchange_name)
11-
self.list_of_pairs = list_of_pairs
11+
self.list_of_pairs = list_of_pairs

deploy/constants.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from enums.deploy_units import DEPLOY_UNIT
2-
from deploy.classes.DeployUnit import DeployUnit
2+
from deploy.classes.deploy_unit import DeployUnit
33

44
# pypy is option as well. NOTE: it can be 2x-3x faster
55
PYTHON_INTERPETATOR = "python"

deploy/update_nonce_redis.py renamed to deploy/redis_queues.py

+3-8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
import redis as _redis
21
import time
2+
import redis as _redis
3+
34
from dao.db import get_arbitrage_id, init_pg_connection
5+
from data_access.message_queue import QUEUE_TOPICS
46

57
# FIXME NOTE:
68
# 1. Read settings from cfg file
@@ -22,19 +24,12 @@ def update_arbitrage_id():
2224
next_arbitrage_id = get_arbitrage_id(pg_conn)
2325
r.set('arbitrage_id', str(next_arbitrage_id))
2426

25-
# update_nonce()
26-
# update_arbitrage_id()a
27-
2827

2928
def show_failed_orders():
30-
from data_access.message_queue import QUEUE_TOPICS, ORDERS_MSG, FAILED_ORDERS_MSG
3129
r = _redis.StrictRedis(host='54.193.19.230', port=6379, db=0)
3230

3331
for topic_id in QUEUE_TOPICS:
3432
print "For {nn} topic we have {ll} messages".format(nn=topic_id, ll=r.llen(topic_id))
3533

36-
print "For {nn} topic we have {ll} messages".format(nn=FAILED_ORDERS_MSG, ll=r.llen(topic_id))
37-
print "For {nn} topic we have {ll} messages".format(nn=ORDERS_MSG, ll=r.zcard(topic_id))
38-
3934

4035
show_failed_orders()

deploy/screen_utils.py

+17-14
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,24 @@
66

77

88
def is_screen_present(screen_name):
9-
var = check_output(["screen -ls; true"],shell=True)
10-
if "." + screen_name + "\t(" in var:
11-
print screen_name + " is running!"
9+
var = check_output(["screen -ls; true"], shell=True)
10+
if ".{}\t(".format(screen_name) in var:
11+
print("Screen with name {} is running!".format(screen_name))
1212
return True
13-
else:
14-
print screen_name + " is not running"
15-
return False
13+
14+
print("Screen with name {} is not running".format(screen_name))
15+
return False
1616

1717

1818
def generate_screen_name(sell_exchange_id, buy_exchange_id):
19-
screen_name = "{sell_exch}==>{buy_exch}".format(sell_exch=get_exchange_name_by_id(sell_exchange_id),
20-
buy_exch=get_exchange_name_by_id(buy_exchange_id))
19+
screen_name = "{sell_exch}==>{buy_exch}".format(
20+
sell_exch=get_exchange_name_by_id(sell_exchange_id),
21+
buy_exch=get_exchange_name_by_id(buy_exchange_id))
2122
return screen_name
2223

2324

2425
def stop_screen(screen_name):
25-
screen_pid = re.findall('\d*\.', commands.getoutput('screen -ls |grep %s' % screen_name))
26+
screen_pid = re.findall(r'\d*\.', commands.getoutput('screen -ls |grep %s' % screen_name))
2627
if screen_pid:
2728
commands.getoutput('kill %s' % screen_pid[0][:-1])
2829

@@ -36,12 +37,13 @@ def create_screen(screen_name):
3637
"""
3738

3839
if is_screen_present(screen_name):
39-
print "NONONO! You already have with exact same name - {screen_name} It will lead to trouble.".format(screen_name=screen_name)
40+
print("NONONO! You already have with exact same name - {screen_name} "
41+
"It will lead to trouble.".format(screen_name=screen_name))
4042
assert False
4143

4244
if isinstance(screen_name, str):
4345
out = commands.getoutput('screen -dmS "%s"' % screen_name)
44-
print out
46+
print(out)
4547
else:
4648
out = "No screen name provided"
4749

@@ -57,7 +59,8 @@ def create_screen_window(screen_name, window_name):
5759
:param window_name:
5860
:return: False, if assert failed or command output
5961
"""
60-
cmd = """screen -S '{screen_name}' -X screen -t '{window_name}'""".format(screen_name=screen_name, window_name=window_name)
62+
cmd = """screen -S '{screen_name}' -X screen -t '{window_name}'""".format(
63+
screen_name=screen_name, window_name=window_name)
6164

6265
return commands.getoutput(cmd)
6366

@@ -71,7 +74,7 @@ def run_command_in_screen(screen_name, window_name, command):
7174
"""
7275

7376
cmd_line = """screen -S '{sn}' -p '{wn}' -X stuff '{exe}\n' """.format(sn=screen_name, wn=window_name, exe=command)
74-
print cmd_line
77+
print("Executing command:\n{}".format(cmd_line))
7578
return commands.getoutput(cmd_line)
7679

7780

@@ -84,4 +87,4 @@ def test_screens():
8487

8588
run_command_in_screen(screen_name, "1", "ls -la")
8689
run_command_in_screen(screen_name, "2", "netstat -tunapl")
87-
run_command_in_screen(screen_name, "3", "htop")
90+
run_command_in_screen(screen_name, "3", "htop")

deploy/service_utils.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,4 +66,4 @@ def deploy_process_in_screen(screen_name, deploy_unit, should_create_window=True
6666
if should_create_window:
6767
create_screen_window(screen_name, deploy_unit.window_name)
6868

69-
run_command_in_screen(screen_name, deploy_unit.window_name, deploy_unit.command)
69+
run_command_in_screen(screen_name, deploy_unit.window_name, deploy_unit.command)

deploy/system_utils.py

-1
This file was deleted.

deploy_arbitrage_bots.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44

55
from deploy.screen_utils import create_screen, generate_screen_name
66
from deploy.constants import FULL_COMMAND
7-
from deploy.classes.ExchangeArbitrageSettings import ExchangeArbitrageSettings
7+
from deploy.classes.exchange_arbitrage_settings import ExchangeArbitrageSettings
88
from deploy.service_utils import deploy_process_in_screen
9-
from deploy.classes.DeployUnit import DeployUnit
9+
from deploy.classes.deploy_unit import DeployUnit
1010

1111
from utils.exchange_utils import get_exchange_id_by_name, get_exchange_name_by_id
1212
from utils.currency_utils import get_pair_id_by_name

deploy_balance_monitoring.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
from debug_utils import print_to_console, LOG_ALL_ERRORS
44
from utils.exchange_utils import get_exchange_name_by_id
55

6-
from deploy.classes.CommonSettings import CommonSettings
7-
from deploy.classes.DeployUnit import DeployUnit
6+
from deploy.classes.common_settings import CommonSettings
7+
from deploy.classes.deploy_unit import DeployUnit
88
from deploy.service_utils import deploy_process_in_screen
99
from deploy.constants import BALANCE_UPDATE_DEPLOY_UNIT
1010
from deploy.screen_utils import create_screen

services/arbitrage_between_pair.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737

3838
from constants import NO_MAX_CAP_LIMIT, BALANCE_EXPIRED_THRESHOLD, MIN_CAP_UPDATE_TIMEOUT
3939

40-
from deploy.classes.CommonSettings import CommonSettings
40+
from deploy.classes.common_settings import CommonSettings
4141

4242

4343
def update_min_cap(cfg, deal_cap, processor):

services/arbitrage_between_pair_subscription.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444

4545
from constants import NO_MAX_CAP_LIMIT, BALANCE_EXPIRED_THRESHOLD
4646

47-
from deploy.classes.CommonSettings import CommonSettings
47+
from deploy.classes.common_settings import CommonSettings
4848

4949
from services.sync_stage import get_stage, set_stage
5050

services/arbitrage_monitoring.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from utils.string_utils import float_to_str
1414
from utils.time_utils import sleep_for, get_now_seconds_utc, ts_to_string_local
1515
import argparse
16-
from deploy.classes.CommonSettings import CommonSettings
16+
from deploy.classes.common_settings import CommonSettings
1717

1818

1919
# time to poll

services/balance_monitoring.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import argparse
22

3-
from deploy.classes.CommonSettings import CommonSettings
3+
from deploy.classes.common_settings import CommonSettings
44

55
from dao.balance_utils import update_balance_by_exchange, init_balances
66
from data_access.message_queue import get_message_queue

services/bot_trade_retrieval.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
from utils.key_utils import load_keys
66
from utils.time_utils import sleep_for, get_now_seconds_utc
7-
from deploy.classes.CommonSettings import CommonSettings
7+
from deploy.classes.common_settings import CommonSettings
88

99
from analysis.data_load_for_profit_report import get_trade_retrieval_method_by_exchange
1010

services/expired_order_processing.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import argparse
22

3-
from deploy.classes.CommonSettings import CommonSettings
3+
from deploy.classes.common_settings import CommonSettings
44

55
from data_access.message_queue import get_message_queue
66
from data_access.priority_queue import ORDERS_EXPIRE_MSG, get_priority_queue

services/failed_order_processing.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from deploy.classes.CommonSettings import CommonSettings
1+
from deploy.classes.common_settings import CommonSettings
22
from data_access.message_queue import get_message_queue, FAILED_ORDERS_MSG
33
from data_access.priority_queue import get_priority_queue
44
from data_access.memory_cache import get_cache

services/history_retrieval.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
from utils.file_utils import log_to_file
1717
from utils.time_utils import get_now_seconds_utc, sleep_for
1818

19-
from deploy.classes.CommonSettings import CommonSettings
19+
from deploy.classes.common_settings import CommonSettings
2020

2121
import argparse
2222

services/master_puppeteer.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import argparse
22
from utils.time_utils import sleep_for
3-
from deploy.classes.CommonSettings import CommonSettings
3+
from deploy.classes.common_settings import CommonSettings
44
from data_access.classes.command_queue import CommandQueue
55

66

services/node_puppeteer.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import socket
22
import argparse
33
from utils.time_utils import sleep_for
4-
from deploy.classes.CommonSettings import CommonSettings
4+
from deploy.classes.common_settings import CommonSettings
55
from data_access.classes.command_queue import CommandQueue
66

77

services/order_book_retrieval.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from utils.file_utils import log_to_file
99
from utils.time_utils import get_now_seconds_utc, sleep_for
1010

11-
from deploy.classes.CommonSettings import CommonSettings
11+
from deploy.classes.common_settings import CommonSettings
1212

1313
import argparse
1414

services/order_storing.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
from constants import HEARTBEAT_TIMEOUT
77
import argparse
8-
from deploy.classes.CommonSettings import CommonSettings
8+
from deploy.classes.common_settings import CommonSettings
99

1010
if __name__ == "__main__":
1111

services/telegram_notifier.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from utils.time_utils import sleep_for
99

1010
import argparse
11-
from deploy.classes.CommonSettings import CommonSettings
11+
from deploy.classes.common_settings import CommonSettings
1212

1313

1414
if __name__ == "__main__":

0 commit comments

Comments
 (0)