Add Binance Spot live trading support (runtime selectable with Alpaca)#478
Open
kiennt23 wants to merge 2 commits into
Open
Add Binance Spot live trading support (runtime selectable with Alpaca)#478kiennt23 wants to merge 2 commits into
kiennt23 wants to merge 2 commits into
Conversation
- New src/binance_spot.zig implementing Exchange.VTable - HMAC-SHA256 signing using std.crypto.auth.hmac.sha2.HmacSha256 - submitOrder/checkOrder/cancelOrder targeting /api/v3 endpoints - getPosition returns null (Spot has no native position API) - buy/sell sync polling wrappers - JSON parsing helpers for Binance string-number format - parseFillCommission and parseAccountBalance for fee/balance data - Update src/main.zig - Runtime exchange selection via EXCHANGE env var - Skip exchange position reconciliation for Spot (Turso is source of truth) - Keep funding rate filter active as market signal for all exchanges - Add 5 Binance Spot JSON parsing tests to src/tests.zig - Update AGENTS.md - Document EXCHANGE, BINANCE_API_KEY, BINANCE_API_SECRET env vars - Document Spot position model (Turso transfers = source of truth) - Document exchange selection pattern Refs #477
98726a0 to
675205d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements Binance Spot live trading as a runtime-selectable alternative to Alpaca paper trading. Closes #477.
Changes
New file:
src/binance_spot.zigExchange.VTablefor Binance Spotstd.crypto.auth.hmac.sha2.HmacSha256)submitOrder→checkOrder→cancelOrder/api/v3/orderendpoints with form-encoded signed requestsgetPositionreturnsnull— Spot has no native position APIparseFillCommissionextracts fee data fromfillsarrayparseAccountBalancequeries/api/v3/accountfor discrepancy alertsUpdated:
src/main.zigEXCHANGEenv var (alpaca|binance_spot)Updated:
src/tests.zigUpdated:
AGENTS.mdEXCHANGE,BINANCE_API_KEY,BINANCE_API_SECRETenv varsUsage
Testnet note
When using testnet, both REST and WS must point to testnet. Prices are simulated — use only for validating order submission, fills, and cancel mechanics.