Closed kurapica closed 1 year ago
Thank you for your feedback. I'll check deep and inform you
I cant see any difference between signed or unsigned responses. Can you share your results please
Here is a simple test code,
public static async Task<bool> UpdateInstrumentInfo(this OKXRestApiClient client, string symbol)
{
try
{
string instrument = client.GetInstrument(symbol); // Convert BTCUSDT to BTC-USDT-SWAP
// A modify version with sign
RestCallResult<IEnumerable<OkxInstrument>> result =
await client.Account.GetInstrumentsAsync(OkxInstrumentType.Swap, instrumentId: instrument);
if (result.Success)
{
result.Data.ForEach(r =>
{
if (r.ContractType == OkxContractType.Linear)
{
Console.WriteLine($"{instrument}:{r.ToJson()}");
}
});
}
// The original version without sign
result = await client.PublicData.GetInstrumentsAsync(OkxInstrumentType.Swap, instrumentId: instrument);
if (result.Success)
{
result.Data.ForEach(r =>
{
if (r.ContractType == OkxContractType.Linear)
{
Console.WriteLine($"{instrument}:{r.ToJson()}");
}
});
}
}
catch (Exception)
{
return false;
}
return true;
}
Here is what I got
BTC-USDT-SWAP:{"instType":"SWAP","instId":"BTC-USDT-SWAP","uly":"BTC-USDT","instFamily":"BTC-USDT","baseCcy":"","quoteCcy":"","settleCcy":"USDT","ctVal":"0.001","ctMult":"1","ctValCcy":"BTC","listTime":1606468568000,"lever":"125","tickSz":"0.1","lotSz":"1","minSz":"1","ctType":"linear","state":"live","maxLmtSz":"100000000","maxMktSz":"120000","maxTwapSz":"100000000.0000000000000000","maxIcebergSz":"100000000.0000000000000000","maxTriggerSz":"100000000.0000000000000000","maxStopSz":"120000"}
BTC-USDT-SWAP:{"instType":"SWAP","instId":"BTC-USDT-SWAP","uly":"BTC-USDT","instFamily":"BTC-USDT","baseCcy":"","quoteCcy":"","settleCcy":"USDT","ctVal":"0.01","ctMult":"1","ctValCcy":"BTC","listTime":1611916828000,"lever":"125","tickSz":"0.1","lotSz":"1","minSz":"1","ctType":"linear","state":"live","maxLmtSz":"100000000","maxMktSz":"12000","maxTwapSz":"100000000.0000000000000000","maxIcebergSz":"100000000.0000000000000000","maxTriggerSz":"100000000.0000000000000000","maxStopSz":"12000"}
As you can see, the ctVal
is different. I don't know how OKX handle that, sign or IP check or anything other.
The results are same for me. But I added a signed parameter for you. I've changed whole project access hierarchy. You'll be able to use as below:
var public_06 = await api.PublicData.GetInstrumentsAsync(OkxInstrumentType.Swap, instrumentId: "BTC-USDT-SWAP", signed:true);
I'll release new version this night.
Have a great day
Version 1.3.0 has been released https://www.nuget.org/packages/OKX.Api/1.3.0
Thank you, we also test the http api with/without cookie, the result is still different, maybe the IP also affects.
i had chat with okx api developers. it seems we missed the header to get demo data. They asked me to change this header: Add to request header。x-simulated-trading: 1
The check was for this endpoint, but I don't know if you need to add it for others too. api.PublicData.GetInstrumentsAsync(...);
Did you try as below
var api = new OKXRestApiClient(new OKXRestApiClientOptions
{
DemoTradingService = true,
});
it has to have this property to allow to access to demo api.
For example, the BTCUSDT's contract value is 0.01 return by the origin GetInstrumentsAsync, but if changed with signed, it'll be 0.001(the right value for trading).
Can you add another GetInstrumentsAsync in the OKXAccountRestApiClient with siged?