Dockerized, added post-only limit orders to get maker fees instead of taker.#1
Dockerized, added post-only limit orders to get maker fees instead of taker.#1claytondukes wants to merge 65 commits intokurt213:mainfrom
Conversation
…count and 12h timeout
- Enforce post_only on GTD/GTC limit orders; round to product increments and validate product min sizes in [bot/auth_coinbase.py](bot/auth_coinbase.py) - Add fallback-to-market after limit expiry (background thread) to guarantee completion of scheduled buys - Normalize EC private key newlines and quotes; add COINBASE_VERBOSE flag for optional SDK DEBUG logging; support TZ via .env - Update README to document maker-first strategy, (percent-of-100 offsets) and timezone behavior; clarify schedule file usage - Add .env.example and schedule-sample.json (post_only + 600s timeout examples) - Rename docker-compose.yml -> compose.yml (Compose v2 default); update .gitignore - Remove schedule_template.json (replaced by schedule-sample.json)
feat: post-only limit orders with fallback; docs and env updates
There was a problem hiding this comment.
Pull Request Overview
Dockerize the app and migrate from CCXT to Coinbase Advanced Trade SDK, adding support for limit orders with optional maker-first logic and logging to a file.
- Replace CCXT auth with Coinbase Advanced REST client and implement limit/market order placement with maker-first + fallback-to-market
- Add Dockerfile and compose.yml to run the bot in a container and log to logs/dcabot.log
- Provide a schedule sample file and expand README with setup, environment, and Docker instructions
Reviewed Changes
Copilot reviewed 9 out of 11 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
| main.py | Switch to auth_coinbase, pass order options from schedule, and schedule tasks |
| bot/auth_coinbase.py | New Coinbase Advanced Trade client with limit/market order logic and fallback thread |
| compose.yml | Docker Compose service to run the app and append logs to logs/dcabot.log |
| Dockerfile | Build Python image and install requirements |
| schedule-sample.json | New sample schedule with limit order config |
| schedule_template.json | Removed legacy template (now conflicts with README reference) |
| README.md | Major documentation update for features, setup, Docker usage, and scheduling |
| .env.example | Example env vars for Coinbase Advanced and TZ |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Updating per copilot pr feedback
There was a problem hiding this comment.
Pull Request Overview
Copilot reviewed 9 out of 11 changed files in this pull request and generated 4 comments.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
There was a problem hiding this comment.
Pull Request Overview
Copilot reviewed 9 out of 11 changed files in this pull request and generated 5 comments.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
There was a problem hiding this comment.
Pull Request Overview
Copilot reviewed 9 out of 11 changed files in this pull request and generated 6 comments.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
There was a problem hiding this comment.
Pull Request Overview
Copilot reviewed 11 out of 13 changed files in this pull request and generated 2 comments.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
There was a problem hiding this comment.
Pull Request Overview
Copilot reviewed 11 out of 13 changed files in this pull request and generated 2 comments.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
|
Finally. Sheesh. I hate Copilot but I also respect and value it :) |
…ptions
- bot/auth_coinbase.py:
- Extend create_order(...) to accept:
- reprice_interval_seconds
- reprice_duration_seconds
- Start _reprice_and_fallback_worker(...) when repricing is enabled; otherwise
fall back to the existing timed fallback worker.
- Repricing behavior:
- Poll current order; cancel; recompute remaining notional using Decimal.
- Reprice limit to market × (1 - limit_price_pct/100), quantized by
increments, post_only=true.
- Repost GTD/short-slice limit repeatedly every interval until duration
elapses.
- Then execute safe fallback: cancel → poll terminal state
(CANCELLED/EXPIRED/FILLED/REJECTED/FAILED) → recompute remainder →
place market order for the remainder.
- Add logs prefixed with "Reprice:" for repricing steps and final fallback.
- Backward compatible: if reprice_interval_seconds is not set or 0, original
single-limit + timed market fallback behavior is used.
- main.py:
- Read reprice_interval_seconds and reprice_duration_seconds from schedule
items and pass them to create_order(...).
Notes:
- schedule.json is gitignored; not included in this commit.
- Default behavior unchanged unless repricing fields are present in schedule.
de-dup statuses; init status - Introduce RepriceConfig dataclass to group repricing settings and timeout. - Replace long worker signatures with a single config object. - Add safe_float() helper and use it in fallback/reprice workers to remove repeated try/except for fv/fs/ap parsing. - Define TERMINAL_STATUSES on the class and reuse it across flows. - Initialize status explicitly (remove fragile `status in locals()` checks). - Wire create_order() success paths to construct config and start _start_reprice_or_fallback_thread(...). - Backward compatible: if reprice_interval_seconds is unset/0, use the original fallback-only worker.
…backs for durations/timeouts
…nly GTD logging; repair block and constants
… and post-only nudge helper; use in create_order
…sleeps to avoid tight loops
feat(repricing): add maker repricing before fallback; wire schedule options
- Add 'once' frequency to scheduler with self-canceling job
- Implemented in [bot/scheduler.py::_set_once()](cci:1://file:///Users/cdukes/sourcecode/crypto-dca-bot/bot/scheduler.py:98:4-125:10)
- Mapped in [scheduleSetup.create_schedule()](cci:1://file:///Users/cdukes/sourcecode/crypto-dca-bot/bot/scheduler.py:15:4-29:39)
- Support absolute limit price and execution controls
- [bot/auth_coinbase.py::create_order()](cci:1://file:///Users/cdukes/sourcecode/crypto-dca-bot/bot/auth_coinbase.py:170:4-564:13) now accepts:
- `limit_price_absolute` (fixed price instead of percent discount)
- `time_in_force` ("GTC" uses `limit_order_gtc`, else GTD with timeout)
- `disable_fallback` (skips fallback thread and final market buy)
- Extend [RepriceConfig](cci:2://file:///Users/cdukes/sourcecode/crypto-dca-bot/bot/auth_coinbase.py:45:0-52:34) with `disable_fallback`
- [_start_reprice_or_fallback_thread()](cci:1://file:///Users/cdukes/sourcecode/crypto-dca-bot/bot/auth_coinbase.py:571:4-584:108) respects `disable_fallback`
- [_build_reprice_config()](cci:1://file:///Users/cdukes/sourcecode/crypto-dca-bot/bot/auth_coinbase.py:586:4-605:9) propagates `disable_fallback`
- Wire new fields from schedule to order creation
- [main.py](cci:7://file:///Users/cdukes/sourcecode/crypto-dca-bot/main.py:0:0-0:0) reads `limit_price_absolute`, `time_in_force`,
and `disable_fallback` and passes them to [create_order()](cci:1://file:///Users/cdukes/sourcecode/crypto-dca-bot/bot/auth_coinbase.py:170:4-564:13)
Notes:
- Existing percent-based repricing behavior remains unchanged.
- Post-only handling and repricing safety clamps unaffected.
… safety - Execute 'once' schedules immediately if time has passed - Log cancellation errors instead of silently swallowing them - Warn when limit_price_absolute is >5% above market for buys - Honor disable_fallback in repricer to skip final market buy - Update README with new features and examples
- Remove unnecessary try-except around time_in_force conversion - Add missing 'Falling back to GTC' log message - Log exceptions in immediate-execution time check
- Tag 'once' jobs to prevent re-execution on bot restart - Remove unnecessary using_absolute flag, check limit_price_absolute directly - Fix time_in_force None check to use 'is not None' - Clarify time_in_force behavior in README (only GTC/GTD supported)
- Use .upper() directly on time_in_force without str() conversion - Clarify in README that non-GTC values default to GTD (no error)
- Use > instead of >= in time check to avoid duplicate execution - Log exception in absolute price validation instead of silent pass
- Use >= instead of > to handle edge case where current time matches scheduled time - Fallback log message was already in correct location (inside except block)
- Warn when limit_price_absolute >= market with post_only (will be rejected) - Include actual limit_price value in absolute mode log message - Keep existing >5% warning for non-post_only cases
feat(orders,scheduler), add 'once', GTC limit price
Change 'executed and cancelled' to 'completed and removed' to avoid confusion with order cancellation. The message refers to the schedule job being removed, not the order being cancelled.
fix: clarify 'once' schedule log message
feat: post-only limit orders with fallback; docs and env updates
validate product min sizes in bot/auth_coinbase.py
completion of scheduled buys
optional SDK DEBUG logging; support TZ via .env
(percent-of-100 offsets) and timezone behavior; clarify schedule file usage