Skip to content

Commit

Permalink
New command to generate a sample config file
Browse files Browse the repository at this point in the history
  • Loading branch information
maxme committed Dec 7, 2019
1 parent b5ff449 commit 8cc26cb
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 8 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Currently supported exchanges to get data:
Currently supported exchanges to automate trade:

- Bitstamp (USD)
- Paymium (EUR) - (API changed)
- Paymium (EUR)

## WARNING

Expand Down
27 changes: 26 additions & 1 deletion arbitrage/arbitrage.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,10 @@ def exec_command(self, args):
self.get_balance(args)
if "list-public-markets" in args.command:
self.list_markets()
if "generate-config" in args.command:
self.generate_sample_config()

def list_markets(self):
def get_market_list(self):
markets = []
for filename in glob.glob(os.path.join(public_markets.__path__[0], "*.py")):
module_name = os.path.basename(filename).replace(".py", "")
Expand All @@ -42,10 +44,33 @@ def list_markets(self):
if inspect.isclass(obj) and "Market" in (j.__name__ for j in obj.mro()[1:]):
if not obj.__module__.split(".")[-1].startswith("_"):
markets.append(obj.__name__)
return markets

def list_markets(self):
markets = self.get_market_list()
markets.sort()
print("\n".join(markets))
sys.exit(0)

def generate_sample_config(self):
markets = self.get_market_list()
markets.sort()
print("markets = [")
print('",\n'.join([' "' + i for i in markets]) + '"')
print("]")
print('observers = ["Logger"]')
print("""
refresh_rate = 60
market_expiration_time = 120 # in seconds: 2 minutes
# SafeGuards
max_tx_volume = 1 # in BTC
min_tx_volume = 0.01 # in BTC
balance_margin = 0.05 # 5%
profit_thresh = 0 # in USD
perc_thresh = 0 # in %""")
sys.exit(0)

def get_balance(self, args):
if not args.markets:
logging.error("You must use --markets argument to specify markets")
Expand Down
7 changes: 1 addition & 6 deletions arbitrage/public_markets/_binance.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,7 @@ def __init__(self, currency, code):

def update_depth(self):
url = "https://api.binance.com/api/v1/depth?symbol=%s" % self.code
req = urllib.request.Request(
url,
headers={
"Accept": "*/*",
},
)
req = urllib.request.Request(url, headers={"Accept": "*/*"})
res = urllib.request.urlopen(req)
depth = json.loads(res.read().decode("utf8"))
self.depth = self.format_depth(depth)
Expand Down

0 comments on commit 8cc26cb

Please sign in to comment.