ccxt-ir 4.3.46.0.1__py2.py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ccxt/__init__.py +358 -0
- ccxt/abantether.py +316 -0
- ccxt/abstract/__init__.py +0 -0
- ccxt/abstract/abantether.py +5 -0
- ccxt/abstract/ace.py +15 -0
- ccxt/abstract/afratether.py +6 -0
- ccxt/abstract/alpaca.py +70 -0
- ccxt/abstract/arzinja.py +5 -0
- ccxt/abstract/arzplus.py +7 -0
- ccxt/abstract/ascendex.py +77 -0
- ccxt/abstract/bequant.py +115 -0
- ccxt/abstract/bigone.py +45 -0
- ccxt/abstract/binance.py +712 -0
- ccxt/abstract/binancecoinm.py +712 -0
- ccxt/abstract/binanceus.py +764 -0
- ccxt/abstract/binanceusdm.py +712 -0
- ccxt/abstract/bingx.py +113 -0
- ccxt/abstract/bit2c.py +27 -0
- ccxt/abstract/bitbank.py +27 -0
- ccxt/abstract/bitbay.py +53 -0
- ccxt/abstract/bitbns.py +40 -0
- ccxt/abstract/bitcoincom.py +115 -0
- ccxt/abstract/bitfinex.py +69 -0
- ccxt/abstract/bitfinex2.py +139 -0
- ccxt/abstract/bitflyer.py +38 -0
- ccxt/abstract/bitget.py +508 -0
- ccxt/abstract/bithumb.py +32 -0
- ccxt/abstract/bitimen.py +7 -0
- ccxt/abstract/bitir.py +7 -0
- ccxt/abstract/bitmart.py +99 -0
- ccxt/abstract/bitmex.py +97 -0
- ccxt/abstract/bitopro.py +29 -0
- ccxt/abstract/bitpanda.py +35 -0
- ccxt/abstract/bitpin.py +7 -0
- ccxt/abstract/bitrue.py +72 -0
- ccxt/abstract/bitso.py +43 -0
- ccxt/abstract/bitstamp.py +258 -0
- ccxt/abstract/bitteam.py +29 -0
- ccxt/abstract/bitvavo.py +27 -0
- ccxt/abstract/bl3p.py +19 -0
- ccxt/abstract/blockchaincom.py +28 -0
- ccxt/abstract/blofin.py +37 -0
- ccxt/abstract/btcalpha.py +18 -0
- ccxt/abstract/btcbox.py +13 -0
- ccxt/abstract/btcmarkets.py +39 -0
- ccxt/abstract/btcturk.py +20 -0
- ccxt/abstract/bybit.py +298 -0
- ccxt/abstract/cex.py +33 -0
- ccxt/abstract/coinbase.py +94 -0
- ccxt/abstract/coinbaseadvanced.py +94 -0
- ccxt/abstract/coinbaseexchange.py +67 -0
- ccxt/abstract/coinbaseinternational.py +39 -0
- ccxt/abstract/coincatch.py +94 -0
- ccxt/abstract/coincheck.py +33 -0
- ccxt/abstract/coinex.py +237 -0
- ccxt/abstract/coinlist.py +54 -0
- ccxt/abstract/coinmate.py +62 -0
- ccxt/abstract/coinmetro.py +34 -0
- ccxt/abstract/coinone.py +67 -0
- ccxt/abstract/coinsph.py +54 -0
- ccxt/abstract/coinspot.py +28 -0
- ccxt/abstract/cryptocom.py +107 -0
- ccxt/abstract/currencycom.py +68 -0
- ccxt/abstract/delta.py +50 -0
- ccxt/abstract/deribit.py +125 -0
- ccxt/abstract/digifinex.py +91 -0
- ccxt/abstract/eterex.py +5 -0
- ccxt/abstract/excoino.py +7 -0
- ccxt/abstract/exir.py +8 -0
- ccxt/abstract/exmo.py +55 -0
- ccxt/abstract/exnovin.py +6 -0
- ccxt/abstract/farhadexchange.py +5 -0
- ccxt/abstract/fmfwio.py +115 -0
- ccxt/abstract/gate.py +265 -0
- ccxt/abstract/gateio.py +265 -0
- ccxt/abstract/gemini.py +58 -0
- ccxt/abstract/hashkey.py +67 -0
- ccxt/abstract/hitbtc.py +115 -0
- ccxt/abstract/hitbtc3.py +115 -0
- ccxt/abstract/hitobit.py +8 -0
- ccxt/abstract/hollaex.py +33 -0
- ccxt/abstract/htx.py +548 -0
- ccxt/abstract/huobi.py +548 -0
- ccxt/abstract/huobijp.py +114 -0
- ccxt/abstract/hyperliquid.py +6 -0
- ccxt/abstract/idex.py +26 -0
- ccxt/abstract/independentreserve.py +37 -0
- ccxt/abstract/indodax.py +26 -0
- ccxt/abstract/jibitex.py +7 -0
- ccxt/abstract/kraken.py +57 -0
- ccxt/abstract/krakenfutures.py +38 -0
- ccxt/abstract/kucoin.py +214 -0
- ccxt/abstract/kucoinfutures.py +233 -0
- ccxt/abstract/kuna.py +182 -0
- ccxt/abstract/latoken.py +56 -0
- ccxt/abstract/lbank.py +61 -0
- ccxt/abstract/luno.py +37 -0
- ccxt/abstract/lykke.py +29 -0
- ccxt/abstract/mercado.py +25 -0
- ccxt/abstract/mexc.py +178 -0
- ccxt/abstract/ndax.py +97 -0
- ccxt/abstract/nobitex.py +7 -0
- ccxt/abstract/novadax.py +29 -0
- ccxt/abstract/oceanex.py +22 -0
- ccxt/abstract/okcoin.py +74 -0
- ccxt/abstract/okexchange.py +8 -0
- ccxt/abstract/okx.py +324 -0
- ccxt/abstract/ompfinex.py +7 -0
- ccxt/abstract/onetrading.py +35 -0
- ccxt/abstract/oxfun.py +34 -0
- ccxt/abstract/p2b.py +22 -0
- ccxt/abstract/paradex.py +40 -0
- ccxt/abstract/paymium.py +28 -0
- ccxt/abstract/phemex.py +115 -0
- ccxt/abstract/poloniex.py +69 -0
- ccxt/abstract/poloniexfutures.py +48 -0
- ccxt/abstract/probit.py +23 -0
- ccxt/abstract/ramzinex.py +7 -0
- ccxt/abstract/sarmayex.py +5 -0
- ccxt/abstract/sarrafex.py +7 -0
- ccxt/abstract/tabdeal.py +7 -0
- ccxt/abstract/tetherland.py +5 -0
- ccxt/abstract/timex.py +62 -0
- ccxt/abstract/tokocrypto.py +37 -0
- ccxt/abstract/tradeogre.py +16 -0
- ccxt/abstract/twox.py +5 -0
- ccxt/abstract/ubitex.py +7 -0
- ccxt/abstract/upbit.py +38 -0
- ccxt/abstract/vertex.py +19 -0
- ccxt/abstract/wallex.py +8 -0
- ccxt/abstract/wavesexchange.py +154 -0
- ccxt/abstract/wazirx.py +30 -0
- ccxt/abstract/whitebit.py +98 -0
- ccxt/abstract/woo.py +83 -0
- ccxt/abstract/woofipro.py +119 -0
- ccxt/abstract/xt.py +152 -0
- ccxt/abstract/yobit.py +16 -0
- ccxt/abstract/zaif.py +38 -0
- ccxt/abstract/zonda.py +53 -0
- ccxt/ace.py +1012 -0
- ccxt/afratether.py +293 -0
- ccxt/alpaca.py +1083 -0
- ccxt/arzinja.py +285 -0
- ccxt/arzplus.py +412 -0
- ccxt/ascendex.py +3330 -0
- ccxt/async_support/__init__.py +337 -0
- ccxt/async_support/abantether.py +316 -0
- ccxt/async_support/ace.py +1012 -0
- ccxt/async_support/afratether.py +293 -0
- ccxt/async_support/alpaca.py +1083 -0
- ccxt/async_support/arzinja.py +285 -0
- ccxt/async_support/arzplus.py +412 -0
- ccxt/async_support/ascendex.py +3330 -0
- ccxt/async_support/base/__init__.py +1 -0
- ccxt/async_support/base/exchange.py +1966 -0
- ccxt/async_support/base/throttler.py +50 -0
- ccxt/async_support/base/ws/__init__.py +38 -0
- ccxt/async_support/base/ws/aiohttp_client.py +125 -0
- ccxt/async_support/base/ws/cache.py +212 -0
- ccxt/async_support/base/ws/client.py +193 -0
- ccxt/async_support/base/ws/fast_client.py +96 -0
- ccxt/async_support/base/ws/functions.py +59 -0
- ccxt/async_support/base/ws/future.py +58 -0
- ccxt/async_support/base/ws/order_book.py +78 -0
- ccxt/async_support/base/ws/order_book_side.py +174 -0
- ccxt/async_support/bequant.py +33 -0
- ccxt/async_support/bigone.py +2113 -0
- ccxt/async_support/binance.py +12234 -0
- ccxt/async_support/binancecoinm.py +45 -0
- ccxt/async_support/binanceus.py +211 -0
- ccxt/async_support/binanceusdm.py +58 -0
- ccxt/async_support/bingx.py +4325 -0
- ccxt/async_support/bit2c.py +866 -0
- ccxt/async_support/bitbank.py +1001 -0
- ccxt/async_support/bitbay.py +17 -0
- ccxt/async_support/bitbns.py +1154 -0
- ccxt/async_support/bitcoincom.py +17 -0
- ccxt/async_support/bitfinex.py +1617 -0
- ccxt/async_support/bitfinex2.py +3552 -0
- ccxt/async_support/bitflyer.py +995 -0
- ccxt/async_support/bitget.py +8273 -0
- ccxt/async_support/bithumb.py +1061 -0
- ccxt/async_support/bitimen.py +401 -0
- ccxt/async_support/bitir.py +490 -0
- ccxt/async_support/bitmart.py +4415 -0
- ccxt/async_support/bitmex.py +2756 -0
- ccxt/async_support/bitopro.py +1630 -0
- ccxt/async_support/bitpanda.py +16 -0
- ccxt/async_support/bitpin.py +454 -0
- ccxt/async_support/bitrue.py +3027 -0
- ccxt/async_support/bitso.py +1670 -0
- ccxt/async_support/bitstamp.py +2203 -0
- ccxt/async_support/bitteam.py +2239 -0
- ccxt/async_support/bitvavo.py +1968 -0
- ccxt/async_support/bl3p.py +485 -0
- ccxt/async_support/blockchaincom.py +1104 -0
- ccxt/async_support/blofin.py +2066 -0
- ccxt/async_support/btcalpha.py +891 -0
- ccxt/async_support/btcbox.py +544 -0
- ccxt/async_support/btcmarkets.py +1221 -0
- ccxt/async_support/btcturk.py +911 -0
- ccxt/async_support/bybit.py +8159 -0
- ccxt/async_support/cex.py +1605 -0
- ccxt/async_support/coinbase.py +4475 -0
- ccxt/async_support/coinbaseadvanced.py +17 -0
- ccxt/async_support/coinbaseexchange.py +1734 -0
- ccxt/async_support/coinbaseinternational.py +1899 -0
- ccxt/async_support/coincatch.py +5069 -0
- ccxt/async_support/coincheck.py +815 -0
- ccxt/async_support/coinex.py +5526 -0
- ccxt/async_support/coinlist.py +2243 -0
- ccxt/async_support/coinmate.py +1067 -0
- ccxt/async_support/coinmetro.py +1797 -0
- ccxt/async_support/coinone.py +1127 -0
- ccxt/async_support/coinsph.py +1850 -0
- ccxt/async_support/coinspot.py +534 -0
- ccxt/async_support/cryptocom.py +2822 -0
- ccxt/async_support/currencycom.py +1950 -0
- ccxt/async_support/delta.py +3376 -0
- ccxt/async_support/deribit.py +3437 -0
- ccxt/async_support/digifinex.py +3960 -0
- ccxt/async_support/eterex.py +286 -0
- ccxt/async_support/excoino.py +399 -0
- ccxt/async_support/exir.py +375 -0
- ccxt/async_support/exmo.py +2462 -0
- ccxt/async_support/exnovin.py +360 -0
- ccxt/async_support/farhadexchange.py +266 -0
- ccxt/async_support/fmfwio.py +34 -0
- ccxt/async_support/gate.py +6976 -0
- ccxt/async_support/gateio.py +16 -0
- ccxt/async_support/gemini.py +1825 -0
- ccxt/async_support/hashkey.py +4150 -0
- ccxt/async_support/hitbtc.py +3423 -0
- ccxt/async_support/hitbtc3.py +16 -0
- ccxt/async_support/hitobit.py +391 -0
- ccxt/async_support/hollaex.py +1813 -0
- ccxt/async_support/htx.py +8506 -0
- ccxt/async_support/huobi.py +16 -0
- ccxt/async_support/huobijp.py +1801 -0
- ccxt/async_support/hyperliquid.py +2431 -0
- ccxt/async_support/idex.py +1766 -0
- ccxt/async_support/independentreserve.py +784 -0
- ccxt/async_support/indodax.py +1247 -0
- ccxt/async_support/jibitex.py +395 -0
- ccxt/async_support/kraken.py +2894 -0
- ccxt/async_support/krakenfutures.py +2601 -0
- ccxt/async_support/kucoin.py +4602 -0
- ccxt/async_support/kucoinfutures.py +2698 -0
- ccxt/async_support/kuna.py +1841 -0
- ccxt/async_support/latoken.py +1664 -0
- ccxt/async_support/lbank.py +2683 -0
- ccxt/async_support/luno.py +1067 -0
- ccxt/async_support/lykke.py +1270 -0
- ccxt/async_support/mercado.py +842 -0
- ccxt/async_support/mexc.py +5369 -0
- ccxt/async_support/ndax.py +2354 -0
- ccxt/async_support/nobitex.py +419 -0
- ccxt/async_support/novadax.py +1484 -0
- ccxt/async_support/oceanex.py +903 -0
- ccxt/async_support/okcoin.py +2936 -0
- ccxt/async_support/okexchange.py +349 -0
- ccxt/async_support/okx.py +7827 -0
- ccxt/async_support/ompfinex.py +472 -0
- ccxt/async_support/onetrading.py +1911 -0
- ccxt/async_support/oxfun.py +2773 -0
- ccxt/async_support/p2b.py +1194 -0
- ccxt/async_support/paradex.py +2015 -0
- ccxt/async_support/paymium.py +564 -0
- ccxt/async_support/phemex.py +4473 -0
- ccxt/async_support/poloniex.py +2232 -0
- ccxt/async_support/poloniexfutures.py +1717 -0
- ccxt/async_support/probit.py +1734 -0
- ccxt/async_support/ramzinex.py +476 -0
- ccxt/async_support/sarmayex.py +357 -0
- ccxt/async_support/sarrafex.py +478 -0
- ccxt/async_support/tabdeal.py +364 -0
- ccxt/async_support/tetherland.py +349 -0
- ccxt/async_support/timex.py +1593 -0
- ccxt/async_support/tokocrypto.py +2405 -0
- ccxt/async_support/tradeogre.py +608 -0
- ccxt/async_support/twox.py +326 -0
- ccxt/async_support/ubitex.py +409 -0
- ccxt/async_support/upbit.py +1833 -0
- ccxt/async_support/vertex.py +2922 -0
- ccxt/async_support/wallex.py +445 -0
- ccxt/async_support/wavesexchange.py +2473 -0
- ccxt/async_support/wazirx.py +1224 -0
- ccxt/async_support/whitebit.py +2469 -0
- ccxt/async_support/woo.py +3114 -0
- ccxt/async_support/woofipro.py +2533 -0
- ccxt/async_support/xt.py +4454 -0
- ccxt/async_support/yobit.py +1283 -0
- ccxt/async_support/zaif.py +725 -0
- ccxt/async_support/zonda.py +1828 -0
- ccxt/base/__init__.py +27 -0
- ccxt/base/decimal_to_precision.py +174 -0
- ccxt/base/errors.py +242 -0
- ccxt/base/exchange.py +5941 -0
- ccxt/base/precise.py +287 -0
- ccxt/base/types.py +502 -0
- ccxt/bequant.py +33 -0
- ccxt/bigone.py +2112 -0
- ccxt/binance.py +12233 -0
- ccxt/binancecoinm.py +45 -0
- ccxt/binanceus.py +211 -0
- ccxt/binanceusdm.py +58 -0
- ccxt/bingx.py +4324 -0
- ccxt/bit2c.py +866 -0
- ccxt/bitbank.py +1001 -0
- ccxt/bitbay.py +17 -0
- ccxt/bitbns.py +1154 -0
- ccxt/bitcoincom.py +17 -0
- ccxt/bitfinex.py +1617 -0
- ccxt/bitfinex2.py +3552 -0
- ccxt/bitflyer.py +995 -0
- ccxt/bitget.py +8272 -0
- ccxt/bithumb.py +1061 -0
- ccxt/bitimen.py +401 -0
- ccxt/bitir.py +490 -0
- ccxt/bitmart.py +4415 -0
- ccxt/bitmex.py +2756 -0
- ccxt/bitopro.py +1630 -0
- ccxt/bitpanda.py +16 -0
- ccxt/bitpin.py +454 -0
- ccxt/bitrue.py +3026 -0
- ccxt/bitso.py +1670 -0
- ccxt/bitstamp.py +2203 -0
- ccxt/bitteam.py +2239 -0
- ccxt/bitvavo.py +1968 -0
- ccxt/bl3p.py +485 -0
- ccxt/blockchaincom.py +1104 -0
- ccxt/blofin.py +2066 -0
- ccxt/btcalpha.py +891 -0
- ccxt/btcbox.py +544 -0
- ccxt/btcmarkets.py +1221 -0
- ccxt/btcturk.py +911 -0
- ccxt/bybit.py +8158 -0
- ccxt/cex.py +1605 -0
- ccxt/coinbase.py +4474 -0
- ccxt/coinbaseadvanced.py +17 -0
- ccxt/coinbaseexchange.py +1734 -0
- ccxt/coinbaseinternational.py +1899 -0
- ccxt/coincatch.py +5069 -0
- ccxt/coincheck.py +815 -0
- ccxt/coinex.py +5525 -0
- ccxt/coinlist.py +2243 -0
- ccxt/coinmate.py +1067 -0
- ccxt/coinmetro.py +1797 -0
- ccxt/coinone.py +1127 -0
- ccxt/coinsph.py +1850 -0
- ccxt/coinspot.py +534 -0
- ccxt/cryptocom.py +2822 -0
- ccxt/currencycom.py +1950 -0
- ccxt/delta.py +3376 -0
- ccxt/deribit.py +3437 -0
- ccxt/digifinex.py +3959 -0
- ccxt/eterex.py +286 -0
- ccxt/excoino.py +399 -0
- ccxt/exir.py +375 -0
- ccxt/exmo.py +2462 -0
- ccxt/exnovin.py +360 -0
- ccxt/farhadexchange.py +266 -0
- ccxt/fmfwio.py +34 -0
- ccxt/gate.py +6975 -0
- ccxt/gateio.py +16 -0
- ccxt/gemini.py +1824 -0
- ccxt/hashkey.py +4150 -0
- ccxt/hitbtc.py +3423 -0
- ccxt/hitbtc3.py +16 -0
- ccxt/hitobit.py +391 -0
- ccxt/hollaex.py +1813 -0
- ccxt/htx.py +8505 -0
- ccxt/huobi.py +16 -0
- ccxt/huobijp.py +1801 -0
- ccxt/hyperliquid.py +2430 -0
- ccxt/idex.py +1766 -0
- ccxt/independentreserve.py +784 -0
- ccxt/indodax.py +1247 -0
- ccxt/jibitex.py +395 -0
- ccxt/kraken.py +2894 -0
- ccxt/krakenfutures.py +2601 -0
- ccxt/kucoin.py +4601 -0
- ccxt/kucoinfutures.py +2698 -0
- ccxt/kuna.py +1841 -0
- ccxt/latoken.py +1664 -0
- ccxt/lbank.py +2682 -0
- ccxt/luno.py +1067 -0
- ccxt/lykke.py +1270 -0
- ccxt/mercado.py +842 -0
- ccxt/mexc.py +5369 -0
- ccxt/ndax.py +2354 -0
- ccxt/nobitex.py +419 -0
- ccxt/novadax.py +1484 -0
- ccxt/oceanex.py +903 -0
- ccxt/okcoin.py +2936 -0
- ccxt/okexchange.py +349 -0
- ccxt/okx.py +7826 -0
- ccxt/ompfinex.py +472 -0
- ccxt/onetrading.py +1911 -0
- ccxt/oxfun.py +2772 -0
- ccxt/p2b.py +1194 -0
- ccxt/paradex.py +2015 -0
- ccxt/paymium.py +564 -0
- ccxt/phemex.py +4473 -0
- ccxt/poloniex.py +2232 -0
- ccxt/poloniexfutures.py +1717 -0
- ccxt/pro/__init__.py +149 -0
- ccxt/pro/alpaca.py +685 -0
- ccxt/pro/ascendex.py +916 -0
- ccxt/pro/bequant.py +38 -0
- ccxt/pro/binance.py +3488 -0
- ccxt/pro/binancecoinm.py +28 -0
- ccxt/pro/binanceus.py +48 -0
- ccxt/pro/binanceusdm.py +31 -0
- ccxt/pro/bingx.py +1264 -0
- ccxt/pro/bitcoincom.py +34 -0
- ccxt/pro/bitfinex.py +621 -0
- ccxt/pro/bitfinex2.py +1083 -0
- ccxt/pro/bitget.py +1692 -0
- ccxt/pro/bithumb.py +368 -0
- ccxt/pro/bitmart.py +1449 -0
- ccxt/pro/bitmex.py +1656 -0
- ccxt/pro/bitopro.py +445 -0
- ccxt/pro/bitpanda.py +15 -0
- ccxt/pro/bitrue.py +447 -0
- ccxt/pro/bitstamp.py +522 -0
- ccxt/pro/bitvavo.py +1270 -0
- ccxt/pro/blockchaincom.py +738 -0
- ccxt/pro/blofin.py +692 -0
- ccxt/pro/bybit.py +2000 -0
- ccxt/pro/cex.py +1440 -0
- ccxt/pro/coinbase.py +678 -0
- ccxt/pro/coinbaseadvanced.py +16 -0
- ccxt/pro/coinbaseexchange.py +895 -0
- ccxt/pro/coinbaseinternational.py +620 -0
- ccxt/pro/coincatch.py +1464 -0
- ccxt/pro/coincheck.py +199 -0
- ccxt/pro/coinex.py +1061 -0
- ccxt/pro/coinone.py +395 -0
- ccxt/pro/cryptocom.py +947 -0
- ccxt/pro/currencycom.py +536 -0
- ccxt/pro/deribit.py +892 -0
- ccxt/pro/exmo.py +629 -0
- ccxt/pro/gate.py +1416 -0
- ccxt/pro/gateio.py +15 -0
- ccxt/pro/gemini.py +865 -0
- ccxt/pro/hashkey.py +802 -0
- ccxt/pro/hitbtc.py +1216 -0
- ccxt/pro/hollaex.py +563 -0
- ccxt/pro/htx.py +2215 -0
- ccxt/pro/huobi.py +15 -0
- ccxt/pro/huobijp.py +570 -0
- ccxt/pro/hyperliquid.py +525 -0
- ccxt/pro/idex.py +672 -0
- ccxt/pro/independentreserve.py +270 -0
- ccxt/pro/kraken.py +1356 -0
- ccxt/pro/krakenfutures.py +1492 -0
- ccxt/pro/kucoin.py +1133 -0
- ccxt/pro/kucoinfutures.py +1081 -0
- ccxt/pro/lbank.py +843 -0
- ccxt/pro/luno.py +303 -0
- ccxt/pro/mexc.py +1122 -0
- ccxt/pro/ndax.py +506 -0
- ccxt/pro/okcoin.py +698 -0
- ccxt/pro/okx.py +1851 -0
- ccxt/pro/onetrading.py +1275 -0
- ccxt/pro/oxfun.py +950 -0
- ccxt/pro/p2b.py +419 -0
- ccxt/pro/paradex.py +352 -0
- ccxt/pro/phemex.py +1441 -0
- ccxt/pro/poloniex.py +1166 -0
- ccxt/pro/poloniexfutures.py +990 -0
- ccxt/pro/probit.py +551 -0
- ccxt/pro/upbit.py +520 -0
- ccxt/pro/vertex.py +943 -0
- ccxt/pro/wazirx.py +749 -0
- ccxt/pro/whitebit.py +864 -0
- ccxt/pro/woo.py +1078 -0
- ccxt/pro/woofipro.py +1183 -0
- ccxt/pro/xt.py +1067 -0
- ccxt/probit.py +1734 -0
- ccxt/ramzinex.py +476 -0
- ccxt/sarmayex.py +357 -0
- ccxt/sarrafex.py +478 -0
- ccxt/static_dependencies/__init__.py +1 -0
- ccxt/static_dependencies/ecdsa/__init__.py +14 -0
- ccxt/static_dependencies/ecdsa/_version.py +520 -0
- ccxt/static_dependencies/ecdsa/curves.py +56 -0
- ccxt/static_dependencies/ecdsa/der.py +221 -0
- ccxt/static_dependencies/ecdsa/ecdsa.py +310 -0
- ccxt/static_dependencies/ecdsa/ellipticcurve.py +197 -0
- ccxt/static_dependencies/ecdsa/keys.py +332 -0
- ccxt/static_dependencies/ecdsa/numbertheory.py +531 -0
- ccxt/static_dependencies/ecdsa/rfc6979.py +100 -0
- ccxt/static_dependencies/ecdsa/util.py +266 -0
- ccxt/static_dependencies/ethereum/__init__.py +7 -0
- ccxt/static_dependencies/ethereum/abi/__init__.py +16 -0
- ccxt/static_dependencies/ethereum/abi/abi.py +19 -0
- ccxt/static_dependencies/ethereum/abi/base.py +152 -0
- ccxt/static_dependencies/ethereum/abi/codec.py +217 -0
- ccxt/static_dependencies/ethereum/abi/constants.py +3 -0
- ccxt/static_dependencies/ethereum/abi/decoding.py +565 -0
- ccxt/static_dependencies/ethereum/abi/encoding.py +720 -0
- ccxt/static_dependencies/ethereum/abi/exceptions.py +139 -0
- ccxt/static_dependencies/ethereum/abi/grammar.py +443 -0
- ccxt/static_dependencies/ethereum/abi/packed.py +13 -0
- ccxt/static_dependencies/ethereum/abi/py.typed +0 -0
- ccxt/static_dependencies/ethereum/abi/registry.py +643 -0
- ccxt/static_dependencies/ethereum/abi/tools/__init__.py +3 -0
- ccxt/static_dependencies/ethereum/abi/tools/_strategies.py +230 -0
- ccxt/static_dependencies/ethereum/abi/utils/__init__.py +0 -0
- ccxt/static_dependencies/ethereum/abi/utils/numeric.py +83 -0
- ccxt/static_dependencies/ethereum/abi/utils/padding.py +27 -0
- ccxt/static_dependencies/ethereum/abi/utils/string.py +19 -0
- ccxt/static_dependencies/ethereum/account/__init__.py +3 -0
- ccxt/static_dependencies/ethereum/account/encode_typed_data/__init__.py +4 -0
- ccxt/static_dependencies/ethereum/account/encode_typed_data/encoding_and_hashing.py +239 -0
- ccxt/static_dependencies/ethereum/account/encode_typed_data/helpers.py +40 -0
- ccxt/static_dependencies/ethereum/account/messages.py +263 -0
- ccxt/static_dependencies/ethereum/account/py.typed +0 -0
- ccxt/static_dependencies/ethereum/hexbytes/__init__.py +5 -0
- ccxt/static_dependencies/ethereum/hexbytes/_utils.py +54 -0
- ccxt/static_dependencies/ethereum/hexbytes/main.py +65 -0
- ccxt/static_dependencies/ethereum/hexbytes/py.typed +0 -0
- ccxt/static_dependencies/ethereum/typing/__init__.py +63 -0
- ccxt/static_dependencies/ethereum/typing/abi.py +6 -0
- ccxt/static_dependencies/ethereum/typing/bls.py +7 -0
- ccxt/static_dependencies/ethereum/typing/discovery.py +5 -0
- ccxt/static_dependencies/ethereum/typing/encoding.py +7 -0
- ccxt/static_dependencies/ethereum/typing/enums.py +17 -0
- ccxt/static_dependencies/ethereum/typing/ethpm.py +9 -0
- ccxt/static_dependencies/ethereum/typing/evm.py +20 -0
- ccxt/static_dependencies/ethereum/typing/networks.py +1122 -0
- ccxt/static_dependencies/ethereum/typing/py.typed +0 -0
- ccxt/static_dependencies/ethereum/utils/__init__.py +115 -0
- ccxt/static_dependencies/ethereum/utils/abi.py +72 -0
- ccxt/static_dependencies/ethereum/utils/address.py +171 -0
- ccxt/static_dependencies/ethereum/utils/applicators.py +151 -0
- ccxt/static_dependencies/ethereum/utils/conversions.py +190 -0
- ccxt/static_dependencies/ethereum/utils/currency.py +107 -0
- ccxt/static_dependencies/ethereum/utils/curried/__init__.py +269 -0
- ccxt/static_dependencies/ethereum/utils/debug.py +20 -0
- ccxt/static_dependencies/ethereum/utils/decorators.py +132 -0
- ccxt/static_dependencies/ethereum/utils/encoding.py +6 -0
- ccxt/static_dependencies/ethereum/utils/exceptions.py +4 -0
- ccxt/static_dependencies/ethereum/utils/functional.py +75 -0
- ccxt/static_dependencies/ethereum/utils/hexadecimal.py +74 -0
- ccxt/static_dependencies/ethereum/utils/humanize.py +188 -0
- ccxt/static_dependencies/ethereum/utils/logging.py +159 -0
- ccxt/static_dependencies/ethereum/utils/module_loading.py +31 -0
- ccxt/static_dependencies/ethereum/utils/numeric.py +43 -0
- ccxt/static_dependencies/ethereum/utils/py.typed +0 -0
- ccxt/static_dependencies/ethereum/utils/toolz.py +76 -0
- ccxt/static_dependencies/ethereum/utils/types.py +54 -0
- ccxt/static_dependencies/ethereum/utils/typing/__init__.py +18 -0
- ccxt/static_dependencies/ethereum/utils/typing/misc.py +14 -0
- ccxt/static_dependencies/ethereum/utils/units.py +31 -0
- ccxt/static_dependencies/keccak/__init__.py +3 -0
- ccxt/static_dependencies/keccak/keccak.py +197 -0
- ccxt/static_dependencies/lark/__init__.py +38 -0
- ccxt/static_dependencies/lark/__pyinstaller/__init__.py +6 -0
- ccxt/static_dependencies/lark/__pyinstaller/hook-lark.py +14 -0
- ccxt/static_dependencies/lark/ast_utils.py +59 -0
- ccxt/static_dependencies/lark/common.py +86 -0
- ccxt/static_dependencies/lark/exceptions.py +292 -0
- ccxt/static_dependencies/lark/grammar.py +130 -0
- ccxt/static_dependencies/lark/grammars/__init__.py +0 -0
- ccxt/static_dependencies/lark/indenter.py +143 -0
- ccxt/static_dependencies/lark/lark.py +658 -0
- ccxt/static_dependencies/lark/lexer.py +678 -0
- ccxt/static_dependencies/lark/load_grammar.py +1428 -0
- ccxt/static_dependencies/lark/parse_tree_builder.py +391 -0
- ccxt/static_dependencies/lark/parser_frontends.py +257 -0
- ccxt/static_dependencies/lark/parsers/__init__.py +0 -0
- ccxt/static_dependencies/lark/parsers/cyk.py +340 -0
- ccxt/static_dependencies/lark/parsers/earley.py +314 -0
- ccxt/static_dependencies/lark/parsers/earley_common.py +42 -0
- ccxt/static_dependencies/lark/parsers/earley_forest.py +801 -0
- ccxt/static_dependencies/lark/parsers/grammar_analysis.py +203 -0
- ccxt/static_dependencies/lark/parsers/lalr_analysis.py +332 -0
- ccxt/static_dependencies/lark/parsers/lalr_interactive_parser.py +158 -0
- ccxt/static_dependencies/lark/parsers/lalr_parser.py +122 -0
- ccxt/static_dependencies/lark/parsers/lalr_parser_state.py +110 -0
- ccxt/static_dependencies/lark/parsers/xearley.py +165 -0
- ccxt/static_dependencies/lark/reconstruct.py +107 -0
- ccxt/static_dependencies/lark/tools/__init__.py +70 -0
- ccxt/static_dependencies/lark/tools/nearley.py +202 -0
- ccxt/static_dependencies/lark/tools/serialize.py +32 -0
- ccxt/static_dependencies/lark/tools/standalone.py +196 -0
- ccxt/static_dependencies/lark/tree.py +267 -0
- ccxt/static_dependencies/lark/tree_matcher.py +186 -0
- ccxt/static_dependencies/lark/tree_templates.py +180 -0
- ccxt/static_dependencies/lark/utils.py +343 -0
- ccxt/static_dependencies/lark/visitors.py +596 -0
- ccxt/static_dependencies/marshmallow/__init__.py +81 -0
- ccxt/static_dependencies/marshmallow/base.py +65 -0
- ccxt/static_dependencies/marshmallow/class_registry.py +94 -0
- ccxt/static_dependencies/marshmallow/decorators.py +231 -0
- ccxt/static_dependencies/marshmallow/error_store.py +60 -0
- ccxt/static_dependencies/marshmallow/exceptions.py +71 -0
- ccxt/static_dependencies/marshmallow/fields.py +2114 -0
- ccxt/static_dependencies/marshmallow/orderedset.py +89 -0
- ccxt/static_dependencies/marshmallow/schema.py +1228 -0
- ccxt/static_dependencies/marshmallow/types.py +12 -0
- ccxt/static_dependencies/marshmallow/utils.py +378 -0
- ccxt/static_dependencies/marshmallow/validate.py +678 -0
- ccxt/static_dependencies/marshmallow/warnings.py +2 -0
- ccxt/static_dependencies/marshmallow_dataclass/__init__.py +1047 -0
- ccxt/static_dependencies/marshmallow_dataclass/collection_field.py +51 -0
- ccxt/static_dependencies/marshmallow_dataclass/lazy_class_attribute.py +45 -0
- ccxt/static_dependencies/marshmallow_dataclass/mypy.py +71 -0
- ccxt/static_dependencies/marshmallow_dataclass/typing.py +14 -0
- ccxt/static_dependencies/marshmallow_dataclass/union_field.py +82 -0
- ccxt/static_dependencies/marshmallow_oneofschema/__init__.py +1 -0
- ccxt/static_dependencies/marshmallow_oneofschema/one_of_schema.py +193 -0
- ccxt/static_dependencies/msgpack/__init__.py +55 -0
- ccxt/static_dependencies/msgpack/exceptions.py +48 -0
- ccxt/static_dependencies/msgpack/ext.py +168 -0
- ccxt/static_dependencies/msgpack/fallback.py +951 -0
- ccxt/static_dependencies/parsimonious/__init__.py +10 -0
- ccxt/static_dependencies/parsimonious/exceptions.py +105 -0
- ccxt/static_dependencies/parsimonious/expressions.py +479 -0
- ccxt/static_dependencies/parsimonious/grammar.py +487 -0
- ccxt/static_dependencies/parsimonious/nodes.py +325 -0
- ccxt/static_dependencies/parsimonious/utils.py +40 -0
- ccxt/static_dependencies/starknet/__init__.py +0 -0
- ccxt/static_dependencies/starknet/cairo/__init__.py +0 -0
- ccxt/static_dependencies/starknet/cairo/data_types.py +123 -0
- ccxt/static_dependencies/starknet/cairo/deprecated_parse/__init__.py +0 -0
- ccxt/static_dependencies/starknet/cairo/deprecated_parse/cairo_types.py +77 -0
- ccxt/static_dependencies/starknet/cairo/deprecated_parse/parser.py +46 -0
- ccxt/static_dependencies/starknet/cairo/deprecated_parse/parser_transformer.py +138 -0
- ccxt/static_dependencies/starknet/cairo/felt.py +64 -0
- ccxt/static_dependencies/starknet/cairo/type_parser.py +121 -0
- ccxt/static_dependencies/starknet/cairo/v1/__init__.py +0 -0
- ccxt/static_dependencies/starknet/cairo/v1/type_parser.py +59 -0
- ccxt/static_dependencies/starknet/cairo/v2/__init__.py +0 -0
- ccxt/static_dependencies/starknet/cairo/v2/type_parser.py +77 -0
- ccxt/static_dependencies/starknet/ccxt_utils.py +7 -0
- ccxt/static_dependencies/starknet/common.py +15 -0
- ccxt/static_dependencies/starknet/constants.py +39 -0
- ccxt/static_dependencies/starknet/hash/__init__.py +0 -0
- ccxt/static_dependencies/starknet/hash/address.py +79 -0
- ccxt/static_dependencies/starknet/hash/compiled_class_hash_objects.py +111 -0
- ccxt/static_dependencies/starknet/hash/selector.py +16 -0
- ccxt/static_dependencies/starknet/hash/storage.py +12 -0
- ccxt/static_dependencies/starknet/hash/utils.py +78 -0
- ccxt/static_dependencies/starknet/models/__init__.py +0 -0
- ccxt/static_dependencies/starknet/models/typed_data.py +45 -0
- ccxt/static_dependencies/starknet/serialization/__init__.py +24 -0
- ccxt/static_dependencies/starknet/serialization/_calldata_reader.py +40 -0
- ccxt/static_dependencies/starknet/serialization/_context.py +142 -0
- ccxt/static_dependencies/starknet/serialization/data_serializers/__init__.py +10 -0
- ccxt/static_dependencies/starknet/serialization/data_serializers/_common.py +82 -0
- ccxt/static_dependencies/starknet/serialization/data_serializers/array_serializer.py +43 -0
- ccxt/static_dependencies/starknet/serialization/data_serializers/bool_serializer.py +37 -0
- ccxt/static_dependencies/starknet/serialization/data_serializers/byte_array_serializer.py +66 -0
- ccxt/static_dependencies/starknet/serialization/data_serializers/cairo_data_serializer.py +71 -0
- ccxt/static_dependencies/starknet/serialization/data_serializers/enum_serializer.py +71 -0
- ccxt/static_dependencies/starknet/serialization/data_serializers/felt_serializer.py +50 -0
- ccxt/static_dependencies/starknet/serialization/data_serializers/named_tuple_serializer.py +58 -0
- ccxt/static_dependencies/starknet/serialization/data_serializers/option_serializer.py +43 -0
- ccxt/static_dependencies/starknet/serialization/data_serializers/output_serializer.py +40 -0
- ccxt/static_dependencies/starknet/serialization/data_serializers/payload_serializer.py +72 -0
- ccxt/static_dependencies/starknet/serialization/data_serializers/struct_serializer.py +36 -0
- ccxt/static_dependencies/starknet/serialization/data_serializers/tuple_serializer.py +36 -0
- ccxt/static_dependencies/starknet/serialization/data_serializers/uint256_serializer.py +76 -0
- ccxt/static_dependencies/starknet/serialization/data_serializers/uint_serializer.py +100 -0
- ccxt/static_dependencies/starknet/serialization/data_serializers/unit_serializer.py +32 -0
- ccxt/static_dependencies/starknet/serialization/errors.py +10 -0
- ccxt/static_dependencies/starknet/serialization/factory.py +229 -0
- ccxt/static_dependencies/starknet/serialization/function_serialization_adapter.py +110 -0
- ccxt/static_dependencies/starknet/serialization/tuple_dataclass.py +59 -0
- ccxt/static_dependencies/starknet/utils/__init__.py +0 -0
- ccxt/static_dependencies/starknet/utils/constructor_args_translator.py +86 -0
- ccxt/static_dependencies/starknet/utils/iterable.py +13 -0
- ccxt/static_dependencies/starknet/utils/schema.py +13 -0
- ccxt/static_dependencies/starknet/utils/typed_data.py +182 -0
- ccxt/static_dependencies/starkware/__init__.py +0 -0
- ccxt/static_dependencies/starkware/crypto/__init__.py +0 -0
- ccxt/static_dependencies/starkware/crypto/fast_pedersen_hash.py +50 -0
- ccxt/static_dependencies/starkware/crypto/math_utils.py +78 -0
- ccxt/static_dependencies/starkware/crypto/signature.py +2344 -0
- ccxt/static_dependencies/starkware/crypto/utils.py +63 -0
- ccxt/static_dependencies/sympy/__init__.py +0 -0
- ccxt/static_dependencies/sympy/core/__init__.py +0 -0
- ccxt/static_dependencies/sympy/core/intfunc.py +35 -0
- ccxt/static_dependencies/sympy/external/__init__.py +0 -0
- ccxt/static_dependencies/sympy/external/gmpy.py +345 -0
- ccxt/static_dependencies/sympy/external/importtools.py +187 -0
- ccxt/static_dependencies/sympy/external/ntheory.py +637 -0
- ccxt/static_dependencies/sympy/external/pythonmpq.py +341 -0
- ccxt/static_dependencies/toolz/__init__.py +26 -0
- ccxt/static_dependencies/toolz/_signatures.py +784 -0
- ccxt/static_dependencies/toolz/_version.py +520 -0
- ccxt/static_dependencies/toolz/compatibility.py +30 -0
- ccxt/static_dependencies/toolz/curried/__init__.py +101 -0
- ccxt/static_dependencies/toolz/curried/exceptions.py +22 -0
- ccxt/static_dependencies/toolz/curried/operator.py +22 -0
- ccxt/static_dependencies/toolz/dicttoolz.py +339 -0
- ccxt/static_dependencies/toolz/functoolz.py +1049 -0
- ccxt/static_dependencies/toolz/itertoolz.py +1057 -0
- ccxt/static_dependencies/toolz/recipes.py +46 -0
- ccxt/static_dependencies/toolz/utils.py +9 -0
- ccxt/static_dependencies/typing_inspect/__init__.py +0 -0
- ccxt/static_dependencies/typing_inspect/typing_inspect.py +851 -0
- ccxt/tabdeal.py +364 -0
- ccxt/test/__init__.py +3 -0
- ccxt/test/base/__init__.py +29 -0
- ccxt/test/base/test_account.py +26 -0
- ccxt/test/base/test_balance.py +56 -0
- ccxt/test/base/test_borrow_interest.py +35 -0
- ccxt/test/base/test_borrow_rate.py +32 -0
- ccxt/test/base/test_calculate_fee.py +51 -0
- ccxt/test/base/test_crypto.py +127 -0
- ccxt/test/base/test_currency.py +76 -0
- ccxt/test/base/test_datetime.py +109 -0
- ccxt/test/base/test_decimal_to_precision.py +392 -0
- ccxt/test/base/test_deep_extend.py +68 -0
- ccxt/test/base/test_deposit_withdrawal.py +50 -0
- ccxt/test/base/test_exchange_datetime_functions.py +76 -0
- ccxt/test/base/test_funding_rate_history.py +29 -0
- ccxt/test/base/test_last_price.py +31 -0
- ccxt/test/base/test_ledger_entry.py +45 -0
- ccxt/test/base/test_ledger_item.py +48 -0
- ccxt/test/base/test_leverage_tier.py +33 -0
- ccxt/test/base/test_liquidation.py +50 -0
- ccxt/test/base/test_margin_mode.py +24 -0
- ccxt/test/base/test_margin_modification.py +35 -0
- ccxt/test/base/test_market.py +193 -0
- ccxt/test/base/test_number.py +411 -0
- ccxt/test/base/test_ohlcv.py +33 -0
- ccxt/test/base/test_open_interest.py +32 -0
- ccxt/test/base/test_order.py +64 -0
- ccxt/test/base/test_order_book.py +69 -0
- ccxt/test/base/test_position.py +60 -0
- ccxt/test/base/test_shared_methods.py +353 -0
- ccxt/test/base/test_status.py +24 -0
- ccxt/test/base/test_throttle.py +126 -0
- ccxt/test/base/test_ticker.py +92 -0
- ccxt/test/base/test_trade.py +47 -0
- ccxt/test/base/test_trading_fee.py +26 -0
- ccxt/test/base/test_transaction.py +39 -0
- ccxt/test/test_async.py +1649 -0
- ccxt/test/test_sync.py +1648 -0
- ccxt/test/tests_async.py +1558 -0
- ccxt/test/tests_helpers.py +287 -0
- ccxt/test/tests_init.py +39 -0
- ccxt/test/tests_sync.py +1555 -0
- ccxt/tetherland.py +349 -0
- ccxt/timex.py +1593 -0
- ccxt/tokocrypto.py +2405 -0
- ccxt/tradeogre.py +608 -0
- ccxt/twox.py +326 -0
- ccxt/ubitex.py +409 -0
- ccxt/upbit.py +1833 -0
- ccxt/vertex.py +2922 -0
- ccxt/wallex.py +445 -0
- ccxt/wavesexchange.py +2472 -0
- ccxt/wazirx.py +1224 -0
- ccxt/whitebit.py +2469 -0
- ccxt/woo.py +3114 -0
- ccxt/woofipro.py +2533 -0
- ccxt/xt.py +4453 -0
- ccxt/yobit.py +1283 -0
- ccxt/zaif.py +725 -0
- ccxt/zonda.py +1828 -0
- ccxt_ir-4.3.46.0.1.dist-info/LICENSE.txt +21 -0
- ccxt_ir-4.3.46.0.1.dist-info/METADATA +655 -0
- ccxt_ir-4.3.46.0.1.dist-info/RECORD +772 -0
- ccxt_ir-4.3.46.0.1.dist-info/WHEEL +6 -0
- ccxt_ir-4.3.46.0.1.dist-info/top_level.txt +1 -0
ccxt/delta.py
ADDED
|
@@ -0,0 +1,3376 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
|
|
3
|
+
# PLEASE DO NOT EDIT THIS FILE, IT IS GENERATED AND WILL BE OVERWRITTEN:
|
|
4
|
+
# https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md#how-to-contribute-code
|
|
5
|
+
|
|
6
|
+
from ccxt.base.exchange import Exchange
|
|
7
|
+
from ccxt.abstract.delta import ImplicitAPI
|
|
8
|
+
import hashlib
|
|
9
|
+
from ccxt.base.types import Balances, Currencies, Currency, Greeks, Int, Leverage, MarginMode, MarginModification, Market, MarketInterface, Num, Option, Order, OrderBook, OrderSide, OrderType, Position, Str, Strings, Ticker, Tickers, Trade
|
|
10
|
+
from typing import List
|
|
11
|
+
from ccxt.base.errors import ExchangeError
|
|
12
|
+
from ccxt.base.errors import AuthenticationError
|
|
13
|
+
from ccxt.base.errors import ArgumentsRequired
|
|
14
|
+
from ccxt.base.errors import BadRequest
|
|
15
|
+
from ccxt.base.errors import BadSymbol
|
|
16
|
+
from ccxt.base.errors import InsufficientFunds
|
|
17
|
+
from ccxt.base.errors import InvalidOrder
|
|
18
|
+
from ccxt.base.errors import OrderNotFound
|
|
19
|
+
from ccxt.base.errors import ExchangeNotAvailable
|
|
20
|
+
from ccxt.base.decimal_to_precision import TICK_SIZE
|
|
21
|
+
from ccxt.base.precise import Precise
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class delta(Exchange, ImplicitAPI):
|
|
25
|
+
|
|
26
|
+
def describe(self):
|
|
27
|
+
return self.deep_extend(super(delta, self).describe(), {
|
|
28
|
+
'id': 'delta',
|
|
29
|
+
'name': 'Delta Exchange',
|
|
30
|
+
'countries': ['VC'], # Saint Vincent and the Grenadines
|
|
31
|
+
'rateLimit': 300,
|
|
32
|
+
'version': 'v2',
|
|
33
|
+
# new metainfo interface
|
|
34
|
+
'has': {
|
|
35
|
+
'CORS': None,
|
|
36
|
+
'spot': True,
|
|
37
|
+
'margin': False,
|
|
38
|
+
'swap': True,
|
|
39
|
+
'future': False,
|
|
40
|
+
'option': True,
|
|
41
|
+
'addMargin': True,
|
|
42
|
+
'cancelAllOrders': True,
|
|
43
|
+
'cancelOrder': True,
|
|
44
|
+
'closeAllPositions': True,
|
|
45
|
+
'closePosition': False,
|
|
46
|
+
'createOrder': True,
|
|
47
|
+
'createReduceOnlyOrder': True,
|
|
48
|
+
'editOrder': True,
|
|
49
|
+
'fetchBalance': True,
|
|
50
|
+
'fetchClosedOrders': True,
|
|
51
|
+
'fetchCurrencies': True,
|
|
52
|
+
'fetchDeposit': None,
|
|
53
|
+
'fetchDepositAddress': True,
|
|
54
|
+
'fetchDeposits': None,
|
|
55
|
+
'fetchFundingHistory': False,
|
|
56
|
+
'fetchFundingRate': True,
|
|
57
|
+
'fetchFundingRateHistory': False,
|
|
58
|
+
'fetchFundingRates': True,
|
|
59
|
+
'fetchGreeks': True,
|
|
60
|
+
'fetchIndexOHLCV': True,
|
|
61
|
+
'fetchLedger': True,
|
|
62
|
+
'fetchLeverage': True,
|
|
63
|
+
'fetchLeverageTiers': False, # An infinite number of tiers, see examples/js/delta-maintenance-margin-rate-max-leverage.js
|
|
64
|
+
'fetchMarginMode': True,
|
|
65
|
+
'fetchMarginModes': False,
|
|
66
|
+
'fetchMarketLeverageTiers': False,
|
|
67
|
+
'fetchMarkets': True,
|
|
68
|
+
'fetchMarkOHLCV': True,
|
|
69
|
+
'fetchMySettlementHistory': False,
|
|
70
|
+
'fetchMyTrades': True,
|
|
71
|
+
'fetchOHLCV': True,
|
|
72
|
+
'fetchOpenInterest': True,
|
|
73
|
+
'fetchOpenOrders': True,
|
|
74
|
+
'fetchOption': True,
|
|
75
|
+
'fetchOptionChain': False,
|
|
76
|
+
'fetchOrderBook': True,
|
|
77
|
+
'fetchPosition': True,
|
|
78
|
+
'fetchPositionMode': False,
|
|
79
|
+
'fetchPositions': True,
|
|
80
|
+
'fetchPremiumIndexOHLCV': False,
|
|
81
|
+
'fetchSettlementHistory': True,
|
|
82
|
+
'fetchStatus': True,
|
|
83
|
+
'fetchTicker': True,
|
|
84
|
+
'fetchTickers': True,
|
|
85
|
+
'fetchTime': True,
|
|
86
|
+
'fetchTrades': True,
|
|
87
|
+
'fetchTransfer': None,
|
|
88
|
+
'fetchTransfers': None,
|
|
89
|
+
'fetchUnderlyingAssets': False,
|
|
90
|
+
'fetchVolatilityHistory': False,
|
|
91
|
+
'fetchWithdrawal': None,
|
|
92
|
+
'fetchWithdrawals': None,
|
|
93
|
+
'reduceMargin': True,
|
|
94
|
+
'setLeverage': True,
|
|
95
|
+
'setMargin': False,
|
|
96
|
+
'setMarginMode': False,
|
|
97
|
+
'setPositionMode': False,
|
|
98
|
+
'transfer': False,
|
|
99
|
+
'withdraw': False,
|
|
100
|
+
},
|
|
101
|
+
'timeframes': {
|
|
102
|
+
'1m': '1m',
|
|
103
|
+
'3m': '3m',
|
|
104
|
+
'5m': '5m',
|
|
105
|
+
'15m': '15m',
|
|
106
|
+
'30m': '30m',
|
|
107
|
+
'1h': '1h',
|
|
108
|
+
'2h': '2h',
|
|
109
|
+
'4h': '4h',
|
|
110
|
+
'6h': '6h',
|
|
111
|
+
'1d': '1d',
|
|
112
|
+
'7d': '7d',
|
|
113
|
+
'1w': '1w',
|
|
114
|
+
'2w': '2w',
|
|
115
|
+
'1M': '30d',
|
|
116
|
+
},
|
|
117
|
+
'urls': {
|
|
118
|
+
'logo': 'https://user-images.githubusercontent.com/1294454/99450025-3be60a00-2931-11eb-9302-f4fd8d8589aa.jpg',
|
|
119
|
+
'test': {
|
|
120
|
+
'public': 'https://testnet-api.delta.exchange',
|
|
121
|
+
'private': 'https://testnet-api.delta.exchange',
|
|
122
|
+
},
|
|
123
|
+
'api': {
|
|
124
|
+
'public': 'https://api.delta.exchange',
|
|
125
|
+
'private': 'https://api.delta.exchange',
|
|
126
|
+
},
|
|
127
|
+
'www': 'https://www.delta.exchange',
|
|
128
|
+
'doc': [
|
|
129
|
+
'https://docs.delta.exchange',
|
|
130
|
+
],
|
|
131
|
+
'fees': 'https://www.delta.exchange/fees',
|
|
132
|
+
'referral': 'https://www.delta.exchange/app/signup/?code=IULYNB',
|
|
133
|
+
},
|
|
134
|
+
'api': {
|
|
135
|
+
'public': {
|
|
136
|
+
'get': [
|
|
137
|
+
'assets',
|
|
138
|
+
'indices',
|
|
139
|
+
'products',
|
|
140
|
+
'products/{symbol}',
|
|
141
|
+
'tickers',
|
|
142
|
+
'tickers/{symbol}',
|
|
143
|
+
'l2orderbook/{symbol}',
|
|
144
|
+
'trades/{symbol}',
|
|
145
|
+
'stats',
|
|
146
|
+
'history/candles',
|
|
147
|
+
'history/sparklines',
|
|
148
|
+
'settings',
|
|
149
|
+
],
|
|
150
|
+
},
|
|
151
|
+
'private': {
|
|
152
|
+
'get': [
|
|
153
|
+
'orders',
|
|
154
|
+
'products/{product_id}/orders/leverage',
|
|
155
|
+
'positions/margined',
|
|
156
|
+
'positions',
|
|
157
|
+
'orders/history',
|
|
158
|
+
'fills',
|
|
159
|
+
'fills/history/download/csv',
|
|
160
|
+
'wallet/balances',
|
|
161
|
+
'wallet/transactions',
|
|
162
|
+
'wallet/transactions/download',
|
|
163
|
+
'wallets/sub_accounts_transfer_history',
|
|
164
|
+
'users/trading_preferences',
|
|
165
|
+
'sub_accounts',
|
|
166
|
+
'profile',
|
|
167
|
+
'deposits/address',
|
|
168
|
+
'orders/leverage',
|
|
169
|
+
],
|
|
170
|
+
'post': [
|
|
171
|
+
'orders',
|
|
172
|
+
'orders/bracket',
|
|
173
|
+
'orders/batch',
|
|
174
|
+
'products/{product_id}/orders/leverage',
|
|
175
|
+
'positions/change_margin',
|
|
176
|
+
'positions/close_all',
|
|
177
|
+
'wallets/sub_account_balance_transfer',
|
|
178
|
+
'orders/cancel_after',
|
|
179
|
+
'orders/leverage',
|
|
180
|
+
],
|
|
181
|
+
'put': [
|
|
182
|
+
'orders',
|
|
183
|
+
'orders/bracket',
|
|
184
|
+
'orders/batch',
|
|
185
|
+
'positions/auto_topup',
|
|
186
|
+
'users/update_mmp',
|
|
187
|
+
'users/reset_mmp',
|
|
188
|
+
],
|
|
189
|
+
'delete': [
|
|
190
|
+
'orders',
|
|
191
|
+
'orders/all',
|
|
192
|
+
'orders/batch',
|
|
193
|
+
],
|
|
194
|
+
},
|
|
195
|
+
},
|
|
196
|
+
'fees': {
|
|
197
|
+
'trading': {
|
|
198
|
+
'tierBased': True,
|
|
199
|
+
'percentage': True,
|
|
200
|
+
'taker': self.parse_number('0.0015'),
|
|
201
|
+
'maker': self.parse_number('0.0010'),
|
|
202
|
+
'tiers': {
|
|
203
|
+
'taker': [
|
|
204
|
+
[self.parse_number('0'), self.parse_number('0.0015')],
|
|
205
|
+
[self.parse_number('100'), self.parse_number('0.0013')],
|
|
206
|
+
[self.parse_number('250'), self.parse_number('0.0013')],
|
|
207
|
+
[self.parse_number('1000'), self.parse_number('0.001')],
|
|
208
|
+
[self.parse_number('5000'), self.parse_number('0.0009')],
|
|
209
|
+
[self.parse_number('10000'), self.parse_number('0.00075')],
|
|
210
|
+
[self.parse_number('20000'), self.parse_number('0.00065')],
|
|
211
|
+
],
|
|
212
|
+
'maker': [
|
|
213
|
+
[self.parse_number('0'), self.parse_number('0.001')],
|
|
214
|
+
[self.parse_number('100'), self.parse_number('0.001')],
|
|
215
|
+
[self.parse_number('250'), self.parse_number('0.0009')],
|
|
216
|
+
[self.parse_number('1000'), self.parse_number('0.00075')],
|
|
217
|
+
[self.parse_number('5000'), self.parse_number('0.0006')],
|
|
218
|
+
[self.parse_number('10000'), self.parse_number('0.0005')],
|
|
219
|
+
[self.parse_number('20000'), self.parse_number('0.0005')],
|
|
220
|
+
],
|
|
221
|
+
},
|
|
222
|
+
},
|
|
223
|
+
},
|
|
224
|
+
'options': {
|
|
225
|
+
'networks': {
|
|
226
|
+
'TRC20': 'TRC20(TRON)',
|
|
227
|
+
'BEP20': 'BEP20(BSC)',
|
|
228
|
+
},
|
|
229
|
+
},
|
|
230
|
+
'precisionMode': TICK_SIZE,
|
|
231
|
+
'requiredCredentials': {
|
|
232
|
+
'apiKey': True,
|
|
233
|
+
'secret': True,
|
|
234
|
+
},
|
|
235
|
+
'exceptions': {
|
|
236
|
+
'exact': {
|
|
237
|
+
# Margin required to place order with selected leverage and quantity is insufficient.
|
|
238
|
+
'insufficient_margin': InsufficientFunds, # {"error":{"code":"insufficient_margin","context":{"available_balance":"0.000000000000000000","required_additional_balance":"1.618626000000000000000000000"}},"success":false}
|
|
239
|
+
'order_size_exceed_available': InvalidOrder, # The order book doesn't have sufficient liquidity, hence the order couldnt be filled, for example, ioc orders
|
|
240
|
+
'risk_limits_breached': BadRequest, # orders couldn't be placed will breach allowed risk limits.
|
|
241
|
+
'invalid_contract': BadSymbol, # The contract/product is either doesn't exist or has already expired.
|
|
242
|
+
'immediate_liquidation': InvalidOrder, # Order will cause immediate liquidation.
|
|
243
|
+
'out_of_bankruptcy': InvalidOrder, # Order prices are out of position bankruptcy limits.
|
|
244
|
+
'self_matching_disrupted_post_only': InvalidOrder, # Self matching is not allowed during auction.
|
|
245
|
+
'immediate_execution_post_only': InvalidOrder, # orders couldn't be placed includes post only orders which will be immediately executed
|
|
246
|
+
'bad_schema': BadRequest, # {"error":{"code":"bad_schema","context":{"schema_errors":[{"code":"validation_error","message":"id is required","param":""}]}},"success":false}
|
|
247
|
+
'invalid_api_key': AuthenticationError, # {"success":false,"error":{"code":"invalid_api_key"}}
|
|
248
|
+
'invalid_signature': AuthenticationError, # {"success":false,"error":{"code":"invalid_signature"}}
|
|
249
|
+
'open_order_not_found': OrderNotFound, # {"error":{"code":"open_order_not_found"},"success":false}
|
|
250
|
+
'unavailable': ExchangeNotAvailable, # {"error":{"code":"unavailable"},"success":false}
|
|
251
|
+
},
|
|
252
|
+
'broad': {
|
|
253
|
+
},
|
|
254
|
+
},
|
|
255
|
+
})
|
|
256
|
+
|
|
257
|
+
def create_expired_option_market(self, symbol: str):
|
|
258
|
+
# support expired option contracts
|
|
259
|
+
quote = 'USDT'
|
|
260
|
+
optionParts = symbol.split('-')
|
|
261
|
+
symbolBase = symbol.split('/')
|
|
262
|
+
base = None
|
|
263
|
+
expiry = None
|
|
264
|
+
optionType = None
|
|
265
|
+
if symbol.find('/') > -1:
|
|
266
|
+
base = self.safe_string(symbolBase, 0)
|
|
267
|
+
expiry = self.safe_string(optionParts, 1)
|
|
268
|
+
optionType = self.safe_string(optionParts, 3)
|
|
269
|
+
else:
|
|
270
|
+
base = self.safe_string(optionParts, 1)
|
|
271
|
+
expiry = self.safe_string(optionParts, 3)
|
|
272
|
+
optionType = self.safe_string(optionParts, 0)
|
|
273
|
+
settle = quote
|
|
274
|
+
strike = self.safe_string(optionParts, 2)
|
|
275
|
+
datetime = self.convert_expire_date(expiry)
|
|
276
|
+
timestamp = self.parse8601(datetime)
|
|
277
|
+
return {
|
|
278
|
+
'id': optionType + '-' + base + '-' + strike + '-' + expiry,
|
|
279
|
+
'symbol': base + '/' + quote + ':' + settle + '-' + expiry + '-' + strike + '-' + optionType,
|
|
280
|
+
'base': base,
|
|
281
|
+
'quote': quote,
|
|
282
|
+
'settle': settle,
|
|
283
|
+
'baseId': base,
|
|
284
|
+
'quoteId': quote,
|
|
285
|
+
'settleId': settle,
|
|
286
|
+
'active': False,
|
|
287
|
+
'type': 'option',
|
|
288
|
+
'linear': None,
|
|
289
|
+
'inverse': None,
|
|
290
|
+
'spot': False,
|
|
291
|
+
'swap': False,
|
|
292
|
+
'future': False,
|
|
293
|
+
'option': True,
|
|
294
|
+
'margin': False,
|
|
295
|
+
'contract': True,
|
|
296
|
+
'contractSize': self.parse_number('1'),
|
|
297
|
+
'expiry': timestamp,
|
|
298
|
+
'expiryDatetime': datetime,
|
|
299
|
+
'optionType': 'call' if (optionType == 'C') else 'put',
|
|
300
|
+
'strike': self.parse_number(strike),
|
|
301
|
+
'precision': {
|
|
302
|
+
'amount': None,
|
|
303
|
+
'price': None,
|
|
304
|
+
},
|
|
305
|
+
'limits': {
|
|
306
|
+
'amount': {
|
|
307
|
+
'min': None,
|
|
308
|
+
'max': None,
|
|
309
|
+
},
|
|
310
|
+
'price': {
|
|
311
|
+
'min': None,
|
|
312
|
+
'max': None,
|
|
313
|
+
},
|
|
314
|
+
'cost': {
|
|
315
|
+
'min': None,
|
|
316
|
+
'max': None,
|
|
317
|
+
},
|
|
318
|
+
},
|
|
319
|
+
'info': None,
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
def safe_market(self, marketId: Str = None, market: Market = None, delimiter: Str = None, marketType: Str = None) -> MarketInterface:
|
|
323
|
+
isOption = (marketId is not None) and ((marketId.endswith('-C')) or (marketId.endswith('-P')) or (marketId.startswith('C-')) or (marketId.startswith('P-')))
|
|
324
|
+
if isOption and not (marketId in self.markets_by_id):
|
|
325
|
+
# handle expired option contracts
|
|
326
|
+
return self.create_expired_option_market(marketId)
|
|
327
|
+
return super(delta, self).safe_market(marketId, market, delimiter, marketType)
|
|
328
|
+
|
|
329
|
+
def fetch_time(self, params={}):
|
|
330
|
+
"""
|
|
331
|
+
fetches the current integer timestamp in milliseconds from the exchange server
|
|
332
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
|
333
|
+
:returns int: the current integer timestamp in milliseconds from the exchange server
|
|
334
|
+
"""
|
|
335
|
+
response = self.publicGetSettings(params)
|
|
336
|
+
# full response sample under `fetchStatus`
|
|
337
|
+
result = self.safe_dict(response, 'result', {})
|
|
338
|
+
return self.safe_integer_product(result, 'server_time', 0.001)
|
|
339
|
+
|
|
340
|
+
def fetch_status(self, params={}):
|
|
341
|
+
"""
|
|
342
|
+
the latest known information on the availability of the exchange API
|
|
343
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
|
344
|
+
:returns dict: a `status structure <https://docs.ccxt.com/#/?id=exchange-status-structure>`
|
|
345
|
+
"""
|
|
346
|
+
response = self.publicGetSettings(params)
|
|
347
|
+
#
|
|
348
|
+
# {
|
|
349
|
+
# "result": {
|
|
350
|
+
# "deto_liquidity_mining_daily_reward": "40775",
|
|
351
|
+
# "deto_msp": "1.0",
|
|
352
|
+
# "deto_staking_daily_reward": "23764.08",
|
|
353
|
+
# "enabled_wallets": [
|
|
354
|
+
# "BTC",
|
|
355
|
+
# ...
|
|
356
|
+
# ],
|
|
357
|
+
# "portfolio_margin_params": {
|
|
358
|
+
# "enabled_portfolios": {
|
|
359
|
+
# ".DEAVAXUSDT": {
|
|
360
|
+
# "asset_id": 5,
|
|
361
|
+
# "futures_contingency_margin_percent": "1",
|
|
362
|
+
# "interest_rate": "0",
|
|
363
|
+
# "maintenance_margin_multiplier": "0.8",
|
|
364
|
+
# "max_price_shock": "20",
|
|
365
|
+
# "max_short_notional_limit": "2000",
|
|
366
|
+
# "options_contingency_margin_percent": "1",
|
|
367
|
+
# "options_discount_range": "10",
|
|
368
|
+
# "options_liq_band_range_percentage": "25",
|
|
369
|
+
# "settling_asset": "USDT",
|
|
370
|
+
# "sort_priority": 5,
|
|
371
|
+
# "underlying_asset": "AVAX",
|
|
372
|
+
# "volatility_down_shock": "30",
|
|
373
|
+
# "volatility_up_shock": "45"
|
|
374
|
+
# },
|
|
375
|
+
# ...
|
|
376
|
+
# },
|
|
377
|
+
# "portfolio_enabled_contracts": [
|
|
378
|
+
# "futures",
|
|
379
|
+
# "perpetual_futures",
|
|
380
|
+
# "call_options",
|
|
381
|
+
# "put_options"
|
|
382
|
+
# ]
|
|
383
|
+
# },
|
|
384
|
+
# "server_time": 1650640673500273,
|
|
385
|
+
# "trade_farming_daily_reward": "100000",
|
|
386
|
+
# "circulating_supply": "140000000",
|
|
387
|
+
# "circulating_supply_update_time": "1636752800",
|
|
388
|
+
# "deto_referral_mining_daily_reward": "0",
|
|
389
|
+
# "deto_total_reward_pool": "100000000",
|
|
390
|
+
# "deto_trade_mining_daily_reward": "0",
|
|
391
|
+
# "kyc_deposit_limit": "20",
|
|
392
|
+
# "kyc_withdrawal_limit": "10000",
|
|
393
|
+
# "maintenance_start_time": "1650387600000000",
|
|
394
|
+
# "msp_deto_commission_percent": "25",
|
|
395
|
+
# "under_maintenance": "false"
|
|
396
|
+
# },
|
|
397
|
+
# "success": True
|
|
398
|
+
# }
|
|
399
|
+
#
|
|
400
|
+
result = self.safe_dict(response, 'result', {})
|
|
401
|
+
underMaintenance = self.safe_string(result, 'under_maintenance')
|
|
402
|
+
status = 'maintenance' if (underMaintenance == 'true') else 'ok'
|
|
403
|
+
updated = self.safe_integer_product(result, 'server_time', 0.001, self.milliseconds())
|
|
404
|
+
return {
|
|
405
|
+
'status': status,
|
|
406
|
+
'updated': updated,
|
|
407
|
+
'eta': None,
|
|
408
|
+
'url': None,
|
|
409
|
+
'info': response,
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
def fetch_currencies(self, params={}) -> Currencies:
|
|
413
|
+
"""
|
|
414
|
+
fetches all available currencies on an exchange
|
|
415
|
+
:see: https://docs.delta.exchange/#get-list-of-all-assets
|
|
416
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
|
417
|
+
:returns dict: an associative dictionary of currencies
|
|
418
|
+
"""
|
|
419
|
+
response = self.publicGetAssets(params)
|
|
420
|
+
#
|
|
421
|
+
# {
|
|
422
|
+
# "result":[
|
|
423
|
+
# {
|
|
424
|
+
# "base_withdrawal_fee":"0.0005",
|
|
425
|
+
# "deposit_status":"enabled",
|
|
426
|
+
# "id":2,
|
|
427
|
+
# "interest_credit":true,
|
|
428
|
+
# "interest_slabs":[
|
|
429
|
+
# {"limit":"0.1","rate":"0"},
|
|
430
|
+
# {"limit":"1","rate":"0.05"},
|
|
431
|
+
# {"limit":"5","rate":"0.075"},
|
|
432
|
+
# {"limit":"10","rate":"0.1"},
|
|
433
|
+
# {"limit":"9999999999999999","rate":"0"}
|
|
434
|
+
# ],
|
|
435
|
+
# "kyc_deposit_limit":"10",
|
|
436
|
+
# "kyc_withdrawal_limit":"2",
|
|
437
|
+
# "min_withdrawal_amount":"0.001",
|
|
438
|
+
# "minimum_precision":4,
|
|
439
|
+
# "name":"Bitcoin",
|
|
440
|
+
# "precision":8,
|
|
441
|
+
# "sort_priority":1,
|
|
442
|
+
# "symbol":"BTC",
|
|
443
|
+
# "variable_withdrawal_fee":"0",
|
|
444
|
+
# "withdrawal_status":"enabled"
|
|
445
|
+
# },
|
|
446
|
+
# ],
|
|
447
|
+
# "success":true
|
|
448
|
+
# }
|
|
449
|
+
#
|
|
450
|
+
currencies = self.safe_list(response, 'result', [])
|
|
451
|
+
result: dict = {}
|
|
452
|
+
for i in range(0, len(currencies)):
|
|
453
|
+
currency = currencies[i]
|
|
454
|
+
id = self.safe_string(currency, 'symbol')
|
|
455
|
+
numericId = self.safe_integer(currency, 'id')
|
|
456
|
+
code = self.safe_currency_code(id)
|
|
457
|
+
depositStatus = self.safe_string(currency, 'deposit_status')
|
|
458
|
+
withdrawalStatus = self.safe_string(currency, 'withdrawal_status')
|
|
459
|
+
depositsEnabled = (depositStatus == 'enabled')
|
|
460
|
+
withdrawalsEnabled = (withdrawalStatus == 'enabled')
|
|
461
|
+
active = depositsEnabled and withdrawalsEnabled
|
|
462
|
+
result[code] = {
|
|
463
|
+
'id': id,
|
|
464
|
+
'numericId': numericId,
|
|
465
|
+
'code': code,
|
|
466
|
+
'name': self.safe_string(currency, 'name'),
|
|
467
|
+
'info': currency, # the original payload
|
|
468
|
+
'active': active,
|
|
469
|
+
'deposit': depositsEnabled,
|
|
470
|
+
'withdraw': withdrawalsEnabled,
|
|
471
|
+
'fee': self.safe_number(currency, 'base_withdrawal_fee'),
|
|
472
|
+
'precision': self.parse_number(self.parse_precision(self.safe_string(currency, 'precision'))),
|
|
473
|
+
'limits': {
|
|
474
|
+
'amount': {'min': None, 'max': None},
|
|
475
|
+
'withdraw': {
|
|
476
|
+
'min': self.safe_number(currency, 'min_withdrawal_amount'),
|
|
477
|
+
'max': None,
|
|
478
|
+
},
|
|
479
|
+
},
|
|
480
|
+
'networks': {},
|
|
481
|
+
}
|
|
482
|
+
return result
|
|
483
|
+
|
|
484
|
+
def load_markets(self, reload=False, params={}):
|
|
485
|
+
markets = super(delta, self).load_markets(reload, params)
|
|
486
|
+
currenciesByNumericId = self.safe_dict(self.options, 'currenciesByNumericId')
|
|
487
|
+
if (currenciesByNumericId is None) or reload:
|
|
488
|
+
self.options['currenciesByNumericId'] = self.index_by_stringified_numeric_id(self.currencies)
|
|
489
|
+
marketsByNumericId = self.safe_dict(self.options, 'marketsByNumericId')
|
|
490
|
+
if (marketsByNumericId is None) or reload:
|
|
491
|
+
self.options['marketsByNumericId'] = self.index_by_stringified_numeric_id(self.markets)
|
|
492
|
+
return markets
|
|
493
|
+
|
|
494
|
+
def index_by_stringified_numeric_id(self, input):
|
|
495
|
+
result: dict = {}
|
|
496
|
+
if input is None:
|
|
497
|
+
return None
|
|
498
|
+
keys = list(input.keys())
|
|
499
|
+
for i in range(0, len(keys)):
|
|
500
|
+
key = keys[i]
|
|
501
|
+
item = input[key]
|
|
502
|
+
numericIdString = self.safe_string(item, 'numericId')
|
|
503
|
+
if numericIdString is None:
|
|
504
|
+
continue
|
|
505
|
+
result[numericIdString] = item
|
|
506
|
+
return result
|
|
507
|
+
|
|
508
|
+
def fetch_markets(self, params={}) -> List[Market]:
|
|
509
|
+
"""
|
|
510
|
+
retrieves data on all markets for delta
|
|
511
|
+
:see: https://docs.delta.exchange/#get-list-of-products
|
|
512
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
|
513
|
+
:returns dict[]: an array of objects representing market data
|
|
514
|
+
"""
|
|
515
|
+
response = self.publicGetProducts(params)
|
|
516
|
+
#
|
|
517
|
+
# {
|
|
518
|
+
# "meta":{"after":null, "before":null, "limit":100, "total_count":81},
|
|
519
|
+
# "result":[
|
|
520
|
+
# # the below response represents item from perpetual market
|
|
521
|
+
# {
|
|
522
|
+
# "annualized_funding":"5.475000000000000000",
|
|
523
|
+
# "is_quanto":false,
|
|
524
|
+
# "ui_config":{
|
|
525
|
+
# "default_trading_view_candle":"15",
|
|
526
|
+
# "leverage_slider_values":[1,3,5,10,25,50],
|
|
527
|
+
# "price_clubbing_values":[0.001,0.005,0.05,0.1,0.5,1,5],
|
|
528
|
+
# "show_bracket_orders":false,
|
|
529
|
+
# "sort_priority":29,
|
|
530
|
+
# "tags":[]
|
|
531
|
+
# },
|
|
532
|
+
# "basis_factor_max_limit":"0.15",
|
|
533
|
+
# "symbol":"P-LINK-D-151120",
|
|
534
|
+
# "id":1584,
|
|
535
|
+
# "default_leverage":"5.000000000000000000",
|
|
536
|
+
# "maker_commission_rate":"0.0005",
|
|
537
|
+
# "contract_unit_currency":"LINK",
|
|
538
|
+
# "strike_price":"12.507948",
|
|
539
|
+
# "settling_asset":{
|
|
540
|
+
# # asset structure
|
|
541
|
+
# },
|
|
542
|
+
# "auction_start_time":null,
|
|
543
|
+
# "auction_finish_time":null,
|
|
544
|
+
# "settlement_time":"2020-11-15T12:00:00Z",
|
|
545
|
+
# "launch_time":"2020-11-14T11:55:05Z",
|
|
546
|
+
# "spot_index":{
|
|
547
|
+
# # index structure
|
|
548
|
+
# },
|
|
549
|
+
# "trading_status":"operational",
|
|
550
|
+
# "tick_size":"0.001",
|
|
551
|
+
# "position_size_limit":100000,
|
|
552
|
+
# "notional_type":"vanilla", # vanilla, inverse
|
|
553
|
+
# "price_band":"0.4",
|
|
554
|
+
# "barrier_price":null,
|
|
555
|
+
# "description":"Daily LINK PUT options quoted in USDT and settled in USDT",
|
|
556
|
+
# "insurance_fund_margin_contribution":"1",
|
|
557
|
+
# "quoting_asset":{
|
|
558
|
+
# # asset structure
|
|
559
|
+
# },
|
|
560
|
+
# "liquidation_penalty_factor":"0.2",
|
|
561
|
+
# "product_specs":{"max_volatility":3,"min_volatility":0.3,"spot_price_band":"0.40"},
|
|
562
|
+
# "initial_margin_scaling_factor":"0.0001",
|
|
563
|
+
# "underlying_asset":{
|
|
564
|
+
# # asset structure
|
|
565
|
+
# },
|
|
566
|
+
# "state":"live",
|
|
567
|
+
# "contract_value":"1",
|
|
568
|
+
# "initial_margin":"2",
|
|
569
|
+
# "impact_size":5000,
|
|
570
|
+
# "settlement_price":null,
|
|
571
|
+
# "contract_type":"put_options", # put_options, call_options, move_options, perpetual_futures, interest_rate_swaps, futures, spreads
|
|
572
|
+
# "taker_commission_rate":"0.0005",
|
|
573
|
+
# "maintenance_margin":"1",
|
|
574
|
+
# "short_description":"LINK Daily PUT Options",
|
|
575
|
+
# "maintenance_margin_scaling_factor":"0.00005",
|
|
576
|
+
# "funding_method":"mark_price",
|
|
577
|
+
# "max_leverage_notional":"20000"
|
|
578
|
+
# },
|
|
579
|
+
# # the below response represents item from spot market
|
|
580
|
+
# {
|
|
581
|
+
# "position_size_limit": 10000000,
|
|
582
|
+
# "settlement_price": null,
|
|
583
|
+
# "funding_method": "mark_price",
|
|
584
|
+
# "settling_asset": null,
|
|
585
|
+
# "impact_size": 10,
|
|
586
|
+
# "id": 32258,
|
|
587
|
+
# "auction_finish_time": null,
|
|
588
|
+
# "description": "Solana tether spot market",
|
|
589
|
+
# "trading_status": "operational",
|
|
590
|
+
# "tick_size": "0.01",
|
|
591
|
+
# "liquidation_penalty_factor": "1",
|
|
592
|
+
# "spot_index": {
|
|
593
|
+
# "config": {"quoting_asset": "USDT", "service_id": 8, "underlying_asset": "SOL"},
|
|
594
|
+
# "constituent_exchanges": [
|
|
595
|
+
# {"exchange": "binance", "health_interval": 60, "health_priority": 1, "weight": 1},
|
|
596
|
+
# {"exchange": "huobi", "health_interval": 60, "health_priority": 2, "weight": 1}
|
|
597
|
+
# ],
|
|
598
|
+
# "constituent_indices": null,
|
|
599
|
+
# "description": "Solana index from binance and huobi",
|
|
600
|
+
# "health_interval": 300,
|
|
601
|
+
# "id": 105,
|
|
602
|
+
# "impact_size": "40.000000000000000000",
|
|
603
|
+
# "index_type": "spot_pair",
|
|
604
|
+
# "is_composite": False,
|
|
605
|
+
# "price_method": "ltp",
|
|
606
|
+
# "quoting_asset_id": 5,
|
|
607
|
+
# "symbol": ".DESOLUSDT",
|
|
608
|
+
# "tick_size": "0.000100000000000000",
|
|
609
|
+
# "underlying_asset_id": 66
|
|
610
|
+
# },
|
|
611
|
+
# "contract_type": "spot",
|
|
612
|
+
# "launch_time": "2022-02-03T10:18:11Z",
|
|
613
|
+
# "symbol": "SOL_USDT",
|
|
614
|
+
# "disruption_reason": null,
|
|
615
|
+
# "settlement_time": null,
|
|
616
|
+
# "insurance_fund_margin_contribution": "1",
|
|
617
|
+
# "is_quanto": False,
|
|
618
|
+
# "maintenance_margin": "5",
|
|
619
|
+
# "taker_commission_rate": "0.0005",
|
|
620
|
+
# "auction_start_time": null,
|
|
621
|
+
# "max_leverage_notional": "10000000",
|
|
622
|
+
# "state": "live",
|
|
623
|
+
# "annualized_funding": "0",
|
|
624
|
+
# "notional_type": "vanilla",
|
|
625
|
+
# "price_band": "100",
|
|
626
|
+
# "product_specs": {"kyc_required": False, "max_order_size": 2000, "min_order_size": 0.01, "quoting_precision": 4, "underlying_precision": 2},
|
|
627
|
+
# "default_leverage": "1.000000000000000000",
|
|
628
|
+
# "initial_margin": "10",
|
|
629
|
+
# "maintenance_margin_scaling_factor": "1",
|
|
630
|
+
# "ui_config": {
|
|
631
|
+
# "default_trading_view_candle": "1d",
|
|
632
|
+
# "leverage_slider_values": [],
|
|
633
|
+
# "price_clubbing_values": [0.01, 0.05, 0.1, 0.5, 1, 2.5, 5],
|
|
634
|
+
# "show_bracket_orders": False,
|
|
635
|
+
# "sort_priority": 2,
|
|
636
|
+
# "tags": []
|
|
637
|
+
# },
|
|
638
|
+
# "basis_factor_max_limit": "10000",
|
|
639
|
+
# "contract_unit_currency": "SOL",
|
|
640
|
+
# "strike_price": null,
|
|
641
|
+
# "quoting_asset": {
|
|
642
|
+
# "base_withdrawal_fee": "10.000000000000000000",
|
|
643
|
+
# "deposit_status": "enabled",
|
|
644
|
+
# "id": 5,
|
|
645
|
+
# "interest_credit": False,
|
|
646
|
+
# "interest_slabs": null,
|
|
647
|
+
# "kyc_deposit_limit": "100000.000000000000000000",
|
|
648
|
+
# "kyc_withdrawal_limit": "10000.000000000000000000",
|
|
649
|
+
# "min_withdrawal_amount": "30.000000000000000000",
|
|
650
|
+
# "minimum_precision": 2,
|
|
651
|
+
# "name": "Tether",
|
|
652
|
+
# "networks": [
|
|
653
|
+
# {"base_withdrawal_fee": "25", "deposit_status": "enabled", "memo_required": False, "network": "ERC20", "variable_withdrawal_fee": "0", "withdrawal_status": "enabled"},
|
|
654
|
+
# {"base_withdrawal_fee": "1", "deposit_status": "enabled", "memo_required": False, "network": "BEP20(BSC)", "variable_withdrawal_fee": "0", "withdrawal_status": "enabled"},
|
|
655
|
+
# {"base_withdrawal_fee": "1", "deposit_status": "disabled", "memo_required": False, "network": "TRC20(TRON)", "variable_withdrawal_fee": "0", "withdrawal_status": "disabled"}
|
|
656
|
+
# ],
|
|
657
|
+
# "precision": 8,
|
|
658
|
+
# "sort_priority": 1,
|
|
659
|
+
# "symbol": "USDT",
|
|
660
|
+
# "variable_withdrawal_fee": "0.000000000000000000",
|
|
661
|
+
# "withdrawal_status": "enabled"
|
|
662
|
+
# },
|
|
663
|
+
# "maker_commission_rate": "0.0005",
|
|
664
|
+
# "initial_margin_scaling_factor": "2",
|
|
665
|
+
# "underlying_asset": {
|
|
666
|
+
# "base_withdrawal_fee": "0.000000000000000000",
|
|
667
|
+
# "deposit_status": "enabled",
|
|
668
|
+
# "id": 66,
|
|
669
|
+
# "interest_credit": False,
|
|
670
|
+
# "interest_slabs": null,
|
|
671
|
+
# "kyc_deposit_limit": "0.000000000000000000",
|
|
672
|
+
# "kyc_withdrawal_limit": "0.000000000000000000",
|
|
673
|
+
# "min_withdrawal_amount": "0.020000000000000000",
|
|
674
|
+
# "minimum_precision": 4,
|
|
675
|
+
# "name": "Solana",
|
|
676
|
+
# "networks": [
|
|
677
|
+
# {"base_withdrawal_fee": "0.01", "deposit_status": "enabled", "memo_required": False, "network": "SOLANA", "variable_withdrawal_fee": "0", "withdrawal_status": "enabled"},
|
|
678
|
+
# {"base_withdrawal_fee": "0.01", "deposit_status": "enabled", "memo_required": False, "network": "BEP20(BSC)", "variable_withdrawal_fee": "0", "withdrawal_status": "enabled"}
|
|
679
|
+
# ],
|
|
680
|
+
# "precision": 8,
|
|
681
|
+
# "sort_priority": 7,
|
|
682
|
+
# "symbol": "SOL",
|
|
683
|
+
# "variable_withdrawal_fee": "0.000000000000000000",
|
|
684
|
+
# "withdrawal_status": "enabled"
|
|
685
|
+
# },
|
|
686
|
+
# "barrier_price": null,
|
|
687
|
+
# "contract_value": "1",
|
|
688
|
+
# "short_description": "SOL-USDT spot market"
|
|
689
|
+
# },
|
|
690
|
+
# ],
|
|
691
|
+
# "success":true
|
|
692
|
+
# }
|
|
693
|
+
#
|
|
694
|
+
markets = self.safe_list(response, 'result', [])
|
|
695
|
+
result = []
|
|
696
|
+
for i in range(0, len(markets)):
|
|
697
|
+
market = markets[i]
|
|
698
|
+
type = self.safe_string(market, 'contract_type')
|
|
699
|
+
if type == 'options_combos':
|
|
700
|
+
continue
|
|
701
|
+
# settlingAsset = self.safe_value(market, 'settling_asset', {})
|
|
702
|
+
quotingAsset = self.safe_dict(market, 'quoting_asset', {})
|
|
703
|
+
underlyingAsset = self.safe_dict(market, 'underlying_asset', {})
|
|
704
|
+
settlingAsset = self.safe_dict(market, 'settling_asset')
|
|
705
|
+
productSpecs = self.safe_dict(market, 'product_specs', {})
|
|
706
|
+
baseId = self.safe_string(underlyingAsset, 'symbol')
|
|
707
|
+
quoteId = self.safe_string(quotingAsset, 'symbol')
|
|
708
|
+
settleId = self.safe_string(settlingAsset, 'symbol')
|
|
709
|
+
id = self.safe_string(market, 'symbol')
|
|
710
|
+
numericId = self.safe_integer(market, 'id')
|
|
711
|
+
base = self.safe_currency_code(baseId)
|
|
712
|
+
quote = self.safe_currency_code(quoteId)
|
|
713
|
+
settle = self.safe_currency_code(settleId)
|
|
714
|
+
callOptions = (type == 'call_options')
|
|
715
|
+
putOptions = (type == 'put_options')
|
|
716
|
+
moveOptions = (type == 'move_options')
|
|
717
|
+
spot = (type == 'spot')
|
|
718
|
+
swap = (type == 'perpetual_futures')
|
|
719
|
+
future = (type == 'futures')
|
|
720
|
+
option = (callOptions or putOptions or moveOptions)
|
|
721
|
+
strike = self.safe_string(market, 'strike_price')
|
|
722
|
+
expiryDatetime = self.safe_string(market, 'settlement_time')
|
|
723
|
+
expiry = self.parse8601(expiryDatetime)
|
|
724
|
+
contractSize = self.safe_number(market, 'contract_value')
|
|
725
|
+
amountPrecision = None
|
|
726
|
+
if spot:
|
|
727
|
+
amountPrecision = self.parse_number(self.parse_precision(self.safe_string(productSpecs, 'underlying_precision'))) # seems inverse of 'impact_size'
|
|
728
|
+
else:
|
|
729
|
+
# other markets(swap, futures, move, spread, irs) seem to use the step of '1' contract
|
|
730
|
+
amountPrecision = self.parse_number('1')
|
|
731
|
+
linear = (settle == base)
|
|
732
|
+
optionType = None
|
|
733
|
+
symbol = base + '/' + quote
|
|
734
|
+
if swap or future or option:
|
|
735
|
+
symbol = symbol + ':' + settle
|
|
736
|
+
if future or option:
|
|
737
|
+
symbol = symbol + '-' + self.yymmdd(expiry)
|
|
738
|
+
if option:
|
|
739
|
+
type = 'option'
|
|
740
|
+
letter = 'C'
|
|
741
|
+
optionType = 'call'
|
|
742
|
+
if putOptions:
|
|
743
|
+
letter = 'P'
|
|
744
|
+
optionType = 'put'
|
|
745
|
+
elif moveOptions:
|
|
746
|
+
letter = 'M'
|
|
747
|
+
optionType = 'move'
|
|
748
|
+
symbol = symbol + '-' + strike + '-' + letter
|
|
749
|
+
else:
|
|
750
|
+
type = 'future'
|
|
751
|
+
else:
|
|
752
|
+
type = 'swap'
|
|
753
|
+
state = self.safe_string(market, 'state')
|
|
754
|
+
result.append({
|
|
755
|
+
'id': id,
|
|
756
|
+
'numericId': numericId,
|
|
757
|
+
'symbol': symbol,
|
|
758
|
+
'base': base,
|
|
759
|
+
'quote': quote,
|
|
760
|
+
'settle': settle,
|
|
761
|
+
'baseId': baseId,
|
|
762
|
+
'quoteId': quoteId,
|
|
763
|
+
'settleId': settleId,
|
|
764
|
+
'type': type,
|
|
765
|
+
'spot': spot,
|
|
766
|
+
'margin': None if spot else False,
|
|
767
|
+
'swap': swap,
|
|
768
|
+
'future': future,
|
|
769
|
+
'option': option,
|
|
770
|
+
'active': (state == 'live'),
|
|
771
|
+
'contract': not spot,
|
|
772
|
+
'linear': None if spot else linear,
|
|
773
|
+
'inverse': None if spot else not linear,
|
|
774
|
+
'taker': self.safe_number(market, 'taker_commission_rate'),
|
|
775
|
+
'maker': self.safe_number(market, 'maker_commission_rate'),
|
|
776
|
+
'contractSize': contractSize,
|
|
777
|
+
'expiry': expiry,
|
|
778
|
+
'expiryDatetime': expiryDatetime,
|
|
779
|
+
'strike': self.parse_number(strike),
|
|
780
|
+
'optionType': optionType,
|
|
781
|
+
'precision': {
|
|
782
|
+
'amount': amountPrecision,
|
|
783
|
+
'price': self.safe_number(market, 'tick_size'),
|
|
784
|
+
},
|
|
785
|
+
'limits': {
|
|
786
|
+
'leverage': {
|
|
787
|
+
'min': None,
|
|
788
|
+
'max': None,
|
|
789
|
+
},
|
|
790
|
+
'amount': {
|
|
791
|
+
'min': self.parse_number('1'),
|
|
792
|
+
'max': self.safe_number(market, 'position_size_limit'),
|
|
793
|
+
},
|
|
794
|
+
'price': {
|
|
795
|
+
'min': None,
|
|
796
|
+
'max': None,
|
|
797
|
+
},
|
|
798
|
+
'cost': {
|
|
799
|
+
'min': self.safe_number(market, 'min_size'),
|
|
800
|
+
'max': None,
|
|
801
|
+
},
|
|
802
|
+
},
|
|
803
|
+
'created': self.parse8601(self.safe_string(market, 'launch_time')),
|
|
804
|
+
'info': market,
|
|
805
|
+
})
|
|
806
|
+
return result
|
|
807
|
+
|
|
808
|
+
def parse_ticker(self, ticker: dict, market: Market = None) -> Ticker:
|
|
809
|
+
#
|
|
810
|
+
# spot: fetchTicker, fetchTickers
|
|
811
|
+
#
|
|
812
|
+
# {
|
|
813
|
+
# "close": 30634.0,
|
|
814
|
+
# "contract_type": "spot",
|
|
815
|
+
# "greeks": null,
|
|
816
|
+
# "high": 30780.0,
|
|
817
|
+
# "low": 30340.5,
|
|
818
|
+
# "mark_price": "48000",
|
|
819
|
+
# "oi": "0.0000",
|
|
820
|
+
# "oi_change_usd_6h": "0.0000",
|
|
821
|
+
# "oi_contracts": "0",
|
|
822
|
+
# "oi_value": "0.0000",
|
|
823
|
+
# "oi_value_symbol": "BTC",
|
|
824
|
+
# "oi_value_usd": "0.0000",
|
|
825
|
+
# "open": 30464.0,
|
|
826
|
+
# "price_band": null,
|
|
827
|
+
# "product_id": 8320,
|
|
828
|
+
# "quotes": {},
|
|
829
|
+
# "size": 2.6816639999999996,
|
|
830
|
+
# "spot_price": "30637.91465121",
|
|
831
|
+
# "symbol": "BTC_USDT",
|
|
832
|
+
# "timestamp": 1689139767621299,
|
|
833
|
+
# "turnover": 2.6816639999999996,
|
|
834
|
+
# "turnover_symbol": "BTC",
|
|
835
|
+
# "turnover_usd": 81896.45613400004,
|
|
836
|
+
# "volume": 2.6816639999999996
|
|
837
|
+
# }
|
|
838
|
+
#
|
|
839
|
+
# swap: fetchTicker, fetchTickers
|
|
840
|
+
#
|
|
841
|
+
# {
|
|
842
|
+
# "close": 30600.5,
|
|
843
|
+
# "contract_type": "perpetual_futures",
|
|
844
|
+
# "funding_rate": "0.00602961",
|
|
845
|
+
# "greeks": null,
|
|
846
|
+
# "high": 30803.0,
|
|
847
|
+
# "low": 30265.5,
|
|
848
|
+
# "mark_basis": "-0.45601594",
|
|
849
|
+
# "mark_price": "30600.10481568",
|
|
850
|
+
# "oi": "469.9190",
|
|
851
|
+
# "oi_change_usd_6h": "2226314.9900",
|
|
852
|
+
# "oi_contracts": "469919",
|
|
853
|
+
# "oi_value": "469.9190",
|
|
854
|
+
# "oi_value_symbol": "BTC",
|
|
855
|
+
# "oi_value_usd": "14385640.6802",
|
|
856
|
+
# "open": 30458.5,
|
|
857
|
+
# "price_band": {
|
|
858
|
+
# "lower_limit": "29067.08312627",
|
|
859
|
+
# "upper_limit": "32126.77608693"
|
|
860
|
+
# },
|
|
861
|
+
# "product_id": 139,
|
|
862
|
+
# "quotes": {
|
|
863
|
+
# "ask_iv": null,
|
|
864
|
+
# "ask_size": "965",
|
|
865
|
+
# "best_ask": "30600.5",
|
|
866
|
+
# "best_bid": "30599.5",
|
|
867
|
+
# "bid_iv": null,
|
|
868
|
+
# "bid_size": "196",
|
|
869
|
+
# "impact_mid_price": null,
|
|
870
|
+
# "mark_iv": "-0.44931641"
|
|
871
|
+
# },
|
|
872
|
+
# "size": 1226303,
|
|
873
|
+
# "spot_price": "30612.85362773",
|
|
874
|
+
# "symbol": "BTCUSDT",
|
|
875
|
+
# "timestamp": 1689136597460456,
|
|
876
|
+
# "turnover": 37392218.45999999,
|
|
877
|
+
# "turnover_symbol": "USDT",
|
|
878
|
+
# "turnover_usd": 37392218.45999999,
|
|
879
|
+
# "volume": 1226.3029999999485
|
|
880
|
+
# }
|
|
881
|
+
#
|
|
882
|
+
# option: fetchTicker, fetchTickers
|
|
883
|
+
#
|
|
884
|
+
# {
|
|
885
|
+
# "contract_type": "call_options",
|
|
886
|
+
# "greeks": {
|
|
887
|
+
# "delta": "0.60873994",
|
|
888
|
+
# "gamma": "0.00014854",
|
|
889
|
+
# "rho": "7.71808010",
|
|
890
|
+
# "spot": "30598.49040622",
|
|
891
|
+
# "theta": "-30.44743017",
|
|
892
|
+
# "vega": "24.83508248"
|
|
893
|
+
# },
|
|
894
|
+
# "mark_price": "1347.74819696",
|
|
895
|
+
# "mark_vol": "0.39966303",
|
|
896
|
+
# "oi": "2.7810",
|
|
897
|
+
# "oi_change_usd_6h": "0.0000",
|
|
898
|
+
# "oi_contracts": "2781",
|
|
899
|
+
# "oi_value": "2.7810",
|
|
900
|
+
# "oi_value_symbol": "BTC",
|
|
901
|
+
# "oi_value_usd": "85127.4337",
|
|
902
|
+
# "price_band": {
|
|
903
|
+
# "lower_limit": "91.27423497",
|
|
904
|
+
# "upper_limit": "7846.19454697"
|
|
905
|
+
# },
|
|
906
|
+
# "product_id": 107150,
|
|
907
|
+
# "quotes": {
|
|
908
|
+
# "ask_iv": "0.41023239",
|
|
909
|
+
# "ask_size": "2397",
|
|
910
|
+
# "best_ask": "1374",
|
|
911
|
+
# "best_bid": "1322",
|
|
912
|
+
# "bid_iv": "0.38929375",
|
|
913
|
+
# "bid_size": "3995",
|
|
914
|
+
# "impact_mid_price": null,
|
|
915
|
+
# "mark_iv": "0.39965618"
|
|
916
|
+
# },
|
|
917
|
+
# "spot_price": "30598.43379314",
|
|
918
|
+
# "strike_price": "30000",
|
|
919
|
+
# "symbol": "C-BTC-30000-280723",
|
|
920
|
+
# "timestamp": 1689136932893181,
|
|
921
|
+
# "turnover_symbol": "USDT"
|
|
922
|
+
# }
|
|
923
|
+
#
|
|
924
|
+
timestamp = self.safe_integer_product(ticker, 'timestamp', 0.001)
|
|
925
|
+
marketId = self.safe_string(ticker, 'symbol')
|
|
926
|
+
symbol = self.safe_symbol(marketId, market)
|
|
927
|
+
last = self.safe_string(ticker, 'close')
|
|
928
|
+
quotes = self.safe_dict(ticker, 'quotes', {})
|
|
929
|
+
return self.safe_ticker({
|
|
930
|
+
'symbol': symbol,
|
|
931
|
+
'timestamp': timestamp,
|
|
932
|
+
'datetime': self.iso8601(timestamp),
|
|
933
|
+
'high': self.safe_number(ticker, 'high'),
|
|
934
|
+
'low': self.safe_number(ticker, 'low'),
|
|
935
|
+
'bid': self.safe_number(quotes, 'best_bid'),
|
|
936
|
+
'bidVolume': self.safe_number(quotes, 'bid_size'),
|
|
937
|
+
'ask': self.safe_number(quotes, 'best_ask'),
|
|
938
|
+
'askVolume': self.safe_number(quotes, 'ask_size'),
|
|
939
|
+
'vwap': None,
|
|
940
|
+
'open': self.safe_string(ticker, 'open'),
|
|
941
|
+
'close': last,
|
|
942
|
+
'last': last,
|
|
943
|
+
'previousClose': None,
|
|
944
|
+
'change': None,
|
|
945
|
+
'percentage': None,
|
|
946
|
+
'average': None,
|
|
947
|
+
'baseVolume': self.safe_number(ticker, 'volume'),
|
|
948
|
+
'quoteVolume': self.safe_number(ticker, 'turnover'),
|
|
949
|
+
'info': ticker,
|
|
950
|
+
}, market)
|
|
951
|
+
|
|
952
|
+
def fetch_ticker(self, symbol: str, params={}) -> Ticker:
|
|
953
|
+
"""
|
|
954
|
+
fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
|
|
955
|
+
:see: https://docs.delta.exchange/#get-ticker-for-a-product-by-symbol
|
|
956
|
+
:param str symbol: unified symbol of the market to fetch the ticker for
|
|
957
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
|
958
|
+
:returns dict: a `ticker structure <https://docs.ccxt.com/#/?id=ticker-structure>`
|
|
959
|
+
"""
|
|
960
|
+
self.load_markets()
|
|
961
|
+
market = self.market(symbol)
|
|
962
|
+
request: dict = {
|
|
963
|
+
'symbol': market['id'],
|
|
964
|
+
}
|
|
965
|
+
response = self.publicGetTickersSymbol(self.extend(request, params))
|
|
966
|
+
#
|
|
967
|
+
# spot
|
|
968
|
+
#
|
|
969
|
+
# {
|
|
970
|
+
# "result": {
|
|
971
|
+
# "close": 30634.0,
|
|
972
|
+
# "contract_type": "spot",
|
|
973
|
+
# "greeks": null,
|
|
974
|
+
# "high": 30780.0,
|
|
975
|
+
# "low": 30340.5,
|
|
976
|
+
# "mark_price": "48000",
|
|
977
|
+
# "oi": "0.0000",
|
|
978
|
+
# "oi_change_usd_6h": "0.0000",
|
|
979
|
+
# "oi_contracts": "0",
|
|
980
|
+
# "oi_value": "0.0000",
|
|
981
|
+
# "oi_value_symbol": "BTC",
|
|
982
|
+
# "oi_value_usd": "0.0000",
|
|
983
|
+
# "open": 30464.0,
|
|
984
|
+
# "price_band": null,
|
|
985
|
+
# "product_id": 8320,
|
|
986
|
+
# "quotes": {},
|
|
987
|
+
# "size": 2.6816639999999996,
|
|
988
|
+
# "spot_price": "30637.91465121",
|
|
989
|
+
# "symbol": "BTC_USDT",
|
|
990
|
+
# "timestamp": 1689139767621299,
|
|
991
|
+
# "turnover": 2.6816639999999996,
|
|
992
|
+
# "turnover_symbol": "BTC",
|
|
993
|
+
# "turnover_usd": 81896.45613400004,
|
|
994
|
+
# "volume": 2.6816639999999996
|
|
995
|
+
# },
|
|
996
|
+
# "success": True
|
|
997
|
+
# }
|
|
998
|
+
#
|
|
999
|
+
# swap
|
|
1000
|
+
#
|
|
1001
|
+
# {
|
|
1002
|
+
# "result": {
|
|
1003
|
+
# "close": 30600.5,
|
|
1004
|
+
# "contract_type": "perpetual_futures",
|
|
1005
|
+
# "funding_rate": "0.00602961",
|
|
1006
|
+
# "greeks": null,
|
|
1007
|
+
# "high": 30803.0,
|
|
1008
|
+
# "low": 30265.5,
|
|
1009
|
+
# "mark_basis": "-0.45601594",
|
|
1010
|
+
# "mark_price": "30600.10481568",
|
|
1011
|
+
# "oi": "469.9190",
|
|
1012
|
+
# "oi_change_usd_6h": "2226314.9900",
|
|
1013
|
+
# "oi_contracts": "469919",
|
|
1014
|
+
# "oi_value": "469.9190",
|
|
1015
|
+
# "oi_value_symbol": "BTC",
|
|
1016
|
+
# "oi_value_usd": "14385640.6802",
|
|
1017
|
+
# "open": 30458.5,
|
|
1018
|
+
# "price_band": {
|
|
1019
|
+
# "lower_limit": "29067.08312627",
|
|
1020
|
+
# "upper_limit": "32126.77608693"
|
|
1021
|
+
# },
|
|
1022
|
+
# "product_id": 139,
|
|
1023
|
+
# "quotes": {
|
|
1024
|
+
# "ask_iv": null,
|
|
1025
|
+
# "ask_size": "965",
|
|
1026
|
+
# "best_ask": "30600.5",
|
|
1027
|
+
# "best_bid": "30599.5",
|
|
1028
|
+
# "bid_iv": null,
|
|
1029
|
+
# "bid_size": "196",
|
|
1030
|
+
# "impact_mid_price": null,
|
|
1031
|
+
# "mark_iv": "-0.44931641"
|
|
1032
|
+
# },
|
|
1033
|
+
# "size": 1226303,
|
|
1034
|
+
# "spot_price": "30612.85362773",
|
|
1035
|
+
# "symbol": "BTCUSDT",
|
|
1036
|
+
# "timestamp": 1689136597460456,
|
|
1037
|
+
# "turnover": 37392218.45999999,
|
|
1038
|
+
# "turnover_symbol": "USDT",
|
|
1039
|
+
# "turnover_usd": 37392218.45999999,
|
|
1040
|
+
# "volume": 1226.3029999999485
|
|
1041
|
+
# },
|
|
1042
|
+
# "success": True
|
|
1043
|
+
# }
|
|
1044
|
+
#
|
|
1045
|
+
# option
|
|
1046
|
+
#
|
|
1047
|
+
# {
|
|
1048
|
+
# "result": {
|
|
1049
|
+
# "contract_type": "call_options",
|
|
1050
|
+
# "greeks": {
|
|
1051
|
+
# "delta": "0.60873994",
|
|
1052
|
+
# "gamma": "0.00014854",
|
|
1053
|
+
# "rho": "7.71808010",
|
|
1054
|
+
# "spot": "30598.49040622",
|
|
1055
|
+
# "theta": "-30.44743017",
|
|
1056
|
+
# "vega": "24.83508248"
|
|
1057
|
+
# },
|
|
1058
|
+
# "mark_price": "1347.74819696",
|
|
1059
|
+
# "mark_vol": "0.39966303",
|
|
1060
|
+
# "oi": "2.7810",
|
|
1061
|
+
# "oi_change_usd_6h": "0.0000",
|
|
1062
|
+
# "oi_contracts": "2781",
|
|
1063
|
+
# "oi_value": "2.7810",
|
|
1064
|
+
# "oi_value_symbol": "BTC",
|
|
1065
|
+
# "oi_value_usd": "85127.4337",
|
|
1066
|
+
# "price_band": {
|
|
1067
|
+
# "lower_limit": "91.27423497",
|
|
1068
|
+
# "upper_limit": "7846.19454697"
|
|
1069
|
+
# },
|
|
1070
|
+
# "product_id": 107150,
|
|
1071
|
+
# "quotes": {
|
|
1072
|
+
# "ask_iv": "0.41023239",
|
|
1073
|
+
# "ask_size": "2397",
|
|
1074
|
+
# "best_ask": "1374",
|
|
1075
|
+
# "best_bid": "1322",
|
|
1076
|
+
# "bid_iv": "0.38929375",
|
|
1077
|
+
# "bid_size": "3995",
|
|
1078
|
+
# "impact_mid_price": null,
|
|
1079
|
+
# "mark_iv": "0.39965618"
|
|
1080
|
+
# },
|
|
1081
|
+
# "spot_price": "30598.43379314",
|
|
1082
|
+
# "strike_price": "30000",
|
|
1083
|
+
# "symbol": "C-BTC-30000-280723",
|
|
1084
|
+
# "timestamp": 1689136932893181,
|
|
1085
|
+
# "turnover_symbol": "USDT"
|
|
1086
|
+
# },
|
|
1087
|
+
# "success": True
|
|
1088
|
+
# }
|
|
1089
|
+
#
|
|
1090
|
+
result = self.safe_dict(response, 'result', {})
|
|
1091
|
+
return self.parse_ticker(result, market)
|
|
1092
|
+
|
|
1093
|
+
def fetch_tickers(self, symbols: Strings = None, params={}) -> Tickers:
|
|
1094
|
+
"""
|
|
1095
|
+
fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
|
|
1096
|
+
:see: https://docs.delta.exchange/#get-tickers-for-products
|
|
1097
|
+
:param str[]|None symbols: unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
|
|
1098
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
|
1099
|
+
:returns dict: a dictionary of `ticker structures <https://docs.ccxt.com/#/?id=ticker-structure>`
|
|
1100
|
+
"""
|
|
1101
|
+
self.load_markets()
|
|
1102
|
+
symbols = self.market_symbols(symbols)
|
|
1103
|
+
response = self.publicGetTickers(params)
|
|
1104
|
+
#
|
|
1105
|
+
# spot
|
|
1106
|
+
#
|
|
1107
|
+
# {
|
|
1108
|
+
# "result": [
|
|
1109
|
+
# {
|
|
1110
|
+
# "close": 30634.0,
|
|
1111
|
+
# "contract_type": "spot",
|
|
1112
|
+
# "greeks": null,
|
|
1113
|
+
# "high": 30780.0,
|
|
1114
|
+
# "low": 30340.5,
|
|
1115
|
+
# "mark_price": "48000",
|
|
1116
|
+
# "oi": "0.0000",
|
|
1117
|
+
# "oi_change_usd_6h": "0.0000",
|
|
1118
|
+
# "oi_contracts": "0",
|
|
1119
|
+
# "oi_value": "0.0000",
|
|
1120
|
+
# "oi_value_symbol": "BTC",
|
|
1121
|
+
# "oi_value_usd": "0.0000",
|
|
1122
|
+
# "open": 30464.0,
|
|
1123
|
+
# "price_band": null,
|
|
1124
|
+
# "product_id": 8320,
|
|
1125
|
+
# "quotes": {},
|
|
1126
|
+
# "size": 2.6816639999999996,
|
|
1127
|
+
# "spot_price": "30637.91465121",
|
|
1128
|
+
# "symbol": "BTC_USDT",
|
|
1129
|
+
# "timestamp": 1689139767621299,
|
|
1130
|
+
# "turnover": 2.6816639999999996,
|
|
1131
|
+
# "turnover_symbol": "BTC",
|
|
1132
|
+
# "turnover_usd": 81896.45613400004,
|
|
1133
|
+
# "volume": 2.6816639999999996
|
|
1134
|
+
# },
|
|
1135
|
+
# ],
|
|
1136
|
+
# "success":true
|
|
1137
|
+
# }
|
|
1138
|
+
#
|
|
1139
|
+
# swap
|
|
1140
|
+
#
|
|
1141
|
+
# {
|
|
1142
|
+
# "result": [
|
|
1143
|
+
# {
|
|
1144
|
+
# "close": 30600.5,
|
|
1145
|
+
# "contract_type": "perpetual_futures",
|
|
1146
|
+
# "funding_rate": "0.00602961",
|
|
1147
|
+
# "greeks": null,
|
|
1148
|
+
# "high": 30803.0,
|
|
1149
|
+
# "low": 30265.5,
|
|
1150
|
+
# "mark_basis": "-0.45601594",
|
|
1151
|
+
# "mark_price": "30600.10481568",
|
|
1152
|
+
# "oi": "469.9190",
|
|
1153
|
+
# "oi_change_usd_6h": "2226314.9900",
|
|
1154
|
+
# "oi_contracts": "469919",
|
|
1155
|
+
# "oi_value": "469.9190",
|
|
1156
|
+
# "oi_value_symbol": "BTC",
|
|
1157
|
+
# "oi_value_usd": "14385640.6802",
|
|
1158
|
+
# "open": 30458.5,
|
|
1159
|
+
# "price_band": {
|
|
1160
|
+
# "lower_limit": "29067.08312627",
|
|
1161
|
+
# "upper_limit": "32126.77608693"
|
|
1162
|
+
# },
|
|
1163
|
+
# "product_id": 139,
|
|
1164
|
+
# "quotes": {
|
|
1165
|
+
# "ask_iv": null,
|
|
1166
|
+
# "ask_size": "965",
|
|
1167
|
+
# "best_ask": "30600.5",
|
|
1168
|
+
# "best_bid": "30599.5",
|
|
1169
|
+
# "bid_iv": null,
|
|
1170
|
+
# "bid_size": "196",
|
|
1171
|
+
# "impact_mid_price": null,
|
|
1172
|
+
# "mark_iv": "-0.44931641"
|
|
1173
|
+
# },
|
|
1174
|
+
# "size": 1226303,
|
|
1175
|
+
# "spot_price": "30612.85362773",
|
|
1176
|
+
# "symbol": "BTCUSDT",
|
|
1177
|
+
# "timestamp": 1689136597460456,
|
|
1178
|
+
# "turnover": 37392218.45999999,
|
|
1179
|
+
# "turnover_symbol": "USDT",
|
|
1180
|
+
# "turnover_usd": 37392218.45999999,
|
|
1181
|
+
# "volume": 1226.3029999999485
|
|
1182
|
+
# },
|
|
1183
|
+
# ],
|
|
1184
|
+
# "success":true
|
|
1185
|
+
# }
|
|
1186
|
+
#
|
|
1187
|
+
# option
|
|
1188
|
+
#
|
|
1189
|
+
# {
|
|
1190
|
+
# "result": [
|
|
1191
|
+
# {
|
|
1192
|
+
# "contract_type": "call_options",
|
|
1193
|
+
# "greeks": {
|
|
1194
|
+
# "delta": "0.60873994",
|
|
1195
|
+
# "gamma": "0.00014854",
|
|
1196
|
+
# "rho": "7.71808010",
|
|
1197
|
+
# "spot": "30598.49040622",
|
|
1198
|
+
# "theta": "-30.44743017",
|
|
1199
|
+
# "vega": "24.83508248"
|
|
1200
|
+
# },
|
|
1201
|
+
# "mark_price": "1347.74819696",
|
|
1202
|
+
# "mark_vol": "0.39966303",
|
|
1203
|
+
# "oi": "2.7810",
|
|
1204
|
+
# "oi_change_usd_6h": "0.0000",
|
|
1205
|
+
# "oi_contracts": "2781",
|
|
1206
|
+
# "oi_value": "2.7810",
|
|
1207
|
+
# "oi_value_symbol": "BTC",
|
|
1208
|
+
# "oi_value_usd": "85127.4337",
|
|
1209
|
+
# "price_band": {
|
|
1210
|
+
# "lower_limit": "91.27423497",
|
|
1211
|
+
# "upper_limit": "7846.19454697"
|
|
1212
|
+
# },
|
|
1213
|
+
# "product_id": 107150,
|
|
1214
|
+
# "quotes": {
|
|
1215
|
+
# "ask_iv": "0.41023239",
|
|
1216
|
+
# "ask_size": "2397",
|
|
1217
|
+
# "best_ask": "1374",
|
|
1218
|
+
# "best_bid": "1322",
|
|
1219
|
+
# "bid_iv": "0.38929375",
|
|
1220
|
+
# "bid_size": "3995",
|
|
1221
|
+
# "impact_mid_price": null,
|
|
1222
|
+
# "mark_iv": "0.39965618"
|
|
1223
|
+
# },
|
|
1224
|
+
# "spot_price": "30598.43379314",
|
|
1225
|
+
# "strike_price": "30000",
|
|
1226
|
+
# "symbol": "C-BTC-30000-280723",
|
|
1227
|
+
# "timestamp": 1689136932893181,
|
|
1228
|
+
# "turnover_symbol": "USDT"
|
|
1229
|
+
# },
|
|
1230
|
+
# ],
|
|
1231
|
+
# "success":true
|
|
1232
|
+
# }
|
|
1233
|
+
#
|
|
1234
|
+
tickers = self.safe_list(response, 'result', [])
|
|
1235
|
+
result: dict = {}
|
|
1236
|
+
for i in range(0, len(tickers)):
|
|
1237
|
+
ticker = self.parse_ticker(tickers[i])
|
|
1238
|
+
symbol = ticker['symbol']
|
|
1239
|
+
result[symbol] = ticker
|
|
1240
|
+
return self.filter_by_array_tickers(result, 'symbol', symbols)
|
|
1241
|
+
|
|
1242
|
+
def fetch_order_book(self, symbol: str, limit: Int = None, params={}) -> OrderBook:
|
|
1243
|
+
"""
|
|
1244
|
+
fetches information on open orders with bid(buy) and ask(sell) prices, volumes and other data
|
|
1245
|
+
:see: https://docs.delta.exchange/#get-l2-orderbook
|
|
1246
|
+
:param str symbol: unified symbol of the market to fetch the order book for
|
|
1247
|
+
:param int [limit]: the maximum amount of order book entries to return
|
|
1248
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
|
1249
|
+
:returns dict: A dictionary of `order book structures <https://docs.ccxt.com/#/?id=order-book-structure>` indexed by market symbols
|
|
1250
|
+
"""
|
|
1251
|
+
self.load_markets()
|
|
1252
|
+
market = self.market(symbol)
|
|
1253
|
+
request: dict = {
|
|
1254
|
+
'symbol': market['id'],
|
|
1255
|
+
}
|
|
1256
|
+
if limit is not None:
|
|
1257
|
+
request['depth'] = limit
|
|
1258
|
+
response = self.publicGetL2orderbookSymbol(self.extend(request, params))
|
|
1259
|
+
#
|
|
1260
|
+
# {
|
|
1261
|
+
# "result":{
|
|
1262
|
+
# "buy":[
|
|
1263
|
+
# {"price":"15814.0","size":912},
|
|
1264
|
+
# {"price":"15813.5","size":1279},
|
|
1265
|
+
# {"price":"15813.0","size":1634},
|
|
1266
|
+
# ],
|
|
1267
|
+
# "sell":[
|
|
1268
|
+
# {"price":"15814.5","size":625},
|
|
1269
|
+
# {"price":"15815.0","size":982},
|
|
1270
|
+
# {"price":"15815.5","size":1328},
|
|
1271
|
+
# ],
|
|
1272
|
+
# "symbol":"BTCUSDT"
|
|
1273
|
+
# },
|
|
1274
|
+
# "success":true
|
|
1275
|
+
# }
|
|
1276
|
+
#
|
|
1277
|
+
result = self.safe_dict(response, 'result', {})
|
|
1278
|
+
return self.parse_order_book(result, market['symbol'], None, 'buy', 'sell', 'price', 'size')
|
|
1279
|
+
|
|
1280
|
+
def parse_trade(self, trade: dict, market: Market = None) -> Trade:
|
|
1281
|
+
#
|
|
1282
|
+
# public fetchTrades
|
|
1283
|
+
#
|
|
1284
|
+
# {
|
|
1285
|
+
# "buyer_role":"maker",
|
|
1286
|
+
# "price":"15896.5",
|
|
1287
|
+
# "seller_role":"taker",
|
|
1288
|
+
# "size":241,
|
|
1289
|
+
# "symbol":"BTCUSDT",
|
|
1290
|
+
# "timestamp":1605376684714595
|
|
1291
|
+
# }
|
|
1292
|
+
#
|
|
1293
|
+
# private fetchMyTrades
|
|
1294
|
+
#
|
|
1295
|
+
# {
|
|
1296
|
+
# "commission":"0.008335000000000000",
|
|
1297
|
+
# "created_at":"2020-11-16T19:07:19Z",
|
|
1298
|
+
# "fill_type":"normal",
|
|
1299
|
+
# "id":"e7ff05c233a74245b72381f8dd91d1ce",
|
|
1300
|
+
# "meta_data":{
|
|
1301
|
+
# "effective_commission_rate":"0.0005",
|
|
1302
|
+
# "order_price":"16249",
|
|
1303
|
+
# "order_size":1,
|
|
1304
|
+
# "order_type":"market_order",
|
|
1305
|
+
# "order_unfilled_size":0,
|
|
1306
|
+
# "trading_fee_credits_used":"0"
|
|
1307
|
+
# },
|
|
1308
|
+
# "order_id":"152999629",
|
|
1309
|
+
# "price":"16669",
|
|
1310
|
+
# "product":{
|
|
1311
|
+
# "contract_type":"perpetual_futures",
|
|
1312
|
+
# "contract_unit_currency":"BTC",
|
|
1313
|
+
# "contract_value":"0.001",
|
|
1314
|
+
# "id":139,
|
|
1315
|
+
# "notional_type":"vanilla",
|
|
1316
|
+
# "quoting_asset":{"minimum_precision":2,"precision":6,"symbol":"USDT"},
|
|
1317
|
+
# "settling_asset":{"minimum_precision":2,"precision":6,"symbol":"USDT"},
|
|
1318
|
+
# "symbol":"BTCUSDT",
|
|
1319
|
+
# "tick_size":"0.5",
|
|
1320
|
+
# "underlying_asset":{"minimum_precision":4,"precision":8,"symbol":"BTC"}
|
|
1321
|
+
# },
|
|
1322
|
+
# "product_id":139,
|
|
1323
|
+
# "role":"taker",
|
|
1324
|
+
# "side":"sell",
|
|
1325
|
+
# "size":1
|
|
1326
|
+
# }
|
|
1327
|
+
#
|
|
1328
|
+
id = self.safe_string(trade, 'id')
|
|
1329
|
+
orderId = self.safe_string(trade, 'order_id')
|
|
1330
|
+
timestamp = self.parse8601(self.safe_string(trade, 'created_at'))
|
|
1331
|
+
timestamp = self.safe_integer_product(trade, 'timestamp', 0.001, timestamp)
|
|
1332
|
+
priceString = self.safe_string(trade, 'price')
|
|
1333
|
+
amountString = self.safe_string(trade, 'size')
|
|
1334
|
+
product = self.safe_dict(trade, 'product', {})
|
|
1335
|
+
marketId = self.safe_string(product, 'symbol')
|
|
1336
|
+
symbol = self.safe_symbol(marketId, market)
|
|
1337
|
+
sellerRole = self.safe_string(trade, 'seller_role')
|
|
1338
|
+
side = self.safe_string(trade, 'side')
|
|
1339
|
+
if side is None:
|
|
1340
|
+
if sellerRole == 'taker':
|
|
1341
|
+
side = 'sell'
|
|
1342
|
+
elif sellerRole == 'maker':
|
|
1343
|
+
side = 'buy'
|
|
1344
|
+
takerOrMaker = self.safe_string(trade, 'role')
|
|
1345
|
+
metaData = self.safe_dict(trade, 'meta_data', {})
|
|
1346
|
+
type = self.safe_string(metaData, 'order_type')
|
|
1347
|
+
if type is not None:
|
|
1348
|
+
type = type.replace('_order', '')
|
|
1349
|
+
feeCostString = self.safe_string(trade, 'commission')
|
|
1350
|
+
fee = None
|
|
1351
|
+
if feeCostString is not None:
|
|
1352
|
+
settlingAsset = self.safe_dict(product, 'settling_asset', {})
|
|
1353
|
+
feeCurrencyId = self.safe_string(settlingAsset, 'symbol')
|
|
1354
|
+
feeCurrencyCode = self.safe_currency_code(feeCurrencyId)
|
|
1355
|
+
fee = {
|
|
1356
|
+
'cost': feeCostString,
|
|
1357
|
+
'currency': feeCurrencyCode,
|
|
1358
|
+
}
|
|
1359
|
+
return self.safe_trade({
|
|
1360
|
+
'id': id,
|
|
1361
|
+
'order': orderId,
|
|
1362
|
+
'timestamp': timestamp,
|
|
1363
|
+
'datetime': self.iso8601(timestamp),
|
|
1364
|
+
'symbol': symbol,
|
|
1365
|
+
'type': type,
|
|
1366
|
+
'side': side,
|
|
1367
|
+
'price': priceString,
|
|
1368
|
+
'amount': amountString,
|
|
1369
|
+
'cost': None,
|
|
1370
|
+
'takerOrMaker': takerOrMaker,
|
|
1371
|
+
'fee': fee,
|
|
1372
|
+
'info': trade,
|
|
1373
|
+
}, market)
|
|
1374
|
+
|
|
1375
|
+
def fetch_trades(self, symbol: str, since: Int = None, limit: Int = None, params={}) -> List[Trade]:
|
|
1376
|
+
"""
|
|
1377
|
+
get the list of most recent trades for a particular symbol
|
|
1378
|
+
:see: https://docs.delta.exchange/#get-public-trades
|
|
1379
|
+
:param str symbol: unified symbol of the market to fetch trades for
|
|
1380
|
+
:param int [since]: timestamp in ms of the earliest trade to fetch
|
|
1381
|
+
:param int [limit]: the maximum amount of trades to fetch
|
|
1382
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
|
1383
|
+
:returns Trade[]: a list of `trade structures <https://docs.ccxt.com/#/?id=public-trades>`
|
|
1384
|
+
"""
|
|
1385
|
+
self.load_markets()
|
|
1386
|
+
market = self.market(symbol)
|
|
1387
|
+
request: dict = {
|
|
1388
|
+
'symbol': market['id'],
|
|
1389
|
+
}
|
|
1390
|
+
response = self.publicGetTradesSymbol(self.extend(request, params))
|
|
1391
|
+
#
|
|
1392
|
+
# {
|
|
1393
|
+
# "result":[
|
|
1394
|
+
# {
|
|
1395
|
+
# "buyer_role":"maker",
|
|
1396
|
+
# "price":"15896.5",
|
|
1397
|
+
# "seller_role":"taker",
|
|
1398
|
+
# "size":241,
|
|
1399
|
+
# "symbol":"BTCUSDT",
|
|
1400
|
+
# "timestamp":1605376684714595
|
|
1401
|
+
# }
|
|
1402
|
+
# ],
|
|
1403
|
+
# "success":true
|
|
1404
|
+
# }
|
|
1405
|
+
#
|
|
1406
|
+
result = self.safe_list(response, 'result', [])
|
|
1407
|
+
return self.parse_trades(result, market, since, limit)
|
|
1408
|
+
|
|
1409
|
+
def parse_ohlcv(self, ohlcv, market: Market = None) -> list:
|
|
1410
|
+
#
|
|
1411
|
+
# {
|
|
1412
|
+
# "time":1605393120,
|
|
1413
|
+
# "open":15989,
|
|
1414
|
+
# "high":15989,
|
|
1415
|
+
# "low":15987.5,
|
|
1416
|
+
# "close":15987.5,
|
|
1417
|
+
# "volume":565
|
|
1418
|
+
# }
|
|
1419
|
+
#
|
|
1420
|
+
return [
|
|
1421
|
+
self.safe_timestamp(ohlcv, 'time'),
|
|
1422
|
+
self.safe_number(ohlcv, 'open'),
|
|
1423
|
+
self.safe_number(ohlcv, 'high'),
|
|
1424
|
+
self.safe_number(ohlcv, 'low'),
|
|
1425
|
+
self.safe_number(ohlcv, 'close'),
|
|
1426
|
+
self.safe_number(ohlcv, 'volume'),
|
|
1427
|
+
]
|
|
1428
|
+
|
|
1429
|
+
def fetch_ohlcv(self, symbol: str, timeframe='1m', since: Int = None, limit: Int = None, params={}) -> List[list]:
|
|
1430
|
+
"""
|
|
1431
|
+
fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
|
|
1432
|
+
:see: https://docs.delta.exchange/#get-ohlc-candles
|
|
1433
|
+
:param str symbol: unified symbol of the market to fetch OHLCV data for
|
|
1434
|
+
:param str timeframe: the length of time each candle represents
|
|
1435
|
+
:param int [since]: timestamp in ms of the earliest candle to fetch
|
|
1436
|
+
:param int [limit]: the maximum amount of candles to fetch
|
|
1437
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
|
1438
|
+
:returns int[][]: A list of candles ordered, open, high, low, close, volume
|
|
1439
|
+
"""
|
|
1440
|
+
self.load_markets()
|
|
1441
|
+
market = self.market(symbol)
|
|
1442
|
+
request: dict = {
|
|
1443
|
+
'resolution': self.safe_string(self.timeframes, timeframe, timeframe),
|
|
1444
|
+
}
|
|
1445
|
+
duration = self.parse_timeframe(timeframe)
|
|
1446
|
+
limit = limit if limit else 2000 # max 2000
|
|
1447
|
+
if since is None:
|
|
1448
|
+
end = self.seconds()
|
|
1449
|
+
request['end'] = end
|
|
1450
|
+
request['start'] = end - limit * duration
|
|
1451
|
+
else:
|
|
1452
|
+
start = self.parse_to_int(since / 1000)
|
|
1453
|
+
request['start'] = start
|
|
1454
|
+
request['end'] = self.sum(start, limit * duration)
|
|
1455
|
+
price = self.safe_string(params, 'price')
|
|
1456
|
+
if price == 'mark':
|
|
1457
|
+
request['symbol'] = 'MARK:' + market['id']
|
|
1458
|
+
elif price == 'index':
|
|
1459
|
+
request['symbol'] = market['info']['spot_index']['symbol']
|
|
1460
|
+
else:
|
|
1461
|
+
request['symbol'] = market['id']
|
|
1462
|
+
params = self.omit(params, 'price')
|
|
1463
|
+
response = self.publicGetHistoryCandles(self.extend(request, params))
|
|
1464
|
+
#
|
|
1465
|
+
# {
|
|
1466
|
+
# "success":true,
|
|
1467
|
+
# "result":[
|
|
1468
|
+
# {"time":1605393120,"open":15989,"high":15989,"low":15987.5,"close":15987.5,"volume":565},
|
|
1469
|
+
# {"time":1605393180,"open":15966,"high":15966,"low":15959,"close":15959,"volume":24},
|
|
1470
|
+
# {"time":1605393300,"open":15973,"high":15973,"low":15973,"close":15973,"volume":1288},
|
|
1471
|
+
# ]
|
|
1472
|
+
# }
|
|
1473
|
+
#
|
|
1474
|
+
result = self.safe_list(response, 'result', [])
|
|
1475
|
+
return self.parse_ohlcvs(result, market, timeframe, since, limit)
|
|
1476
|
+
|
|
1477
|
+
def parse_balance(self, response) -> Balances:
|
|
1478
|
+
balances = self.safe_list(response, 'result', [])
|
|
1479
|
+
result: dict = {'info': response}
|
|
1480
|
+
currenciesByNumericId = self.safe_dict(self.options, 'currenciesByNumericId', {})
|
|
1481
|
+
for i in range(0, len(balances)):
|
|
1482
|
+
balance = balances[i]
|
|
1483
|
+
currencyId = self.safe_string(balance, 'asset_id')
|
|
1484
|
+
currency = self.safe_dict(currenciesByNumericId, currencyId)
|
|
1485
|
+
code = currencyId if (currency is None) else currency['code']
|
|
1486
|
+
account = self.account()
|
|
1487
|
+
account['total'] = self.safe_string(balance, 'balance')
|
|
1488
|
+
account['free'] = self.safe_string(balance, 'available_balance')
|
|
1489
|
+
result[code] = account
|
|
1490
|
+
return self.safe_balance(result)
|
|
1491
|
+
|
|
1492
|
+
def fetch_balance(self, params={}) -> Balances:
|
|
1493
|
+
"""
|
|
1494
|
+
query for balance and get the amount of funds available for trading or funds locked in orders
|
|
1495
|
+
:see: https://docs.delta.exchange/#get-wallet-balances
|
|
1496
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
|
1497
|
+
:returns dict: a `balance structure <https://docs.ccxt.com/#/?id=balance-structure>`
|
|
1498
|
+
"""
|
|
1499
|
+
self.load_markets()
|
|
1500
|
+
response = self.privateGetWalletBalances(params)
|
|
1501
|
+
#
|
|
1502
|
+
# {
|
|
1503
|
+
# "result":[
|
|
1504
|
+
# {
|
|
1505
|
+
# "asset_id":1,
|
|
1506
|
+
# "available_balance":"0",
|
|
1507
|
+
# "balance":"0",
|
|
1508
|
+
# "commission":"0",
|
|
1509
|
+
# "id":154883,
|
|
1510
|
+
# "interest_credit":"0",
|
|
1511
|
+
# "order_margin":"0",
|
|
1512
|
+
# "pending_referral_bonus":"0",
|
|
1513
|
+
# "pending_trading_fee_credit":"0",
|
|
1514
|
+
# "position_margin":"0",
|
|
1515
|
+
# "trading_fee_credit":"0",
|
|
1516
|
+
# "user_id":22142
|
|
1517
|
+
# },
|
|
1518
|
+
# ],
|
|
1519
|
+
# "success":true
|
|
1520
|
+
# }
|
|
1521
|
+
#
|
|
1522
|
+
return self.parse_balance(response)
|
|
1523
|
+
|
|
1524
|
+
def fetch_position(self, symbol: str, params={}):
|
|
1525
|
+
"""
|
|
1526
|
+
fetch data on a single open contract trade position
|
|
1527
|
+
:see: https://docs.delta.exchange/#get-position
|
|
1528
|
+
:param str symbol: unified market symbol of the market the position is held in, default is None
|
|
1529
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
|
1530
|
+
:returns dict: a `position structure <https://docs.ccxt.com/#/?id=position-structure>`
|
|
1531
|
+
"""
|
|
1532
|
+
self.load_markets()
|
|
1533
|
+
market = self.market(symbol)
|
|
1534
|
+
request: dict = {
|
|
1535
|
+
'product_id': market['numericId'],
|
|
1536
|
+
}
|
|
1537
|
+
response = self.privateGetPositions(self.extend(request, params))
|
|
1538
|
+
#
|
|
1539
|
+
# {
|
|
1540
|
+
# "result":{
|
|
1541
|
+
# "entry_price":null,
|
|
1542
|
+
# "size":0,
|
|
1543
|
+
# "timestamp":1605454074268079
|
|
1544
|
+
# },
|
|
1545
|
+
# "success":true
|
|
1546
|
+
# }
|
|
1547
|
+
#
|
|
1548
|
+
result = self.safe_dict(response, 'result', {})
|
|
1549
|
+
return self.parse_position(result, market)
|
|
1550
|
+
|
|
1551
|
+
def fetch_positions(self, symbols: Strings = None, params={}):
|
|
1552
|
+
"""
|
|
1553
|
+
fetch all open positions
|
|
1554
|
+
:see: https://docs.delta.exchange/#get-margined-positions
|
|
1555
|
+
:param str[]|None symbols: list of unified market symbols
|
|
1556
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
|
1557
|
+
:returns dict[]: a list of `position structure <https://docs.ccxt.com/#/?id=position-structure>`
|
|
1558
|
+
"""
|
|
1559
|
+
self.load_markets()
|
|
1560
|
+
response = self.privateGetPositionsMargined(params)
|
|
1561
|
+
#
|
|
1562
|
+
# {
|
|
1563
|
+
# "success": True,
|
|
1564
|
+
# "result": [
|
|
1565
|
+
# {
|
|
1566
|
+
# "user_id": 0,
|
|
1567
|
+
# "size": 0,
|
|
1568
|
+
# "entry_price": "string",
|
|
1569
|
+
# "margin": "string",
|
|
1570
|
+
# "liquidation_price": "string",
|
|
1571
|
+
# "bankruptcy_price": "string",
|
|
1572
|
+
# "adl_level": 0,
|
|
1573
|
+
# "product_id": 0,
|
|
1574
|
+
# "product_symbol": "string",
|
|
1575
|
+
# "commission": "string",
|
|
1576
|
+
# "realized_pnl": "string",
|
|
1577
|
+
# "realized_funding": "string"
|
|
1578
|
+
# }
|
|
1579
|
+
# ]
|
|
1580
|
+
# }
|
|
1581
|
+
#
|
|
1582
|
+
result = self.safe_list(response, 'result', [])
|
|
1583
|
+
return self.parse_positions(result, symbols)
|
|
1584
|
+
|
|
1585
|
+
def parse_position(self, position: dict, market: Market = None):
|
|
1586
|
+
#
|
|
1587
|
+
# fetchPosition
|
|
1588
|
+
#
|
|
1589
|
+
# {
|
|
1590
|
+
# "entry_price":null,
|
|
1591
|
+
# "size":0,
|
|
1592
|
+
# "timestamp":1605454074268079
|
|
1593
|
+
# }
|
|
1594
|
+
#
|
|
1595
|
+
#
|
|
1596
|
+
# fetchPositions
|
|
1597
|
+
#
|
|
1598
|
+
# {
|
|
1599
|
+
# "user_id": 0,
|
|
1600
|
+
# "size": 0,
|
|
1601
|
+
# "entry_price": "string",
|
|
1602
|
+
# "margin": "string",
|
|
1603
|
+
# "liquidation_price": "string",
|
|
1604
|
+
# "bankruptcy_price": "string",
|
|
1605
|
+
# "adl_level": 0,
|
|
1606
|
+
# "product_id": 0,
|
|
1607
|
+
# "product_symbol": "string",
|
|
1608
|
+
# "commission": "string",
|
|
1609
|
+
# "realized_pnl": "string",
|
|
1610
|
+
# "realized_funding": "string"
|
|
1611
|
+
# }
|
|
1612
|
+
#
|
|
1613
|
+
marketId = self.safe_string(position, 'product_symbol')
|
|
1614
|
+
market = self.safe_market(marketId, market)
|
|
1615
|
+
symbol = market['symbol']
|
|
1616
|
+
timestamp = self.safe_integer_product(position, 'timestamp', 0.001)
|
|
1617
|
+
sizeString = self.safe_string(position, 'size')
|
|
1618
|
+
side = None
|
|
1619
|
+
if sizeString is not None:
|
|
1620
|
+
if Precise.string_gt(sizeString, '0'):
|
|
1621
|
+
side = 'buy'
|
|
1622
|
+
elif Precise.string_lt(sizeString, '0'):
|
|
1623
|
+
side = 'sell'
|
|
1624
|
+
return self.safe_position({
|
|
1625
|
+
'info': position,
|
|
1626
|
+
'id': None,
|
|
1627
|
+
'symbol': symbol,
|
|
1628
|
+
'notional': None,
|
|
1629
|
+
'marginMode': None,
|
|
1630
|
+
'liquidationPrice': self.safe_number(position, 'liquidation_price'),
|
|
1631
|
+
'entryPrice': self.safe_number(position, 'entry_price'),
|
|
1632
|
+
'unrealizedPnl': None, # todo - realized_pnl ?
|
|
1633
|
+
'percentage': None,
|
|
1634
|
+
'contracts': self.parse_number(sizeString),
|
|
1635
|
+
'contractSize': self.safe_number(market, 'contractSize'),
|
|
1636
|
+
'markPrice': None,
|
|
1637
|
+
'side': side,
|
|
1638
|
+
'hedged': None,
|
|
1639
|
+
'timestamp': timestamp,
|
|
1640
|
+
'datetime': self.iso8601(timestamp),
|
|
1641
|
+
'maintenanceMargin': None,
|
|
1642
|
+
'maintenanceMarginPercentage': None,
|
|
1643
|
+
'collateral': None,
|
|
1644
|
+
'initialMargin': None,
|
|
1645
|
+
'initialMarginPercentage': None,
|
|
1646
|
+
'leverage': None,
|
|
1647
|
+
'marginRatio': None,
|
|
1648
|
+
'stopLossPrice': None,
|
|
1649
|
+
'takeProfitPrice': None,
|
|
1650
|
+
})
|
|
1651
|
+
|
|
1652
|
+
def parse_order_status(self, status: Str):
|
|
1653
|
+
statuses: dict = {
|
|
1654
|
+
'open': 'open',
|
|
1655
|
+
'pending': 'open',
|
|
1656
|
+
'closed': 'closed',
|
|
1657
|
+
'cancelled': 'canceled',
|
|
1658
|
+
}
|
|
1659
|
+
return self.safe_string(statuses, status, status)
|
|
1660
|
+
|
|
1661
|
+
def parse_order(self, order: dict, market: Market = None) -> Order:
|
|
1662
|
+
#
|
|
1663
|
+
# createOrder, cancelOrder, editOrder, fetchOpenOrders, fetchClosedOrders
|
|
1664
|
+
#
|
|
1665
|
+
# {
|
|
1666
|
+
# "average_fill_price":null,
|
|
1667
|
+
# "bracket_order":null,
|
|
1668
|
+
# "bracket_stop_loss_limit_price":null,
|
|
1669
|
+
# "bracket_stop_loss_price":null,
|
|
1670
|
+
# "bracket_take_profit_limit_price":null,
|
|
1671
|
+
# "bracket_take_profit_price":null,
|
|
1672
|
+
# "bracket_trail_amount":null,
|
|
1673
|
+
# "cancellation_reason":null,
|
|
1674
|
+
# "client_order_id":null,
|
|
1675
|
+
# "close_on_trigger":"false",
|
|
1676
|
+
# "commission":"0",
|
|
1677
|
+
# "created_at":"2020-11-16T02:38:26Z",
|
|
1678
|
+
# "id":152870626,
|
|
1679
|
+
# "limit_price":"10000",
|
|
1680
|
+
# "meta_data":{"source":"api"},
|
|
1681
|
+
# "order_type":"limit_order",
|
|
1682
|
+
# "paid_commission":"0",
|
|
1683
|
+
# "product_id":139,
|
|
1684
|
+
# "reduce_only":false,
|
|
1685
|
+
# "side":"buy",
|
|
1686
|
+
# "size":0,
|
|
1687
|
+
# "state":"open",
|
|
1688
|
+
# "stop_order_type":null,
|
|
1689
|
+
# "stop_price":null,
|
|
1690
|
+
# "stop_trigger_method":"mark_price",
|
|
1691
|
+
# "time_in_force":"gtc",
|
|
1692
|
+
# "trail_amount":null,
|
|
1693
|
+
# "unfilled_size":0,
|
|
1694
|
+
# "user_id":22142
|
|
1695
|
+
# }
|
|
1696
|
+
#
|
|
1697
|
+
id = self.safe_string(order, 'id')
|
|
1698
|
+
clientOrderId = self.safe_string(order, 'client_order_id')
|
|
1699
|
+
timestamp = self.parse8601(self.safe_string(order, 'created_at'))
|
|
1700
|
+
marketId = self.safe_string(order, 'product_id')
|
|
1701
|
+
marketsByNumericId = self.safe_dict(self.options, 'marketsByNumericId', {})
|
|
1702
|
+
market = self.safe_value(marketsByNumericId, marketId, market)
|
|
1703
|
+
symbol = marketId if (market is None) else market['symbol']
|
|
1704
|
+
status = self.parse_order_status(self.safe_string(order, 'state'))
|
|
1705
|
+
side = self.safe_string(order, 'side')
|
|
1706
|
+
type = self.safe_string(order, 'order_type')
|
|
1707
|
+
type = type.replace('_order', '')
|
|
1708
|
+
price = self.safe_string(order, 'limit_price')
|
|
1709
|
+
amount = self.safe_string(order, 'size')
|
|
1710
|
+
remaining = self.safe_string(order, 'unfilled_size')
|
|
1711
|
+
average = self.safe_string(order, 'average_fill_price')
|
|
1712
|
+
fee = None
|
|
1713
|
+
feeCostString = self.safe_string(order, 'paid_commission')
|
|
1714
|
+
if feeCostString is not None:
|
|
1715
|
+
feeCurrencyCode = None
|
|
1716
|
+
if market is not None:
|
|
1717
|
+
settlingAsset = self.safe_dict(market['info'], 'settling_asset', {})
|
|
1718
|
+
feeCurrencyId = self.safe_string(settlingAsset, 'symbol')
|
|
1719
|
+
feeCurrencyCode = self.safe_currency_code(feeCurrencyId)
|
|
1720
|
+
fee = {
|
|
1721
|
+
'cost': feeCostString,
|
|
1722
|
+
'currency': feeCurrencyCode,
|
|
1723
|
+
}
|
|
1724
|
+
return self.safe_order({
|
|
1725
|
+
'info': order,
|
|
1726
|
+
'id': id,
|
|
1727
|
+
'clientOrderId': clientOrderId,
|
|
1728
|
+
'timestamp': timestamp,
|
|
1729
|
+
'datetime': self.iso8601(timestamp),
|
|
1730
|
+
'lastTradeTimestamp': None,
|
|
1731
|
+
'symbol': symbol,
|
|
1732
|
+
'type': type,
|
|
1733
|
+
'side': side,
|
|
1734
|
+
'price': price,
|
|
1735
|
+
'amount': amount,
|
|
1736
|
+
'cost': None,
|
|
1737
|
+
'average': average,
|
|
1738
|
+
'filled': None,
|
|
1739
|
+
'remaining': remaining,
|
|
1740
|
+
'status': status,
|
|
1741
|
+
'fee': fee,
|
|
1742
|
+
'trades': None,
|
|
1743
|
+
}, market)
|
|
1744
|
+
|
|
1745
|
+
def create_order(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, params={}):
|
|
1746
|
+
"""
|
|
1747
|
+
create a trade order
|
|
1748
|
+
:see: https://docs.delta.exchange/#place-order
|
|
1749
|
+
:param str symbol: unified symbol of the market to create an order in
|
|
1750
|
+
:param str type: 'market' or 'limit'
|
|
1751
|
+
:param str side: 'buy' or 'sell'
|
|
1752
|
+
:param float amount: how much of currency you want to trade in units of base currency
|
|
1753
|
+
:param float [price]: the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
|
|
1754
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
|
1755
|
+
:param bool [params.reduceOnly]: *contract only* indicates if self order is to reduce the size of a position
|
|
1756
|
+
:returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
|
|
1757
|
+
"""
|
|
1758
|
+
self.load_markets()
|
|
1759
|
+
orderType = type + '_order'
|
|
1760
|
+
market = self.market(symbol)
|
|
1761
|
+
request: dict = {
|
|
1762
|
+
'product_id': market['numericId'],
|
|
1763
|
+
# 'limit_price': self.price_to_precision(market['symbol'], price),
|
|
1764
|
+
'size': self.amount_to_precision(market['symbol'], amount),
|
|
1765
|
+
'side': side,
|
|
1766
|
+
'order_type': orderType,
|
|
1767
|
+
# 'client_order_id': 'string',
|
|
1768
|
+
# 'time_in_force': 'gtc', # gtc, ioc, fok
|
|
1769
|
+
# 'post_only': 'false', # 'true',
|
|
1770
|
+
# 'reduce_only': 'false', # 'true',
|
|
1771
|
+
}
|
|
1772
|
+
if type == 'limit':
|
|
1773
|
+
request['limit_price'] = self.price_to_precision(market['symbol'], price)
|
|
1774
|
+
clientOrderId = self.safe_string_2(params, 'clientOrderId', 'client_order_id')
|
|
1775
|
+
params = self.omit(params, ['clientOrderId', 'client_order_id'])
|
|
1776
|
+
if clientOrderId is not None:
|
|
1777
|
+
request['client_order_id'] = clientOrderId
|
|
1778
|
+
reduceOnly = self.safe_bool(params, 'reduceOnly')
|
|
1779
|
+
if reduceOnly:
|
|
1780
|
+
request['reduce_only'] = reduceOnly
|
|
1781
|
+
params = self.omit(params, 'reduceOnly')
|
|
1782
|
+
response = self.privatePostOrders(self.extend(request, params))
|
|
1783
|
+
#
|
|
1784
|
+
# {
|
|
1785
|
+
# "result":{
|
|
1786
|
+
# "average_fill_price":null,
|
|
1787
|
+
# "bracket_order":null,
|
|
1788
|
+
# "bracket_stop_loss_limit_price":null,
|
|
1789
|
+
# "bracket_stop_loss_price":null,
|
|
1790
|
+
# "bracket_take_profit_limit_price":null,
|
|
1791
|
+
# "bracket_take_profit_price":null,
|
|
1792
|
+
# "bracket_trail_amount":null,
|
|
1793
|
+
# "cancellation_reason":null,
|
|
1794
|
+
# "client_order_id":null,
|
|
1795
|
+
# "close_on_trigger":"false",
|
|
1796
|
+
# "commission":"0",
|
|
1797
|
+
# "created_at":"2020-11-16T02:38:26Z",
|
|
1798
|
+
# "id":152870626,
|
|
1799
|
+
# "limit_price":"10000",
|
|
1800
|
+
# "meta_data":{"source":"api"},
|
|
1801
|
+
# "order_type":"limit_order",
|
|
1802
|
+
# "paid_commission":"0",
|
|
1803
|
+
# "product_id":139,
|
|
1804
|
+
# "reduce_only":false,
|
|
1805
|
+
# "side":"buy",
|
|
1806
|
+
# "size":0,
|
|
1807
|
+
# "state":"open",
|
|
1808
|
+
# "stop_order_type":null,
|
|
1809
|
+
# "stop_price":null,
|
|
1810
|
+
# "stop_trigger_method":"mark_price",
|
|
1811
|
+
# "time_in_force":"gtc",
|
|
1812
|
+
# "trail_amount":null,
|
|
1813
|
+
# "unfilled_size":0,
|
|
1814
|
+
# "user_id":22142
|
|
1815
|
+
# },
|
|
1816
|
+
# "success":true
|
|
1817
|
+
# }
|
|
1818
|
+
#
|
|
1819
|
+
result = self.safe_dict(response, 'result', {})
|
|
1820
|
+
return self.parse_order(result, market)
|
|
1821
|
+
|
|
1822
|
+
def edit_order(self, id: str, symbol: str, type: OrderType, side: OrderSide, amount: Num = None, price: Num = None, params={}):
|
|
1823
|
+
"""
|
|
1824
|
+
edit a trade order
|
|
1825
|
+
:see: https://docs.delta.exchange/#edit-order
|
|
1826
|
+
:param str id: order id
|
|
1827
|
+
:param str symbol: unified symbol of the market to create an order in
|
|
1828
|
+
:param str type: 'market' or 'limit'
|
|
1829
|
+
:param str side: 'buy' or 'sell'
|
|
1830
|
+
:param float amount: how much of the currency you want to trade in units of the base currency
|
|
1831
|
+
:param float [price]: the price at which the order is to be fullfilled, in units of the quote currency
|
|
1832
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
|
1833
|
+
:returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
|
|
1834
|
+
"""
|
|
1835
|
+
self.load_markets()
|
|
1836
|
+
market = self.market(symbol)
|
|
1837
|
+
request: dict = {
|
|
1838
|
+
'id': int(id),
|
|
1839
|
+
'product_id': market['numericId'],
|
|
1840
|
+
# "limit_price": self.price_to_precision(symbol, price),
|
|
1841
|
+
# "size": self.amount_to_precision(symbol, amount),
|
|
1842
|
+
}
|
|
1843
|
+
if amount is not None:
|
|
1844
|
+
request['size'] = int(self.amount_to_precision(symbol, amount))
|
|
1845
|
+
if price is not None:
|
|
1846
|
+
request['limit_price'] = self.price_to_precision(symbol, price)
|
|
1847
|
+
response = self.privatePutOrders(self.extend(request, params))
|
|
1848
|
+
#
|
|
1849
|
+
# {
|
|
1850
|
+
# "success": True,
|
|
1851
|
+
# "result": {
|
|
1852
|
+
# "id": "ashb1212",
|
|
1853
|
+
# "product_id": 27,
|
|
1854
|
+
# "limit_price": "9200",
|
|
1855
|
+
# "side": "buy",
|
|
1856
|
+
# "size": 100,
|
|
1857
|
+
# "unfilled_size": 50,
|
|
1858
|
+
# "user_id": 1,
|
|
1859
|
+
# "order_type": "limit_order",
|
|
1860
|
+
# "state": "open",
|
|
1861
|
+
# "created_at": "..."
|
|
1862
|
+
# }
|
|
1863
|
+
# }
|
|
1864
|
+
#
|
|
1865
|
+
result = self.safe_dict(response, 'result')
|
|
1866
|
+
return self.parse_order(result, market)
|
|
1867
|
+
|
|
1868
|
+
def cancel_order(self, id: str, symbol: Str = None, params={}):
|
|
1869
|
+
"""
|
|
1870
|
+
cancels an open order
|
|
1871
|
+
:see: https://docs.delta.exchange/#cancel-order
|
|
1872
|
+
:param str id: order id
|
|
1873
|
+
:param str symbol: unified symbol of the market the order was made in
|
|
1874
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
|
1875
|
+
:returns dict: An `order structure <https://docs.ccxt.com/#/?id=order-structure>`
|
|
1876
|
+
"""
|
|
1877
|
+
if symbol is None:
|
|
1878
|
+
raise ArgumentsRequired(self.id + ' cancelOrder() requires a symbol argument')
|
|
1879
|
+
self.load_markets()
|
|
1880
|
+
market = self.market(symbol)
|
|
1881
|
+
request: dict = {
|
|
1882
|
+
'id': int(id),
|
|
1883
|
+
'product_id': market['numericId'],
|
|
1884
|
+
}
|
|
1885
|
+
response = self.privateDeleteOrders(self.extend(request, params))
|
|
1886
|
+
#
|
|
1887
|
+
# {
|
|
1888
|
+
# "result":{
|
|
1889
|
+
# "average_fill_price":null,
|
|
1890
|
+
# "bracket_order":null,
|
|
1891
|
+
# "bracket_stop_loss_limit_price":null,
|
|
1892
|
+
# "bracket_stop_loss_price":null,
|
|
1893
|
+
# "bracket_take_profit_limit_price":null,
|
|
1894
|
+
# "bracket_take_profit_price":null,
|
|
1895
|
+
# "bracket_trail_amount":null,
|
|
1896
|
+
# "cancellation_reason":"cancelled_by_user",
|
|
1897
|
+
# "client_order_id":null,
|
|
1898
|
+
# "close_on_trigger":"false",
|
|
1899
|
+
# "commission":"0",
|
|
1900
|
+
# "created_at":"2020-11-16T02:38:26Z",
|
|
1901
|
+
# "id":152870626,
|
|
1902
|
+
# "limit_price":"10000",
|
|
1903
|
+
# "meta_data":{"source":"api"},
|
|
1904
|
+
# "order_type":"limit_order",
|
|
1905
|
+
# "paid_commission":"0",
|
|
1906
|
+
# "product_id":139,
|
|
1907
|
+
# "reduce_only":false,
|
|
1908
|
+
# "side":"buy",
|
|
1909
|
+
# "size":0,
|
|
1910
|
+
# "state":"cancelled",
|
|
1911
|
+
# "stop_order_type":null,
|
|
1912
|
+
# "stop_price":null,
|
|
1913
|
+
# "stop_trigger_method":"mark_price",
|
|
1914
|
+
# "time_in_force":"gtc",
|
|
1915
|
+
# "trail_amount":null,
|
|
1916
|
+
# "unfilled_size":0,
|
|
1917
|
+
# "user_id":22142
|
|
1918
|
+
# },
|
|
1919
|
+
# "success":true
|
|
1920
|
+
# }
|
|
1921
|
+
#
|
|
1922
|
+
result = self.safe_dict(response, 'result')
|
|
1923
|
+
return self.parse_order(result, market)
|
|
1924
|
+
|
|
1925
|
+
def cancel_all_orders(self, symbol: Str = None, params={}):
|
|
1926
|
+
"""
|
|
1927
|
+
cancel all open orders in a market
|
|
1928
|
+
:see: https://docs.delta.exchange/#cancel-all-open-orders
|
|
1929
|
+
:param str symbol: unified market symbol of the market to cancel orders in
|
|
1930
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
|
1931
|
+
:returns dict[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
|
|
1932
|
+
"""
|
|
1933
|
+
if symbol is None:
|
|
1934
|
+
raise ArgumentsRequired(self.id + ' cancelAllOrders() requires a symbol argument')
|
|
1935
|
+
self.load_markets()
|
|
1936
|
+
market = self.market(symbol)
|
|
1937
|
+
request: dict = {
|
|
1938
|
+
'product_id': market['numericId'],
|
|
1939
|
+
# 'cancel_limit_orders': 'true',
|
|
1940
|
+
# 'cancel_stop_orders': 'true',
|
|
1941
|
+
}
|
|
1942
|
+
response = self.privateDeleteOrdersAll(self.extend(request, params))
|
|
1943
|
+
#
|
|
1944
|
+
# {
|
|
1945
|
+
# "result":{},
|
|
1946
|
+
# "success":true
|
|
1947
|
+
# }
|
|
1948
|
+
#
|
|
1949
|
+
return response
|
|
1950
|
+
|
|
1951
|
+
def fetch_open_orders(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Order]:
|
|
1952
|
+
"""
|
|
1953
|
+
fetch all unfilled currently open orders
|
|
1954
|
+
:see: https://docs.delta.exchange/#get-active-orders
|
|
1955
|
+
:param str symbol: unified market symbol
|
|
1956
|
+
:param int [since]: the earliest time in ms to fetch open orders for
|
|
1957
|
+
:param int [limit]: the maximum number of open order structures to retrieve
|
|
1958
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
|
1959
|
+
:returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
|
|
1960
|
+
"""
|
|
1961
|
+
return self.fetch_orders_with_method('privateGetOrders', symbol, since, limit, params)
|
|
1962
|
+
|
|
1963
|
+
def fetch_closed_orders(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Order]:
|
|
1964
|
+
"""
|
|
1965
|
+
fetches information on multiple closed orders made by the user
|
|
1966
|
+
:see: https://docs.delta.exchange/#get-order-history-cancelled-and-closed
|
|
1967
|
+
:param str symbol: unified market symbol of the market orders were made in
|
|
1968
|
+
:param int [since]: the earliest time in ms to fetch orders for
|
|
1969
|
+
:param int [limit]: the maximum number of order structures to retrieve
|
|
1970
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
|
1971
|
+
:returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
|
|
1972
|
+
"""
|
|
1973
|
+
return self.fetch_orders_with_method('privateGetOrdersHistory', symbol, since, limit, params)
|
|
1974
|
+
|
|
1975
|
+
def fetch_orders_with_method(self, method, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
|
|
1976
|
+
self.load_markets()
|
|
1977
|
+
request: dict = {
|
|
1978
|
+
# 'product_ids': market['id'], # comma-separated
|
|
1979
|
+
# 'contract_types': types, # comma-separated, futures, perpetual_futures, call_options, put_options, interest_rate_swaps, move_options, spreads
|
|
1980
|
+
# 'order_types': types, # comma-separated, market, limit, stop_market, stop_limit, all_stop
|
|
1981
|
+
# 'start_time': since * 1000,
|
|
1982
|
+
# 'end_time': self.microseconds(),
|
|
1983
|
+
# 'after', # after cursor for pagination
|
|
1984
|
+
# 'before', # before cursor for pagination
|
|
1985
|
+
# 'page_size': limit, # number of records per page
|
|
1986
|
+
}
|
|
1987
|
+
market = None
|
|
1988
|
+
if symbol is not None:
|
|
1989
|
+
market = self.market(symbol)
|
|
1990
|
+
request['product_ids'] = market['numericId'] # accepts a comma-separated list of ids
|
|
1991
|
+
if since is not None:
|
|
1992
|
+
request['start_time'] = str(since) + '000'
|
|
1993
|
+
if limit is not None:
|
|
1994
|
+
request['page_size'] = limit
|
|
1995
|
+
response = None
|
|
1996
|
+
if method == 'privateGetOrders':
|
|
1997
|
+
response = self.privateGetOrders(self.extend(request, params))
|
|
1998
|
+
elif method == 'privateGetOrdersHistory':
|
|
1999
|
+
response = self.privateGetOrdersHistory(self.extend(request, params))
|
|
2000
|
+
#
|
|
2001
|
+
# {
|
|
2002
|
+
# "success": True,
|
|
2003
|
+
# "result": [
|
|
2004
|
+
# {
|
|
2005
|
+
# "id": "ashb1212",
|
|
2006
|
+
# "product_id": 27,
|
|
2007
|
+
# "limit_price": "9200",
|
|
2008
|
+
# "side": "buy",
|
|
2009
|
+
# "size": 100,
|
|
2010
|
+
# "unfilled_size": 50,
|
|
2011
|
+
# "user_id": 1,
|
|
2012
|
+
# "order_type": "limit_order",
|
|
2013
|
+
# "state": "open",
|
|
2014
|
+
# "created_at": "..."
|
|
2015
|
+
# }
|
|
2016
|
+
# ],
|
|
2017
|
+
# "meta": {
|
|
2018
|
+
# "after": "string",
|
|
2019
|
+
# "before": "string"
|
|
2020
|
+
# }
|
|
2021
|
+
# }
|
|
2022
|
+
#
|
|
2023
|
+
result = self.safe_list(response, 'result', [])
|
|
2024
|
+
return self.parse_orders(result, market, since, limit)
|
|
2025
|
+
|
|
2026
|
+
def fetch_my_trades(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
|
|
2027
|
+
"""
|
|
2028
|
+
fetch all trades made by the user
|
|
2029
|
+
:see: https://docs.delta.exchange/#get-user-fills-by-filters
|
|
2030
|
+
:param str symbol: unified market symbol
|
|
2031
|
+
:param int [since]: the earliest time in ms to fetch trades for
|
|
2032
|
+
:param int [limit]: the maximum number of trades structures to retrieve
|
|
2033
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
|
2034
|
+
:returns Trade[]: a list of `trade structures <https://docs.ccxt.com/#/?id=trade-structure>`
|
|
2035
|
+
"""
|
|
2036
|
+
self.load_markets()
|
|
2037
|
+
request: dict = {
|
|
2038
|
+
# 'product_ids': market['id'], # comma-separated
|
|
2039
|
+
# 'contract_types': types, # comma-separated, futures, perpetual_futures, call_options, put_options, interest_rate_swaps, move_options, spreads
|
|
2040
|
+
# 'start_time': since * 1000,
|
|
2041
|
+
# 'end_time': self.microseconds(),
|
|
2042
|
+
# 'after', # after cursor for pagination
|
|
2043
|
+
# 'before', # before cursor for pagination
|
|
2044
|
+
# 'page_size': limit, # number of records per page
|
|
2045
|
+
}
|
|
2046
|
+
market = None
|
|
2047
|
+
if symbol is not None:
|
|
2048
|
+
market = self.market(symbol)
|
|
2049
|
+
request['product_ids'] = market['numericId'] # accepts a comma-separated list of ids
|
|
2050
|
+
if since is not None:
|
|
2051
|
+
request['start_time'] = str(since) + '000'
|
|
2052
|
+
if limit is not None:
|
|
2053
|
+
request['page_size'] = limit
|
|
2054
|
+
response = self.privateGetFills(self.extend(request, params))
|
|
2055
|
+
#
|
|
2056
|
+
# {
|
|
2057
|
+
# "meta":{
|
|
2058
|
+
# "after":null,
|
|
2059
|
+
# "before":null,
|
|
2060
|
+
# "limit":10,
|
|
2061
|
+
# "total_count":2
|
|
2062
|
+
# },
|
|
2063
|
+
# "result":[
|
|
2064
|
+
# {
|
|
2065
|
+
# "commission":"0.008335000000000000",
|
|
2066
|
+
# "created_at":"2020-11-16T19:07:19Z",
|
|
2067
|
+
# "fill_type":"normal",
|
|
2068
|
+
# "id":"e7ff05c233a74245b72381f8dd91d1ce",
|
|
2069
|
+
# "meta_data":{
|
|
2070
|
+
# "effective_commission_rate":"0.0005",
|
|
2071
|
+
# "order_price":"16249",
|
|
2072
|
+
# "order_size":1,
|
|
2073
|
+
# "order_type":"market_order",
|
|
2074
|
+
# "order_unfilled_size":0,
|
|
2075
|
+
# "trading_fee_credits_used":"0"
|
|
2076
|
+
# },
|
|
2077
|
+
# "order_id":"152999629",
|
|
2078
|
+
# "price":"16669",
|
|
2079
|
+
# "product":{
|
|
2080
|
+
# "contract_type":"perpetual_futures",
|
|
2081
|
+
# "contract_unit_currency":"BTC",
|
|
2082
|
+
# "contract_value":"0.001",
|
|
2083
|
+
# "id":139,
|
|
2084
|
+
# "notional_type":"vanilla",
|
|
2085
|
+
# "quoting_asset":{"minimum_precision":2,"precision":6,"symbol":"USDT"},
|
|
2086
|
+
# "settling_asset":{"minimum_precision":2,"precision":6,"symbol":"USDT"},
|
|
2087
|
+
# "symbol":"BTCUSDT",
|
|
2088
|
+
# "tick_size":"0.5",
|
|
2089
|
+
# "underlying_asset":{"minimum_precision":4,"precision":8,"symbol":"BTC"}
|
|
2090
|
+
# },
|
|
2091
|
+
# "product_id":139,
|
|
2092
|
+
# "role":"taker",
|
|
2093
|
+
# "side":"sell",
|
|
2094
|
+
# "size":1
|
|
2095
|
+
# }
|
|
2096
|
+
# ],
|
|
2097
|
+
# "success":true
|
|
2098
|
+
# }
|
|
2099
|
+
#
|
|
2100
|
+
result = self.safe_list(response, 'result', [])
|
|
2101
|
+
return self.parse_trades(result, market, since, limit)
|
|
2102
|
+
|
|
2103
|
+
def fetch_ledger(self, code: Str = None, since: Int = None, limit: Int = None, params={}):
|
|
2104
|
+
"""
|
|
2105
|
+
fetch the history of changes, actions done by the user or operations that altered balance of the user
|
|
2106
|
+
:see: https://docs.delta.exchange/#get-wallet-transactions
|
|
2107
|
+
:param str code: unified currency code, default is None
|
|
2108
|
+
:param int [since]: timestamp in ms of the earliest ledger entry, default is None
|
|
2109
|
+
:param int [limit]: max number of ledger entrys to return, default is None
|
|
2110
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
|
2111
|
+
:returns dict: a `ledger structure <https://docs.ccxt.com/#/?id=ledger-structure>`
|
|
2112
|
+
"""
|
|
2113
|
+
self.load_markets()
|
|
2114
|
+
request: dict = {
|
|
2115
|
+
# 'asset_id': currency['numericId'],
|
|
2116
|
+
# 'end_time': self.seconds(),
|
|
2117
|
+
# 'after': 'string', # after cursor for pagination
|
|
2118
|
+
# 'before': 'string', # before cursor for pagination
|
|
2119
|
+
# 'page_size': limit,
|
|
2120
|
+
}
|
|
2121
|
+
currency = None
|
|
2122
|
+
if code is not None:
|
|
2123
|
+
currency = self.currency(code)
|
|
2124
|
+
request['asset_id'] = currency['numericId']
|
|
2125
|
+
if limit is not None:
|
|
2126
|
+
request['page_size'] = limit
|
|
2127
|
+
response = self.privateGetWalletTransactions(self.extend(request, params))
|
|
2128
|
+
#
|
|
2129
|
+
# {
|
|
2130
|
+
# "meta":{"after":null,"before":null,"limit":10,"total_count":1},
|
|
2131
|
+
# "result":[
|
|
2132
|
+
# {
|
|
2133
|
+
# "amount":"29.889184",
|
|
2134
|
+
# "asset_id":5,
|
|
2135
|
+
# "balance":"29.889184",
|
|
2136
|
+
# "created_at":"2020-11-15T21:25:01Z",
|
|
2137
|
+
# "meta_data":{
|
|
2138
|
+
# "deposit_id":3884,
|
|
2139
|
+
# "transaction_id":"0x41a60174849828530abb5008e98fc63c9b598288743ec4ba9620bcce900a3b8d"
|
|
2140
|
+
# },
|
|
2141
|
+
# "transaction_type":"deposit",
|
|
2142
|
+
# "user_id":22142,
|
|
2143
|
+
# "uuid":"70bb5679da3c4637884e2dc63efaa846"
|
|
2144
|
+
# }
|
|
2145
|
+
# ],
|
|
2146
|
+
# "success":true
|
|
2147
|
+
# }
|
|
2148
|
+
#
|
|
2149
|
+
result = self.safe_list(response, 'result', [])
|
|
2150
|
+
return self.parse_ledger(result, currency, since, limit)
|
|
2151
|
+
|
|
2152
|
+
def parse_ledger_entry_type(self, type):
|
|
2153
|
+
types: dict = {
|
|
2154
|
+
'pnl': 'pnl',
|
|
2155
|
+
'deposit': 'transaction',
|
|
2156
|
+
'withdrawal': 'transaction',
|
|
2157
|
+
'commission': 'fee',
|
|
2158
|
+
'conversion': 'trade',
|
|
2159
|
+
# 'perpetual_futures_funding': 'perpetual_futures_funding',
|
|
2160
|
+
# 'withdrawal_cancellation': 'withdrawal_cancellation',
|
|
2161
|
+
'referral_bonus': 'referral',
|
|
2162
|
+
'commission_rebate': 'rebate',
|
|
2163
|
+
# 'promo_credit': 'promo_credit',
|
|
2164
|
+
}
|
|
2165
|
+
return self.safe_string(types, type, type)
|
|
2166
|
+
|
|
2167
|
+
def parse_ledger_entry(self, item: dict, currency: Currency = None):
|
|
2168
|
+
#
|
|
2169
|
+
# {
|
|
2170
|
+
# "amount":"29.889184",
|
|
2171
|
+
# "asset_id":5,
|
|
2172
|
+
# "balance":"29.889184",
|
|
2173
|
+
# "created_at":"2020-11-15T21:25:01Z",
|
|
2174
|
+
# "meta_data":{
|
|
2175
|
+
# "deposit_id":3884,
|
|
2176
|
+
# "transaction_id":"0x41a60174849828530abb5008e98fc63c9b598288743ec4ba9620bcce900a3b8d"
|
|
2177
|
+
# },
|
|
2178
|
+
# "transaction_type":"deposit",
|
|
2179
|
+
# "user_id":22142,
|
|
2180
|
+
# "uuid":"70bb5679da3c4637884e2dc63efaa846"
|
|
2181
|
+
# }
|
|
2182
|
+
#
|
|
2183
|
+
id = self.safe_string(item, 'uuid')
|
|
2184
|
+
direction = None
|
|
2185
|
+
account = None
|
|
2186
|
+
metaData = self.safe_dict(item, 'meta_data', {})
|
|
2187
|
+
referenceId = self.safe_string(metaData, 'transaction_id')
|
|
2188
|
+
referenceAccount = None
|
|
2189
|
+
type = self.safe_string(item, 'transaction_type')
|
|
2190
|
+
if (type == 'deposit') or (type == 'commission_rebate') or (type == 'referral_bonus') or (type == 'pnl') or (type == 'withdrawal_cancellation') or (type == 'promo_credit'):
|
|
2191
|
+
direction = 'in'
|
|
2192
|
+
elif (type == 'withdrawal') or (type == 'commission') or (type == 'conversion') or (type == 'perpetual_futures_funding'):
|
|
2193
|
+
direction = 'out'
|
|
2194
|
+
type = self.parse_ledger_entry_type(type)
|
|
2195
|
+
currencyId = self.safe_string(item, 'asset_id')
|
|
2196
|
+
currenciesByNumericId = self.safe_dict(self.options, 'currenciesByNumericId')
|
|
2197
|
+
currency = self.safe_value(currenciesByNumericId, currencyId, currency)
|
|
2198
|
+
code = None if (currency is None) else currency['code']
|
|
2199
|
+
amount = self.safe_string(item, 'amount')
|
|
2200
|
+
timestamp = self.parse8601(self.safe_string(item, 'created_at'))
|
|
2201
|
+
after = self.safe_string(item, 'balance')
|
|
2202
|
+
before = Precise.string_max('0', Precise.string_sub(after, amount))
|
|
2203
|
+
status = 'ok'
|
|
2204
|
+
return {
|
|
2205
|
+
'info': item,
|
|
2206
|
+
'id': id,
|
|
2207
|
+
'direction': direction,
|
|
2208
|
+
'account': account,
|
|
2209
|
+
'referenceId': referenceId,
|
|
2210
|
+
'referenceAccount': referenceAccount,
|
|
2211
|
+
'type': type,
|
|
2212
|
+
'currency': code,
|
|
2213
|
+
'amount': self.parse_number(amount),
|
|
2214
|
+
'before': self.parse_number(before),
|
|
2215
|
+
'after': self.parse_number(after),
|
|
2216
|
+
'status': status,
|
|
2217
|
+
'timestamp': timestamp,
|
|
2218
|
+
'datetime': self.iso8601(timestamp),
|
|
2219
|
+
'fee': None,
|
|
2220
|
+
}
|
|
2221
|
+
|
|
2222
|
+
def fetch_deposit_address(self, code: str, params={}):
|
|
2223
|
+
"""
|
|
2224
|
+
fetch the deposit address for a currency associated with self account
|
|
2225
|
+
:param str code: unified currency code
|
|
2226
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
|
2227
|
+
:param str [params.network]: unified network code
|
|
2228
|
+
:returns dict: an `address structure <https://docs.ccxt.com/#/?id=address-structure>`
|
|
2229
|
+
"""
|
|
2230
|
+
self.load_markets()
|
|
2231
|
+
currency = self.currency(code)
|
|
2232
|
+
request: dict = {
|
|
2233
|
+
'asset_symbol': currency['id'],
|
|
2234
|
+
}
|
|
2235
|
+
networkCode = self.safe_string_upper(params, 'network')
|
|
2236
|
+
if networkCode is not None:
|
|
2237
|
+
request['network'] = self.network_code_to_id(networkCode, code)
|
|
2238
|
+
params = self.omit(params, 'network')
|
|
2239
|
+
response = self.privateGetDepositsAddress(self.extend(request, params))
|
|
2240
|
+
#
|
|
2241
|
+
# {
|
|
2242
|
+
# "success": True,
|
|
2243
|
+
# "result": {
|
|
2244
|
+
# "id": 1915615,
|
|
2245
|
+
# "user_id": 27854758,
|
|
2246
|
+
# "address": "TXYB4GdKsXKEWbeSNPsmGZu4ZVCkhVh1Zz",
|
|
2247
|
+
# "memo": "",
|
|
2248
|
+
# "status": "active",
|
|
2249
|
+
# "updated_at": "2023-01-12T06:03:46.000Z",
|
|
2250
|
+
# "created_at": "2023-01-12T06:03:46.000Z",
|
|
2251
|
+
# "asset_symbol": "USDT",
|
|
2252
|
+
# "network": "TRC20(TRON)",
|
|
2253
|
+
# "custodian": "fireblocks"
|
|
2254
|
+
# }
|
|
2255
|
+
# }
|
|
2256
|
+
#
|
|
2257
|
+
result = self.safe_dict(response, 'result', {})
|
|
2258
|
+
return self.parse_deposit_address(result, currency)
|
|
2259
|
+
|
|
2260
|
+
def parse_deposit_address(self, depositAddress, currency: Currency = None):
|
|
2261
|
+
#
|
|
2262
|
+
# {
|
|
2263
|
+
# "id": 1915615,
|
|
2264
|
+
# "user_id": 27854758,
|
|
2265
|
+
# "address": "TXYB4GdKsXKEWbeSNPsmGZu4ZVCkhVh1Zz",
|
|
2266
|
+
# "memo": "",
|
|
2267
|
+
# "status": "active",
|
|
2268
|
+
# "updated_at": "2023-01-12T06:03:46.000Z",
|
|
2269
|
+
# "created_at": "2023-01-12T06:03:46.000Z",
|
|
2270
|
+
# "asset_symbol": "USDT",
|
|
2271
|
+
# "network": "TRC20(TRON)",
|
|
2272
|
+
# "custodian": "fireblocks"
|
|
2273
|
+
# }
|
|
2274
|
+
#
|
|
2275
|
+
address = self.safe_string(depositAddress, 'address')
|
|
2276
|
+
marketId = self.safe_string(depositAddress, 'asset_symbol')
|
|
2277
|
+
networkId = self.safe_string(depositAddress, 'network')
|
|
2278
|
+
self.check_address(address)
|
|
2279
|
+
return {
|
|
2280
|
+
'currency': self.safe_currency_code(marketId, currency),
|
|
2281
|
+
'address': address,
|
|
2282
|
+
'tag': self.safe_string(depositAddress, 'memo'),
|
|
2283
|
+
'network': self.network_id_to_code(networkId),
|
|
2284
|
+
'info': depositAddress,
|
|
2285
|
+
}
|
|
2286
|
+
|
|
2287
|
+
def fetch_funding_rate(self, symbol: str, params={}):
|
|
2288
|
+
"""
|
|
2289
|
+
fetch the current funding rate
|
|
2290
|
+
:see: https://docs.delta.exchange/#get-ticker-for-a-product-by-symbol
|
|
2291
|
+
:param str symbol: unified market symbol
|
|
2292
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
|
2293
|
+
:returns dict: a `funding rate structure <https://docs.ccxt.com/#/?id=funding-rate-structure>`
|
|
2294
|
+
"""
|
|
2295
|
+
self.load_markets()
|
|
2296
|
+
market = self.market(symbol)
|
|
2297
|
+
if not market['swap']:
|
|
2298
|
+
raise BadSymbol(self.id + ' fetchFundingRate() supports swap contracts only')
|
|
2299
|
+
request: dict = {
|
|
2300
|
+
'symbol': market['id'],
|
|
2301
|
+
}
|
|
2302
|
+
response = self.publicGetTickersSymbol(self.extend(request, params))
|
|
2303
|
+
#
|
|
2304
|
+
# {
|
|
2305
|
+
# "result": {
|
|
2306
|
+
# "close": 30600.5,
|
|
2307
|
+
# "contract_type": "perpetual_futures",
|
|
2308
|
+
# "funding_rate": "0.00602961",
|
|
2309
|
+
# "greeks": null,
|
|
2310
|
+
# "high": 30803.0,
|
|
2311
|
+
# "low": 30265.5,
|
|
2312
|
+
# "mark_basis": "-0.45601594",
|
|
2313
|
+
# "mark_price": "30600.10481568",
|
|
2314
|
+
# "oi": "469.9190",
|
|
2315
|
+
# "oi_change_usd_6h": "2226314.9900",
|
|
2316
|
+
# "oi_contracts": "469919",
|
|
2317
|
+
# "oi_value": "469.9190",
|
|
2318
|
+
# "oi_value_symbol": "BTC",
|
|
2319
|
+
# "oi_value_usd": "14385640.6802",
|
|
2320
|
+
# "open": 30458.5,
|
|
2321
|
+
# "price_band": {
|
|
2322
|
+
# "lower_limit": "29067.08312627",
|
|
2323
|
+
# "upper_limit": "32126.77608693"
|
|
2324
|
+
# },
|
|
2325
|
+
# "product_id": 139,
|
|
2326
|
+
# "quotes": {
|
|
2327
|
+
# "ask_iv": null,
|
|
2328
|
+
# "ask_size": "965",
|
|
2329
|
+
# "best_ask": "30600.5",
|
|
2330
|
+
# "best_bid": "30599.5",
|
|
2331
|
+
# "bid_iv": null,
|
|
2332
|
+
# "bid_size": "196",
|
|
2333
|
+
# "impact_mid_price": null,
|
|
2334
|
+
# "mark_iv": "-0.44931641"
|
|
2335
|
+
# },
|
|
2336
|
+
# "size": 1226303,
|
|
2337
|
+
# "spot_price": "30612.85362773",
|
|
2338
|
+
# "symbol": "BTCUSDT",
|
|
2339
|
+
# "timestamp": 1689136597460456,
|
|
2340
|
+
# "turnover": 37392218.45999999,
|
|
2341
|
+
# "turnover_symbol": "USDT",
|
|
2342
|
+
# "turnover_usd": 37392218.45999999,
|
|
2343
|
+
# "volume": 1226.3029999999485
|
|
2344
|
+
# },
|
|
2345
|
+
# "success": True
|
|
2346
|
+
# }
|
|
2347
|
+
#
|
|
2348
|
+
result = self.safe_dict(response, 'result', {})
|
|
2349
|
+
return self.parse_funding_rate(result, market)
|
|
2350
|
+
|
|
2351
|
+
def fetch_funding_rates(self, symbols: Strings = None, params={}):
|
|
2352
|
+
"""
|
|
2353
|
+
fetch the funding rate for multiple markets
|
|
2354
|
+
:see: https://docs.delta.exchange/#get-tickers-for-products
|
|
2355
|
+
:param str[]|None symbols: list of unified market symbols
|
|
2356
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
|
2357
|
+
:returns dict: a dictionary of `funding rates structures <https://docs.ccxt.com/#/?id=funding-rates-structure>`, indexe by market symbols
|
|
2358
|
+
"""
|
|
2359
|
+
self.load_markets()
|
|
2360
|
+
symbols = self.market_symbols(symbols)
|
|
2361
|
+
request: dict = {
|
|
2362
|
+
'contract_types': 'perpetual_futures',
|
|
2363
|
+
}
|
|
2364
|
+
response = self.publicGetTickers(self.extend(request, params))
|
|
2365
|
+
#
|
|
2366
|
+
# {
|
|
2367
|
+
# "result": [
|
|
2368
|
+
# {
|
|
2369
|
+
# "close": 30600.5,
|
|
2370
|
+
# "contract_type": "perpetual_futures",
|
|
2371
|
+
# "funding_rate": "0.00602961",
|
|
2372
|
+
# "greeks": null,
|
|
2373
|
+
# "high": 30803.0,
|
|
2374
|
+
# "low": 30265.5,
|
|
2375
|
+
# "mark_basis": "-0.45601594",
|
|
2376
|
+
# "mark_price": "30600.10481568",
|
|
2377
|
+
# "oi": "469.9190",
|
|
2378
|
+
# "oi_change_usd_6h": "2226314.9900",
|
|
2379
|
+
# "oi_contracts": "469919",
|
|
2380
|
+
# "oi_value": "469.9190",
|
|
2381
|
+
# "oi_value_symbol": "BTC",
|
|
2382
|
+
# "oi_value_usd": "14385640.6802",
|
|
2383
|
+
# "open": 30458.5,
|
|
2384
|
+
# "price_band": {
|
|
2385
|
+
# "lower_limit": "29067.08312627",
|
|
2386
|
+
# "upper_limit": "32126.77608693"
|
|
2387
|
+
# },
|
|
2388
|
+
# "product_id": 139,
|
|
2389
|
+
# "quotes": {
|
|
2390
|
+
# "ask_iv": null,
|
|
2391
|
+
# "ask_size": "965",
|
|
2392
|
+
# "best_ask": "30600.5",
|
|
2393
|
+
# "best_bid": "30599.5",
|
|
2394
|
+
# "bid_iv": null,
|
|
2395
|
+
# "bid_size": "196",
|
|
2396
|
+
# "impact_mid_price": null,
|
|
2397
|
+
# "mark_iv": "-0.44931641"
|
|
2398
|
+
# },
|
|
2399
|
+
# "size": 1226303,
|
|
2400
|
+
# "spot_price": "30612.85362773",
|
|
2401
|
+
# "symbol": "BTCUSDT",
|
|
2402
|
+
# "timestamp": 1689136597460456,
|
|
2403
|
+
# "turnover": 37392218.45999999,
|
|
2404
|
+
# "turnover_symbol": "USDT",
|
|
2405
|
+
# "turnover_usd": 37392218.45999999,
|
|
2406
|
+
# "volume": 1226.3029999999485
|
|
2407
|
+
# },
|
|
2408
|
+
# ],
|
|
2409
|
+
# "success":true
|
|
2410
|
+
# }
|
|
2411
|
+
#
|
|
2412
|
+
rates = self.safe_list(response, 'result', [])
|
|
2413
|
+
result = self.parse_funding_rates(rates)
|
|
2414
|
+
return self.filter_by_array(result, 'symbol', symbols)
|
|
2415
|
+
|
|
2416
|
+
def parse_funding_rate(self, contract, market: Market = None):
|
|
2417
|
+
#
|
|
2418
|
+
# {
|
|
2419
|
+
# "close": 30600.5,
|
|
2420
|
+
# "contract_type": "perpetual_futures",
|
|
2421
|
+
# "funding_rate": "0.00602961",
|
|
2422
|
+
# "greeks": null,
|
|
2423
|
+
# "high": 30803.0,
|
|
2424
|
+
# "low": 30265.5,
|
|
2425
|
+
# "mark_basis": "-0.45601594",
|
|
2426
|
+
# "mark_price": "30600.10481568",
|
|
2427
|
+
# "oi": "469.9190",
|
|
2428
|
+
# "oi_change_usd_6h": "2226314.9900",
|
|
2429
|
+
# "oi_contracts": "469919",
|
|
2430
|
+
# "oi_value": "469.9190",
|
|
2431
|
+
# "oi_value_symbol": "BTC",
|
|
2432
|
+
# "oi_value_usd": "14385640.6802",
|
|
2433
|
+
# "open": 30458.5,
|
|
2434
|
+
# "price_band": {
|
|
2435
|
+
# "lower_limit": "29067.08312627",
|
|
2436
|
+
# "upper_limit": "32126.77608693"
|
|
2437
|
+
# },
|
|
2438
|
+
# "product_id": 139,
|
|
2439
|
+
# "quotes": {
|
|
2440
|
+
# "ask_iv": null,
|
|
2441
|
+
# "ask_size": "965",
|
|
2442
|
+
# "best_ask": "30600.5",
|
|
2443
|
+
# "best_bid": "30599.5",
|
|
2444
|
+
# "bid_iv": null,
|
|
2445
|
+
# "bid_size": "196",
|
|
2446
|
+
# "impact_mid_price": null,
|
|
2447
|
+
# "mark_iv": "-0.44931641"
|
|
2448
|
+
# },
|
|
2449
|
+
# "size": 1226303,
|
|
2450
|
+
# "spot_price": "30612.85362773",
|
|
2451
|
+
# "symbol": "BTCUSDT",
|
|
2452
|
+
# "timestamp": 1689136597460456,
|
|
2453
|
+
# "turnover": 37392218.45999999,
|
|
2454
|
+
# "turnover_symbol": "USDT",
|
|
2455
|
+
# "turnover_usd": 37392218.45999999,
|
|
2456
|
+
# "volume": 1226.3029999999485
|
|
2457
|
+
# }
|
|
2458
|
+
#
|
|
2459
|
+
timestamp = self.safe_integer_product(contract, 'timestamp', 0.001)
|
|
2460
|
+
marketId = self.safe_string(contract, 'symbol')
|
|
2461
|
+
fundingRateString = self.safe_string(contract, 'funding_rate')
|
|
2462
|
+
fundingRate = Precise.string_div(fundingRateString, '100')
|
|
2463
|
+
return {
|
|
2464
|
+
'info': contract,
|
|
2465
|
+
'symbol': self.safe_symbol(marketId, market),
|
|
2466
|
+
'markPrice': self.safe_number(contract, 'mark_price'),
|
|
2467
|
+
'indexPrice': self.safe_number(contract, 'spot_price'),
|
|
2468
|
+
'interestRate': None,
|
|
2469
|
+
'estimatedSettlePrice': None,
|
|
2470
|
+
'timestamp': timestamp,
|
|
2471
|
+
'datetime': self.iso8601(timestamp),
|
|
2472
|
+
'fundingRate': self.parse_number(fundingRate),
|
|
2473
|
+
'fundingTimestamp': None,
|
|
2474
|
+
'fundingDatetime': None,
|
|
2475
|
+
'nextFundingRate': None,
|
|
2476
|
+
'nextFundingTimestamp': None,
|
|
2477
|
+
'nextFundingDatetime': None,
|
|
2478
|
+
'previousFundingRate': None,
|
|
2479
|
+
'previousFundingTimestamp': None,
|
|
2480
|
+
'previousFundingDatetime': None,
|
|
2481
|
+
}
|
|
2482
|
+
|
|
2483
|
+
def add_margin(self, symbol: str, amount: float, params={}) -> MarginModification:
|
|
2484
|
+
"""
|
|
2485
|
+
add margin
|
|
2486
|
+
:see: https://docs.delta.exchange/#add-remove-position-margin
|
|
2487
|
+
:param str symbol: unified market symbol
|
|
2488
|
+
:param float amount: amount of margin to add
|
|
2489
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
|
2490
|
+
:returns dict: a `margin structure <https://docs.ccxt.com/#/?id=add-margin-structure>`
|
|
2491
|
+
"""
|
|
2492
|
+
return self.modify_margin_helper(symbol, amount, 'add', params)
|
|
2493
|
+
|
|
2494
|
+
def reduce_margin(self, symbol: str, amount: float, params={}) -> MarginModification:
|
|
2495
|
+
"""
|
|
2496
|
+
remove margin from a position
|
|
2497
|
+
:see: https://docs.delta.exchange/#add-remove-position-margin
|
|
2498
|
+
:param str symbol: unified market symbol
|
|
2499
|
+
:param float amount: the amount of margin to remove
|
|
2500
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
|
2501
|
+
:returns dict: a `margin structure <https://docs.ccxt.com/#/?id=reduce-margin-structure>`
|
|
2502
|
+
"""
|
|
2503
|
+
return self.modify_margin_helper(symbol, amount, 'reduce', params)
|
|
2504
|
+
|
|
2505
|
+
def modify_margin_helper(self, symbol: str, amount, type, params={}) -> MarginModification:
|
|
2506
|
+
self.load_markets()
|
|
2507
|
+
market = self.market(symbol)
|
|
2508
|
+
amount = str(amount)
|
|
2509
|
+
if type == 'reduce':
|
|
2510
|
+
amount = Precise.string_mul(amount, '-1')
|
|
2511
|
+
request: dict = {
|
|
2512
|
+
'product_id': market['numericId'],
|
|
2513
|
+
'delta_margin': amount,
|
|
2514
|
+
}
|
|
2515
|
+
response = self.privatePostPositionsChangeMargin(self.extend(request, params))
|
|
2516
|
+
#
|
|
2517
|
+
# {
|
|
2518
|
+
# "result": {
|
|
2519
|
+
# "auto_topup": False,
|
|
2520
|
+
# "bankruptcy_price": "24934.12",
|
|
2521
|
+
# "commission": "0.01197072",
|
|
2522
|
+
# "created_at": "2023-07-20T03:49:09.159401Z",
|
|
2523
|
+
# "entry_price": "29926.8",
|
|
2524
|
+
# "liquidation_price": "25083.754",
|
|
2525
|
+
# "margin": "4.99268",
|
|
2526
|
+
# "margin_mode": "isolated",
|
|
2527
|
+
# "product_id": 84,
|
|
2528
|
+
# "product_symbol": "BTCUSDT",
|
|
2529
|
+
# "realized_cashflow": "0",
|
|
2530
|
+
# "realized_funding": "0",
|
|
2531
|
+
# "realized_pnl": "0",
|
|
2532
|
+
# "size": 1,
|
|
2533
|
+
# "updated_at": "2023-07-20T03:49:09.159401Z",
|
|
2534
|
+
# "user_id": 30084879
|
|
2535
|
+
# },
|
|
2536
|
+
# "success": True
|
|
2537
|
+
# }
|
|
2538
|
+
#
|
|
2539
|
+
result = self.safe_dict(response, 'result', {})
|
|
2540
|
+
return self.parse_margin_modification(result, market)
|
|
2541
|
+
|
|
2542
|
+
def parse_margin_modification(self, data: dict, market: Market = None) -> MarginModification:
|
|
2543
|
+
#
|
|
2544
|
+
# {
|
|
2545
|
+
# "auto_topup": False,
|
|
2546
|
+
# "bankruptcy_price": "24934.12",
|
|
2547
|
+
# "commission": "0.01197072",
|
|
2548
|
+
# "created_at": "2023-07-20T03:49:09.159401Z",
|
|
2549
|
+
# "entry_price": "29926.8",
|
|
2550
|
+
# "liquidation_price": "25083.754",
|
|
2551
|
+
# "margin": "4.99268",
|
|
2552
|
+
# "margin_mode": "isolated",
|
|
2553
|
+
# "product_id": 84,
|
|
2554
|
+
# "product_symbol": "BTCUSDT",
|
|
2555
|
+
# "realized_cashflow": "0",
|
|
2556
|
+
# "realized_funding": "0",
|
|
2557
|
+
# "realized_pnl": "0",
|
|
2558
|
+
# "size": 1,
|
|
2559
|
+
# "updated_at": "2023-07-20T03:49:09.159401Z",
|
|
2560
|
+
# "user_id": 30084879
|
|
2561
|
+
# }
|
|
2562
|
+
#
|
|
2563
|
+
marketId = self.safe_string(data, 'product_symbol')
|
|
2564
|
+
market = self.safe_market(marketId, market)
|
|
2565
|
+
return {
|
|
2566
|
+
'info': data,
|
|
2567
|
+
'symbol': market['symbol'],
|
|
2568
|
+
'type': None,
|
|
2569
|
+
'marginMode': 'isolated',
|
|
2570
|
+
'amount': None,
|
|
2571
|
+
'total': self.safe_number(data, 'margin'),
|
|
2572
|
+
'code': None,
|
|
2573
|
+
'status': None,
|
|
2574
|
+
'timestamp': None,
|
|
2575
|
+
'datetime': None,
|
|
2576
|
+
}
|
|
2577
|
+
|
|
2578
|
+
def fetch_open_interest(self, symbol: str, params={}):
|
|
2579
|
+
"""
|
|
2580
|
+
retrieves the open interest of a derivative market
|
|
2581
|
+
:see: https://docs.delta.exchange/#get-ticker-for-a-product-by-symbol
|
|
2582
|
+
:param str symbol: unified market symbol
|
|
2583
|
+
:param dict [params]: exchange specific parameters
|
|
2584
|
+
:returns dict} an open interest structure{@link https://docs.ccxt.com/#/?id=open-interest-structure:
|
|
2585
|
+
"""
|
|
2586
|
+
self.load_markets()
|
|
2587
|
+
market = self.market(symbol)
|
|
2588
|
+
if not market['contract']:
|
|
2589
|
+
raise BadRequest(self.id + ' fetchOpenInterest() supports contract markets only')
|
|
2590
|
+
request: dict = {
|
|
2591
|
+
'symbol': market['id'],
|
|
2592
|
+
}
|
|
2593
|
+
response = self.publicGetTickersSymbol(self.extend(request, params))
|
|
2594
|
+
#
|
|
2595
|
+
# {
|
|
2596
|
+
# "result": {
|
|
2597
|
+
# "close": 894.0,
|
|
2598
|
+
# "contract_type": "call_options",
|
|
2599
|
+
# "greeks": {
|
|
2600
|
+
# "delta": "0.67324861",
|
|
2601
|
+
# "gamma": "0.00022178",
|
|
2602
|
+
# "rho": "4.34638266",
|
|
2603
|
+
# "spot": "30178.53195697",
|
|
2604
|
+
# "theta": "-35.64972577",
|
|
2605
|
+
# "vega": "16.34381277"
|
|
2606
|
+
# },
|
|
2607
|
+
# "high": 946.0,
|
|
2608
|
+
# "low": 893.0,
|
|
2609
|
+
# "mark_price": "1037.07582681",
|
|
2610
|
+
# "mark_vol": "0.35899491",
|
|
2611
|
+
# "oi": "0.0910",
|
|
2612
|
+
# "oi_change_usd_6h": "-90.5500",
|
|
2613
|
+
# "oi_contracts": "91",
|
|
2614
|
+
# "oi_value": "0.0910",
|
|
2615
|
+
# "oi_value_symbol": "BTC",
|
|
2616
|
+
# "oi_value_usd": "2746.3549",
|
|
2617
|
+
# "open": 946.0,
|
|
2618
|
+
# "price_band": {
|
|
2619
|
+
# "lower_limit": "133.37794509",
|
|
2620
|
+
# "upper_limit": "5663.66930164"
|
|
2621
|
+
# },
|
|
2622
|
+
# "product_id": 116171,
|
|
2623
|
+
# "quotes": {
|
|
2624
|
+
# "ask_iv": "0.36932389",
|
|
2625
|
+
# "ask_size": "1321",
|
|
2626
|
+
# "best_ask": "1054",
|
|
2627
|
+
# "best_bid": "1020",
|
|
2628
|
+
# "bid_iv": "0.34851914",
|
|
2629
|
+
# "bid_size": "2202",
|
|
2630
|
+
# "impact_mid_price": null,
|
|
2631
|
+
# "mark_iv": "0.35896335"
|
|
2632
|
+
# },
|
|
2633
|
+
# "size": 152,
|
|
2634
|
+
# "spot_price": "30178.53195697",
|
|
2635
|
+
# "strike_price": "29500",
|
|
2636
|
+
# "symbol": "C-BTC-29500-280723",
|
|
2637
|
+
# "timestamp": 1689834695286094,
|
|
2638
|
+
# "turnover": 4546.601744940001,
|
|
2639
|
+
# "turnover_symbol": "USDT",
|
|
2640
|
+
# "turnover_usd": 4546.601744940001,
|
|
2641
|
+
# "volume": 0.15200000000000002
|
|
2642
|
+
# },
|
|
2643
|
+
# "success": True
|
|
2644
|
+
# }
|
|
2645
|
+
#
|
|
2646
|
+
result = self.safe_dict(response, 'result', {})
|
|
2647
|
+
return self.parse_open_interest(result, market)
|
|
2648
|
+
|
|
2649
|
+
def parse_open_interest(self, interest, market: Market = None):
|
|
2650
|
+
#
|
|
2651
|
+
# {
|
|
2652
|
+
# "close": 894.0,
|
|
2653
|
+
# "contract_type": "call_options",
|
|
2654
|
+
# "greeks": {
|
|
2655
|
+
# "delta": "0.67324861",
|
|
2656
|
+
# "gamma": "0.00022178",
|
|
2657
|
+
# "rho": "4.34638266",
|
|
2658
|
+
# "spot": "30178.53195697",
|
|
2659
|
+
# "theta": "-35.64972577",
|
|
2660
|
+
# "vega": "16.34381277"
|
|
2661
|
+
# },
|
|
2662
|
+
# "high": 946.0,
|
|
2663
|
+
# "low": 893.0,
|
|
2664
|
+
# "mark_price": "1037.07582681",
|
|
2665
|
+
# "mark_vol": "0.35899491",
|
|
2666
|
+
# "oi": "0.0910",
|
|
2667
|
+
# "oi_change_usd_6h": "-90.5500",
|
|
2668
|
+
# "oi_contracts": "91",
|
|
2669
|
+
# "oi_value": "0.0910",
|
|
2670
|
+
# "oi_value_symbol": "BTC",
|
|
2671
|
+
# "oi_value_usd": "2746.3549",
|
|
2672
|
+
# "open": 946.0,
|
|
2673
|
+
# "price_band": {
|
|
2674
|
+
# "lower_limit": "133.37794509",
|
|
2675
|
+
# "upper_limit": "5663.66930164"
|
|
2676
|
+
# },
|
|
2677
|
+
# "product_id": 116171,
|
|
2678
|
+
# "quotes": {
|
|
2679
|
+
# "ask_iv": "0.36932389",
|
|
2680
|
+
# "ask_size": "1321",
|
|
2681
|
+
# "best_ask": "1054",
|
|
2682
|
+
# "best_bid": "1020",
|
|
2683
|
+
# "bid_iv": "0.34851914",
|
|
2684
|
+
# "bid_size": "2202",
|
|
2685
|
+
# "impact_mid_price": null,
|
|
2686
|
+
# "mark_iv": "0.35896335"
|
|
2687
|
+
# },
|
|
2688
|
+
# "size": 152,
|
|
2689
|
+
# "spot_price": "30178.53195697",
|
|
2690
|
+
# "strike_price": "29500",
|
|
2691
|
+
# "symbol": "C-BTC-29500-280723",
|
|
2692
|
+
# "timestamp": 1689834695286094,
|
|
2693
|
+
# "turnover": 4546.601744940001,
|
|
2694
|
+
# "turnover_symbol": "USDT",
|
|
2695
|
+
# "turnover_usd": 4546.601744940001,
|
|
2696
|
+
# "volume": 0.15200000000000002
|
|
2697
|
+
# }
|
|
2698
|
+
#
|
|
2699
|
+
timestamp = self.safe_integer_product(interest, 'timestamp', 0.001)
|
|
2700
|
+
marketId = self.safe_string(interest, 'symbol')
|
|
2701
|
+
return self.safe_open_interest({
|
|
2702
|
+
'symbol': self.safe_symbol(marketId, market),
|
|
2703
|
+
'baseVolume': self.safe_number(interest, 'oi_value'),
|
|
2704
|
+
'quoteVolume': self.safe_number(interest, 'oi_value_usd'),
|
|
2705
|
+
'openInterestAmount': self.safe_number(interest, 'oi_contracts'),
|
|
2706
|
+
'openInterestValue': self.safe_number(interest, 'oi'),
|
|
2707
|
+
'timestamp': timestamp,
|
|
2708
|
+
'datetime': self.iso8601(timestamp),
|
|
2709
|
+
'info': interest,
|
|
2710
|
+
}, market)
|
|
2711
|
+
|
|
2712
|
+
def fetch_leverage(self, symbol: str, params={}) -> Leverage:
|
|
2713
|
+
"""
|
|
2714
|
+
fetch the set leverage for a market
|
|
2715
|
+
:see: https://docs.delta.exchange/#get-order-leverage
|
|
2716
|
+
:param str symbol: unified market symbol
|
|
2717
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
|
2718
|
+
:returns dict: a `leverage structure <https://docs.ccxt.com/#/?id=leverage-structure>`
|
|
2719
|
+
"""
|
|
2720
|
+
self.load_markets()
|
|
2721
|
+
market = self.market(symbol)
|
|
2722
|
+
request: dict = {
|
|
2723
|
+
'product_id': market['numericId'],
|
|
2724
|
+
}
|
|
2725
|
+
response = self.privateGetProductsProductIdOrdersLeverage(self.extend(request, params))
|
|
2726
|
+
#
|
|
2727
|
+
# {
|
|
2728
|
+
# "result": {
|
|
2729
|
+
# "index_symbol": null,
|
|
2730
|
+
# "leverage": "10",
|
|
2731
|
+
# "margin_mode": "isolated",
|
|
2732
|
+
# "order_margin": "0",
|
|
2733
|
+
# "product_id": 84,
|
|
2734
|
+
# "user_id": 30084879
|
|
2735
|
+
# },
|
|
2736
|
+
# "success": True
|
|
2737
|
+
# }
|
|
2738
|
+
#
|
|
2739
|
+
result = self.safe_dict(response, 'result', {})
|
|
2740
|
+
return self.parse_leverage(result, market)
|
|
2741
|
+
|
|
2742
|
+
def parse_leverage(self, leverage: dict, market: Market = None) -> Leverage:
|
|
2743
|
+
marketId = self.safe_string(leverage, 'index_symbol')
|
|
2744
|
+
leverageValue = self.safe_integer(leverage, 'leverage')
|
|
2745
|
+
return {
|
|
2746
|
+
'info': leverage,
|
|
2747
|
+
'symbol': self.safe_symbol(marketId, market),
|
|
2748
|
+
'marginMode': self.safe_string_lower(leverage, 'margin_mode'),
|
|
2749
|
+
'longLeverage': leverageValue,
|
|
2750
|
+
'shortLeverage': leverageValue,
|
|
2751
|
+
}
|
|
2752
|
+
|
|
2753
|
+
def set_leverage(self, leverage: Int, symbol: Str = None, params={}):
|
|
2754
|
+
"""
|
|
2755
|
+
set the level of leverage for a market
|
|
2756
|
+
:see: https://docs.delta.exchange/#change-order-leverage
|
|
2757
|
+
:param float leverage: the rate of leverage
|
|
2758
|
+
:param str symbol: unified market symbol
|
|
2759
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
|
2760
|
+
:returns dict: response from the exchange
|
|
2761
|
+
"""
|
|
2762
|
+
if symbol is None:
|
|
2763
|
+
raise ArgumentsRequired(self.id + ' setLeverage() requires a symbol argument')
|
|
2764
|
+
self.load_markets()
|
|
2765
|
+
market = self.market(symbol)
|
|
2766
|
+
request: dict = {
|
|
2767
|
+
'product_id': market['numericId'],
|
|
2768
|
+
'leverage': leverage,
|
|
2769
|
+
}
|
|
2770
|
+
#
|
|
2771
|
+
# {
|
|
2772
|
+
# "result": {
|
|
2773
|
+
# "leverage": "20",
|
|
2774
|
+
# "margin_mode": "isolated",
|
|
2775
|
+
# "order_margin": "0",
|
|
2776
|
+
# "product_id": 84
|
|
2777
|
+
# },
|
|
2778
|
+
# "success": True
|
|
2779
|
+
# }
|
|
2780
|
+
#
|
|
2781
|
+
return self.privatePostProductsProductIdOrdersLeverage(self.extend(request, params))
|
|
2782
|
+
|
|
2783
|
+
def fetch_settlement_history(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
|
|
2784
|
+
"""
|
|
2785
|
+
fetches historical settlement records
|
|
2786
|
+
:see: https://docs.delta.exchange/#get-product-settlement-prices
|
|
2787
|
+
:param str symbol: unified market symbol of the settlement history
|
|
2788
|
+
:param int [since]: timestamp in ms
|
|
2789
|
+
:param int [limit]: number of records
|
|
2790
|
+
:param dict [params]: exchange specific params
|
|
2791
|
+
:returns dict[]: a list of `settlement history objects <https://docs.ccxt.com/#/?id=settlement-history-structure>`
|
|
2792
|
+
"""
|
|
2793
|
+
self.load_markets()
|
|
2794
|
+
market = None
|
|
2795
|
+
if symbol is not None:
|
|
2796
|
+
market = self.market(symbol)
|
|
2797
|
+
request: dict = {
|
|
2798
|
+
'states': 'expired',
|
|
2799
|
+
}
|
|
2800
|
+
if limit is not None:
|
|
2801
|
+
request['page_size'] = limit
|
|
2802
|
+
response = self.publicGetProducts(self.extend(request, params))
|
|
2803
|
+
#
|
|
2804
|
+
# {
|
|
2805
|
+
# "result": [
|
|
2806
|
+
# {
|
|
2807
|
+
# "contract_value": "0.001",
|
|
2808
|
+
# "basis_factor_max_limit": "10.95",
|
|
2809
|
+
# "maker_commission_rate": "0.0003",
|
|
2810
|
+
# "launch_time": "2023-07-19T04:30:03Z",
|
|
2811
|
+
# "trading_status": "operational",
|
|
2812
|
+
# "product_specs": {
|
|
2813
|
+
# "backup_vol_expiry_time": 31536000,
|
|
2814
|
+
# "max_deviation_from_external_vol": 0.75,
|
|
2815
|
+
# "max_lower_deviation_from_external_vol": 0.75,
|
|
2816
|
+
# "max_upper_deviation_from_external_vol": 0.5,
|
|
2817
|
+
# "max_volatility": 3,
|
|
2818
|
+
# "min_volatility": 0.1,
|
|
2819
|
+
# "premium_commission_rate": 0.1,
|
|
2820
|
+
# "settlement_index_price": "29993.536675710806",
|
|
2821
|
+
# "vol_calculation_method": "orderbook",
|
|
2822
|
+
# "vol_expiry_time": 31536000
|
|
2823
|
+
# },
|
|
2824
|
+
# "description": "BTC call option expiring on 19-7-2023",
|
|
2825
|
+
# "settlement_price": "0",
|
|
2826
|
+
# "disruption_reason": null,
|
|
2827
|
+
# "settling_asset": {},
|
|
2828
|
+
# "initial_margin": "1",
|
|
2829
|
+
# "tick_size": "0.1",
|
|
2830
|
+
# "maintenance_margin": "0.5",
|
|
2831
|
+
# "id": 117542,
|
|
2832
|
+
# "notional_type": "vanilla",
|
|
2833
|
+
# "ui_config": {},
|
|
2834
|
+
# "contract_unit_currency": "BTC",
|
|
2835
|
+
# "symbol": "C-BTC-30900-190723",
|
|
2836
|
+
# "insurance_fund_margin_contribution": "1",
|
|
2837
|
+
# "price_band": "2",
|
|
2838
|
+
# "annualized_funding": "10.95",
|
|
2839
|
+
# "impact_size": 200,
|
|
2840
|
+
# "contract_type": "call_options",
|
|
2841
|
+
# "position_size_limit": 255633,
|
|
2842
|
+
# "max_leverage_notional": "200000",
|
|
2843
|
+
# "initial_margin_scaling_factor": "0.000002",
|
|
2844
|
+
# "strike_price": "30900",
|
|
2845
|
+
# "is_quanto": False,
|
|
2846
|
+
# "settlement_time": "2023-07-19T12:00:00Z",
|
|
2847
|
+
# "liquidation_penalty_factor": "0.5",
|
|
2848
|
+
# "funding_method": "mark_price",
|
|
2849
|
+
# "taker_commission_rate": "0.0003",
|
|
2850
|
+
# "default_leverage": "100.000000000000000000",
|
|
2851
|
+
# "state": "expired",
|
|
2852
|
+
# "auction_start_time": null,
|
|
2853
|
+
# "short_description": "BTC Call",
|
|
2854
|
+
# "quoting_asset": {},
|
|
2855
|
+
# "maintenance_margin_scaling_factor":"0.000002"
|
|
2856
|
+
# }
|
|
2857
|
+
# ],
|
|
2858
|
+
# "success": True
|
|
2859
|
+
# }
|
|
2860
|
+
#
|
|
2861
|
+
result = self.safe_list(response, 'result', [])
|
|
2862
|
+
settlements = self.parse_settlements(result, market)
|
|
2863
|
+
sorted = self.sort_by(settlements, 'timestamp')
|
|
2864
|
+
return self.filter_by_symbol_since_limit(sorted, market['symbol'], since, limit)
|
|
2865
|
+
|
|
2866
|
+
def parse_settlement(self, settlement, market):
|
|
2867
|
+
#
|
|
2868
|
+
# {
|
|
2869
|
+
# "contract_value": "0.001",
|
|
2870
|
+
# "basis_factor_max_limit": "10.95",
|
|
2871
|
+
# "maker_commission_rate": "0.0003",
|
|
2872
|
+
# "launch_time": "2023-07-19T04:30:03Z",
|
|
2873
|
+
# "trading_status": "operational",
|
|
2874
|
+
# "product_specs": {
|
|
2875
|
+
# "backup_vol_expiry_time": 31536000,
|
|
2876
|
+
# "max_deviation_from_external_vol": 0.75,
|
|
2877
|
+
# "max_lower_deviation_from_external_vol": 0.75,
|
|
2878
|
+
# "max_upper_deviation_from_external_vol": 0.5,
|
|
2879
|
+
# "max_volatility": 3,
|
|
2880
|
+
# "min_volatility": 0.1,
|
|
2881
|
+
# "premium_commission_rate": 0.1,
|
|
2882
|
+
# "settlement_index_price": "29993.536675710806",
|
|
2883
|
+
# "vol_calculation_method": "orderbook",
|
|
2884
|
+
# "vol_expiry_time": 31536000
|
|
2885
|
+
# },
|
|
2886
|
+
# "description": "BTC call option expiring on 19-7-2023",
|
|
2887
|
+
# "settlement_price": "0",
|
|
2888
|
+
# "disruption_reason": null,
|
|
2889
|
+
# "settling_asset": {},
|
|
2890
|
+
# "initial_margin": "1",
|
|
2891
|
+
# "tick_size": "0.1",
|
|
2892
|
+
# "maintenance_margin": "0.5",
|
|
2893
|
+
# "id": 117542,
|
|
2894
|
+
# "notional_type": "vanilla",
|
|
2895
|
+
# "ui_config": {},
|
|
2896
|
+
# "contract_unit_currency": "BTC",
|
|
2897
|
+
# "symbol": "C-BTC-30900-190723",
|
|
2898
|
+
# "insurance_fund_margin_contribution": "1",
|
|
2899
|
+
# "price_band": "2",
|
|
2900
|
+
# "annualized_funding": "10.95",
|
|
2901
|
+
# "impact_size": 200,
|
|
2902
|
+
# "contract_type": "call_options",
|
|
2903
|
+
# "position_size_limit": 255633,
|
|
2904
|
+
# "max_leverage_notional": "200000",
|
|
2905
|
+
# "initial_margin_scaling_factor": "0.000002",
|
|
2906
|
+
# "strike_price": "30900",
|
|
2907
|
+
# "is_quanto": False,
|
|
2908
|
+
# "settlement_time": "2023-07-19T12:00:00Z",
|
|
2909
|
+
# "liquidation_penalty_factor": "0.5",
|
|
2910
|
+
# "funding_method": "mark_price",
|
|
2911
|
+
# "taker_commission_rate": "0.0003",
|
|
2912
|
+
# "default_leverage": "100.000000000000000000",
|
|
2913
|
+
# "state": "expired",
|
|
2914
|
+
# "auction_start_time": null,
|
|
2915
|
+
# "short_description": "BTC Call",
|
|
2916
|
+
# "quoting_asset": {},
|
|
2917
|
+
# "maintenance_margin_scaling_factor":"0.000002"
|
|
2918
|
+
# }
|
|
2919
|
+
#
|
|
2920
|
+
datetime = self.safe_string(settlement, 'settlement_time')
|
|
2921
|
+
marketId = self.safe_string(settlement, 'symbol')
|
|
2922
|
+
return {
|
|
2923
|
+
'info': settlement,
|
|
2924
|
+
'symbol': self.safe_symbol(marketId, market),
|
|
2925
|
+
'price': self.safe_number(settlement, 'settlement_price'),
|
|
2926
|
+
'timestamp': self.parse8601(datetime),
|
|
2927
|
+
'datetime': datetime,
|
|
2928
|
+
}
|
|
2929
|
+
|
|
2930
|
+
def parse_settlements(self, settlements, market):
|
|
2931
|
+
result = []
|
|
2932
|
+
for i in range(0, len(settlements)):
|
|
2933
|
+
result.append(self.parse_settlement(settlements[i], market))
|
|
2934
|
+
return result
|
|
2935
|
+
|
|
2936
|
+
def fetch_greeks(self, symbol: str, params={}) -> Greeks:
|
|
2937
|
+
"""
|
|
2938
|
+
fetches an option contracts greeks, financial metrics used to measure the factors that affect the price of an options contract
|
|
2939
|
+
:see: https://docs.delta.exchange/#get-ticker-for-a-product-by-symbol
|
|
2940
|
+
:param str symbol: unified symbol of the market to fetch greeks for
|
|
2941
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
|
2942
|
+
:returns dict: a `greeks structure <https://docs.ccxt.com/#/?id=greeks-structure>`
|
|
2943
|
+
"""
|
|
2944
|
+
self.load_markets()
|
|
2945
|
+
market = self.market(symbol)
|
|
2946
|
+
request: dict = {
|
|
2947
|
+
'symbol': market['id'],
|
|
2948
|
+
}
|
|
2949
|
+
response = self.publicGetTickersSymbol(self.extend(request, params))
|
|
2950
|
+
#
|
|
2951
|
+
# {
|
|
2952
|
+
# "result": {
|
|
2953
|
+
# "close": 6793.0,
|
|
2954
|
+
# "contract_type": "call_options",
|
|
2955
|
+
# "greeks": {
|
|
2956
|
+
# "delta": "0.94739174",
|
|
2957
|
+
# "gamma": "0.00002206",
|
|
2958
|
+
# "rho": "11.00890725",
|
|
2959
|
+
# "spot": "36839.58124652",
|
|
2960
|
+
# "theta": "-18.18365310",
|
|
2961
|
+
# "vega": "7.85209698"
|
|
2962
|
+
# },
|
|
2963
|
+
# "high": 7556.0,
|
|
2964
|
+
# "low": 6793.0,
|
|
2965
|
+
# "mark_price": "6955.70698909",
|
|
2966
|
+
# "mark_vol": "0.66916863",
|
|
2967
|
+
# "oi": "1.8980",
|
|
2968
|
+
# "oi_change_usd_6h": "110.4600",
|
|
2969
|
+
# "oi_contracts": "1898",
|
|
2970
|
+
# "oi_value": "1.8980",
|
|
2971
|
+
# "oi_value_symbol": "BTC",
|
|
2972
|
+
# "oi_value_usd": "69940.7319",
|
|
2973
|
+
# "open": 7.2e3,
|
|
2974
|
+
# "price_band": {
|
|
2975
|
+
# "lower_limit": "5533.89814767",
|
|
2976
|
+
# "upper_limit": "11691.37688371"
|
|
2977
|
+
# },
|
|
2978
|
+
# "product_id": 129508,
|
|
2979
|
+
# "quotes": {
|
|
2980
|
+
# "ask_iv": "0.90180438",
|
|
2981
|
+
# "ask_size": "1898",
|
|
2982
|
+
# "best_ask": "7210",
|
|
2983
|
+
# "best_bid": "6913",
|
|
2984
|
+
# "bid_iv": "0.60881706",
|
|
2985
|
+
# "bid_size": "3163",
|
|
2986
|
+
# "impact_mid_price": null,
|
|
2987
|
+
# "mark_iv": "0.66973549"
|
|
2988
|
+
# },
|
|
2989
|
+
# "size": 5,
|
|
2990
|
+
# "spot_price": "36839.58153868",
|
|
2991
|
+
# "strike_price": "30000",
|
|
2992
|
+
# "symbol": "C-BTC-30000-241123",
|
|
2993
|
+
# "timestamp": 1699584998504530,
|
|
2994
|
+
# "turnover": 184.41206804,
|
|
2995
|
+
# "turnover_symbol": "USDT",
|
|
2996
|
+
# "turnover_usd": 184.41206804,
|
|
2997
|
+
# "volume": 0.005
|
|
2998
|
+
# },
|
|
2999
|
+
# "success": True
|
|
3000
|
+
# }
|
|
3001
|
+
#
|
|
3002
|
+
result = self.safe_dict(response, 'result', {})
|
|
3003
|
+
return self.parse_greeks(result, market)
|
|
3004
|
+
|
|
3005
|
+
def parse_greeks(self, greeks: dict, market: Market = None) -> Greeks:
|
|
3006
|
+
#
|
|
3007
|
+
# {
|
|
3008
|
+
# "close": 6793.0,
|
|
3009
|
+
# "contract_type": "call_options",
|
|
3010
|
+
# "greeks": {
|
|
3011
|
+
# "delta": "0.94739174",
|
|
3012
|
+
# "gamma": "0.00002206",
|
|
3013
|
+
# "rho": "11.00890725",
|
|
3014
|
+
# "spot": "36839.58124652",
|
|
3015
|
+
# "theta": "-18.18365310",
|
|
3016
|
+
# "vega": "7.85209698"
|
|
3017
|
+
# },
|
|
3018
|
+
# "high": 7556.0,
|
|
3019
|
+
# "low": 6793.0,
|
|
3020
|
+
# "mark_price": "6955.70698909",
|
|
3021
|
+
# "mark_vol": "0.66916863",
|
|
3022
|
+
# "oi": "1.8980",
|
|
3023
|
+
# "oi_change_usd_6h": "110.4600",
|
|
3024
|
+
# "oi_contracts": "1898",
|
|
3025
|
+
# "oi_value": "1.8980",
|
|
3026
|
+
# "oi_value_symbol": "BTC",
|
|
3027
|
+
# "oi_value_usd": "69940.7319",
|
|
3028
|
+
# "open": 7.2e3,
|
|
3029
|
+
# "price_band": {
|
|
3030
|
+
# "lower_limit": "5533.89814767",
|
|
3031
|
+
# "upper_limit": "11691.37688371"
|
|
3032
|
+
# },
|
|
3033
|
+
# "product_id": 129508,
|
|
3034
|
+
# "quotes": {
|
|
3035
|
+
# "ask_iv": "0.90180438",
|
|
3036
|
+
# "ask_size": "1898",
|
|
3037
|
+
# "best_ask": "7210",
|
|
3038
|
+
# "best_bid": "6913",
|
|
3039
|
+
# "bid_iv": "0.60881706",
|
|
3040
|
+
# "bid_size": "3163",
|
|
3041
|
+
# "impact_mid_price": null,
|
|
3042
|
+
# "mark_iv": "0.66973549"
|
|
3043
|
+
# },
|
|
3044
|
+
# "size": 5,
|
|
3045
|
+
# "spot_price": "36839.58153868",
|
|
3046
|
+
# "strike_price": "30000",
|
|
3047
|
+
# "symbol": "C-BTC-30000-241123",
|
|
3048
|
+
# "timestamp": 1699584998504530,
|
|
3049
|
+
# "turnover": 184.41206804,
|
|
3050
|
+
# "turnover_symbol": "USDT",
|
|
3051
|
+
# "turnover_usd": 184.41206804,
|
|
3052
|
+
# "volume": 0.005
|
|
3053
|
+
# }
|
|
3054
|
+
#
|
|
3055
|
+
timestamp = self.safe_integer_product(greeks, 'timestamp', 0.001)
|
|
3056
|
+
marketId = self.safe_string(greeks, 'symbol')
|
|
3057
|
+
symbol = self.safe_symbol(marketId, market)
|
|
3058
|
+
stats = self.safe_dict(greeks, 'greeks', {})
|
|
3059
|
+
quotes = self.safe_dict(greeks, 'quotes', {})
|
|
3060
|
+
return {
|
|
3061
|
+
'symbol': symbol,
|
|
3062
|
+
'timestamp': timestamp,
|
|
3063
|
+
'datetime': self.iso8601(timestamp),
|
|
3064
|
+
'delta': self.safe_number(stats, 'delta'),
|
|
3065
|
+
'gamma': self.safe_number(stats, 'gamma'),
|
|
3066
|
+
'theta': self.safe_number(stats, 'theta'),
|
|
3067
|
+
'vega': self.safe_number(stats, 'vega'),
|
|
3068
|
+
'rho': self.safe_number(stats, 'rho'),
|
|
3069
|
+
'bidSize': self.safe_number(quotes, 'bid_size'),
|
|
3070
|
+
'askSize': self.safe_number(quotes, 'ask_size'),
|
|
3071
|
+
'bidImpliedVolatility': self.safe_number(quotes, 'bid_iv'),
|
|
3072
|
+
'askImpliedVolatility': self.safe_number(quotes, 'ask_iv'),
|
|
3073
|
+
'markImpliedVolatility': self.safe_number(quotes, 'mark_iv'),
|
|
3074
|
+
'bidPrice': self.safe_number(quotes, 'best_bid'),
|
|
3075
|
+
'askPrice': self.safe_number(quotes, 'best_ask'),
|
|
3076
|
+
'markPrice': self.safe_number(greeks, 'mark_price'),
|
|
3077
|
+
'lastPrice': None,
|
|
3078
|
+
'underlyingPrice': self.safe_number(greeks, 'spot_price'),
|
|
3079
|
+
'info': greeks,
|
|
3080
|
+
}
|
|
3081
|
+
|
|
3082
|
+
def close_all_positions(self, params={}) -> List[Position]:
|
|
3083
|
+
"""
|
|
3084
|
+
closes all open positions for a market type
|
|
3085
|
+
:see: https://docs.delta.exchange/#close-all-positions
|
|
3086
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
|
3087
|
+
:param int [params.user_id]: the users id
|
|
3088
|
+
:returns dict[]: A list of `position structures <https://docs.ccxt.com/#/?id=position-structure>`
|
|
3089
|
+
"""
|
|
3090
|
+
self.load_markets()
|
|
3091
|
+
request: dict = {
|
|
3092
|
+
'close_all_portfolio': True,
|
|
3093
|
+
'close_all_isolated': True,
|
|
3094
|
+
# 'user_id': 12345,
|
|
3095
|
+
}
|
|
3096
|
+
response = self.privatePostPositionsCloseAll(self.extend(request, params))
|
|
3097
|
+
#
|
|
3098
|
+
# {"result":{},"success":true}
|
|
3099
|
+
#
|
|
3100
|
+
position = self.parse_position(self.safe_dict(response, 'result', {}))
|
|
3101
|
+
return [position]
|
|
3102
|
+
|
|
3103
|
+
def fetch_margin_mode(self, symbol: str, params={}) -> MarginMode:
|
|
3104
|
+
"""
|
|
3105
|
+
fetches the margin mode of a trading pair
|
|
3106
|
+
:see: https://docs.delta.exchange/#get-user
|
|
3107
|
+
:param str symbol: unified symbol of the market to fetch the margin mode for
|
|
3108
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
|
3109
|
+
:returns dict: a `margin mode structure <https://docs.ccxt.com/#/?id=margin-mode-structure>`
|
|
3110
|
+
"""
|
|
3111
|
+
self.load_markets()
|
|
3112
|
+
market = None
|
|
3113
|
+
if symbol is not None:
|
|
3114
|
+
market = self.market(symbol)
|
|
3115
|
+
response = self.privateGetProfile(params)
|
|
3116
|
+
#
|
|
3117
|
+
# {
|
|
3118
|
+
# "result": {
|
|
3119
|
+
# "is_password_set": True,
|
|
3120
|
+
# "kyc_expiry_date": null,
|
|
3121
|
+
# "phishing_code": "12345",
|
|
3122
|
+
# "preferences": {
|
|
3123
|
+
# "favorites": []
|
|
3124
|
+
# },
|
|
3125
|
+
# "is_kyc_provisioned": False,
|
|
3126
|
+
# "country": "Canada",
|
|
3127
|
+
# "margin_mode": "isolated",
|
|
3128
|
+
# "mfa_updated_at": "2023-07-19T01:04:43Z",
|
|
3129
|
+
# "last_name": "",
|
|
3130
|
+
# "oauth_apple_active": False,
|
|
3131
|
+
# "pf_index_symbol": null,
|
|
3132
|
+
# "proof_of_identity_status": "approved",
|
|
3133
|
+
# "dob": null,
|
|
3134
|
+
# "email": "abc_123@gmail.com",
|
|
3135
|
+
# "force_change_password": False,
|
|
3136
|
+
# "nick_name": "still-breeze-123",
|
|
3137
|
+
# "oauth_google_active": False,
|
|
3138
|
+
# "phone_verification_status": "verified",
|
|
3139
|
+
# "id": 12345678,
|
|
3140
|
+
# "last_seen": null,
|
|
3141
|
+
# "is_withdrawal_enabled": True,
|
|
3142
|
+
# "force_change_mfa": False,
|
|
3143
|
+
# "enable_bots": False,
|
|
3144
|
+
# "kyc_verified_on": null,
|
|
3145
|
+
# "created_at": "2023-07-19T01:02:32Z",
|
|
3146
|
+
# "withdrawal_blocked_till": null,
|
|
3147
|
+
# "proof_of_address_status": "approved",
|
|
3148
|
+
# "is_password_change_blocked": False,
|
|
3149
|
+
# "is_mfa_enabled": True,
|
|
3150
|
+
# "is_kyc_done": True,
|
|
3151
|
+
# "oauth": null,
|
|
3152
|
+
# "account_name": "Main",
|
|
3153
|
+
# "sub_account_permissions": null,
|
|
3154
|
+
# "phone_number": null,
|
|
3155
|
+
# "tracking_info": {
|
|
3156
|
+
# "ga_cid": "1234.4321",
|
|
3157
|
+
# "is_kyc_gtm_tracked": True,
|
|
3158
|
+
# "sub_account_config": {
|
|
3159
|
+
# "cross": 2,
|
|
3160
|
+
# "isolated": 2,
|
|
3161
|
+
# "portfolio": 2
|
|
3162
|
+
# }
|
|
3163
|
+
# },
|
|
3164
|
+
# "first_name": "",
|
|
3165
|
+
# "phone_verified_on": null,
|
|
3166
|
+
# "seen_intro": False,
|
|
3167
|
+
# "password_updated_at": null,
|
|
3168
|
+
# "is_login_enabled": True,
|
|
3169
|
+
# "registration_date": "2023-07-19T01:02:32Z",
|
|
3170
|
+
# "permissions": {},
|
|
3171
|
+
# "max_sub_accounts_limit": 2,
|
|
3172
|
+
# "country_calling_code": null,
|
|
3173
|
+
# "is_sub_account": False,
|
|
3174
|
+
# "is_kyc_refresh_required": False
|
|
3175
|
+
# },
|
|
3176
|
+
# "success": True
|
|
3177
|
+
# }
|
|
3178
|
+
#
|
|
3179
|
+
result = self.safe_dict(response, 'result', {})
|
|
3180
|
+
return self.parse_margin_mode(result, market)
|
|
3181
|
+
|
|
3182
|
+
def parse_margin_mode(self, marginMode: dict, market=None) -> MarginMode:
|
|
3183
|
+
symbol = None
|
|
3184
|
+
if market is not None:
|
|
3185
|
+
symbol = market['symbol']
|
|
3186
|
+
return {
|
|
3187
|
+
'info': marginMode,
|
|
3188
|
+
'symbol': symbol,
|
|
3189
|
+
'marginMode': self.safe_string(marginMode, 'margin_mode'),
|
|
3190
|
+
}
|
|
3191
|
+
|
|
3192
|
+
def fetch_option(self, symbol: str, params={}) -> Option:
|
|
3193
|
+
"""
|
|
3194
|
+
fetches option data that is commonly found in an option chain
|
|
3195
|
+
:see: https://docs.delta.exchange/#get-ticker-for-a-product-by-symbol
|
|
3196
|
+
:param str symbol: unified market symbol
|
|
3197
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
|
3198
|
+
:returns dict: an `option chain structure <https://docs.ccxt.com/#/?id=option-chain-structure>`
|
|
3199
|
+
"""
|
|
3200
|
+
self.load_markets()
|
|
3201
|
+
market = self.market(symbol)
|
|
3202
|
+
request: dict = {
|
|
3203
|
+
'symbol': market['id'],
|
|
3204
|
+
}
|
|
3205
|
+
response = self.publicGetTickersSymbol(self.extend(request, params))
|
|
3206
|
+
#
|
|
3207
|
+
# {
|
|
3208
|
+
# "result": {
|
|
3209
|
+
# "close": 6793.0,
|
|
3210
|
+
# "contract_type": "call_options",
|
|
3211
|
+
# "greeks": {
|
|
3212
|
+
# "delta": "0.94739174",
|
|
3213
|
+
# "gamma": "0.00002206",
|
|
3214
|
+
# "rho": "11.00890725",
|
|
3215
|
+
# "spot": "36839.58124652",
|
|
3216
|
+
# "theta": "-18.18365310",
|
|
3217
|
+
# "vega": "7.85209698"
|
|
3218
|
+
# },
|
|
3219
|
+
# "high": 7556.0,
|
|
3220
|
+
# "low": 6793.0,
|
|
3221
|
+
# "mark_price": "6955.70698909",
|
|
3222
|
+
# "mark_vol": "0.66916863",
|
|
3223
|
+
# "oi": "1.8980",
|
|
3224
|
+
# "oi_change_usd_6h": "110.4600",
|
|
3225
|
+
# "oi_contracts": "1898",
|
|
3226
|
+
# "oi_value": "1.8980",
|
|
3227
|
+
# "oi_value_symbol": "BTC",
|
|
3228
|
+
# "oi_value_usd": "69940.7319",
|
|
3229
|
+
# "open": 7.2e3,
|
|
3230
|
+
# "price_band": {
|
|
3231
|
+
# "lower_limit": "5533.89814767",
|
|
3232
|
+
# "upper_limit": "11691.37688371"
|
|
3233
|
+
# },
|
|
3234
|
+
# "product_id": 129508,
|
|
3235
|
+
# "quotes": {
|
|
3236
|
+
# "ask_iv": "0.90180438",
|
|
3237
|
+
# "ask_size": "1898",
|
|
3238
|
+
# "best_ask": "7210",
|
|
3239
|
+
# "best_bid": "6913",
|
|
3240
|
+
# "bid_iv": "0.60881706",
|
|
3241
|
+
# "bid_size": "3163",
|
|
3242
|
+
# "impact_mid_price": null,
|
|
3243
|
+
# "mark_iv": "0.66973549"
|
|
3244
|
+
# },
|
|
3245
|
+
# "size": 5,
|
|
3246
|
+
# "spot_price": "36839.58153868",
|
|
3247
|
+
# "strike_price": "30000",
|
|
3248
|
+
# "symbol": "C-BTC-30000-241123",
|
|
3249
|
+
# "timestamp": 1699584998504530,
|
|
3250
|
+
# "turnover": 184.41206804,
|
|
3251
|
+
# "turnover_symbol": "USDT",
|
|
3252
|
+
# "turnover_usd": 184.41206804,
|
|
3253
|
+
# "volume": 0.005
|
|
3254
|
+
# },
|
|
3255
|
+
# "success": True
|
|
3256
|
+
# }
|
|
3257
|
+
#
|
|
3258
|
+
result = self.safe_dict(response, 'result', {})
|
|
3259
|
+
return self.parse_option(result, None, market)
|
|
3260
|
+
|
|
3261
|
+
def parse_option(self, chain: dict, currency: Currency = None, market: Market = None) -> Option:
|
|
3262
|
+
#
|
|
3263
|
+
# {
|
|
3264
|
+
# "close": 6793.0,
|
|
3265
|
+
# "contract_type": "call_options",
|
|
3266
|
+
# "greeks": {
|
|
3267
|
+
# "delta": "0.94739174",
|
|
3268
|
+
# "gamma": "0.00002206",
|
|
3269
|
+
# "rho": "11.00890725",
|
|
3270
|
+
# "spot": "36839.58124652",
|
|
3271
|
+
# "theta": "-18.18365310",
|
|
3272
|
+
# "vega": "7.85209698"
|
|
3273
|
+
# },
|
|
3274
|
+
# "high": 7556.0,
|
|
3275
|
+
# "low": 6793.0,
|
|
3276
|
+
# "mark_price": "6955.70698909",
|
|
3277
|
+
# "mark_vol": "0.66916863",
|
|
3278
|
+
# "oi": "1.8980",
|
|
3279
|
+
# "oi_change_usd_6h": "110.4600",
|
|
3280
|
+
# "oi_contracts": "1898",
|
|
3281
|
+
# "oi_value": "1.8980",
|
|
3282
|
+
# "oi_value_symbol": "BTC",
|
|
3283
|
+
# "oi_value_usd": "69940.7319",
|
|
3284
|
+
# "open": 7.2e3,
|
|
3285
|
+
# "price_band": {
|
|
3286
|
+
# "lower_limit": "5533.89814767",
|
|
3287
|
+
# "upper_limit": "11691.37688371"
|
|
3288
|
+
# },
|
|
3289
|
+
# "product_id": 129508,
|
|
3290
|
+
# "quotes": {
|
|
3291
|
+
# "ask_iv": "0.90180438",
|
|
3292
|
+
# "ask_size": "1898",
|
|
3293
|
+
# "best_ask": "7210",
|
|
3294
|
+
# "best_bid": "6913",
|
|
3295
|
+
# "bid_iv": "0.60881706",
|
|
3296
|
+
# "bid_size": "3163",
|
|
3297
|
+
# "impact_mid_price": null,
|
|
3298
|
+
# "mark_iv": "0.66973549"
|
|
3299
|
+
# },
|
|
3300
|
+
# "size": 5,
|
|
3301
|
+
# "spot_price": "36839.58153868",
|
|
3302
|
+
# "strike_price": "30000",
|
|
3303
|
+
# "symbol": "C-BTC-30000-241123",
|
|
3304
|
+
# "timestamp": 1699584998504530,
|
|
3305
|
+
# "turnover": 184.41206804,
|
|
3306
|
+
# "turnover_symbol": "USDT",
|
|
3307
|
+
# "turnover_usd": 184.41206804,
|
|
3308
|
+
# "volume": 0.005
|
|
3309
|
+
# }
|
|
3310
|
+
#
|
|
3311
|
+
marketId = self.safe_string(chain, 'symbol')
|
|
3312
|
+
market = self.safe_market(marketId, market)
|
|
3313
|
+
quotes = self.safe_dict(chain, 'quotes', {})
|
|
3314
|
+
timestamp = self.safe_integer_product(chain, 'timestamp', 0.001)
|
|
3315
|
+
return {
|
|
3316
|
+
'info': chain,
|
|
3317
|
+
'currency': None,
|
|
3318
|
+
'symbol': market['symbol'],
|
|
3319
|
+
'timestamp': timestamp,
|
|
3320
|
+
'datetime': self.iso8601(timestamp),
|
|
3321
|
+
'impliedVolatility': self.safe_number(quotes, 'mark_iv'),
|
|
3322
|
+
'openInterest': self.safe_number(chain, 'oi'),
|
|
3323
|
+
'bidPrice': self.safe_number(quotes, 'best_bid'),
|
|
3324
|
+
'askPrice': self.safe_number(quotes, 'best_ask'),
|
|
3325
|
+
'midPrice': self.safe_number(quotes, 'impact_mid_price'),
|
|
3326
|
+
'markPrice': self.safe_number(chain, 'mark_price'),
|
|
3327
|
+
'lastPrice': None,
|
|
3328
|
+
'underlyingPrice': self.safe_number(chain, 'spot_price'),
|
|
3329
|
+
'change': None,
|
|
3330
|
+
'percentage': None,
|
|
3331
|
+
'baseVolume': self.safe_number(chain, 'volume'),
|
|
3332
|
+
'quoteVolume': None,
|
|
3333
|
+
}
|
|
3334
|
+
|
|
3335
|
+
def sign(self, path, api='public', method='GET', params={}, headers=None, body=None):
|
|
3336
|
+
requestPath = '/' + self.version + '/' + self.implode_params(path, params)
|
|
3337
|
+
url = self.urls['api'][api] + requestPath
|
|
3338
|
+
query = self.omit(params, self.extract_params(path))
|
|
3339
|
+
if api == 'public':
|
|
3340
|
+
if query:
|
|
3341
|
+
url += '?' + self.urlencode(query)
|
|
3342
|
+
elif api == 'private':
|
|
3343
|
+
self.check_required_credentials()
|
|
3344
|
+
timestamp = str(self.seconds())
|
|
3345
|
+
headers = {
|
|
3346
|
+
'api-key': self.apiKey,
|
|
3347
|
+
'timestamp': timestamp,
|
|
3348
|
+
}
|
|
3349
|
+
auth = method + timestamp + requestPath
|
|
3350
|
+
if (method == 'GET') or (method == 'DELETE'):
|
|
3351
|
+
if query:
|
|
3352
|
+
queryString = '?' + self.urlencode(query)
|
|
3353
|
+
auth += queryString
|
|
3354
|
+
url += queryString
|
|
3355
|
+
else:
|
|
3356
|
+
body = self.json(query)
|
|
3357
|
+
auth += body
|
|
3358
|
+
headers['Content-Type'] = 'application/json'
|
|
3359
|
+
signature = self.hmac(self.encode(auth), self.encode(self.secret), hashlib.sha256)
|
|
3360
|
+
headers['signature'] = signature
|
|
3361
|
+
return {'url': url, 'method': method, 'body': body, 'headers': headers}
|
|
3362
|
+
|
|
3363
|
+
def handle_errors(self, code: int, reason: str, url: str, method: str, headers: dict, body: str, response, requestHeaders, requestBody):
|
|
3364
|
+
if response is None:
|
|
3365
|
+
return None
|
|
3366
|
+
#
|
|
3367
|
+
# {"error":{"code":"insufficient_margin","context":{"available_balance":"0.000000000000000000","required_additional_balance":"1.618626000000000000000000000"}},"success":false}
|
|
3368
|
+
#
|
|
3369
|
+
error = self.safe_dict(response, 'error', {})
|
|
3370
|
+
errorCode = self.safe_string(error, 'code')
|
|
3371
|
+
if errorCode is not None:
|
|
3372
|
+
feedback = self.id + ' ' + body
|
|
3373
|
+
self.throw_exactly_matched_exception(self.exceptions['exact'], errorCode, feedback)
|
|
3374
|
+
self.throw_broadly_matched_exception(self.exceptions['broad'], errorCode, feedback)
|
|
3375
|
+
raise ExchangeError(feedback) # unknown message
|
|
3376
|
+
return None
|