Giter VIP home page Giter VIP logo

okex-api's Introduction

OKCoin OKEX V3 Open Api使用说明

1.使用技术:okhttp3 + retrofit2

2.依赖maven,内部使用 (用户可上传nexus使用)

        <dependency>
            <groupId>com.okcoin.commons</groupId>
            <artifactId>okex-java-sdk-api</artifactId>
            <version>1.0.0</version>
        </dependency>

3.简单使用方式:

 public static void main(String[] args) {

        APIConfiguration config = new APIConfiguration();
        config.setEndpoint("http://192.168.80.14:8118");
        config.setApiKey("75c60758-be16-4acc-8f2d-66403e53072c");
        config.setSecretKey("8DF095FE9C662F787A60F3133A06414C");
        config.setPassphrase("19205A%9980");
        config.setPrint(false);

        GeneralAPIService marketAPIService = new GeneralAPIServiceImpl(config);
        ServerTime time = marketAPIService.getServerTime();
        // eg: {"epoch":"1520848286.633","iso":"2018-03-12T09:51:26.633Z"}
        System.out.println(JSON.toJSONString(time));

        FuturesTradeAPIService tradeAPIService = new FuturesTradeAPIServiceImpl(config);

        Order order = new Order();
        order.setClient_oid("TYPb040b3daa40f793e69f86344a1839");
        order.setType(FuturesTransactionTypeEnum.OPEN_SHORT.code());
        order.setProduct_id("BTC-USD-0331");
        order.setPrice(99900.00);
        order.setAmount(123);
        order.setMatch_price(0);
        order.setLever_rate(10.00);
        OrderResult orderResult = tradeAPIService.newOrder(order);
        // eg : {"client_oid":"TYPb040b3daa40f793e69f86344a1839","order_id":"400574928061440","result":true}
        System.out.println(JSON.toJSONString(orderResult));
 }

4.Spring 或 Spring Boot使用方式:

@RestController
public class TestOKEXOpenApiV3 {

    @Autowired
    private GeneralAPIService generalAPIService;

    @GetMapping("/server-time")
    public ServerTime getServerTime() {
        return generalAPIService.getServerTime();
    }
    
    @Bean
    public APIConfiguration okexApiConfig() {
        APIConfiguration config = new APIConfiguration();
        config.setEndpoint("http://192.168.80.14:8118");
        config.setApiKey("75c60758-be16-4acc-8f2d-66403e53072c");
        config.setSecretKey("8DF095FE9C662F787A60F3133A06414C");
        config.setPassphrase("19205A%9980");
        config.setPrint(false);
        return config;
    }

    @Bean
    public GeneralAPIService generalAPIService(APIConfiguration config) {
        return new GeneralAPIServiceImpl(config);
    }
}
{
"iso": "2018-03-12T10:12:01.468Z",
"epoch": "1520849521.468"
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.