Skip to content

Filler-dev/Lemon-Markets-Java-SDK

 
 

Repository files navigation

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

About

unofficial sdk

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Java 100.0%