Skip to content

Commit d287f84

Browse files
committed
Remove server.py
1 parent d56ac5c commit d287f84

File tree

7 files changed

+10
-87
lines changed

7 files changed

+10
-87
lines changed

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ RUN apt-get update \
99
COPY . .
1010

1111
RUN pip3 install --no-cache-dir -U setuptools wheel pip \
12-
&& pip3 install --no-cache-dir -r requirements.txt -r dev_requirements.txt \
12+
&& pip3 install --no-cache-dir -r requirements.txt \
1313
&& python3 setup.py install
1414

15-
ENTRYPOINT ["python3", "server.py"]
15+
ENTRYPOINT ["python3", "main.py"]

dev_requirements.txt

Lines changed: 0 additions & 5 deletions
This file was deleted.

main.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,20 @@
11
import asyncio
2-
from dotenv import load_dotenv
32

43
import octobot_commons.symbols as symbols
54
import octobot_commons.os_util as os_util
65

76
import triangular_arbitrage.detector
87

98
if __name__ == "__main__":
10-
load_dotenv()
119
benchmark = os_util.parse_boolean_environment_var("IS_BENCHMARKING", "False")
1210
if benchmark:
1311
import time
1412
s = time.perf_counter()
1513

1614
# start arbitrage detection
1715
print("Scanning...")
18-
best_opportunities, best_profit, exchange_name = asyncio.run(triangular_arbitrage.detector.run_detection())
16+
exchange_name = "binance"
17+
best_opportunities, best_profit = asyncio.run(triangular_arbitrage.detector.run_detection(exchange_name))
1918
def opportunity_symbol(opportunity):
2019
return symbols.parse_symbol(str(opportunity.symbol))
2120

requirements.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
tqdm
22
ccxt
33

4-
python-dotenv
54
OctoBot-Commons

server.py

Lines changed: 0 additions & 43 deletions
This file was deleted.

triangular_arbitrage/__init__.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1 @@
1-
REDIS_HOST_ENV="REDIS_HOST"
2-
REDIS_PORT_ENV="REDIS_PORT"
3-
REDIS_PASSWORD_ENV="REDIS_PASSWORD"
4-
REDIS_KEY_ENV="REDIS_KEY"
5-
61
EXCHANGE_NAME_ENV="EXCHANGE_NAME"

triangular_arbitrage/detector.py

Lines changed: 6 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import os
2-
import datetime
32
import ccxt.async_support as ccxt
43
from typing import List
54
from tqdm.auto import tqdm
@@ -9,7 +8,7 @@
98
import octobot_commons.symbols as symbols
109
import octobot_commons.constants as constants
1110

12-
from triangular_arbitrage import REDIS_HOST_ENV, REDIS_PASSWORD_ENV, REDIS_PORT_ENV, REDIS_KEY_ENV, EXCHANGE_NAME_ENV
11+
from triangular_arbitrage import EXCHANGE_NAME_ENV
1312

1413
@dataclass
1514
class ShortTicker:
@@ -93,7 +92,7 @@ def get_opportunity_symbol(a, b):
9392
return best_triplet, best_profit
9493

9594
async def get_exchange_data(exchange_name):
96-
exchange_class = getattr(ccxt, os.getenv(EXCHANGE_NAME_ENV, exchange_name))
95+
exchange_class = getattr(ccxt, exchange_name)
9796
exchange = exchange_class()
9897
tickers = await fetch_tickers(exchange)
9998
exchange_time = exchange.milliseconds()
@@ -105,28 +104,7 @@ async def get_exchange_last_prices(exchange_name):
105104
last_prices = get_last_prices(exchange_time, tickers)
106105
return last_prices
107106

108-
async def run_detection(exchange_name = "binance"):
109-
exchange = os.getenv(EXCHANGE_NAME_ENV, exchange_name)
110-
last_prices = await get_exchange_last_prices(exchange)
111-
best_opportunity, best_profit = get_best_opportunity(last_prices)
112-
if os.getenv(REDIS_HOST_ENV, None) is not None:
113-
upload_result(best_opportunity, best_profit, exchange)
114-
115-
return best_opportunity, best_profit, exchange
116-
117-
def upload_result(best_opportunities, best_profit, exchange_id):
118-
import redis
119-
redis_client = redis.Redis(
120-
host=os.getenv(REDIS_HOST_ENV, None),
121-
port=os.getenv(REDIS_PORT_ENV, None),
122-
password=os.getenv(REDIS_PASSWORD_ENV, None),
123-
ssl=True
124-
)
125-
126-
data = {
127-
'best_opportunity': [str(best_opportunity.symbol) for best_opportunity in best_opportunities],
128-
'best_profit': best_profit,
129-
'exchange_id': exchange_id,
130-
'timestamp': datetime.datetime.utcnow().timestamp()
131-
}
132-
redis_client.json().set(f"{os.getenv(REDIS_KEY_ENV, None)}:{exchange_id}", '$', data)
107+
async def run_detection(exchange_name):
108+
last_prices = await get_exchange_last_prices(exchange_name)
109+
best_opportunity, best_profit = get_best_opportunity(last_prices)
110+
return best_opportunity, best_profit

0 commit comments

Comments
 (0)