Apidays London 2024 - Building Cross-Exchange Trading Library with OpenAPI_AsyncAPI, Sho Kaneko.pdf

APIdays_official 110 views 22 slides Oct 10, 2024
Slide 1
Slide 1 of 22
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16
Slide 17
17
Slide 18
18
Slide 19
19
Slide 20
20
Slide 21
21
Slide 22
22

About This Presentation

Building Cross-Exchange Trading Library with OpenAPI/AsyncAPI
Sho Kaneko, Founder - Repoch

apidays London 2024 - APIs for Smarter Platforms and Business Processes
September 18 & 19, 2024


Slide Content

Building Cross-Exchange
Trading Library with OpenAPI /
AsyncAPI
`
Sho Kaneko
CEO, Repoch Indie Hacker, Rustascean

Sho Kaneko
2019 embedded rust developer / running hardware product prototyping agency
2023 started doing open-source trading in rusttransitioned to crypto trading software
rust
2024 80% contracting rust project,20% open-source trading software100% digital
nomad / indie hacker
intro
trading project
hurdles
solution inspired
by embedded
leveraging
AsyncAPI
useful tools
power of
opensource

doc-first integration
Russian boss who doesn’t speak
Intelligent CTO
intro
trading project
hurdles
solution inspired
by embedded
leveraging
AsyncAPI
useful tools
power of
opensource REST
WebSocket
Events/Signals Strategy
REST
WebSocket
LedgerBacktest
Get Market Data Place
Order
reading inaccurate / unmaintained API document
testing parsers
figuring out cross-exchange trading execution
20-50% of
the dev time spent on

cross-exchange trading libraries
Russian boss who doesn’t speak
Intelligent CTO
intro
trading project
hurdles
solution inspired
by embedded
leveraging
AsyncAPI
useful tools
power of
opensource
Opinionated doesn’t fit into actual software design
requirements
Rust Wrapper on Javascript/Python (like fr?)
Less people using Rust not leveraging the Python
community
Javascript
Python Rust

what we want for a cross exchange trading
library
Russian boss who doesn’t speak
Intelligent CTO
intro
trading project
hurdles
solution inspired
by embedded
leveraging
AsyncAPI
useful tools
power of
opensource
opensourcenative python support
library, not a framework code-gen clients
Sounds familiar as embedded software
engineer…

Idea from embedded to trading: arduino
Russian boss who doesn’t speak
Intelligent CTO
intro
trading project
hurdles
solution
inspired by
embedded
leveraging
AsyncAPI
useful tools
power of
opensource
above:
application
below arduino:
h/w support

Idea from embedded to trading: above the
abstraction
Russian boss who doesn’t speak
Intelligent CTO
intro
trading project
hurdles
solution
inspired by
embedded
leveraging
AsyncAPI
useful tools
power of
opensource
Arduino Uno
R3

Idea from embedded to trading: below the
abstraction
Russian boss who doesn’t speak
Intelligent CTO
intro
trading project
hurdles
solution
inspired by
embedded
leveraging
AsyncAPI
useful tools
power of
opensource
“All of them run the same code,
Can’t we do the same thing for crypto
trading?”

key to openness: abstraction
Russian boss who doesn’t speak
Intelligent CTO
intro
trading project
hurdles
solution
inspired by
embedded
leveraging
AsyncAPI
useful tools
power of
opensource
arduino hardware abstraction layer (HAL)e.g. GPIO, UART, I2C, SPI, PWM
espressif BSP/HAL
Flash driver
nrf52 BSP/HAL
LCD display driver
smartwatch, fleet management, 3D printer
memory map memory map
above:
application
below arduino:
h/w support

key to openness: abstraction
Russian boss who doesn’t speak
Intelligent CTO
intro
trading project
hurdles
solution
inspired by
embedded
leveraging
AsyncAPI
useful tools
power of
opensource
trading abstraction layere.g. order placement, fetch market data
Hyperliquid
local orderbook
Binance
BSP/HAL
trading signals
strategy, backtesting, reporting
REST/ WS Client REST/ WS Client
above:
application
below:CEX
support
OpenAPI / AsyncAPI OpenAPI / AsyncAPI

guilder: the trading abstraction
Russian boss who doesn’t speak
Intelligent CTO
intro
trading project
hurdles
solution inspired
by embedded
leveraging
AsyncAPI
useful tools
power of
opensource
trading.yaml
guilder.py
guilder.r
s
Domain Specific Language (DSL)
“get L2 orderbook”, “get funding rate”
“place order”, “check current balance”

guilder: the trading abstraction
Russian boss who doesn’t speak
Intelligent CTO
intro
trading project
hurdles
solution inspired
by embedded
leveraging
AsyncAPI
useful tools
power of
opensource
trading.py
trading.rs
trading.yaml
ongoing
implemented local orderbook sync
adding backtesting, visualization
porting cyclic arbitrage code

exchange-collection: OpenAPI / AsyncAPI
collection
Russian boss who doesn’t speak
Intelligent CTO
intro
trading project
hurdles
solution inspired
by embedded
leveraging
AsyncAPI
useful tools
power of
opensource
OpenAP
I(REST)
AsyncAP
I(WS)
client code
api testing
toolsgathered 3 exchanges(binance,
coinbase, hyperliquid)
building client code-gen CI
adding AsyncAPI WS codegen

useful tool #1: API viewer
Russian boss who doesn’t speak
Intelligent CTO
intro
trading project
hurdles
solution inspired
by embedded
leveraging
AsyncAPI
useful tools
power of
opensource
https://repoch.co/exchange-collection/
OpenAP
I(REST)
AsyncAP
I(WS)

useful tool #2: client codegen
Russian boss who doesn’t speak
Intelligent CTO
intro
trading project
hurdles
solution inspired
by embedded
leveraging
AsyncAPI
useful tools
power of
opensource
OpenAP
I(REST)
AsyncAP
I(WS)
janky, but I can rebuild it because it is open source

google it or (re)build it
Russian boss who doesn’t speak
Intelligent CTO
intro
trading project
hurdles
solution inspired
by embedded
leveraging
AsyncAPI
useful tools
power of
opensource
fixing OpenAPI REST client codegen
adding AsyncAPI WS client codegen
(maybe) add extensions to OpenAPI / AsyncAPI

useful tool #2: client codegen
Russian boss who doesn’t speak
Intelligent CTO
intro
trading project
hurdles
solution inspired
by embedded
leveraging
AsyncAPI
useful tools
power of
opensource
Rust Trading Bot Dev
https://discord.gg/nabHXUN9RS
Q&A

future integration pipeline:code-first
approach
Russian boss who doesn’t speak
Intelligent CTO
intro
trading project
hurdles
solution inspired
by embedded
leveraging
AsyncAPI
useful tools
power of
opensource
appendix

future integration pipeline:api-first approach
Russian boss who doesn’t speak
Intelligent CTO
intro
trading project
hurdles
solution inspired
by embedded
leveraging
AsyncAPI
useful tools
power of
opensource
200USD
OpenAPI150USD
AsyncAPI1 doc
per week
?

future integration pipeline:code-first
approach
Russian boss who doesn’t speak
Intelligent CTO
intro
trading project
hurdles
solution inspired
by embedded
leveraging
AsyncAPI
useful tools
power of
opensource
poem and
poem-openapi

OpenAPI tools
Russian boss who doesn’t speak
Intelligent CTO
intro
trading project
hurdles
solution inspired
by embedded
leveraging
AsyncAPI
useful tools
power of
opensource

AsyncAPI tools
Russian boss who doesn’t speak
Intelligent CTO
intro
trading project
hurdles
solution inspired
by embedded
leveraging
AsyncAPI
useful tools
power of
opensource