Files
ritmex-bot/docs/ccxt/wiki/examples/py/README.md
T
2025-10-03 15:28:16 +08:00

492 lines
18 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<style>ul { margin-bottom: -10px; }</style>
# [<-](Examples?id=python)
# CCXT Python Examples
To run Python examples from any folder, type in console:
```shell
python path/to/example.py # substitute for actual filename here
```
Example files starting with `async-` require Python 3.6 with `async`/`await` and async generators support.
![basic-chart](https://user-images.githubusercontent.com/1294454/29979754-6d62354c-8f4f-11e7-9e0a-22e87b4a093b.jpg)
## See Also
[co3k-crypto-currency-note](https://github.com/co3k/co3k-crypto-currency-note/blob/master/Untitled.ipynb) an example of using ccxt to fetch OHLCV candles from Kraken and charting them with matplotlib in a Jupyter Notebook, made by [co3k](https://github.com/co3k).
- [Aiohttp Custom Session Connector](./examples/py/aiohttp-custom-session-connector.md)
- [All Exchanges](./examples/py/all-exchanges.md)
- [Arbitrage Pairs](./examples/py/arbitrage-pairs.md)
- [Asciichart](./examples/py/asciichart.md)
- [Async Analyse Augur V1 Vs V2 Exchanges](./examples/py/async-analyse-augur-v1-vs-v2-exchanges.md)
- [Async Balance Coinbasepro](./examples/py/async-balance-coinbasepro.md)
- [Async Balance Gdax](./examples/py/async-balance-gdax.md)
- [Async Balance](./examples/py/async-balance.md)
- [Async Balances](./examples/py/async-balances.md)
- [Async Basic Callchain](./examples/py/async-basic-callchain.md)
- [Async Basic Orderbook](./examples/py/async-basic-orderbook.md)
- [Async Basic Rate Limiter](./examples/py/async-basic-rate-limiter.md)
- [Async Basic](./examples/py/async-basic.md)
- [Async Binance Cancel Option Order](./examples/py/async-binance-cancel-option-order.md)
- [Async Binance Create Margin Order](./examples/py/async-binance-create-margin-order.md)
- [Async Binance Create Option Order](./examples/py/async-binance-create-option-order.md)
- [Async Binance Create Trailing Percent Order](./examples/py/async-binance-create-trailing-percent-order.md)
- [Async Binance Fetch Margin Balance With Options](./examples/py/async-binance-fetch-margin-balance-with-options.md)
- [Async Binance Fetch Margin Balance With Params](./examples/py/async-binance-fetch-margin-balance-with-params.md)
- [Async Binance Fetch Option Ohlcv](./examples/py/async-binance-fetch-option-OHLCV.md)
- [Async Binance Fetch Option Details](./examples/py/async-binance-fetch-option-details.md)
- [Async Binance Fetch Option Order](./examples/py/async-binance-fetch-option-order.md)
- [Async Binance Fetch Option Orderbook](./examples/py/async-binance-fetch-option-orderbook.md)
- [Async Binance Fetch Option Position](./examples/py/async-binance-fetch-option-position.md)
- [Async Binance Fetch Option Ticker](./examples/py/async-binance-fetch-option-ticker.md)
- [Async Binance Fetch Ticker Continuously](./examples/py/async-binance-fetch-ticker-continuously.md)
- [Async Binance Futures Vs Spot](./examples/py/async-binance-futures-vs-spot.md)
- [Async Binance Margin Borrow](./examples/py/async-binance-margin-borrow.md)
- [Async Binance Margin Repay](./examples/py/async-binance-margin-repay.md)
- [Async Binance Usdm Fetch Continuous Klines Ohlcv](./examples/py/async-binance-usdm-fetch-continuous-klines-ohlcv.md)
- [Async Bitfinex Public Get Symbols](./examples/py/async-bitfinex-public-get-symbols.md)
- [Async Bitget Perpetual Futures Swaps](./examples/py/async-bitget-perpetual-futures-swaps.md)
- [Async Bitstamp Create Limit Buy Order](./examples/py/async-bitstamp-create-limit-buy-order.md)
- [Async Bitstamp Create Order Cancel Order](./examples/py/async-bitstamp-create-order-cancel-order.md)
- [Async Bittrex Orderbook](./examples/py/async-bittrex-orderbook.md)
- [Async Bybit Transfer](./examples/py/async-bybit-transfer.md)
- [Async Fetch Balance](./examples/py/async-fetch-balance.md)
- [Async Fetch Many Orderbooks Continuously](./examples/py/async-fetch-many-orderbooks-continuously.md)
- [Async Fetch Ohlcv Indicators Discord Webhook](./examples/py/async-fetch-ohlcv-indicators-discord-webhook.md)
- [Async Fetch Ohlcv Multiple Symbols Continuously](./examples/py/async-fetch-ohlcv-multiple-symbols-continuously.md)
- [Async Fetch Order Book From Many Exchanges](./examples/py/async-fetch-order-book-from-many-exchanges.md)
- [Async Fetch Ticker](./examples/py/async-fetch-ticker.md)
- [Async Gather Concurrency](./examples/py/async-gather-concurrency.md)
- [Async Gdax Fetch Order Book Continuously](./examples/py/async-gdax-fetch-order-book-continuously.md)
- [Async Generator Basic](./examples/py/async-generator-basic.md)
- [Async Generator Multiple Tickers](./examples/py/async-generator-multiple-tickers.md)
- [Async Generator Ticker Poller](./examples/py/async-generator-ticker-poller.md)
- [Async Hollaex Sandbox](./examples/py/async-hollaex-sandbox.md)
- [Async Instantiate All At Once](./examples/py/async-instantiate-all-at-once.md)
- [Async Kucoin Rate Limit](./examples/py/async-kucoin-rate-limit.md)
- [Async Macd](./examples/py/async-macd.md)
- [Async Market Making Symbols](./examples/py/async-market-making-symbols.md)
- [Async Multiple Accounts](./examples/py/async-multiple-accounts.md)
- [Async Multiple Parallel Calls](./examples/py/async-multiple-parallel-calls.md)
- [Async Okx Create Margin Order](./examples/py/async-okx-create-margin-order.md)
- [Async Okx Margin Borrow](./examples/py/async-okx-margin-borrow.md)
- [Async Okx Margin Repay](./examples/py/async-okx-margin-repay.md)
- [Async Okx Positional Orders](./examples/py/async-okx-positional-orders.md)
- [Async Orderbooks From Multiple Exchanges At Once](./examples/py/async-orderbooks-from-multiple-exchanges-at-once.md)
- [Async Orderbooks](./examples/py/async-orderbooks.md)
- [Async Rtt](./examples/py/async-rtt.md)
- [Async Theocean Orderbook](./examples/py/async-theocean-orderbook.md)
- [Async Theocean Tickers](./examples/py/async-theocean-tickers.md)
- [Async Ticker](./examples/py/async-ticker.md)
- [Async Tickers From Many Exchanges At Once](./examples/py/async-tickers-from-many-exchanges-at-once.md)
- [Async Tickers](./examples/py/async-tickers.md)
- [Async With Threads](./examples/py/async-with-threads.md)
- [Async](./examples/py/async.md)
- [Balance Coinbasepro](./examples/py/balance-coinbasepro.md)
- [Balance Gdax](./examples/py/balance-gdax.md)
- [Balance Kraken](./examples/py/balance-kraken.md)
- [Balances](./examples/py/balances.md)
- [Basic Chart](./examples/py/basic-chart.md)
- [Basic Rate Limiting](./examples/py/basic-rate-limiting.md)
- [Binance Batch Orders](./examples/py/binance-batch-orders.md)
- [Binance Coin Margined Take Profit](./examples/py/binance-coin-margined-take-profit.md)
- [Binance Conditional Orders](./examples/py/binance-conditional-orders.md)
- [Binance Create Oco Order With Implicit Methods](./examples/py/binance-create-oco-order-with-implicit-methods.md)
- [Binance Ema](./examples/py/binance-ema.md)
- [Binance Fetch All My Trades Paginate By Id](./examples/py/binance-fetch-all-my-trades-paginate-by-id.md)
- [Binance Fetch All My Trades](./examples/py/binance-fetch-all-my-trades.md)
- [Binance Fetch All Trades](./examples/py/binance-fetch-all-trades.md)
- [Binance Fetch Ohlcv Closing Time 1](./examples/py/binance-fetch-ohlcv-closing-time-1.md)
- [Binance Fetch Ohlcv Closing Time 2](./examples/py/binance-fetch-ohlcv-closing-time-2.md)
- [Binance Fetch Ohlcv Pagination](./examples/py/binance-fetch-ohlcv-pagination.md)
- [Binance Fetch Ohlcv Quote Volume](./examples/py/binance-fetch-ohlcv-quote-volume.md)
- [Binance Fetch Ohlcv To Csv](./examples/py/binance-fetch-ohlcv-to-csv.md)
- [Binance Fetch Ohlcv](./examples/py/binance-fetch-ohlcv.md)
- [Binance Fiat](./examples/py/binance-fiat.md)
- [Binance Futures Margin](./examples/py/binance-futures-margin.md)
- [Binance Futures Positions](./examples/py/binance-futures-positions.md)
- [Binance Futures Set Leverage Implicit Api](./examples/py/binance-futures-set-leverage-implicit-api.md)
- [Binance Futures Set Leverage](./examples/py/binance-futures-set-leverage.md)
- [Binance Market Order Quote Usdt](./examples/py/binance-market-order-quote-usdt.md)
- [Binance Poll Balance](./examples/py/binance-poll-balance.md)
- [Binance Poll Positions](./examples/py/binance-poll-positions.md)
- [Binance Savings Endpoints](./examples/py/binance-savings-endpoints.md)
- [Binance Spot Trailing](./examples/py/binance-spot-trailing.md)
- [Binance Stop Loss Take Profit](./examples/py/binance-stop-loss-take-profit.md)
- [Binance Test Order](./examples/py/binance-test-order.md)
- [Binance Universal Transfer](./examples/py/binance-universal-transfer.md)
- [Binance Usdm Fetch Continuous Klines Ohlcv](./examples/py/binance-usdm-fetch-continuous-klines-ohlcv.md)
- [Bitfinex Rate Limiting](./examples/py/bitfinex-rate-limiting.md)
- [Bitget Perpetual Futures Swaps](./examples/py/bitget-perpetual-futures-swaps.md)
- [Bitmex Cancel Orders](./examples/py/bitmex-cancel-orders.md)
- [Bitmex Create Order](./examples/py/bitmex-create-order.md)
- [Bitmex Fetch Ohlcv With Extra Params](./examples/py/bitmex-fetch-ohlcv-with-extra-params.md)
- [Bitmex Ohlcv Convert 5m To 15m](./examples/py/bitmex-ohlcv-convert-5m-to-15m.md)
- [Bitmex Order Value](./examples/py/bitmex-order-value.md)
- [Bittrex Fetch Closed Orders History](./examples/py/bittrex-fetch-closed-orders-history.md)
- [Build Ohlcv Bars](./examples/py/build-ohlcv-bars.md)
- [Builtin Rate Limiting Long Poller](./examples/py/builtin-rate-limiting-long-poller.md)
- [Bybit Usdc Create Option Order](./examples/py/bybit-USDC-create-option-order.md)
- [Bybit Conditional Orders](./examples/py/bybit-conditional-orders.md)
- [Bybit Positions](./examples/py/bybit-positions.md)
- [Bybit Trailling](./examples/py/bybit-trailling.md)
- [Bybit Updated](./examples/py/bybit-updated.md)
- [Cli](./examples/py/cli.md)
- [Coinbase Cancel Order](./examples/py/coinbase-cancel-order.md)
- [Coinbase Create Order](./examples/py/coinbase-create-order.md)
- [Coinbase Fetch Ohlcv](./examples/py/coinbase-fetch-OHLCV.md)
- [Coinbase Fetch Order](./examples/py/coinbase-fetch-order.md)
- [Coinbase Fetch Ticker](./examples/py/coinbase-fetch-ticker.md)
- [Coinbase Fetch Trades](./examples/py/coinbase-fetch-trades.md)
- [Coinbasepro Fetch My Trades Pagination](./examples/py/coinbasepro-fetch-my-trades-pagination.md)
- [Coinex Futures](./examples/py/coinex-futures.md)
- [Coinone Fetch Tickers](./examples/py/coinone-fetch-tickers.md)
- [Coinone Markets](./examples/py/coinone-markets.md)
- [Compare Two Exchanges Capabilities](./examples/py/compare-two-exchanges-capabilities.md)
- [Create Order Position With Takeprofit Stoploss](./examples/py/create-order-position-with-takeprofit-stoploss.md)
- [Create Order Ws Example](./examples/py/create-order-ws-example.md)
- [Create Orders Example](./examples/py/create-orders-example.md)
- [Create Trailing Amount Order](./examples/py/create-trailing-amount-order.md)
- [Create Trailing Percent Order](./examples/py/create-trailing-percent-order.md)
- [Exchange Save Load Markets Cache](./examples/py/exchange-save-load-markets-cache.md)
- [Exchanges By Country](./examples/py/exchanges-by-country.md)
- [Exchanges](./examples/py/exchanges.md)
- [Fetch All Okex Ohclv](./examples/py/fetch-all-okex-ohclv.md)
- [Fetch All Tickers](./examples/py/fetch-all-tickers.md)
- [Fetch Balance Asset Valuation](./examples/py/fetch-balance-asset-valuation.md)
- [Fetch Bitfinex Ohlcv History](./examples/py/fetch-bitfinex-ohlcv-history.md)
- [Fetch Coinbasepro Ohlcv Sequentially](./examples/py/fetch-coinbasepro-ohlcv-sequentially.md)
- [Fetch Create Deposit Address](./examples/py/fetch-create-deposit-address.md)
- [Fetch First Ohlcv Timestamp](./examples/py/fetch-first-ohlcv-timestamp.md)
- [Fetch Gdax Ohlcv Sequentially](./examples/py/fetch-gdax-ohlcv-sequentially.md)
- [Fetch Ohlcv Cex](./examples/py/fetch-ohlcv-cex.md)
- [Fetch Ohlcv Kraken](./examples/py/fetch-ohlcv-kraken.md)
- [Fetch Ohlcv Many Exchanges Continuosly](./examples/py/fetch-ohlcv-many-exchanges-continuosly.md)
- [Fetch Ohlcv Mark Index Price](./examples/py/fetch-ohlcv-mark-index-price.md)
- [Fetch Ohlcv On New Candle](./examples/py/fetch-ohlcv-on-new-candle.md)
- [Fetch Ohlcv Sequentially](./examples/py/fetch-ohlcv-sequentially.md)
- [Fetch Ohlcv](./examples/py/fetch-ohlcv.md)
- [Fetch Okex Futures](./examples/py/fetch-okex-futures.md)
- [Fetch Open Orders](./examples/py/fetch-open-orders.md)
- [Fetch Order Book Rtt](./examples/py/fetch-order-book-rtt.md)
- [Fetch Orders](./examples/py/fetch-orders.md)
- [Fetch Ticker Many Exchanges Many Symbols](./examples/py/fetch-ticker-many-exchanges-many-symbols.md)
- [Fetch_longer_ohlcv_through_multiple_calls_and_save_to_csv](./examples/py/fetch_longer_ohlcv_through_multiple_calls_and_save_to_csv.md)
- [Gateio Fetch Ohlcv Pagination](./examples/py/gateio-fetch-ohlcv-pagination.md)
- [Gateio Futures](./examples/py/gateio-futures.md)
- [Gateio Open Close Contract](./examples/py/gateio-open-close-contract.md)
- [Gateio Swaps](./examples/py/gateio-swaps.md)
- [Gdax Fetch My Trades Pagination](./examples/py/gdax-fetch-my-trades-pagination.md)
- [Hitbtc Withdraw](./examples/py/hitbtc-withdraw.md)
- [Huobi Futures](./examples/py/huobi-futures.md)
- [Huobi Open Close Contract](./examples/py/huobi-open-close-contract.md)
- [Huobi Open Close Position Bbo](./examples/py/huobi-open-close-position-bbo.md)
- [Huobi Spot](./examples/py/huobi-spot.md)
- [Huobi Swaps](./examples/py/huobi-swaps.md)
- [Instantiate All At Once](./examples/py/instantiate-all-at-once.md)
- [Kraken Conditional Close Order](./examples/py/kraken-conditional-close-order.md)
- [Kraken Create And Close Position](./examples/py/kraken-create-and-close-position.md)
- [Kraken Fetch My Trades Pagination](./examples/py/kraken-fetch-my-trades-pagination.md)
- [Krakenfutures Basic](./examples/py/krakenfutures-basic.md)
- [Kucoin Fetch All Deposit Addresses By Network](./examples/py/kucoin-fetch-all-deposit-addresses-by-network.md)
- [Kucoin Fetch All Deposit Addresses](./examples/py/kucoin-fetch-all-deposit-addresses.md)
- [Kucoin Fetch Closed Orders Pagination](./examples/py/kucoin-fetch-closed-orders-pagination.md)
- [Kucoin Rate Limit](./examples/py/kucoin-rate-limit.md)
- [Kucoin Withdraw Chain](./examples/py/kucoin-withdraw-chain.md)
- [Kucoinfutures Create Stop Order](./examples/py/kucoinfutures-create-stop-order.md)
- [Latoken Create Order](./examples/py/latoken-create-order.md)
- [Latoken Example](./examples/py/latoken-example.md)
- [Manual Rate Limiting Long Poller](./examples/py/manual-rate-limiting-long-poller.md)
- [Margin Leverage Order Kraken](./examples/py/margin-leverage-order-kraken.md)
- [Margin Loan Borrow Buy Sell Repay](./examples/py/margin-loan-borrow-buy-sell-repay.md)
- [Measure Latency](./examples/py/measure-latency.md)
- [Minimal 2 Lines](./examples/py/minimal-2-lines.md)
- [Multiple Subscriptions Watchxforsymbols](./examples/py/multiple-subscriptions-watchXForSymbols.md)
- [Normalize Sparse Candle Timestamps](./examples/py/normalize-sparse-candle-timestamps.md)
- [Okx Fetch All My Trades](./examples/py/okx-fetch-all-my-trades.md)
- [Okx Fetch Closed Orders Pagenumber Pagination](./examples/py/okx-fetch-closed-orders-pagenumber-pagination.md)
- [Okx Position Takeprofit Stoploss](./examples/py/okx-position-takeprofit-stoploss.md)
- [Okx Transfer](./examples/py/okx-transfer.md)
- [Order Book Extra Level Depth Param](./examples/py/order-book-extra-level-depth-param.md)
- [Phemex Create Order Position With Takeprofit Stoploss](./examples/py/phemex-create-order-position-with-takeprofit-stoploss.md)
- [Phemex Create Stop Order](./examples/py/phemex-create-stop-order.md)
- [Phemex Leverage Orders](./examples/py/phemex-leverage-orders.md)
- [Phemex Open Cancel Close Positions](./examples/py/phemex-open-cancel-close-positions.md)
- [Phemex Perpetual Balance](./examples/py/phemex-perpetual-balance.md)
- [Phemex Positions](./examples/py/phemex-positions.md)
- [Phemex Transfer](./examples/py/phemex-transfer.md)
- [Playing_with_ccxt_example](./examples/py/playing_with_ccxt_example.md)
- [Poloniex Fetch Ohlcv Continuously](./examples/py/poloniex-fetch-ohlcv-continuously.md)
- [Poloniex Fetch Ohlcv With Pagination](./examples/py/poloniex-fetch-ohlcv-with-pagination.md)
- [Poloniex Fetch Order Books](./examples/py/poloniex-fetch-order-books.md)
- [Poloniex Fetch Trades Continuously](./examples/py/poloniex-fetch-trades-continuously.md)
- [Poloniex Fetch Trades With Pagination To Csv](./examples/py/poloniex-fetch-trades-with-pagination-to-csv.md)
- [Poloniex Python2 Memleak Test](./examples/py/poloniex-python2-memleak-test.md)
- [Poloniex Python3 Memleak Test](./examples/py/poloniex-python3-memleak-test.md)
- [Proxy Usage](./examples/py/proxy-usage.md)
- [Rsi](./examples/py/rsi.md)
- [Rtt](./examples/py/rtt.md)
- [Sample Local Proxy Server With Cors](./examples/py/sample-local-proxy-server-with-cors.md)
- [Set_markets_from_exchange](./examples/py/set_markets_from_exchange.md)
- [Sign In](./examples/py/sign-in.md)
- [Sort Swap Markets By Hourly Price Change](./examples/py/sort-swap-markets-by-hourly-price-change.md)
- [Source Ip Address](./examples/py/source-ip-address.md)
- [Symbols](./examples/py/symbols.md)
- [Test Server](./examples/py/test-server.md)
- [Theocean](./examples/py/theocean.md)
- [Tickers](./examples/py/tickers.md)
- [Watch Ohlcv For Symbols](./examples/py/watch-OHLCV-For-Symbols.md)
- [Watch Ohlcv](./examples/py/watch-OHLCV.md)
- [Watch Orderbook For Symbols](./examples/py/watch-OrderBook-For-Symbols.md)
- [Watch Trades For Symbols](./examples/py/watch-Trades-For-Symbols.md)
- [Watch Tickers](./examples/py/watch-tickers.md)
- [Watchohlcvforsymbols](./examples/py/watchOHLCVForSymbols.md)
- [Watchorderbookforsymbols](./examples/py/watchOrderBookForSymbols.md)
- [Watchpositions Many Exchanges Continuosly](./examples/py/watchPositions-many-exchanges-continuosly.md)
- [Watchpositions](./examples/py/watchPositions.md)
- [Watchpositionsforsymbols](./examples/py/watchPositionsForSymbols.md)
- [Watchtradesforsymbols](./examples/py/watchTradesForSymbols.md)
- [Wazirx Create Cancel Orders](./examples/py/wazirx-create-cancel-orders.md)
- [Withdraw From One Exchange To Another](./examples/py/withdraw-from-one-exchange-to-another.md)
- [Ws_test_load](./examples/py/ws_test_load.md)