knowm / XChange

XChange is a Java library providing a streamlined API for interacting with 60+ Bitcoin and Altcoin exchanges providing a consistent interface for trading and accessing market data.
http://knowm.org/open-source/xchange/
MIT License
3.85k stars 1.94k forks source link

Add futures to okx exchange metadata #4772

Open douggie opened 1 year ago

douggie commented 1 year ago

Currently the remoteInit for okx only loads the spot and swap products, I propose we add the futures products, so that functions like getOpenPostions will work when they do things key looks ups like this on futures positiions exchangeMetaData.getInstruments().get(adaptOkexInstrumentId(okexPosition.getInstrumentId())).getContractValue()

        ((OkexMarketDataServiceRaw) marketDataService)
            .getOkexInstruments(SPOT, null, null)
            .getData();

    List<OkexInstrument> swap_instruments =
            ((OkexMarketDataServiceRaw) marketDataService)
                    .getOkexInstruments(SWAP, null, null)
                    .getData();

    instruments.addAll(swap_instruments);

    List<OkexInstrument> futures_instruments =
        ((OkexMarketDataServiceRaw) marketDataService)
            .getOkexInstruments(FUTURES, null, null)
            .getData();

    instruments.addAll(futures_instruments);