From 0716a22d1fab76a18606ec031d33914ccbc56633 Mon Sep 17 00:00:00 2001 From: Dan Rostovtsev Date: Mon, 6 Apr 2026 15:48:14 -0400 Subject: First working IBKR API implementation. * doc/ibkr.org: Docs for using the IBKR API. * manifest.scm: Guix Manifest of all project dependencies. * scripts/run-gateway.bash: A script for building and deploying the IBKR Client Gateway. * src/ibkr/api.scm: Support for specific endpoints, and generic tools for using the IBKR API. * src/ibkr/types.scm: Basic types for the IBKR endpoints. Orders, positions, securities, etc. * test/*.json: IBKR response and request examples for testing. * test/api.scm: Response handling and endpoint construction. * test/types.scm: Tests JSON parsing of IBKR requests and responses. --- scripts/preview-order.scm | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 scripts/preview-order.scm (limited to 'scripts/preview-order.scm') diff --git a/scripts/preview-order.scm b/scripts/preview-order.scm new file mode 100644 index 0000000..5550a88 --- /dev/null +++ b/scripts/preview-order.scm @@ -0,0 +1,17 @@ +(use-modules (ibkr api) (ibkr types) (ice-9 format)) +(define base "http://localhost:5000") + +(format #t "auth-status=~a\n" (auth-status base)) +(define accts (accounts base)) +(format #t "accounts=~a\n" accts) +(define acct-id (account-id (car accts))) +(format #t "positions=~a\n" (positions base acct-id)) +(format #t "ledger=~a\n" (ledger base acct-id "USD")) +(format #t "stocks-by-symbol(IBKR)=~a\n" (stocks-by-symbol base "IBKR")) +(define ibkr-id (contract-id (contract-for-stock-ticker base "IBKR" "NASDAQ"))) +(format #t "contract-id(IBKR)=~a\n" ibkr-id) +(format #t "last-trade=~a\n" (contract-snapshot base ibkr-id 'last-trade)) +(define order (make-order acct-id ibkr-id "MARKET" "BUY" "IOC" 100.0)) +(format #t "order=~a\n" order) +(format #t "order-json=\"[~a]\"\n" (order->json order)) +(format #t "order-preview=~a\n" (order-preview base acct-id order)) -- cgit v1.3