|
1 | 1 | # pylint: disable=W0702, C0325 |
2 | 2 |
|
3 | 3 | import ccxt.async_support as ccxt |
4 | | -from typing import List |
| 4 | +from typing import List, Tuple |
5 | 5 | from tqdm.auto import tqdm |
6 | 6 | from itertools import combinations |
7 | 7 | from dataclasses import dataclass |
@@ -37,7 +37,7 @@ def get_last_prices(exchange_time, tickers): |
37 | 37 | if tickers[key]['close'] is not None and not is_delisted_symbols(exchange_time, tickers[key]) |
38 | 38 | ] |
39 | 39 |
|
40 | | -def get_best_opportunity(tickers: List[ShortTicker]) -> List[ShortTicker]: |
| 40 | +def get_best_opportunity(tickers: List[ShortTicker]) -> Tuple[List[ShortTicker], float]: |
41 | 41 | # pylint: disable=W1114 |
42 | 42 | ticker_dict = {str(ticker.symbol): ticker for ticker in tickers if ticker.symbol is not None} |
43 | 43 |
|
@@ -85,6 +85,12 @@ def get_opportunity_symbol(a, b): |
85 | 85 | best_profit = profit |
86 | 86 | best_triplet = [a_to_b, b_to_c, c_to_a] |
87 | 87 |
|
| 88 | + # restore original symbols for reversed pairs |
| 89 | + best_triplet = [ |
| 90 | + ShortTicker(symbols.Symbol(f"{triplet.symbol.quote}/{triplet.symbol.base}"), triplet.last_price, reversed=True) |
| 91 | + if triplet.reversed else triplet |
| 92 | + for triplet in best_triplet] |
| 93 | + |
88 | 94 | return best_triplet, best_profit |
89 | 95 |
|
90 | 96 | async def get_exchange_data(exchange_name): |
|
0 commit comments