CCXT-readme-17.py
· 1.2 KiB · Python
Eredeti
# coding=utf-8
import ccxt
hitbtc = ccxt.hitbtc({'verbose': True})
bitmex = ccxt.bitmex()
huobipro = ccxt.huobipro()
exmo = ccxt.exmo({
'apiKey': 'YOUR_PUBLIC_API_KEY',
'secret': 'YOUR_SECRET_PRIVATE_KEY',
})
kraken = ccxt.kraken({
'apiKey': 'YOUR_PUBLIC_API_KEY',
'secret': 'YOUR_SECRET_PRIVATE_KEY',
})
exchange_id = 'binance'
exchange_class = getattr(ccxt, exchange_id)
exchange = exchange_class({
'apiKey': 'YOUR_API_KEY',
'secret': 'YOUR_SECRET',
})
hitbtc_markets = hitbtc.load_markets()
print(hitbtc.id, hitbtc_markets)
print(bitmex.id, bitmex.load_markets())
print(huobipro.id, huobipro.load_markets())
print(hitbtc.fetch_order_book(hitbtc.symbols[0]))
print(bitmex.fetch_ticker('BTC/USD'))
print(huobipro.fetch_trades('LTC/USDT'))
print(exmo.fetch_balance())
# sell one ฿ for market price and receive $ right now
print(exmo.id, exmo.create_market_sell_order('BTC/USD', 1))
# limit buy BTC/EUR, you pay €2500 and receive ฿1 when the order is closed
print(exmo.id, exmo.create_limit_buy_order('BTC/EUR', 1, 2500.00))
# pass/redefine custom exchange-specific order params: type, amount, price, flags, etc...
kraken.create_market_buy_order('BTC/USD', 1, {'trading_agreement': 'agree'})
1 | # coding=utf-8 |
2 | |
3 | import ccxt |
4 | |
5 | hitbtc = ccxt.hitbtc({'verbose': True}) |
6 | bitmex = ccxt.bitmex() |
7 | huobipro = ccxt.huobipro() |
8 | exmo = ccxt.exmo({ |
9 | 'apiKey': 'YOUR_PUBLIC_API_KEY', |
10 | 'secret': 'YOUR_SECRET_PRIVATE_KEY', |
11 | }) |
12 | kraken = ccxt.kraken({ |
13 | 'apiKey': 'YOUR_PUBLIC_API_KEY', |
14 | 'secret': 'YOUR_SECRET_PRIVATE_KEY', |
15 | }) |
16 | |
17 | exchange_id = 'binance' |
18 | exchange_class = getattr(ccxt, exchange_id) |
19 | exchange = exchange_class({ |
20 | 'apiKey': 'YOUR_API_KEY', |
21 | 'secret': 'YOUR_SECRET', |
22 | }) |
23 | |
24 | hitbtc_markets = hitbtc.load_markets() |
25 | |
26 | print(hitbtc.id, hitbtc_markets) |
27 | print(bitmex.id, bitmex.load_markets()) |
28 | print(huobipro.id, huobipro.load_markets()) |
29 | |
30 | print(hitbtc.fetch_order_book(hitbtc.symbols[0])) |
31 | print(bitmex.fetch_ticker('BTC/USD')) |
32 | print(huobipro.fetch_trades('LTC/USDT')) |
33 | |
34 | print(exmo.fetch_balance()) |
35 | |
36 | # sell one ฿ for market price and receive $ right now |
37 | print(exmo.id, exmo.create_market_sell_order('BTC/USD', 1)) |
38 | |
39 | # limit buy BTC/EUR, you pay €2500 and receive ฿1 when the order is closed |
40 | print(exmo.id, exmo.create_limit_buy_order('BTC/EUR', 1, 2500.00)) |
41 | |
42 | # pass/redefine custom exchange-specific order params: type, amount, price, flags, etc... |
43 | kraken.create_market_buy_order('BTC/USD', 1, {'trading_agreement': 'agree'}) |