diff --git a/README.md b/README.md index 1124f46..956a1ec 100644 --- a/README.md +++ b/README.md @@ -58,7 +58,7 @@ As you can see in this example you have saved $681.90 in fees and spent that ins * Permissions: "Trading" 0. Copy `settings.conf.example` to `settings.conf` 0. Update the `CLIENT_KEY` and `CLIENT_SECRET` in the `[production]` section. -0. Add fiat to your Gemini account. +0. Add fiat to your Gemini account. ### Sandbox @@ -79,7 +79,7 @@ usage: gemini_bot.py [-h] [-s] [-w WARN_AFTER] [-j] [-c CONFIG_FILE] [-l LOGLEVE BTCUSD BUY 0.00125 BTC (buy 0.00125 BTC) ETHBTC SELL 0.00125 BTC (sell 0.00125 BTC worth of ETH) ETHBTC SELL 0.1 ETH (sell 0.1 ETH) - + positional arguments: market_name (e.g. BTCUSD, ETHBTC, etc) @@ -107,7 +107,7 @@ You can run this manually for one-off buys or sells. ``` cd gemini_bot -/path/to/gemini_bot/venv/bin/python gemini_bot.py --sandbox BTCUSD BUY 5 BTC +/path/to/gemini_bot/venv/bin/python gemini_bot.py --sandbox BTCUSD BUY 5 USD ``` This will call the sandbox Gemini API to place a "Maker-or-Cancel" buy order for USD$5 worth of Bitcoin. @@ -121,7 +121,7 @@ The best way to run this script is via a cronjob as this gives us the Dollar Cos I would suggest using the full paths to the python venv python, `gemini_bot.py`, and the `settings.conf` file as below. This usually gets around many common cron issues. ``` -05 */2 * * * /path/to/geminibot/bot/venv/bin/python gemini_bot.py /path/to/geminibot/bot/gemini_bot.py --config /var/lib/geminibot/bot/settings.conf BTCUSD BUY 5.00 BTC +05 */2 * * * /path/to/geminibot/bot/venv/bin/python gemini_bot.py /path/to/geminibot/bot/gemini_bot.py --config /var/lib/geminibot/bot/settings.conf BTCUSD BUY 5.00 USD ``` This will buy USD$5 worth of BTC every other hour at 5min past the hour. diff --git a/gemini_api.py b/gemini_api.py index 24e1a0e..79397f8 100644 --- a/gemini_api.py +++ b/gemini_api.py @@ -127,9 +127,9 @@ def new_order(self, market: str, side: str, amount: Decimal, price: Decimal): return self._make_authenticated_request("POST", "/order/new", payload=payload) - def order_status(self, order_id: str): + def order_status(self, order_id: str, include_trades: bool): payload = { "order_id": order_id, - "include_trades": False, + "include_trades": include_trades, } return self._make_authenticated_request("POST", "/order/status", payload=payload) diff --git a/gemini_bot.py b/gemini_bot.py index 7183931..8cfdb24 100644 --- a/gemini_bot.py +++ b/gemini_bot.py @@ -217,12 +217,16 @@ def place_order(price): ) time.sleep(wait_time) total_wait_time += wait_time - order = gemini_api_conn.order_status(order_id=order_id) + order = gemini_api_conn.order_status(order_id=order_id, include_trades=True) # Order status is no longer pending! + trades = order.get("trades") + fee_amount = sum([Decimal(t['fee_amount']) for t in trades]) + fee_currency = trades[0]['fee_currency'] # safe, since only one currency was used logging.info( f"{market_name} {order_side} order of {amount} {amount_currency} " - f"complete @ {midmarket_price} {quote_currency}" + f"complete @ {midmarket_price} {quote_currency} " + f"fee: {fee_amount} {fee_currency}" ) sys.exit(0)