8000 GitHub - kanekoshoyu/exchange-collection: Collection of Crypto Exchange OpenAPI and Generated Clients
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

kanekoshoyu/exchange-collection

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

exchange-collection

list of machine-readable crypto exchange OpenAPI AsyncAPI documents and code generators.

Important

generated code is now ready at exchange-collection-rust

doc license discord

why use OpenAPI AsyncAPI docs

pain points in cross exchange trading

Many trading strategies require cross exchange data and execution. There are trading libraries that provides abstraction across exchanges.

library / framework multi-exchange primary language wrapper language
ccxt yes js python, php, csharp
hummingbot yes python, cpp n/a
openlimits yes rust python, js, go
barter-rs yes rust n/a
kelp yes go n/a

These libraries are each good in their way but does not solve the below 4 points at once.

  1. integration effort: N crypto exchanges, L programming languages, its a better when effort is N + L rather than N * L
  2. document consistecy and code maintenance: exchanges freqently update API. Without proper pipeline and versioning, code and API inconsistency is common
  3. opinionated framework: battery-included cross-exchange libraries has complex design, and often fail to meet the actual needs in low latency
  4. multi-language support: people use python for strategy proof of concept and rust for production.

solution: building from bottom up

by gathering OpenAPI / AsyncAPI docuements, we can build a CI pipeline that generate and test versioned clients for different languages solving the above issues.

  1. gather both OpenAPI / AsyncAPI YAML per exchange
  2. develop codegen CI for generating REST/WS clients
  3. deploy CI for generating REST/WS clients
  4. implement trading traits per generated model
    1. I have set up trading traits in guilder for generated codes
    2. or you can still use the this repo for the OpenAPI / AsyncAPI

project structure

location feature
asset OpenAPI and AsyncAPI YAML
codegen code generator script written in rust
index.html OpenAPI / AsyncAPI viewer, hosted here

this repo includes a CI which generates rust client and pushes to exchange-collection-rust

guidelines

specs guidelines
OpenAPI format {exchange}_rest_openapi.yaml, v3.X.Y, convert swagger to OpenAPI here
AsyncAPI format {exchange}_ws_asyncapi.yaml, YAML, v3.0.X, codegen topology natively supports V3 now
codegen written in Rust
official codegen output support rust python (codegen coming soon)
unofficial support typescript csharp golang java dart kotlin php cplusplus scala

exchange integration status

below are the list of exchanges planned for integration. Please contact Sho if you want to request exchanges for integration.

Exchange API KYC REST (OpenAPI) WS (AsyncAPI)
ccxtrest / done /
hyperliquid no done done
mexc no done done
bitwyre yes done done
bitget yes done done
binance yes done done
coinbase yes done done
coincheck (JP) yes done done
hashkey (HK) yes done done
okx yes done done
krakenfutures yes done done
gateio yes WIP WIP
dydx no postponed /
polkadex no postponed /
zkex no postponed /
gmx no postponed /
coinex no WIP WIP
bybit yes planned planned
kucoin yes planned planned
htx yes planned planned
bitbank (JP) yes postponed postponed
bitflyer (JP) yes postponed postponed
korbit (KR) yes postponed postponed
bitkub (TH) yes postponed postponed
  • I currently have no plan of supporting FIX protocol due to limited number of supported exchanges. Once the project reaches certain maturity it will be implemented.
  • For AMM DEX like Uniswap, I will add support if there is a proper demand. My suggestion is to make use of JSON-RPC clients like ether-rs to connect RPC providers like infura and alchemy.

codegen status

Document Language framework CI status code issues
OpenAPI rust reqwest integrated generated code cannot differentiate fields like "m" and "M"
AsyncAPI rust tokio-tungstenite integrated does not parse variables in URL/channel name like "price_{base}_{quote}"
AsyncAPI rust async-tungstenite planned /
OpenAPI python reqwest planned /
AsyncAPI rust tokio-tungstenite planned /

codegen commands used

you can use these commands to generate code manually as well

initial set up

install OpenAPI CLI

npm install -g @openapitools/openapi-generator-cli

install AsyncAPI CLI

npm install -g @asyncapi/cli

each codegen command

language input command
rust openapi (REST, reqwest) openapi-generator-cli generate -i {YAML} -g rust -o {OUTPUT_DIR} --additional-properties=library=reqwest
rust asyncapi (WS, tokio-tungstenite) asyncapi generate fromTemplate {YAML} asyncapi-rust-ws-template -p exchange={EXCHANGE}
python openapi (REST, asyncio) openapi-generator-cli generate -i {YAML} -g python -o {OUTPUT_DIR} --additional-properties=asyncio=true
python asyncapi (WS, asyncio-websockets) wip

TODO

  • gather assets
    • gather 3 sets of API docs initial assets
    • gather 10 exchanges to validate the idea
    • gather 100 exchanges to have a competitive trading library
  • set up CI for codegen model
    • rust codegen
      • REST (reqwest) client
      • WS (tokio-tungstenite) client template
      • CI for pushing to sub-repo on generated code
      • CI for release on crates.io
    • python codegen
      • REST client
      • WS (asyncio-websockets)
      • CI for pushing to sub-repo on generated code
      • CI for release on pip
  • set up guilder trading library
    • define market data traits
    • define order placement traits
    • define ledger traits
    • implement traits on top of the codegen model
    • package models with opinionated trait per language

notes

  • the ag command seems to be deprecated and cannot generate code properly, use asyncapi generate instead
  • you can install asyncapi-preview extension on vs code for preview
  • comnunity AsyncAPI templates like python-sanic-template are not working properly

partnership & recruitment

I keep this project opensource so that everyone can take part of it. If you have any OpenAPI / AsyncAPI document for a crypto exchange, you are more than welcome to add with a pull request, or I am willing to purchase at reasonable cost as well.
Please contact Sho for partnerships.

OpenAPI / AsyncAPI Author

I am gathering API doc with @pakTech786 would be great if more people can help with it.

TypeScript AsyncAPI Template Developer

asyncapi-rust-ws-template

I have set up a repo to develop AsyncAPI template for Rust WS in React. I want a version for python/go as well. I am not a TS expert, so I would love to have an expert to accelarate development.

see also

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •  
0