Giter Site home page Giter Site logo

lemon-markets-java-sdk's Introduction

Lemon-Markets-Java-SDK

Hey there, I enjoyed the API so much, that I decided to create a simple SDK for Java. I hope you enjoy it.

--Mentioned on their Website: https://docs.lemon.markets/resources/community-sdks --

build.gradle implementation(Jitpack):

Jitpack implementation

Gradle.. 

allprojects {
repositories {
    maven { url 'https://jitpack.io' }
    }
}
or...Maven...

<repositories>
	<repository>
	    <id>jitpack.io</id>
	    <url>https://jitpack.io</url>
	</repository>
</repositories>

Repo implementation

Gradle...

dependencies {
    implementation 'com.github.CodeCLS:Lemon-Markets-Java-SDK:1.0.0.0'
}
or...Maven...

<dependency>
	    <groupId>com.github.CodeCLS</groupId>
	    <artifactId>Lemon-Markets-Java-SDK</artifactId>
	    <version>Tag</version>
</dependency>

Setup Environment & Token

  1. Choose your environment (Paper/Live)
TradingEnvironment.PAPER
TradingEnvironment.LIVE
  1. Enter your token
TradingApplication tradingApplication = new TradingApplication.Builder()
    .setEnvironment(TradingEnvironment.PAPER)
    .setToken("<TOKEN>");
  1. Start coding

    PositionsRepository > Retrieve all your positions

    StockRepository > Endpoints regarding stocks

    OrderRepository > Buying and selling/Activating

    QuoteRepository > Retrieving data for Stocks UNFINISHED

    AccountRepository > Retrieving data regarding your account

Example Code

public class SDKTesting {
    public static void main(String args[]) {
        //SETUP APPLICATION
        TradingApplication tradingApplication = new TradingApplication.Builder()
                .setEnvironment(TradingEnvironment.PAPER)
                .setToken("TOKEN");
        
        //GET STOCK VIA NAME
        new StockRepository().getStockViaSearch("Coinbase", new ContentPackage.ApiAsyncReturn() {
            @Override
            public void getPackage(ContentPackage contentPackage) {
                if (contentPackage.getValue() != null) {
                    //CREATE A FUTURE ORDER
                    FutureOrder futureOrder = new FutureOrder.Builder()
                            .setIsin(((Stock)contentPackage.getValue()).getIsin())
                            .setAmountShares(100)
                            .setExpiresAt(System.currentTimeMillis() + 10000000)
                            .setSide(Side.BUY)
                            .setVenue(((Stock)contentPackage.getValue()).getVenues().get(0))
                            .create();
                    //PLACE ORDER
                    new OrderRepository().placeOrder(futureOrder, new ContentPackage.ApiAsyncReturn() {
                        @Override
                        public void getPackage(ContentPackage contentPackage) {
                            if (contentPackage.getValue() != null) {
                                //ACTIVATE THE PRIOR ORDER
                                new OrderRepository().activateOrder(((PlacedOrder)contentPackage.getValue()).getId(), new ContentPackage.ApiAsyncReturn() {
                                    @Override
                                    public void getPackage(ContentPackage contentPackage) {
                                        if (contentPackage.getValue() != null) {
                                            System.out.println("Activated Order");
                                        }
                                        else{
                                            System.out.println("Failed to activate Order");

                                        }

                                    }
                                });
                                System.out.println("Success placing order");

                            }
                            else{
                                System.out.println("Failure placing order");

                            }

                        }
                    });


                }
                else
                    System.out.println("Error: " + contentPackage.getException().getMessage());
            }
        });

//GET POSITIONS
        new PositionRepository().getPositions(new ContentPackage.ApiAsyncReturn() {
            @Override
            public void getPackage(ContentPackage contentPackage) {
                if (contentPackage.getValue() != null){
                    if ( ((ArrayList<Position>)contentPackage.getValue()).size() != 0) {
                        System.out.println("Positions: " + ((ArrayList<Position>) contentPackage.getValue()).get(0));
                    }
                }

                else
                    System.out.println("Error: " + contentPackage.getException().getMessage());

            }
        });



    }

}

Buy Me a Coffee at ko-fi.com

lemon-markets-java-sdk's People

Contributors

codecls avatar

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.