|
| 1 | +module Contract |
| 2 | + |
| 3 | +export ContractQuery, |
| 4 | + ContractData, |
| 5 | + contract |
| 6 | + |
| 7 | +using Serde |
| 8 | +using Dates, NanoDates, TimeZones |
| 9 | + |
| 10 | +using CryptoAPIs.Kucoin |
| 11 | +using CryptoAPIs.Kucoin: Data, Page |
| 12 | +using CryptoAPIs: Maybe, APIsRequest |
| 13 | + |
| 14 | +Base.@kwdef struct ContractQuery <: KucoinPublicQuery |
| 15 | + #__ empty |
| 16 | +end |
| 17 | + |
| 18 | +struct ContractData <: KucoinData |
| 19 | + symbol::String |
| 20 | + rootSymbol::String |
| 21 | + type::String |
| 22 | + firstOpenDate::NanoDate |
| 23 | + expireDate::Maybe{NanoDate} |
| 24 | + settleDate::Maybe{NanoDate} |
| 25 | + baseCurrency::String |
| 26 | + quoteCurrency::String |
| 27 | + settleCurrency::String |
| 28 | + maxOrderQty::Maybe{Int64} |
| 29 | + maxPrice::Maybe{Float64} |
| 30 | + lotSize::Maybe{Int64} |
| 31 | + tickSize::Maybe{Float64} |
| 32 | + indexPriceTickSize::Maybe{Float64} |
| 33 | + multiplier::Maybe{Float64} |
| 34 | + initialMargin::Maybe{Float64} |
| 35 | + maintainMargin::Maybe{Float64} |
| 36 | + maxRiskLimit::Maybe{Int64} |
| 37 | + minRiskLimit::Maybe{Int64} |
| 38 | + riskStep::Maybe{Int64} |
| 39 | + makerFeeRate::Maybe{Float64} |
| 40 | + takerFeeRate::Maybe{Float64} |
| 41 | + takerFixFee::Maybe{Float64} |
| 42 | + makerFixFee::Maybe{Float64} |
| 43 | + settlementFee::Maybe{Float64} |
| 44 | + isDeleverage::Bool |
| 45 | + isQuanto::Bool |
| 46 | + isInverse::Bool |
| 47 | + markMethod::Maybe{String} |
| 48 | + fairMethod::Maybe{String} |
| 49 | + fundingBaseSymbol::Maybe{String} |
| 50 | + fundingQuoteSymbol::Maybe{String} |
| 51 | + fundingRateSymbol::Maybe{String} |
| 52 | + indexSymbol::Maybe{String} |
| 53 | + settlementSymbol::Maybe{String} |
| 54 | + status::String |
| 55 | + fundingFeeRate::Maybe{Float64} |
| 56 | + predictedFundingFeeRate::Maybe{Float64} |
| 57 | + openInterest::Maybe{String} |
| 58 | + turnoverOf24h::Maybe{Float64} |
| 59 | + volumeOf24h::Maybe{Float64} |
| 60 | + markPrice::Maybe{Float64} |
| 61 | + indexPrice::Maybe{Float64} |
| 62 | + lastTradePrice::Maybe{Float64} |
| 63 | + nextFundingRateTime::Maybe{Int64} |
| 64 | + maxLeverage::Maybe{Int64} |
| 65 | + sourceExchanges::Maybe{Vector} |
| 66 | + premiumsSymbol1M::Maybe{String} |
| 67 | + premiumsSymbol8H::Maybe{String} |
| 68 | + fundingBaseSymbol1M::Maybe{String} |
| 69 | + fundingQuoteSymbol1M::Maybe{String} |
| 70 | + lowPrice::Maybe{Float64} |
| 71 | + highPrice::Maybe{Float64} |
| 72 | + priceChgPct::Maybe{Float64} |
| 73 | + priceChg::Maybe{Float64} |
| 74 | +end |
| 75 | + |
| 76 | +""" |
| 77 | + contract(client::KucoinClient, query::ContractQuery) |
| 78 | + contract(client::KucoinClient = Kucoin.Futures.public_client; kw...) |
| 79 | +
|
| 80 | +Submit request to get the info of all open contracts. |
| 81 | +
|
| 82 | +[`GET api/v1/contracts/active`](https://www.kucoin.com/docs/rest/futures-trading/market-data/get-symbols-list) |
| 83 | +
|
| 84 | +## Code samples: |
| 85 | +
|
| 86 | +```julia |
| 87 | +using Serde |
| 88 | +using CryptoAPIs.Kucoin |
| 89 | +
|
| 90 | +result = Kucoin.Futures.contract() |
| 91 | +
|
| 92 | +to_pretty_json(result.result) |
| 93 | +``` |
| 94 | +
|
| 95 | +## Result: |
| 96 | +
|
| 97 | +```json |
| 98 | +{ |
| 99 | + "code":200000, |
| 100 | + "data":[ |
| 101 | + { |
| 102 | + "symbol":"XEMUSDTM", |
| 103 | + "rootSymbol":"USDT", |
| 104 | + "type":"FFWCSX", |
| 105 | + "firstOpenDate":"2021-04-09T08:00:00", |
| 106 | + "expireDate":null, |
| 107 | + "settleDate":null, |
| 108 | + "baseCurrency":"XEM", |
| 109 | + "quoteCurrency":"USDT", |
| 110 | + "settleCurrency":"USDT", |
| 111 | + "maxOrderQty":1000000, |
| 112 | + "maxPrice":1.0e6, |
| 113 | + "lotSize":1, |
| 114 | + "tickSize":1.0e-5, |
| 115 | + "indexPriceTickSize":1.0e-5, |
| 116 | + "multiplier":1.0, |
| 117 | + "initialMargin":0.034, |
| 118 | + "maintainMargin":0.017, |
| 119 | + "maxRiskLimit":10000, |
| 120 | + "minRiskLimit":10000, |
| 121 | + "riskStep":5000, |
| 122 | + "makerFeeRate":0.0002, |
| 123 | + "takerFeeRate":0.0006, |
| 124 | + "takerFixFee":0.0, |
| 125 | + "makerFixFee":0.0, |
| 126 | + "settlementFee":null, |
| 127 | + "isDeleverage":true, |
| 128 | + "isQuanto":false, |
| 129 | + "isInverse":false, |
| 130 | + "markMethod":"FairPrice", |
| 131 | + "fairMethod":"FundingRate", |
| 132 | + "fundingBaseSymbol":".XEMINT8H", |
| 133 | + "fundingQuoteSymbol":".USDTINT8H", |
| 134 | + "fundingRateSymbol":".XEMUSDTMFPI8H", |
| 135 | + "indexSymbol":".KXEMUSDT", |
| 136 | + "settlementSymbol":"", |
| 137 | + "status":"Open", |
| 138 | + "fundingFeeRate":7.2e-5, |
| 139 | + "predictedFundingFeeRate":-1.5e-5, |
| 140 | + "openInterest":"14240708", |
| 141 | + "turnoverOf24h":39512.89870461, |
| 142 | + "volumeOf24h":1.114053e6, |
| 143 | + "markPrice":0.03541, |
| 144 | + "indexPrice":0.03541, |
| 145 | + "lastTradePrice":0.03535, |
| 146 | + "nextFundingRateTime":12755619, |
| 147 | + "maxLeverage":30, |
| 148 | + "sourceExchanges":[ |
| 149 | + "binance", |
| 150 | + "okex", |
| 151 | + "kucoin", |
| 152 | + "bitget", |
| 153 | + "gateio" |
| 154 | + ], |
| 155 | + "premiumsSymbol1M":".XEMUSDTMPI", |
| 156 | + "premiumsSymbol8H":".XEMUSDTMPI8H", |
| 157 | + "fundingBaseSymbol1M":".XEMINT", |
| 158 | + "fundingQuoteSymbol1M":".USDTINT", |
| 159 | + "lowPrice":0.03469, |
| 160 | + "highPrice":0.03585, |
| 161 | + "priceChgPct":-0.0106, |
| 162 | + "priceChg":-0.00038 |
| 163 | + }, |
| 164 | + ... |
| 165 | + ] |
| 166 | +} |
| 167 | +``` |
| 168 | +""" |
| 169 | +function contract(client::KucoinClient, query::ContractQuery) |
| 170 | + return APIsRequest{Data{Vector{ContractData}}}("GET", "api/v1/contracts/active", query)(client) |
| 171 | +end |
| 172 | + |
| 173 | +function contract(client::KucoinClient = Kucoin.Futures.public_client; kw...) |
| 174 | + return contract(client, ContractQuery(; kw...)) |
| 175 | +end |
| 176 | + |
| 177 | +end |
0 commit comments