diff --git a/AutoTradingApplicationMonitor/AutoTradingApplicationMonitor.iml b/AutoTradingApplicationMonitor/AutoTradingApplicationMonitor.iml new file mode 100644 index 0000000..78b2cc5 --- /dev/null +++ b/AutoTradingApplicationMonitor/AutoTradingApplicationMonitor.iml @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/AutoTradingApplicationMonitor/src/main/java/com/suneesh/trading/monitor/MainApplication.java b/AutoTradingApplicationMonitor/src/main/java/com/suneesh/trading/monitor/MainApplication.java new file mode 100644 index 0000000..c839acc --- /dev/null +++ b/AutoTradingApplicationMonitor/src/main/java/com/suneesh/trading/monitor/MainApplication.java @@ -0,0 +1,43 @@ +package com.suneesh.trading.monitor; + +import lombok.extern.slf4j.Slf4j; + +import java.io.IOException; +import java.util.concurrent.TimeUnit; + +@Slf4j +public class MainApplication { + static int count; + public static Process startAutoTradingApplication(){ + log.info("Starting application count = {}",++count); + Process process = null; + ProcessBuilder processBuilder = new ProcessBuilder(); + processBuilder.command("notepad.exe"); + + try { + process = processBuilder.start(); + boolean b = process.waitFor(1, TimeUnit.SECONDS); + } catch (IOException | InterruptedException e) { + e.printStackTrace(); + } + return process; + } + public static void main(String[] args) { + log.info("Starting Automated Trading Application monitor"); + Process process = startAutoTradingApplication(); + + while (process!=null) + { + while(process.isAlive()){ + try { + Thread.sleep(100); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + if(!process.isAlive()){ + process = startAutoTradingApplication(); + } + } + } +} diff --git a/AutoTradingApplicationMonitor/src/main/resources/log4j2.properties b/AutoTradingApplicationMonitor/src/main/resources/log4j2.properties new file mode 100644 index 0000000..d4142ba --- /dev/null +++ b/AutoTradingApplicationMonitor/src/main/resources/log4j2.properties @@ -0,0 +1,20 @@ +status = error +name = PropertiesConfig + +filters = threshold + +filter.threshold.type = ThresholdFilter +filter.threshold.level = info + +appenders = console + +appender.console.type = Console +appender.console.name = STDOUT +appender.console.layout.type = PatternLayout +#appender.console.layout.pattern = %d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n +#appender.file.layout.pattern=[%-5level] %d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %c{1} - %msg%n +appender.file.layout.pattern=%sn %d{yyyy/MM/dd HH:mm:ss,SSS} %r [%-6p] [%t] %c{3} %C{3}.%M(%F:%L) – %m%n + +rootLogger.level = info +rootLogger.appenderRefs = stdout +rootLogger.appenderRef.stdout.ref = STDOUT diff --git a/AutomatedTrading_SpringThread/.idea/AutomatedTrading_SpringThread.iml b/AutomatedTrading_SpringThread/.idea/AutomatedTrading_SpringThread.iml new file mode 100644 index 0000000..792597b --- /dev/null +++ b/AutomatedTrading_SpringThread/.idea/AutomatedTrading_SpringThread.iml @@ -0,0 +1,79 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/AutomatedTrading_SpringThread/.idea/codeStyles/Project.xml b/AutomatedTrading_SpringThread/.idea/codeStyles/Project.xml new file mode 100644 index 0000000..3cdc6ae --- /dev/null +++ b/AutomatedTrading_SpringThread/.idea/codeStyles/Project.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/AutomatedTrading_SpringThread/.idea/dbnavigator.xml b/AutomatedTrading_SpringThread/.idea/dbnavigator.xml new file mode 100644 index 0000000..3f4b56c --- /dev/null +++ b/AutomatedTrading_SpringThread/.idea/dbnavigator.xml @@ -0,0 +1,456 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/AutomatedTrading_SpringThread/pom.xml b/AutomatedTrading_SpringThread/pom.xml new file mode 100644 index 0000000..635e78c --- /dev/null +++ b/AutomatedTrading_SpringThread/pom.xml @@ -0,0 +1,75 @@ + + + 4.0.0 + + com.suneesh + AutomatedTrading_Spring_Postgres_Threading + jar + Spring Boot Spring Data Postgresql - Threading + 1.0-SNAPSHOT + + + org.springframework.boot + spring-boot-starter-parent + 2.1.2.RELEASE + + + + 1.8 + true + true + + + + + + + org.springframework.boot + spring-boot-starter-data-jpa + + + + + org.postgresql + postgresql + + + + org.springframework.boot + spring-boot-starter-test + test + + + + org.projectlombok + lombok + + + + org.apache.logging.log4j + log4j-slf4j-impl + 2.13.0 + + + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + org.apache.maven.plugins + maven-surefire-plugin + 2.22.0 + + + + + + diff --git a/AutomatedTrading_SpringThread/src/main/java/com/suneesh/trading/springdata/repository/Application.java b/AutomatedTrading_SpringThread/src/main/java/com/suneesh/trading/springdata/repository/Application.java new file mode 100644 index 0000000..0ab8150 --- /dev/null +++ b/AutomatedTrading_SpringThread/src/main/java/com/suneesh/trading/springdata/repository/Application.java @@ -0,0 +1,46 @@ +package com.suneesh.trading.springdata.repository; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +import java.util.concurrent.*; + +public class Application { + private static final Logger LOGGER = LogManager.getLogger(); + protected BlockingQueue inputMessageQueue = new LinkedBlockingQueue<>(); + protected Publisher publisher; + protected Calculator calculator; + protected BookRepository repository; + + + public void threadCreation(){ + LOGGER.info("Timed threads..."); + + ExecutorService publisherThread = Executors.newFixedThreadPool(1); + publisherThread.submit(()->{ + Thread.currentThread().setName("PublisherThread"); + LOGGER.info("{} started ... ", Thread.currentThread().getName()); + publisher.threadWork(); + }); + + ScheduledExecutorService ses = Executors.newSingleThreadScheduledExecutor(); + ses.scheduleAtFixedRate(()->{ + Thread.currentThread().setName("Calculator Thread 1"); + LOGGER.info("{} started ... ", Thread.currentThread().getName()); + calculator.sendRequest(); + },0,1,TimeUnit.SECONDS); + + ScheduledExecutorService ses2 = Executors.newSingleThreadScheduledExecutor(); + ses.scheduleAtFixedRate(()->{ + Thread.currentThread().setName("Calculator Thread 2 "); + LOGGER.info("{} started ... ", Thread.currentThread().getName()); + calculator.sendRequest(); + },0,3,TimeUnit.SECONDS); + } + + public void init(BookRepository bookRepository) { + this.repository = bookRepository; + publisher = new Publisher(inputMessageQueue,this.repository); + calculator = new Calculator(inputMessageQueue); + } +} diff --git a/AutomatedTrading_SpringThread/src/main/java/com/suneesh/trading/springdata/repository/Book.java b/AutomatedTrading_SpringThread/src/main/java/com/suneesh/trading/springdata/repository/Book.java new file mode 100644 index 0000000..8b84b83 --- /dev/null +++ b/AutomatedTrading_SpringThread/src/main/java/com/suneesh/trading/springdata/repository/Book.java @@ -0,0 +1,26 @@ +package com.suneesh.trading.springdata.repository; + +import lombok.Data; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; + +@Entity +@Data +public class Book { + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private Long id; + private String name; + + public Book() { + } + + public Book(String name) { + this.name = name; + } + +} diff --git a/AutomatedTrading_SpringThread/src/main/java/com/suneesh/trading/springdata/repository/BookRepository.java b/AutomatedTrading_SpringThread/src/main/java/com/suneesh/trading/springdata/repository/BookRepository.java new file mode 100644 index 0000000..a465e04 --- /dev/null +++ b/AutomatedTrading_SpringThread/src/main/java/com/suneesh/trading/springdata/repository/BookRepository.java @@ -0,0 +1,11 @@ +package com.suneesh.trading.springdata.repository; + +import org.springframework.data.repository.CrudRepository; + +import java.util.List; + +public interface BookRepository extends CrudRepository { + + List findByName(String name); + +} diff --git a/AutomatedTrading_SpringThread/src/main/java/com/suneesh/trading/springdata/repository/Calculator.java b/AutomatedTrading_SpringThread/src/main/java/com/suneesh/trading/springdata/repository/Calculator.java new file mode 100644 index 0000000..c59e67d --- /dev/null +++ b/AutomatedTrading_SpringThread/src/main/java/com/suneesh/trading/springdata/repository/Calculator.java @@ -0,0 +1,31 @@ +package com.suneesh.trading.springdata.repository; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +import java.util.Random; +import java.util.concurrent.BlockingQueue; +import java.util.concurrent.LinkedBlockingQueue; + +public class Calculator { + private static final Logger LOGGER = LogManager.getLogger(); + private BlockingQueue inputMessageQueue = new LinkedBlockingQueue<>(); + private float startValue; + + public Calculator(BlockingQueue inputMessageQueue) { + this.inputMessageQueue = inputMessageQueue; + this.startValue = 0; + } + + public void sendRequest(){ + float newValue = 0.0f; + try{ + float delta = (new Random()).nextFloat(); + int direction = (new Random()).nextBoolean()==true?1:-1; + newValue += (delta * direction); + inputMessageQueue.put(newValue); + } catch (Exception e) { + e.printStackTrace(); + } + } +} diff --git a/AutomatedTrading_SpringThread/src/main/java/com/suneesh/trading/springdata/repository/Publisher.java b/AutomatedTrading_SpringThread/src/main/java/com/suneesh/trading/springdata/repository/Publisher.java new file mode 100644 index 0000000..4989b91 --- /dev/null +++ b/AutomatedTrading_SpringThread/src/main/java/com/suneesh/trading/springdata/repository/Publisher.java @@ -0,0 +1,46 @@ +package com.suneesh.trading.springdata.repository; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +import java.util.concurrent.BlockingQueue; +import java.util.concurrent.LinkedBlockingQueue; +import java.util.concurrent.TimeUnit; + +public class Publisher { + private static final Logger LOGGER = LogManager.getLogger(); + private BlockingQueue inputMessageQueue = new LinkedBlockingQueue<>(); + private float startValue; + private BookRepository repository; + + public Publisher(BlockingQueue inputMessageQueue, BookRepository repository) { + this.inputMessageQueue = inputMessageQueue; + this.startValue = 0; + this.repository = repository; + } + + public void threadWork(){ + LOGGER.info("Thread work ... "); + Long count = 0L; + while(true){ + try { + final Float data = inputMessageQueue.poll(100, TimeUnit.MILLISECONDS); + if(data!=null){ + count++; + LOGGER.info("data = {}", data); + if(repository!=null) { + repository.save(new Book(String.valueOf(data.floatValue()))); +// bookRepository.findAll().forEach(x->LOGGER.info("Repository value = {}",x)); + } + else{ + LOGGER.info("Repository is null."); + } + } + } catch (Exception e) { + e.printStackTrace(); + } + + } + } + +} diff --git a/AutomatedTrading_SpringThread/src/main/java/com/suneesh/trading/springdata/repository/StartApplication.java b/AutomatedTrading_SpringThread/src/main/java/com/suneesh/trading/springdata/repository/StartApplication.java new file mode 100644 index 0000000..1840c82 --- /dev/null +++ b/AutomatedTrading_SpringThread/src/main/java/com/suneesh/trading/springdata/repository/StartApplication.java @@ -0,0 +1,53 @@ +package com.suneesh.trading.springdata.repository; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.CommandLineRunner; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class StartApplication implements CommandLineRunner { + + private static final Logger log = LogManager.getLogger(); + + @Autowired + private BookRepository bookRepository; + + public static void main(String[] args) { + SpringApplication.run(StartApplication.class, args); + } + + private void oldExampleCode(){ + Book java = new Book("Java"); + bookRepository.save(java); + bookRepository.save(new Book("Node")); + bookRepository.save(new Book("Python")); + + System.out.println("\nfindAll()"); + bookRepository.findAll().forEach(x -> System.out.println(x)); + + System.out.println("\nfindById(1L)"); + bookRepository.findById(1l).ifPresent(x -> System.out.println(x)); + + System.out.println("\nfindByName('Node')"); + bookRepository.findByName("Node").forEach(x -> System.out.println(x)); + } + + @Override + public void run(String... args) { + + log.info("StartApplication..."); + + oldExampleCode(); + Application mainApplication = new Application(); + mainApplication.init(bookRepository); + + mainApplication.threadCreation(); + + bookRepository.save(new Book("Python 2")); + + } + +} diff --git a/AutomatedTrading_SpringThread/src/main/resources/application.properties b/AutomatedTrading_SpringThread/src/main/resources/application.properties new file mode 100644 index 0000000..7637edc --- /dev/null +++ b/AutomatedTrading_SpringThread/src/main/resources/application.properties @@ -0,0 +1,21 @@ +logging.level.org.springframework=INFO +logging.level.com.mkyong=INFO +logging.level.com.zaxxer=INFO +logging.level.root=ERROR + +spring.datasource.hikari.connectionTimeout=20000 +spring.datasource.hikari.maximumPoolSize=5 + +logging.pattern.console=%-5level %logger{36} - %msg%n + +## PostgreSQL +spring.datasource.url=jdbc:postgresql://localhost:5432/automated_trading +spring.datasource.username=suneesh +spring.datasource.password=suneesh + +#`hibernate_sequence' doesn't exist +spring.jpa.hibernate.use-new-id-generator-mappings=false + +#drop n create table again, good for testing, comment this in production +spring.jpa.hibernate.ddl-auto=create + diff --git a/AutomatedTrading_SpringThread/src/main/resources/log4j2.xml b/AutomatedTrading_SpringThread/src/main/resources/log4j2.xml new file mode 100644 index 0000000..9b3ea0c --- /dev/null +++ b/AutomatedTrading_SpringThread/src/main/resources/log4j2.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/AutomatedTrading_SpringThread/src/test/java/com/suneesh/trading/springdata/repository/BookRepositoryTest.java b/AutomatedTrading_SpringThread/src/test/java/com/suneesh/trading/springdata/repository/BookRepositoryTest.java new file mode 100644 index 0000000..e635dae --- /dev/null +++ b/AutomatedTrading_SpringThread/src/test/java/com/suneesh/trading/springdata/repository/BookRepositoryTest.java @@ -0,0 +1,38 @@ +package com.suneesh.trading.springdata.repository; + +import org.assertj.core.api.Assertions; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; +import org.springframework.boot.test.autoconfigure.orm.jpa.TestEntityManager; +import org.springframework.test.context.junit4.SpringRunner; + +import java.util.List; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.Assert.assertEquals; + +@RunWith(SpringRunner.class) +@DataJpaTest +public class BookRepositoryTest { + + @Autowired + private TestEntityManager entityManager; + + @Autowired + private BookRepository repository; + + @Test + public void testFindByName() { + + entityManager.persist(new Book("C++")); + + List books = repository.findByName("C++"); + assertEquals(1, books.size()); + + Assertions.assertThat(books).extracting(Book::getName).containsOnly("C++"); + + } + +} diff --git a/AutomatedTrading_SpringThread/target/classes/META-INF/AutomatedTrading_SpringThread.kotlin_module b/AutomatedTrading_SpringThread/target/classes/META-INF/AutomatedTrading_SpringThread.kotlin_module new file mode 100644 index 0000000..a49347a Binary files /dev/null and b/AutomatedTrading_SpringThread/target/classes/META-INF/AutomatedTrading_SpringThread.kotlin_module differ diff --git a/AutomatedTrading_SpringThread/target/classes/application.properties b/AutomatedTrading_SpringThread/target/classes/application.properties new file mode 100644 index 0000000..7637edc --- /dev/null +++ b/AutomatedTrading_SpringThread/target/classes/application.properties @@ -0,0 +1,21 @@ +logging.level.org.springframework=INFO +logging.level.com.mkyong=INFO +logging.level.com.zaxxer=INFO +logging.level.root=ERROR + +spring.datasource.hikari.connectionTimeout=20000 +spring.datasource.hikari.maximumPoolSize=5 + +logging.pattern.console=%-5level %logger{36} - %msg%n + +## PostgreSQL +spring.datasource.url=jdbc:postgresql://localhost:5432/automated_trading +spring.datasource.username=suneesh +spring.datasource.password=suneesh + +#`hibernate_sequence' doesn't exist +spring.jpa.hibernate.use-new-id-generator-mappings=false + +#drop n create table again, good for testing, comment this in production +spring.jpa.hibernate.ddl-auto=create + diff --git a/AutomatedTrading_SpringThread/target/classes/com/suneesh/trading/springdata/repository/Application.class b/AutomatedTrading_SpringThread/target/classes/com/suneesh/trading/springdata/repository/Application.class new file mode 100644 index 0000000..68f85ef Binary files /dev/null and b/AutomatedTrading_SpringThread/target/classes/com/suneesh/trading/springdata/repository/Application.class differ diff --git a/AutomatedTrading_SpringThread/target/classes/com/suneesh/trading/springdata/repository/Book.class b/AutomatedTrading_SpringThread/target/classes/com/suneesh/trading/springdata/repository/Book.class new file mode 100644 index 0000000..f2c8b69 Binary files /dev/null and b/AutomatedTrading_SpringThread/target/classes/com/suneesh/trading/springdata/repository/Book.class differ diff --git a/AutomatedTrading_SpringThread/target/classes/com/suneesh/trading/springdata/repository/BookRepository.class b/AutomatedTrading_SpringThread/target/classes/com/suneesh/trading/springdata/repository/BookRepository.class new file mode 100644 index 0000000..0a47689 Binary files /dev/null and b/AutomatedTrading_SpringThread/target/classes/com/suneesh/trading/springdata/repository/BookRepository.class differ diff --git a/AutomatedTrading_SpringThread/target/classes/com/suneesh/trading/springdata/repository/Calculator.class b/AutomatedTrading_SpringThread/target/classes/com/suneesh/trading/springdata/repository/Calculator.class new file mode 100644 index 0000000..b9d74b2 Binary files /dev/null and b/AutomatedTrading_SpringThread/target/classes/com/suneesh/trading/springdata/repository/Calculator.class differ diff --git a/AutomatedTrading_SpringThread/target/classes/com/suneesh/trading/springdata/repository/Publisher.class b/AutomatedTrading_SpringThread/target/classes/com/suneesh/trading/springdata/repository/Publisher.class new file mode 100644 index 0000000..d55a88d Binary files /dev/null and b/AutomatedTrading_SpringThread/target/classes/com/suneesh/trading/springdata/repository/Publisher.class differ diff --git a/AutomatedTrading_SpringThread/target/classes/com/suneesh/trading/springdata/repository/StartApplication.class b/AutomatedTrading_SpringThread/target/classes/com/suneesh/trading/springdata/repository/StartApplication.class new file mode 100644 index 0000000..0fc65db Binary files /dev/null and b/AutomatedTrading_SpringThread/target/classes/com/suneesh/trading/springdata/repository/StartApplication.class differ diff --git a/AutomatedTrading_SpringThread/target/test-classes/META-INF/AutomatedTrading_SpringThread.kotlin_module b/AutomatedTrading_SpringThread/target/test-classes/META-INF/AutomatedTrading_SpringThread.kotlin_module new file mode 100644 index 0000000..a49347a Binary files /dev/null and b/AutomatedTrading_SpringThread/target/test-classes/META-INF/AutomatedTrading_SpringThread.kotlin_module differ diff --git a/AutomatedTrading_SpringThread/target/test-classes/com/suneesh/trading/springdata/repository/BookRepositoryTest.class b/AutomatedTrading_SpringThread/target/test-classes/com/suneesh/trading/springdata/repository/BookRepositoryTest.class new file mode 100644 index 0000000..9982dfe Binary files /dev/null and b/AutomatedTrading_SpringThread/target/test-classes/com/suneesh/trading/springdata/repository/BookRepositoryTest.class differ diff --git a/LambdaApiGateway/.classpath b/LambdaApiGateway/.classpath new file mode 100644 index 0000000..ceec4b7 --- /dev/null +++ b/LambdaApiGateway/.classpath @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/LambdaApiGateway/.project b/LambdaApiGateway/.project new file mode 100644 index 0000000..34f1aff --- /dev/null +++ b/LambdaApiGateway/.project @@ -0,0 +1,23 @@ + + + LambdaApiGateway + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.eclipse.jdt.core.javanature + org.eclipse.m2e.core.maven2Nature + + diff --git a/LambdaApiGateway/.settings/org.eclipse.core.resources.prefs b/LambdaApiGateway/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000..5b781ec --- /dev/null +++ b/LambdaApiGateway/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,3 @@ +eclipse.preferences.version=1 +encoding//src/main/java=UTF-8 +encoding//src/test/java=UTF-8 diff --git a/LambdaApiGateway/.settings/org.eclipse.jdt.core.prefs b/LambdaApiGateway/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..b8947ec --- /dev/null +++ b/LambdaApiGateway/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,6 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning +org.eclipse.jdt.core.compiler.release=disabled +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/LambdaApiGateway/.settings/org.eclipse.m2e.core.prefs b/LambdaApiGateway/.settings/org.eclipse.m2e.core.prefs new file mode 100644 index 0000000..f897a7f --- /dev/null +++ b/LambdaApiGateway/.settings/org.eclipse.m2e.core.prefs @@ -0,0 +1,4 @@ +activeProfiles= +eclipse.preferences.version=1 +resolveWorkspaceProjects=true +version=1 diff --git a/LambdaApiGateway/README.html b/LambdaApiGateway/README.html new file mode 100644 index 0000000..689d5d2 --- /dev/null +++ b/LambdaApiGateway/README.html @@ -0,0 +1,201 @@ + + + + +
+
+ +
+ +

Welcome to AWS Lambda Eclipse Plugin

+ +

Congratulations! You have created your first AWS Lambda project. So what's next?

+ +
+ +
+ +
+ +

Step 1: Implement your function

+ +

Open up LambdaFunctionHandler.java and implement the handleRequest method. This method is the entry point for your Lambda function, and it will be invoked by Lambda in response to input from the event sources of your function.

+ +
+

Note: You can add new classes and additional external dependencies in your project if needed.

+
+ +
+ +
+ +
+ +

Step 2: Test your function

+ +

Open up LambdaFunctionHandlerTest.java. Fill in your test logic to validate the input and output of your function handler, and then run it locally as a normal JUnit test.

+ +
+

Note: The unit test provides a sample JSON input file if you have chosen a predefined event type as your function input. You can modify the JSON file, or create new ones based on it.

+
+ +
+ +
+ +
+ +

Step 3: Upload your function

+ +

+Under Project or Package Explorer View, right-click on your project and select Amazon Web Services -> Upload Function to AWS Lambda. +Then follow the steps to create a new Lambda function or upload your code to an existing function. +

+ + +
+ +
+ +
+ +

Step 4: Invoke your function

+ +

Now we are ready to run the function in the cloud. Right-click on your project again and select Amazon Web Services -> Run on AWS Lambda.
+In the input dialog, enter the JSON input for your function, or select one of the JSON files in your project.

+ +
+

Tip: You can add new JSON input files in your project, and they will show up in this dialog as long as the file name ends with ".json".

+
+ +

Click Invoke and check the output of your function in the Eclipse Console View.

+ +
+ +
+ +
+ +

What's next?

+ +

If you want to know more about AWS Lambda, check out the following links:

+ + + +

Contact us to send bug reports and feedbacks.

+ +

AWS SDK for Java team

+ +
+ +
+ +
+ \ No newline at end of file diff --git a/LambdaApiGateway/dependency-reduced-pom.xml b/LambdaApiGateway/dependency-reduced-pom.xml new file mode 100644 index 0000000..e3fe52d --- /dev/null +++ b/LambdaApiGateway/dependency-reduced-pom.xml @@ -0,0 +1,59 @@ + + + 4.0.0 + com.amazonaws.lambda + demo + 1.0.0 + + + + maven-compiler-plugin + 3.6.0 + + 1.8 + 1.8 + UTF-8 + true + + + + maven-shade-plugin + 3.0.0 + + + package + + shade + + + + + + + + + junit + junit + 4.12 + test + + + hamcrest-core + org.hamcrest + + + + + + + + com.amazonaws + aws-java-sdk-bom + 1.11.570 + pom + import + + + + + diff --git a/LambdaApiGateway/pom.xml b/LambdaApiGateway/pom.xml new file mode 100644 index 0000000..8f82d6b --- /dev/null +++ b/LambdaApiGateway/pom.xml @@ -0,0 +1,70 @@ + + 4.0.0 + + com.amazonaws.lambda + demo + 1.0.0 + jar + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.6.0 + + 1.8 + 1.8 + UTF-8 + true + + + + org.apache.maven.plugins + maven-shade-plugin + 3.0.0 + + + package + + shade + + + + + + + + + + + com.amazonaws + aws-java-sdk-bom + 1.11.570 + pom + import + + + + + + + junit + junit + 4.12 + test + + + + com.amazonaws + aws-lambda-java-events + 1.3.0 + + + com.amazonaws + aws-lambda-java-core + 1.1.0 + + + diff --git a/LambdaApiGateway/src/main/java/com/amazonaws/lambda/demo/LambdaFunctionHandler.java b/LambdaApiGateway/src/main/java/com/amazonaws/lambda/demo/LambdaFunctionHandler.java new file mode 100644 index 0000000..9d37dbe --- /dev/null +++ b/LambdaApiGateway/src/main/java/com/amazonaws/lambda/demo/LambdaFunctionHandler.java @@ -0,0 +1,37 @@ +package com.amazonaws.lambda.demo; + +import com.amazonaws.services.dynamodbv2.AmazonDynamoDB; +import com.amazonaws.services.dynamodbv2.AmazonDynamoDBClientBuilder; +import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapper; +import com.amazonaws.services.lambda.runtime.Context; + +public class LambdaFunctionHandler { + + public static Object handleRequest(Request request, Context context) throws Exception { + + AmazonDynamoDB client = AmazonDynamoDBClientBuilder.defaultClient(); + DynamoDBMapper mapper = new DynamoDBMapper(client); + + Student student = null; + + switch (request.getHttpMethod()) { + case "GET": + student = mapper.load(Student.class, request.getId()); + if (student == null) { + throw new Exception("Resource not found " + request.getId()); + } + return student; + case "POST": + student = request.getStudent(); + mapper.save(student); + return student; + default: + break; + + } + + // TODO: implement your handler + return "null"; + } + +} diff --git a/LambdaApiGateway/src/main/java/com/amazonaws/lambda/demo/Request.java b/LambdaApiGateway/src/main/java/com/amazonaws/lambda/demo/Request.java new file mode 100644 index 0000000..6852a34 --- /dev/null +++ b/LambdaApiGateway/src/main/java/com/amazonaws/lambda/demo/Request.java @@ -0,0 +1,37 @@ +package com.amazonaws.lambda.demo; + +public class Request { + + private String httpMethod; + + public String getHttpMethod() { + return httpMethod; + } + + public void setHttpMethod(String httpMethod) { + this.httpMethod = httpMethod; + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public Student getStudent() { + return student; + } + + public void setStudent(Student student) { + this.student = student; + } + + private int id; + private Student student; + + public Request() { + + } +} diff --git a/LambdaApiGateway/src/main/java/com/amazonaws/lambda/demo/Student.java b/LambdaApiGateway/src/main/java/com/amazonaws/lambda/demo/Student.java new file mode 100644 index 0000000..164c8e3 --- /dev/null +++ b/LambdaApiGateway/src/main/java/com/amazonaws/lambda/demo/Student.java @@ -0,0 +1,39 @@ +package com.amazonaws.lambda.demo; + +import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBHashKey; +import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBTable; + +@DynamoDBTable(tableName = "Students") +public class Student { + + @DynamoDBHashKey + private int id; + private String name; + + public Student() { + + } + + public Student(int id, String name) { + super(); + this.id = id; + this.name = name; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + +} diff --git a/LambdaApiGateway/src/test/java/com/amazonaws/lambda/demo/LambdaFunctionHandlerTest.java b/LambdaApiGateway/src/test/java/com/amazonaws/lambda/demo/LambdaFunctionHandlerTest.java new file mode 100644 index 0000000..4b6c991 --- /dev/null +++ b/LambdaApiGateway/src/test/java/com/amazonaws/lambda/demo/LambdaFunctionHandlerTest.java @@ -0,0 +1,31 @@ +package com.amazonaws.lambda.demo; + +import java.io.IOException; + +import org.junit.BeforeClass; + +import com.amazonaws.services.lambda.runtime.Context; + +/** + * A simple test harness for locally invoking your Lambda function handler. + */ +public class LambdaFunctionHandlerTest { + + private static Object input; + + @BeforeClass + public static void createInput() throws IOException { + // TODO: set up your sample input object here. + input = null; + } + + private Context createContext() { + TestContext ctx = new TestContext(); + + // TODO: customize your context here if needed. + ctx.setFunctionName("Your Function Name"); + + return ctx; + } + +} diff --git a/LambdaApiGateway/src/test/java/com/amazonaws/lambda/demo/TestContext.java b/LambdaApiGateway/src/test/java/com/amazonaws/lambda/demo/TestContext.java new file mode 100644 index 0000000..57bdbdb --- /dev/null +++ b/LambdaApiGateway/src/test/java/com/amazonaws/lambda/demo/TestContext.java @@ -0,0 +1,136 @@ +package com.amazonaws.lambda.demo; + +import com.amazonaws.services.lambda.runtime.ClientContext; +import com.amazonaws.services.lambda.runtime.CognitoIdentity; +import com.amazonaws.services.lambda.runtime.Context; +import com.amazonaws.services.lambda.runtime.LambdaLogger; + +/** + * A simple mock implementation of the {@code Context} interface. Default + * values are stubbed out, and setters are provided so you can customize + * the context before passing it to your function. + */ +public class TestContext implements Context { + + private String awsRequestId = "EXAMPLE"; + private ClientContext clientContext; + private String functionName = "EXAMPLE"; + private CognitoIdentity identity; + private String logGroupName = "EXAMPLE"; + private String logStreamName = "EXAMPLE"; + private LambdaLogger logger = new TestLogger(); + private int memoryLimitInMB = 128; + private int remainingTimeInMillis = 15000; + private String functionVersion = "EXAMPLE"; + private String invokedFunctionArn = "EXAMPLE"; + + @Override + public String getAwsRequestId() { + return awsRequestId; + } + + public void setAwsRequestId(String value) { + awsRequestId = value; + } + + @Override + public ClientContext getClientContext() { + return clientContext; + } + + public void setClientContext(ClientContext value) { + clientContext = value; + } + + @Override + public String getFunctionName() { + return functionName; + } + + public void setFunctionName(String value) { + functionName = value; + } + + @Override + public CognitoIdentity getIdentity() { + return identity; + } + + public void setIdentity(CognitoIdentity value) { + identity = value; + } + + @Override + public String getLogGroupName() { + return logGroupName; + } + + public void setLogGroupName(String value) { + logGroupName = value; + } + + @Override + public String getLogStreamName() { + return logStreamName; + } + + public void setLogStreamName(String value) { + logStreamName = value; + } + + @Override + public LambdaLogger getLogger() { + return logger; + } + + public void setLogger(LambdaLogger value) { + logger = value; + } + + @Override + public int getMemoryLimitInMB() { + return memoryLimitInMB; + } + + public void setMemoryLimitInMB(int value) { + memoryLimitInMB = value; + } + + @Override + public int getRemainingTimeInMillis() { + return remainingTimeInMillis; + } + + public void setRemainingTimeInMillis(int value) { + remainingTimeInMillis = value; + } + + @Override + public String getFunctionVersion() { + return functionVersion; + } + + public void setFunctionVersion(String value) { + functionVersion = value; + } + + @Override + public String getInvokedFunctionArn() { + return invokedFunctionArn; + } + + public void setInvokedFunctionArn(String value) { + invokedFunctionArn = value; + } + + /** + * A simple {@code LambdaLogger} that prints everything to stderr. + */ + private static class TestLogger implements LambdaLogger { + + @Override + public void log(String message) { + System.err.println(message); + } + } +} diff --git a/LambdaApiGateway/src/test/java/com/amazonaws/lambda/demo/TestUtils.java b/LambdaApiGateway/src/test/java/com/amazonaws/lambda/demo/TestUtils.java new file mode 100644 index 0000000..59d66f4 --- /dev/null +++ b/LambdaApiGateway/src/test/java/com/amazonaws/lambda/demo/TestUtils.java @@ -0,0 +1,233 @@ +package com.amazonaws.lambda.demo; + +import java.io.IOException; +import java.io.InputStream; +import java.nio.ByteBuffer; +import java.util.Date; +import java.util.List; +import java.util.Map; + +import org.joda.time.DateTime; +import org.joda.time.format.DateTimeFormatter; +import org.joda.time.format.ISODateTimeFormat; +import org.joda.time.tz.FixedDateTimeZone; + +import com.amazonaws.services.dynamodbv2.model.AttributeValue; +import com.amazonaws.services.dynamodbv2.model.Record; +import com.amazonaws.services.dynamodbv2.model.StreamRecord; +import com.amazonaws.services.lambda.runtime.events.DynamodbEvent; +import com.amazonaws.services.lambda.runtime.events.S3Event; +import com.amazonaws.services.lambda.runtime.events.SNSEvent; +import com.amazonaws.services.s3.event.S3EventNotification; +import com.amazonaws.util.IOUtils; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.JsonDeserializer; +import com.fasterxml.jackson.databind.JsonSerializer; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.PropertyNamingStrategy; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.module.SimpleModule; + +/** + * Helper utilities for testing Lambda functions. + */ +public class TestUtils { + + private static final ObjectMapper mapper = new ObjectMapper(); + private static final ObjectMapper snsEventMapper = new ObjectMapper(); + private static final ObjectMapper dynamodbEventMapper = new ObjectMapper(); + + static { + mapper.configure(JsonParser.Feature.ALLOW_COMMENTS, true); + mapper.setPropertyNamingStrategy(new UpperCaseRecordsPropertyNamingStrategy()); + mapper.registerModule(new TestJacksonMapperModule()); + + snsEventMapper.configure(JsonParser.Feature.ALLOW_COMMENTS, true); + snsEventMapper.setPropertyNamingStrategy(PropertyNamingStrategy.PASCAL_CASE_TO_CAMEL_CASE); + snsEventMapper.registerModule(new TestJacksonMapperModule()); + + dynamodbEventMapper.configure(JsonParser.Feature.ALLOW_COMMENTS, true); + dynamodbEventMapper.setPropertyNamingStrategy(new UpperCaseRecordsPropertyNamingStrategy()); + dynamodbEventMapper.registerModule(new TestJacksonMapperModule()); + dynamodbEventMapper.addMixIn(Record.class, DynamodbEventMixin.RecordMixin.class); + dynamodbEventMapper.addMixIn(StreamRecord.class, DynamodbEventMixin.StreamRecordMixin.class); + dynamodbEventMapper.addMixIn(AttributeValue.class, DynamodbEventMixin.AttributeValueMixIn.class); + } + + private static final DateTimeFormatter dateTimeFormatter = + ISODateTimeFormat.dateTime() + .withZone(new FixedDateTimeZone("GMT", "GMT", 0, 0)); + + /** + * Helper method that parses a JSON object from a resource on the classpath + * as an instance of the provided type. + * + * @param resource the path to the resource (relative to this class) + * @param clazz the type to parse the JSON into + */ + public static T parse(String resource, Class clazz) + throws IOException { + + InputStream stream = TestUtils.class.getResourceAsStream(resource); + try { + if (clazz == S3Event.class) { + String json = IOUtils.toString(stream); + S3EventNotification event = S3EventNotification.parseJson(json); + + @SuppressWarnings("unchecked") + T result = (T) new S3Event(event.getRecords()); + return result; + + } else if (clazz == SNSEvent.class) { + return snsEventMapper.readValue(stream, clazz); + } else if (clazz == DynamodbEvent.class) { + return dynamodbEventMapper.readValue(stream, clazz); + } else { + return mapper.readValue(stream, clazz); + } + } finally { + stream.close(); + } + } + + private static class TestJacksonMapperModule extends SimpleModule { + + private static final long serialVersionUID = 1L; + + public TestJacksonMapperModule() { + super("TestJacksonMapperModule"); + + super.addSerializer(DateTime.class, new DateTimeSerializer()); + super.addDeserializer(DateTime.class, new DateTimeDeserializer()); + } + } + + private static class DateTimeSerializer extends JsonSerializer { + + @Override + public void serialize( + DateTime value, + JsonGenerator gen, + SerializerProvider provider) throws IOException { + + gen.writeString(dateTimeFormatter.print(value)); + } + } + + private static class DateTimeDeserializer + extends JsonDeserializer { + + @Override + public DateTime deserialize( + JsonParser parser, + DeserializationContext context) throws IOException { + + return dateTimeFormatter.parseDateTime(parser.getText()); + } + } + + private static class UpperCaseRecordsPropertyNamingStrategy + extends PropertyNamingStrategy.PropertyNamingStrategyBase { + + private static final long serialVersionUID = 1L; + + @Override + public String translate(String propertyName) { + if (propertyName.equals("records")) { + return "Records"; + } + return propertyName; + } + } + + private static interface DynamodbEventMixin { + public static final String L = "L"; + public static final String M = "M"; + public static final String BS = "BS"; + public static final String NS = "NS"; + public static final String SS = "SS"; + public static final String BOOL = "BOOL"; + public static final String NULL = "NULL"; + public static final String B = "B"; + public static final String N = "N"; + public static final String S = "S"; + public static final String OLD_IMAGE = "OldImage"; + public static final String NEW_IMAGE = "NewImage"; + public static final String STREAM_VIEW_TYPE = "StreamViewType"; + public static final String SEQUENCE_NUMBER = "SequenceNumber"; + public static final String SIZE_BYTES = "SizeBytes"; + public static final String KEYS = "Keys"; + public static final String AWS_REGION = "awsRegion"; + public static final String DYNAMODB = "dynamodb"; + public static final String EVENT_ID = "eventID"; + public static final String EVENT_NAME = "eventName"; + public static final String EVENT_SOURCE = "eventSource"; + public static final String EVENT_VERSION = "eventVersion"; + public static final String EVENT_SOURCE_ARN = "eventSourceARN"; + public static final String APPROXIMATE_CREATION_DATE_TIME = "ApproximateCreationDateTime"; + + @JsonProperty(value = "Records") + public List getRecords(); + + static interface RecordMixin { + @JsonProperty(AWS_REGION) public String getAwsRegion(); + @JsonProperty(AWS_REGION) public void setAwsRegion(String awsRegion); + @JsonProperty(DYNAMODB) public Object getDynamodb(); + @JsonProperty(DYNAMODB) public void setDynamodb(Object dynamodb); + @JsonProperty(EVENT_ID) public String getEventID(); + @JsonProperty(EVENT_ID) public void setEventID(String eventID); + @JsonProperty(EVENT_NAME) public String getEventName(); + @JsonProperty(EVENT_NAME) public void setEventName(String eventName); + @JsonProperty(EVENT_SOURCE) public String getEventSource(); + @JsonProperty(EVENT_SOURCE) public void setEventSource(String eventSource); + @JsonProperty(EVENT_VERSION) public String getEventVersion(); + @JsonProperty(EVENT_VERSION) public void setEventVersion(String eventVersion); + @JsonProperty(EVENT_SOURCE_ARN) public String getEventSourceArn(); + @JsonProperty(EVENT_SOURCE_ARN) public void setEventSourceArn(String eventSourceArn); + } + + static interface StreamRecordMixin { + + @JsonProperty(KEYS) public Map getKeys(); + @JsonProperty(KEYS) public void setKeys(Map keys); + @JsonProperty(SIZE_BYTES) public Long getSizeBytes(); + @JsonProperty(SIZE_BYTES) public void setSizeBytes(Long sizeBytes); + @JsonProperty(SEQUENCE_NUMBER) public String getSequenceNumber(); + @JsonProperty(SEQUENCE_NUMBER) public void setSequenceNumber(String sequenceNumber); + @JsonProperty(STREAM_VIEW_TYPE) public String getStreamViewType(); + @JsonProperty(STREAM_VIEW_TYPE) public void setStreamViewType(String streamViewType); + @JsonProperty(NEW_IMAGE) public Map getNewImage(); + @JsonProperty(NEW_IMAGE) public void setNewImage(Map newImage); + @JsonProperty(OLD_IMAGE) public Map getOldImage(); + @JsonProperty(OLD_IMAGE) public void setOldImage(Map oldImage); + @JsonProperty(APPROXIMATE_CREATION_DATE_TIME) public Date getApproximateCreationDateTime(); + @JsonProperty(APPROXIMATE_CREATION_DATE_TIME) public void setApproximateCreationDateTime(Date approximateCreationDateTime); + } + + static interface AttributeValueMixIn { + @JsonProperty(S) public String getS(); + @JsonProperty(S) public void setS(String s); + @JsonProperty(N) public String getN(); + @JsonProperty(N) public void setN(String n); + @JsonProperty(B) public ByteBuffer getB(); + @JsonProperty(B) public void setB(ByteBuffer b); + @JsonProperty(NULL) public Boolean isNULL(); + @JsonProperty(NULL) public void setNULL(Boolean nU); + @JsonProperty(BOOL) public Boolean getBOOL(); + @JsonProperty(BOOL) public void setBOOL(Boolean bO); + @JsonProperty(SS) public List getSS(); + @JsonProperty(SS) public void setSS(List sS); + @JsonProperty(NS) public List getNS(); + @JsonProperty(NS) public void setNS(List nS); + @JsonProperty(BS) public List getBS(); + @JsonProperty(BS) public void setBS(List bS); + @JsonProperty(M) public Map getM(); + @JsonProperty(M) public void setM(Map val); + @JsonProperty(L) public List getL(); + @JsonProperty(L) public void setL(List val); + } + } +} diff --git a/LambdaApiGateway/target/classes/com/amazonaws/lambda/demo/LambdaFunctionHandler.class b/LambdaApiGateway/target/classes/com/amazonaws/lambda/demo/LambdaFunctionHandler.class new file mode 100644 index 0000000..c834f67 Binary files /dev/null and b/LambdaApiGateway/target/classes/com/amazonaws/lambda/demo/LambdaFunctionHandler.class differ diff --git a/LambdaApiGateway/target/classes/com/amazonaws/lambda/demo/Request.class b/LambdaApiGateway/target/classes/com/amazonaws/lambda/demo/Request.class new file mode 100644 index 0000000..c5fa60d Binary files /dev/null and b/LambdaApiGateway/target/classes/com/amazonaws/lambda/demo/Request.class differ diff --git a/LambdaApiGateway/target/classes/com/amazonaws/lambda/demo/Student.class b/LambdaApiGateway/target/classes/com/amazonaws/lambda/demo/Student.class new file mode 100644 index 0000000..21f2a0a Binary files /dev/null and b/LambdaApiGateway/target/classes/com/amazonaws/lambda/demo/Student.class differ diff --git a/LambdaApiGateway/target/demo-1.0.0.jar b/LambdaApiGateway/target/demo-1.0.0.jar new file mode 100644 index 0000000..ef40a59 Binary files /dev/null and b/LambdaApiGateway/target/demo-1.0.0.jar differ diff --git a/LambdaApiGateway/target/maven-archiver/pom.properties b/LambdaApiGateway/target/maven-archiver/pom.properties new file mode 100644 index 0000000..9df7811 --- /dev/null +++ b/LambdaApiGateway/target/maven-archiver/pom.properties @@ -0,0 +1,5 @@ +#Generated by Maven +#Tue Jun 11 23:36:05 BST 2019 +groupId=com.amazonaws.lambda +artifactId=demo +version=1.0.0 diff --git a/LambdaApiGateway/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst b/LambdaApiGateway/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst new file mode 100644 index 0000000..d8bb0f8 --- /dev/null +++ b/LambdaApiGateway/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst @@ -0,0 +1,3 @@ +com\amazonaws\lambda\demo\LambdaFunctionHandler.class +com\amazonaws\lambda\demo\Request.class +com\amazonaws\lambda\demo\Student.class diff --git a/LambdaApiGateway/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst b/LambdaApiGateway/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst new file mode 100644 index 0000000..485b183 --- /dev/null +++ b/LambdaApiGateway/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst @@ -0,0 +1,3 @@ +G:\Development\GitHub\JavaDevelopment\LambdaApiGateway\src\main\java\com\amazonaws\lambda\demo\Student.java +G:\Development\GitHub\JavaDevelopment\LambdaApiGateway\src\main\java\com\amazonaws\lambda\demo\Request.java +G:\Development\GitHub\JavaDevelopment\LambdaApiGateway\src\main\java\com\amazonaws\lambda\demo\LambdaFunctionHandler.java diff --git a/LambdaApiGateway/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst b/LambdaApiGateway/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst new file mode 100644 index 0000000..e667738 --- /dev/null +++ b/LambdaApiGateway/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst @@ -0,0 +1,14 @@ +com\amazonaws\lambda\demo\TestContext.class +com\amazonaws\lambda\demo\TestUtils$DateTimeDeserializer.class +com\amazonaws\lambda\demo\TestUtils$DynamodbEventMixin$RecordMixin.class +com\amazonaws\lambda\demo\TestUtils$DynamodbEventMixin.class +com\amazonaws\lambda\demo\LambdaFunctionHandlerTest.class +com\amazonaws\lambda\demo\TestContext$1.class +com\amazonaws\lambda\demo\TestUtils$UpperCaseRecordsPropertyNamingStrategy.class +com\amazonaws\lambda\demo\TestUtils$DateTimeSerializer.class +com\amazonaws\lambda\demo\TestUtils$DynamodbEventMixin$AttributeValueMixIn.class +com\amazonaws\lambda\demo\TestUtils$DynamodbEventMixin$StreamRecordMixin.class +com\amazonaws\lambda\demo\TestContext$TestLogger.class +com\amazonaws\lambda\demo\TestUtils.class +com\amazonaws\lambda\demo\TestUtils$1.class +com\amazonaws\lambda\demo\TestUtils$TestJacksonMapperModule.class diff --git a/LambdaApiGateway/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst b/LambdaApiGateway/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst new file mode 100644 index 0000000..3d75ba2 --- /dev/null +++ b/LambdaApiGateway/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst @@ -0,0 +1,3 @@ +G:\Development\GitHub\JavaDevelopment\LambdaApiGateway\src\test\java\com\amazonaws\lambda\demo\TestContext.java +G:\Development\GitHub\JavaDevelopment\LambdaApiGateway\src\test\java\com\amazonaws\lambda\demo\LambdaFunctionHandlerTest.java +G:\Development\GitHub\JavaDevelopment\LambdaApiGateway\src\test\java\com\amazonaws\lambda\demo\TestUtils.java diff --git a/LambdaApiGateway/target/original-demo-1.0.0.jar b/LambdaApiGateway/target/original-demo-1.0.0.jar new file mode 100644 index 0000000..d0ee05f Binary files /dev/null and b/LambdaApiGateway/target/original-demo-1.0.0.jar differ diff --git a/LambdaApiGateway/target/test-classes/com/amazonaws/lambda/demo/LambdaFunctionHandlerTest.class b/LambdaApiGateway/target/test-classes/com/amazonaws/lambda/demo/LambdaFunctionHandlerTest.class new file mode 100644 index 0000000..a608ce1 Binary files /dev/null and b/LambdaApiGateway/target/test-classes/com/amazonaws/lambda/demo/LambdaFunctionHandlerTest.class differ diff --git a/LambdaApiGateway/target/test-classes/com/amazonaws/lambda/demo/TestContext$1.class b/LambdaApiGateway/target/test-classes/com/amazonaws/lambda/demo/TestContext$1.class new file mode 100644 index 0000000..216a9b4 Binary files /dev/null and b/LambdaApiGateway/target/test-classes/com/amazonaws/lambda/demo/TestContext$1.class differ diff --git a/LambdaApiGateway/target/test-classes/com/amazonaws/lambda/demo/TestContext$TestLogger.class b/LambdaApiGateway/target/test-classes/com/amazonaws/lambda/demo/TestContext$TestLogger.class new file mode 100644 index 0000000..ff6cc22 Binary files /dev/null and b/LambdaApiGateway/target/test-classes/com/amazonaws/lambda/demo/TestContext$TestLogger.class differ diff --git a/LambdaApiGateway/target/test-classes/com/amazonaws/lambda/demo/TestContext.class b/LambdaApiGateway/target/test-classes/com/amazonaws/lambda/demo/TestContext.class new file mode 100644 index 0000000..5ec1faf Binary files /dev/null and b/LambdaApiGateway/target/test-classes/com/amazonaws/lambda/demo/TestContext.class differ diff --git a/LambdaApiGateway/target/test-classes/com/amazonaws/lambda/demo/TestUtils$1.class b/LambdaApiGateway/target/test-classes/com/amazonaws/lambda/demo/TestUtils$1.class new file mode 100644 index 0000000..f9fd287 Binary files /dev/null and b/LambdaApiGateway/target/test-classes/com/amazonaws/lambda/demo/TestUtils$1.class differ diff --git a/LambdaApiGateway/target/test-classes/com/amazonaws/lambda/demo/TestUtils$DateTimeDeserializer.class b/LambdaApiGateway/target/test-classes/com/amazonaws/lambda/demo/TestUtils$DateTimeDeserializer.class new file mode 100644 index 0000000..c62e8af Binary files /dev/null and b/LambdaApiGateway/target/test-classes/com/amazonaws/lambda/demo/TestUtils$DateTimeDeserializer.class differ diff --git a/LambdaApiGateway/target/test-classes/com/amazonaws/lambda/demo/TestUtils$DateTimeSerializer.class b/LambdaApiGateway/target/test-classes/com/amazonaws/lambda/demo/TestUtils$DateTimeSerializer.class new file mode 100644 index 0000000..c3d7fb3 Binary files /dev/null and b/LambdaApiGateway/target/test-classes/com/amazonaws/lambda/demo/TestUtils$DateTimeSerializer.class differ diff --git a/LambdaApiGateway/target/test-classes/com/amazonaws/lambda/demo/TestUtils$DynamodbEventMixin$AttributeValueMixIn.class b/LambdaApiGateway/target/test-classes/com/amazonaws/lambda/demo/TestUtils$DynamodbEventMixin$AttributeValueMixIn.class new file mode 100644 index 0000000..89b3a6d Binary files /dev/null and b/LambdaApiGateway/target/test-classes/com/amazonaws/lambda/demo/TestUtils$DynamodbEventMixin$AttributeValueMixIn.class differ diff --git a/LambdaApiGateway/target/test-classes/com/amazonaws/lambda/demo/TestUtils$DynamodbEventMixin$RecordMixin.class b/LambdaApiGateway/target/test-classes/com/amazonaws/lambda/demo/TestUtils$DynamodbEventMixin$RecordMixin.class new file mode 100644 index 0000000..77bb9c1 Binary files /dev/null and b/LambdaApiGateway/target/test-classes/com/amazonaws/lambda/demo/TestUtils$DynamodbEventMixin$RecordMixin.class differ diff --git a/LambdaApiGateway/target/test-classes/com/amazonaws/lambda/demo/TestUtils$DynamodbEventMixin$StreamRecordMixin.class b/LambdaApiGateway/target/test-classes/com/amazonaws/lambda/demo/TestUtils$DynamodbEventMixin$StreamRecordMixin.class new file mode 100644 index 0000000..3a48aee Binary files /dev/null and b/LambdaApiGateway/target/test-classes/com/amazonaws/lambda/demo/TestUtils$DynamodbEventMixin$StreamRecordMixin.class differ diff --git a/LambdaApiGateway/target/test-classes/com/amazonaws/lambda/demo/TestUtils$DynamodbEventMixin.class b/LambdaApiGateway/target/test-classes/com/amazonaws/lambda/demo/TestUtils$DynamodbEventMixin.class new file mode 100644 index 0000000..b0066d3 Binary files /dev/null and b/LambdaApiGateway/target/test-classes/com/amazonaws/lambda/demo/TestUtils$DynamodbEventMixin.class differ diff --git a/LambdaApiGateway/target/test-classes/com/amazonaws/lambda/demo/TestUtils$TestJacksonMapperModule.class b/LambdaApiGateway/target/test-classes/com/amazonaws/lambda/demo/TestUtils$TestJacksonMapperModule.class new file mode 100644 index 0000000..c786aaf Binary files /dev/null and b/LambdaApiGateway/target/test-classes/com/amazonaws/lambda/demo/TestUtils$TestJacksonMapperModule.class differ diff --git a/LambdaApiGateway/target/test-classes/com/amazonaws/lambda/demo/TestUtils$UpperCaseRecordsPropertyNamingStrategy.class b/LambdaApiGateway/target/test-classes/com/amazonaws/lambda/demo/TestUtils$UpperCaseRecordsPropertyNamingStrategy.class new file mode 100644 index 0000000..fb19242 Binary files /dev/null and b/LambdaApiGateway/target/test-classes/com/amazonaws/lambda/demo/TestUtils$UpperCaseRecordsPropertyNamingStrategy.class differ diff --git a/LambdaApiGateway/target/test-classes/com/amazonaws/lambda/demo/TestUtils.class b/LambdaApiGateway/target/test-classes/com/amazonaws/lambda/demo/TestUtils.class new file mode 100644 index 0000000..eb02e28 Binary files /dev/null and b/LambdaApiGateway/target/test-classes/com/amazonaws/lambda/demo/TestUtils.class differ diff --git a/SpringH2Application/.idea/.gitignore b/SpringH2Application/.idea/.gitignore new file mode 100644 index 0000000..5c98b42 --- /dev/null +++ b/SpringH2Application/.idea/.gitignore @@ -0,0 +1,2 @@ +# Default ignored files +/workspace.xml \ No newline at end of file diff --git a/SpringH2Application/.idea/codeStyles/Project.xml b/SpringH2Application/.idea/codeStyles/Project.xml new file mode 100644 index 0000000..3cdc6ae --- /dev/null +++ b/SpringH2Application/.idea/codeStyles/Project.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/SpringH2Application/.idea/compiler.xml b/SpringH2Application/.idea/compiler.xml new file mode 100644 index 0000000..61a3ad8 --- /dev/null +++ b/SpringH2Application/.idea/compiler.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/SpringH2Application/.idea/dbnavigator.xml b/SpringH2Application/.idea/dbnavigator.xml new file mode 100644 index 0000000..3f4b56c --- /dev/null +++ b/SpringH2Application/.idea/dbnavigator.xml @@ -0,0 +1,456 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/SpringH2Application/.idea/encodings.xml b/SpringH2Application/.idea/encodings.xml new file mode 100644 index 0000000..63e9001 --- /dev/null +++ b/SpringH2Application/.idea/encodings.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/SpringH2Application/.idea/misc.xml b/SpringH2Application/.idea/misc.xml new file mode 100644 index 0000000..3423671 --- /dev/null +++ b/SpringH2Application/.idea/misc.xml @@ -0,0 +1,14 @@ + + + + + + + + + + \ No newline at end of file diff --git a/SpringH2Application/.idea/uiDesigner.xml b/SpringH2Application/.idea/uiDesigner.xml new file mode 100644 index 0000000..e96534f --- /dev/null +++ b/SpringH2Application/.idea/uiDesigner.xml @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/SpringH2Application/.idea/vcs.xml b/SpringH2Application/.idea/vcs.xml new file mode 100644 index 0000000..6c0b863 --- /dev/null +++ b/SpringH2Application/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/SpringH2Application/SpringH2Application.iml b/SpringH2Application/SpringH2Application.iml new file mode 100644 index 0000000..78b2cc5 --- /dev/null +++ b/SpringH2Application/SpringH2Application.iml @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/SpringH2Application/pom.xml b/SpringH2Application/pom.xml new file mode 100644 index 0000000..34a9bad --- /dev/null +++ b/SpringH2Application/pom.xml @@ -0,0 +1,102 @@ + + + 4.0.0 + org.example + SpringH2Application + 1.0-SNAPSHOT + jar + jpa-with-in-memory-db-in-10-steps + Demo project for in memory database H2 + + org.springframework.boot + spring-boot-starter-parent + 2.0.0.BUILD-SNAPSHOT + + + + + UTF-8 + UTF-8 + 1.8 + + + + + jakarta.xml.bind + jakarta.xml.bind-api + 2.3.2 + + + + + org.glassfish.jaxb + jaxb-runtime + 2.3.2 + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.boot + spring-boot-starter-data-jpa + + + com.h2database + h2 + runtime + + + org.springframework.boot + spring-boot-starter-test + test + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + + + spring-snapshots + Spring Snapshots + https://repo.spring.io/snapshot + + true + + + + spring-milestones + Spring Milestones + https://repo.spring.io/milestone + + false + + + + + + spring-snapshots + Spring Snapshots + https://repo.spring.io/snapshot + + true + + + + spring-milestones + Spring Milestones + https://repo.spring.io/milestone + + false + + + + diff --git a/SpringH2Application/src/main/java/com/suneesh/h2/H2InMemoryApplication.java b/SpringH2Application/src/main/java/com/suneesh/h2/H2InMemoryApplication.java new file mode 100644 index 0000000..b797ff6 --- /dev/null +++ b/SpringH2Application/src/main/java/com/suneesh/h2/H2InMemoryApplication.java @@ -0,0 +1,9 @@ +package com.suneesh.h2; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +@SpringBootApplication +public class H2InMemoryApplication { + public static void main(String[] args) { + SpringApplication.run(H2InMemoryApplication.class, args); + } +} \ No newline at end of file diff --git a/SpringH2Application/src/main/java/com/suneesh/h2/UserEntityManagerCommandLineRunner.java b/SpringH2Application/src/main/java/com/suneesh/h2/UserEntityManagerCommandLineRunner.java new file mode 100644 index 0000000..0b58d7f --- /dev/null +++ b/SpringH2Application/src/main/java/com/suneesh/h2/UserEntityManagerCommandLineRunner.java @@ -0,0 +1,35 @@ +package com.suneesh.h2; + + +import com.suneesh.h2.user.UserService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.CommandLineRunner; +import org.springframework.stereotype.Component; +import com.suneesh.h2.user.User; +import com.suneesh.h2.user.UserService; +@Component +public class UserEntityManagerCommandLineRunner implements CommandLineRunner { + private static final Logger log = LoggerFactory.getLogger(UserEntityManagerCommandLineRunner.class); + @Autowired + private UserService userService; + @Override + public void run(String...args) { + log.info("-------------------------------"); + log.info("Adding Tom as Admin"); + log.info("-------------------------------"); + User tom = new User("Tom", "Admin"); + userService.insert(tom); + log.info("Inserted Tom" + tom); + log.info("-------------------------------"); + log.info("Finding user with id 1"); + log.info("-------------------------------"); + User user = userService.find(1L); + log.info(user.toString()); + log.info("-------------------------------"); + log.info("Finding all users"); + log.info("-------------------------------"); + log.info(userService.findAll().toString()); + } +} diff --git a/SpringH2Application/src/main/java/com/suneesh/h2/UserRepositoryCommandLineRunner.java b/SpringH2Application/src/main/java/com/suneesh/h2/UserRepositoryCommandLineRunner.java new file mode 100644 index 0000000..ae561c5 --- /dev/null +++ b/SpringH2Application/src/main/java/com/suneesh/h2/UserRepositoryCommandLineRunner.java @@ -0,0 +1,26 @@ +package com.suneesh.h2; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.CommandLineRunner; +import org.springframework.stereotype.Component; +import com.suneesh.h2.user.User; +import com.suneesh.h2.user.UserRepository; +@Component +public class UserRepositoryCommandLineRunner implements CommandLineRunner { + private static final Logger log = LoggerFactory.getLogger(UserRepositoryCommandLineRunner.class); + @Autowired + private UserRepository userRepository; + @Override + public void run(String...args) { + User harry = new User("Harry", "Admin"); + userRepository.save(harry); + log.info("-------------------------------"); + log.info("Finding all users"); + log.info("-------------------------------"); + for (User user: userRepository.findAll()) { + log.info(user.toString()); + } + } +} \ No newline at end of file diff --git a/SpringH2Application/src/main/java/com/suneesh/h2/user/User.java b/SpringH2Application/src/main/java/com/suneesh/h2/user/User.java new file mode 100644 index 0000000..0a68b0c --- /dev/null +++ b/SpringH2Application/src/main/java/com/suneesh/h2/user/User.java @@ -0,0 +1,36 @@ +package com.suneesh.h2.user; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.NamedQuery; + +@Entity +@NamedQuery(query = "select u from User u", name = "query_find_all_users") +public class User { + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private Long id; + private String name; // Not perfect!! Should be a proper object! + private String role; // Not perfect!! An enum should be a better choice! + protected User() {} + public User(String name, String role) { + super(); + this.name = name; + this.role = role; + } + public Long getId() { + return id; + } + public String getName() { + return name; + } + public String getRole() { + return role; + } + @Override + public String toString() { + return String.format("User [id=%s, name=%s, role=%s]", id, name, role); + } +} \ No newline at end of file diff --git a/SpringH2Application/src/main/java/com/suneesh/h2/user/UserRepository.java b/SpringH2Application/src/main/java/com/suneesh/h2/user/UserRepository.java new file mode 100644 index 0000000..1f033a8 --- /dev/null +++ b/SpringH2Application/src/main/java/com/suneesh/h2/user/UserRepository.java @@ -0,0 +1,4 @@ +package com.suneesh.h2.user; + +import org.springframework.data.jpa.repository.JpaRepository; +public interface UserRepository extends JpaRepository < User, Long > {} diff --git a/SpringH2Application/src/main/java/com/suneesh/h2/user/UserService.java b/SpringH2Application/src/main/java/com/suneesh/h2/user/UserService.java new file mode 100644 index 0000000..22f4c57 --- /dev/null +++ b/SpringH2Application/src/main/java/com/suneesh/h2/user/UserService.java @@ -0,0 +1,29 @@ +package com.suneesh.h2.user; + +import java.util.List; +import javax.persistence.EntityManager; +import javax.persistence.PersistenceContext; +import javax.persistence.Query; +import javax.transaction.Transactional; +import org.springframework.stereotype.Repository; + +@Repository +@Transactional +public class UserService { + @PersistenceContext + private EntityManager entityManager; + public long insert(User user) { + entityManager.persist(user); + return user.getId(); + } + + public User find(long id) { + return entityManager.find(User.class, id); + } + + public List < User > findAll() { + Query query = entityManager.createNamedQuery( + "query_find_all_users", User.class); + return query.getResultList(); + } +} \ No newline at end of file diff --git a/SpringH2Application/src/main/resources/application.properties b/SpringH2Application/src/main/resources/application.properties new file mode 100644 index 0000000..65ded1e --- /dev/null +++ b/SpringH2Application/src/main/resources/application.properties @@ -0,0 +1,4 @@ +spring.h2.console.enabled=true +logging.level.org.hibernate=debug +spring.jpa.show-sql=true + diff --git a/SpringH2Application/src/main/resources/data.sql b/SpringH2Application/src/main/resources/data.sql new file mode 100644 index 0000000..8dd668c --- /dev/null +++ b/SpringH2Application/src/main/resources/data.sql @@ -0,0 +1,3 @@ +insert into user (id, name, role) values (101, 'Ranga', 'Admin'); +insert into user (id, name, role) values (102, 'Ravi', 'User'); +insert into user (id, name, role) values (103, 'Satish', 'Admin'); diff --git a/SpringH2Application/src/test/java/com/suneesh/h2/H2InMemoryDbDemoApplicationTests.java b/SpringH2Application/src/test/java/com/suneesh/h2/H2InMemoryDbDemoApplicationTests.java new file mode 100644 index 0000000..9337d31 --- /dev/null +++ b/SpringH2Application/src/test/java/com/suneesh/h2/H2InMemoryDbDemoApplicationTests.java @@ -0,0 +1,12 @@ +package com.suneesh.h2; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; +@RunWith(SpringRunner.class) +@SpringBootTest +public class H2InMemoryDbDemoApplicationTests { + @Test + public void contextLoads() {} +} \ No newline at end of file diff --git a/SpringH2Application/src/test/java/com/suneesh/h2/UserRepositoryTest.java b/SpringH2Application/src/test/java/com/suneesh/h2/UserRepositoryTest.java new file mode 100644 index 0000000..c82b4c4 --- /dev/null +++ b/SpringH2Application/src/test/java/com/suneesh/h2/UserRepositoryTest.java @@ -0,0 +1,22 @@ +package com.suneesh.h2; + +import static org.junit.Assert.assertEquals; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; +import org.springframework.boot.test.autoconfigure.orm.jpa.TestEntityManager; +import org.springframework.test.context.junit4.SpringRunner; +import com.suneesh.h2.user.UserRepository; +@DataJpaTest +@RunWith(SpringRunner.class) +public class UserRepositoryTest { + @Autowired + UserRepository userRepository; + @Autowired + TestEntityManager entityManager; + @Test + public void check_todo_count() { + assertEquals(3, userRepository.count()); + } +} diff --git a/SpringH2Application/target/classes/application.properties b/SpringH2Application/target/classes/application.properties new file mode 100644 index 0000000..65ded1e --- /dev/null +++ b/SpringH2Application/target/classes/application.properties @@ -0,0 +1,4 @@ +spring.h2.console.enabled=true +logging.level.org.hibernate=debug +spring.jpa.show-sql=true + diff --git a/SpringH2Application/target/classes/com/suneesh/h2/H2InMemoryApplication.class b/SpringH2Application/target/classes/com/suneesh/h2/H2InMemoryApplication.class new file mode 100644 index 0000000..ac1f4d6 Binary files /dev/null and b/SpringH2Application/target/classes/com/suneesh/h2/H2InMemoryApplication.class differ diff --git a/SpringH2Application/target/classes/com/suneesh/h2/UserEntityManagerCommandLineRunner.class b/SpringH2Application/target/classes/com/suneesh/h2/UserEntityManagerCommandLineRunner.class new file mode 100644 index 0000000..7c08ae9 Binary files /dev/null and b/SpringH2Application/target/classes/com/suneesh/h2/UserEntityManagerCommandLineRunner.class differ diff --git a/SpringH2Application/target/classes/com/suneesh/h2/UserRepositoryCommandLineRunner.class b/SpringH2Application/target/classes/com/suneesh/h2/UserRepositoryCommandLineRunner.class new file mode 100644 index 0000000..63047c2 Binary files /dev/null and b/SpringH2Application/target/classes/com/suneesh/h2/UserRepositoryCommandLineRunner.class differ diff --git a/SpringH2Application/target/classes/com/suneesh/h2/user/User.class b/SpringH2Application/target/classes/com/suneesh/h2/user/User.class new file mode 100644 index 0000000..e570241 Binary files /dev/null and b/SpringH2Application/target/classes/com/suneesh/h2/user/User.class differ diff --git a/SpringH2Application/target/classes/com/suneesh/h2/user/UserRepository.class b/SpringH2Application/target/classes/com/suneesh/h2/user/UserRepository.class new file mode 100644 index 0000000..4c84cdf Binary files /dev/null and b/SpringH2Application/target/classes/com/suneesh/h2/user/UserRepository.class differ diff --git a/SpringH2Application/target/classes/com/suneesh/h2/user/UserService.class b/SpringH2Application/target/classes/com/suneesh/h2/user/UserService.class new file mode 100644 index 0000000..01b9e69 Binary files /dev/null and b/SpringH2Application/target/classes/com/suneesh/h2/user/UserService.class differ diff --git a/SpringH2Application/target/classes/data.sql b/SpringH2Application/target/classes/data.sql new file mode 100644 index 0000000..8dd668c --- /dev/null +++ b/SpringH2Application/target/classes/data.sql @@ -0,0 +1,3 @@ +insert into user (id, name, role) values (101, 'Ranga', 'Admin'); +insert into user (id, name, role) values (102, 'Ravi', 'User'); +insert into user (id, name, role) values (103, 'Satish', 'Admin'); diff --git a/SpringH2Application/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst b/SpringH2Application/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst new file mode 100644 index 0000000..2938c05 --- /dev/null +++ b/SpringH2Application/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst @@ -0,0 +1,6 @@ +com\suneesh\h2\UserEntityManagerCommandLineRunner.class +com\suneesh\h2\UserRepositoryCommandLineRunner.class +com\suneesh\h2\H2InMemoryApplication.class +com\suneesh\h2\user\UserService.class +com\suneesh\h2\user\UserRepository.class +com\suneesh\h2\user\User.class diff --git a/SpringH2Application/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst b/SpringH2Application/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst new file mode 100644 index 0000000..e8475de --- /dev/null +++ b/SpringH2Application/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst @@ -0,0 +1,6 @@ +G:\Development\GitHub\JavaDevelopment\SpringH2Application\src\main\java\com\suneesh\h2\H2InMemoryApplication.java +G:\Development\GitHub\JavaDevelopment\SpringH2Application\src\main\java\com\suneesh\h2\user\User.java +G:\Development\GitHub\JavaDevelopment\SpringH2Application\src\main\java\com\suneesh\h2\UserEntityManagerCommandLineRunner.java +G:\Development\GitHub\JavaDevelopment\SpringH2Application\src\main\java\com\suneesh\h2\user\UserRepository.java +G:\Development\GitHub\JavaDevelopment\SpringH2Application\src\main\java\com\suneesh\h2\UserRepositoryCommandLineRunner.java +G:\Development\GitHub\JavaDevelopment\SpringH2Application\src\main\java\com\suneesh\h2\user\UserService.java diff --git a/SpringH2Application/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst b/SpringH2Application/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst new file mode 100644 index 0000000..df698c3 --- /dev/null +++ b/SpringH2Application/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst @@ -0,0 +1,2 @@ +com\suneesh\h2\H2InMemoryDbDemoApplicationTests.class +com\suneesh\h2\UserRepositoryTest.class diff --git a/SpringH2Application/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst b/SpringH2Application/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst new file mode 100644 index 0000000..6dccd18 --- /dev/null +++ b/SpringH2Application/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst @@ -0,0 +1,2 @@ +G:\Development\GitHub\JavaDevelopment\SpringH2Application\src\test\java\com\suneesh\h2\UserRepositoryTest.java +G:\Development\GitHub\JavaDevelopment\SpringH2Application\src\test\java\com\suneesh\h2\H2InMemoryDbDemoApplicationTests.java diff --git a/SpringH2Application/target/surefire-reports/2020-01-19T23-21-34_040.dumpstream b/SpringH2Application/target/surefire-reports/2020-01-19T23-21-34_040.dumpstream new file mode 100644 index 0000000..850db27 --- /dev/null +++ b/SpringH2Application/target/surefire-reports/2020-01-19T23-21-34_040.dumpstream @@ -0,0 +1,15 @@ +# Created on 2020-01-19T23:21:34.042 +WARNING: An illegal reflective access operation has occurred + +# Created on 2020-01-19T23:21:34.043 +WARNING: Illegal reflective access by org.springframework.cglib.core.ReflectUtils$1 (file:/G:/Development/MavenRepository/org/springframework/spring-core/5.0.4.RELEASE/spring-core-5.0.4.RELEASE.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain) + +# Created on 2020-01-19T23:21:34.043 +WARNING: Please consider reporting this to the maintainers of org.springframework.cglib.core.ReflectUtils$1 + +# Created on 2020-01-19T23:21:34.043 +WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations + +# Created on 2020-01-19T23:21:34.044 +WARNING: All illegal access operations will be denied in a future release + diff --git a/SpringH2Application/target/surefire-reports/TEST-com.suneesh.h2.H2InMemoryDbDemoApplicationTests.xml b/SpringH2Application/target/surefire-reports/TEST-com.suneesh.h2.H2InMemoryDbDemoApplicationTests.xml new file mode 100644 index 0000000..83cc800 --- /dev/null +++ b/SpringH2Application/target/surefire-reports/TEST-com.suneesh.h2.H2InMemoryDbDemoApplicationTests.xml @@ -0,0 +1,275 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + java.lang.IllegalStateException: Failed to load ApplicationContext +Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: javax/transaction/SystemException +Caused by: java.lang.NoClassDefFoundError: javax/transaction/SystemException +Caused by: java.lang.ClassNotFoundException: javax.transaction.SystemException + + true]], class annotated with @DirtiesContext [false] with mode [null]. +23:21:32.836 [main] DEBUG org.springframework.test.annotation.ProfileValueUtils - Retrieved @ProfileValueSourceConfiguration [null] for test class [com.suneesh.h2.H2InMemoryDbDemoApplicationTests] +23:21:32.836 [main] DEBUG org.springframework.test.annotation.ProfileValueUtils - Retrieved ProfileValueSource type [class org.springframework.test.annotation.SystemProfileValueSource] for class [com.suneesh.h2.H2InMemoryDbDemoApplicationTests] +23:21:32.854 [main] DEBUG org.springframework.core.env.StandardEnvironment - Adding PropertySource 'systemProperties' with lowest search precedence +23:21:32.854 [main] DEBUG org.springframework.core.env.StandardEnvironment - Adding PropertySource 'systemEnvironment' with lowest search precedence +23:21:32.854 [main] DEBUG org.springframework.core.env.StandardEnvironment - Initialized StandardEnvironment with PropertySources [MapPropertySource@2073299099 {name='systemProperties', properties={sun.desktop=windows, awt.toolkit=sun.awt.windows.WToolkit, java.specification.version=9, file.encoding.pkg=sun.io, sun.cpu.isalist=amd64, sun.jnu.encoding=Cp1252, java.class.path=G:\Development\GitHub\JavaDevelopment\SpringH2Application\target\test-classes;G:\Development\GitHub\JavaDevelopment\SpringH2Application\target\classes;G:\Development\MavenRepository\org\springframework\boot\spring-boot-starter-web\2.0.0.BUILD-SNAPSHOT\spring-boot-starter-web-2.0.0.BUILD-SNAPSHOT.jar;G:\Development\MavenRepository\org\springframework\boot\spring-boot-starter\2.0.0.BUILD-SNAPSHOT\spring-boot-starter-2.0.0.BUILD-SNAPSHOT.jar;G:\Development\MavenRepository\org\springframework\boot\spring-boot\2.0.0.BUILD-SNAPSHOT\spring-boot-2.0.0.BUILD-SNAPSHOT.jar;G:\Development\MavenRepository\org\springframework\boot\spring-boot-autoconfigure\2.0.0.BUILD-SNAPSHOT\spring-boot-autoconfigure-2.0.0.BUILD-SNAPSHOT.jar;G:\Development\MavenRepository\org\springframework\boot\spring-boot-starter-logging\2.0.0.BUILD-SNAPSHOT\spring-boot-starter-logging-2.0.0.BUILD-SNAPSHOT.jar;G:\Development\MavenRepository\ch\qos\logback\logback-classic\1.2.3\logback-classic-1.2.3.jar;G:\Development\MavenRepository\ch\qos\logback\logback-core\1.2.3\logback-core-1.2.3.jar;G:\Development\MavenRepository\org\apache\logging\log4j\log4j-to-slf4j\2.10.0\log4j-to-slf4j-2.10.0.jar;G:\Development\MavenRepository\org\apache\logging\log4j\log4j-api\2.10.0\log4j-api-2.10.0.jar;G:\Development\MavenRepository\org\slf4j\jul-to-slf4j\1.7.25\jul-to-slf4j-1.7.25.jar;G:\Development\MavenRepository\javax\annotation\javax.annotation-api\1.3.2\javax.annotation-api-1.3.2.jar;G:\Development\MavenRepository\org\yaml\snakeyaml\1.19\snakeyaml-1.19.jar;G:\Development\MavenRepository\org\springframework\boot\spring-boot-starter-json\2.0.0.BUILD-SNAPSHOT\spring-boot-starter-json-2.0.0.BUILD-SNAPSHOT.jar;G:\Development\MavenRepository\com\fasterxml\jackson\core\jackson-databind\2.9.4\jackson-databind-2.9.4.jar;G:\Development\MavenRepository\com\fasterxml\jackson\core\jackson-annotations\2.9.0\jackson-annotations-2.9.0.jar;G:\Development\MavenRepository\com\fasterxml\jackson\core\jackson-core\2.9.4\jackson-core-2.9.4.jar;G:\Development\MavenRepository\com\fasterxml\jackson\datatype\jackson-datatype-jdk8\2.9.4\jackson-datatype-jdk8-2.9.4.jar;G:\Development\MavenRepository\com\fasterxml\jackson\datatype\jackson-datatype-jsr310\2.9.4\jackson-datatype-jsr310-2.9.4.jar;G:\Development\MavenRepository\com\fasterxml\jackson\module\jackson-module-parameter-names\2.9.4\jackson-module-parameter-names-2.9.4.jar;G:\Development\MavenRepository\org\springframework\boot\spring-boot-starter-tomcat\2.0.0.BUILD-SNAPSHOT\spring-boot-starter-tomcat-2.0.0.BUILD-SNAPSHOT.jar;G:\Development\MavenRepository\org\apache\tomcat\embed\tomcat-embed-core\8.5.28\tomcat-embed-core-8.5.28.jar;G:\Development\MavenRepository\org\apache\tomcat\embed\tomcat-embed-el\8.5.28\tomcat-embed-el-8.5.28.jar;G:\Development\MavenRepository\org\apache\tomcat\embed\tomcat-embed-websocket\8.5.28\tomcat-embed-websocket-8.5.28.jar;G:\Development\MavenRepository\org\hibernate\validator\hibernate-validator\6.0.7.Final\hibernate-validator-6.0.7.Final.jar;G:\Development\MavenRepository\javax\validation\validation-api\2.0.1.Final\validation-api-2.0.1.Final.jar;G:\Development\MavenRepository\org\jboss\logging\jboss-logging\3.3.2.Final\jboss-logging-3.3.2.Final.jar;G:\Development\MavenRepository\com\fasterxml\classmate\1.3.4\classmate-1.3.4.jar;G:\Development\MavenRepository\org\springframework\spring-web\5.0.4.RELEASE\spring-web-5.0.4.RELEASE.jar;G:\Development\MavenRepository\org\springframework\spring-beans\5.0.4.RELEASE\spring-beans-5.0.4.RELEASE.jar;G:\Development\MavenRepository\org\springframework\spring-webmvc\5.0.4.RELEASE\spring-webmvc-5.0.4.RELEASE.jar;G:\Development\MavenRepository\org\springframework\spring-aop\5.0.4.RELEASE\spring-aop-5.0.4.RELEASE.jar;G:\Development\MavenRepository\org\springframework\spring-context\5.0.4.RELEASE\spring-context-5.0.4.RELEASE.jar;G:\Development\MavenRepository\org\springframework\spring-expression\5.0.4.RELEASE\spring-expression-5.0.4.RELEASE.jar;G:\Development\MavenRepository\org\springframework\boot\spring-boot-starter-data-jpa\2.0.0.BUILD-SNAPSHOT\spring-boot-starter-data-jpa-2.0.0.BUILD-SNAPSHOT.jar;G:\Development\MavenRepository\org\springframework\boot\spring-boot-starter-aop\2.0.0.BUILD-SNAPSHOT\spring-boot-starter-aop-2.0.0.BUILD-SNAPSHOT.jar;G:\Development\MavenRepository\org\aspectj\aspectjweaver\1.8.13\aspectjweaver-1.8.13.jar;G:\Development\MavenRepository\org\springframework\boot\spring-boot-starter-jdbc\2.0.0.BUILD-SNAPSHOT\spring-boot-starter-jdbc-2.0.0.BUILD-SNAPSHOT.jar;G:\Development\MavenRepository\com\zaxxer\HikariCP\2.7.8\HikariCP-2.7.8.jar;G:\Development\MavenRepository\org\springframework\spring-jdbc\5.0.4.RELEASE\spring-jdbc-5.0.4.RELEASE.jar;G:\Development\MavenRepository\org\hibernate\hibernate-core\5.2.14.Final\hibernate-core-5.2.14.Final.jar;G:\Development\MavenRepository\org\hibernate\javax\persistence\hibernate-jpa-2.1-api\1.0.0.Final\hibernate-jpa-2.1-api-1.0.0.Final.jar;G:\Development\MavenRepository\org\javassist\javassist\3.22.0-GA\javassist-3.22.0-GA.jar;G:\Development\MavenRepository\antlr\antlr\2.7.7\antlr-2.7.7.jar;G:\Development\MavenRepository\org\jboss\jandex\2.0.3.Final\jandex-2.0.3.Final.jar;G:\Development\MavenRepository\dom4j\dom4j\1.6.1\dom4j-1.6.1.jar;G:\Development\MavenRepository\org\hibernate\common\hibernate-commons-annotations\5.0.1.Final\hibernate-commons-annotations-5.0.1.Final.jar;G:\Development\MavenRepository\javax\transaction\javax.transaction-api\1.2\javax.transaction-api-1.2.jar;G:\Development\MavenRepository\org\springframework\data\spring-data-jpa\2.0.5.RELEASE\spring-data-jpa-2.0.5.RELEASE.jar;G:\Development\MavenRepository\org\springframework\data\spring-data-commons\2.0.5.RELEASE\spring-data-commons-2.0.5.RELEASE.jar;G:\Development\MavenRepository\org\springframework\spring-orm\5.0.4.RELEASE\spring-orm-5.0.4.RELEASE.jar;G:\Development\MavenRepository\org\springframework\spring-tx\5.0.4.RELEASE\spring-tx-5.0.4.RELEASE.jar;G:\Development\MavenRepository\org\slf4j\slf4j-api\1.7.25\slf4j-api-1.7.25.jar;G:\Development\MavenRepository\org\springframework\spring-aspects\5.0.4.RELEASE\spring-aspects-5.0.4.RELEASE.jar;G:\Development\MavenRepository\com\h2database\h2\1.4.196\h2-1.4.196.jar;G:\Development\MavenRepository\org\springframework\boot\spring-boot-starter-test\2.0.0.BUILD-SNAPSHOT\spring-boot-starter-test-2.0.0.BUILD-SNAPSHOT.jar;G:\Development\MavenRepository\org\springframework\boot\spring-boot-test\2.0.0.BUILD-SNAPSHOT\spring-boot-test-2.0.0.BUILD-SNAPSHOT.jar;G:\Development\MavenRepository\org\springframework\boot\spring-boot-test-autoconfigure\2.0.0.BUILD-SNAPSHOT\spring-boot-test-autoconfigure-2.0.0.BUILD-SNAPSHOT.jar;G:\Development\MavenRepository\com\jayway\jsonpath\json-path\2.4.0\json-path-2.4.0.jar;G:\Development\MavenRepository\net\minidev\json-smart\2.3\json-smart-2.3.jar;G:\Development\MavenRepository\net\minidev\accessors-smart\1.2\accessors-smart-1.2.jar;G:\Development\MavenRepository\org\ow2\asm\asm\5.0.4\asm-5.0.4.jar;G:\Development\MavenRepository\junit\junit\4.12\junit-4.12.jar;G:\Development\MavenRepository\org\assertj\assertj-core\3.9.1\assertj-core-3.9.1.jar;G:\Development\MavenRepository\org\mockito\mockito-core\2.15.0\mockito-core-2.15.0.jar;G:\Development\MavenRepository\net\bytebuddy\byte-buddy\1.7.10\byte-buddy-1.7.10.jar;G:\Development\MavenRepository\net\bytebuddy\byte-buddy-agent\1.7.10\byte-buddy-agent-1.7.10.jar;G:\Development\MavenRepository\org\objenesis\objenesis\2.6\objenesis-2.6.jar;G:\Development\MavenRepository\org\hamcrest\hamcrest-core\1.3\hamcrest-core-1.3.jar;G:\Development\MavenRepository\org\hamcrest\hamcrest-library\1.3\hamcrest-library-1.3.jar;G:\Development\MavenRepository\org\skyscreamer\jsonassert\1.5.0\jsonassert-1.5.0.jar;G:\Development\MavenRepository\com\vaadin\external\google\android-json\0.0.20131108.vaadin1\android-json-0.0.20131108.vaadin1.jar;G:\Development\MavenRepository\org\springframework\spring-core\5.0.4.RELEASE\spring-core-5.0.4.RELEASE.jar;G:\Development\MavenRepository\org\springframework\spring-jcl\5.0.4.RELEASE\spring-jcl-5.0.4.RELEASE.jar;G:\Development\MavenRepository\org\springframework\spring-test\5.0.4.RELEASE\spring-test-5.0.4.RELEASE.jar;G:\Development\MavenRepository\org\xmlunit\xmlunit-core\2.5.1\xmlunit-core-2.5.1.jar;, java.vm.vendor=Oracle Corporation, sun.arch.data.model=64, user.variant=, java.vendor.url=http://java.oracle.com/, user.timezone=Europe/London, os.name=Windows 10, java.vm.specification.version=9, sun.java.launcher=SUN_STANDARD, user.country=GB, sun.boot.library.path=C:\Program Files\Java\jdk-9.0.1\bin, sun.java.command=C:\Users\sunee\AppData\Local\Temp\surefire11253842243414686282\surefirebooter9590102627159498564.jar C:\Users\sunee\AppData\Local\Temp\surefire11253842243414686282 2020-01-19T23-21-25_816-jvmRun1 surefire8304468099330974679tmp surefire_06592669144205719307tmp, jdk.debug=release, surefire.test.class.path=G:\Development\GitHub\JavaDevelopment\SpringH2Application\target\test-classes;G:\Development\GitHub\JavaDevelopment\SpringH2Application\target\classes;G:\Development\MavenRepository\org\springframework\boot\spring-boot-starter-web\2.0.0.BUILD-SNAPSHOT\spring-boot-starter-web-2.0.0.BUILD-SNAPSHOT.jar;G:\Development\MavenRepository\org\springframework\boot\spring-boot-starter\2.0.0.BUILD-SNAPSHOT\spring-boot-starter-2.0.0.BUILD-SNAPSHOT.jar;G:\Development\MavenRepository\org\springframework\boot\spring-boot\2.0.0.BUILD-SNAPSHOT\spring-boot-2.0.0.BUILD-SNAPSHOT.jar;G:\Development\MavenRepository\org\springframework\boot\spring-boot-autoconfigure\2.0.0.BUILD-SNAPSHOT\spring-boot-autoconfigure-2.0.0.BUILD-SNAPSHOT.jar;G:\Development\MavenRepository\org\springframework\boot\spring-boot-starter-logging\2.0.0.BUILD-SNAPSHOT\spring-boot-starter-logging-2.0.0.BUILD-SNAPSHOT.jar;G:\Development\MavenRepository\ch\qos\logback\logback-classic\1.2.3\logback-classic-1.2.3.jar;G:\Development\MavenRepository\ch\qos\logback\logback-core\1.2.3\logback-core-1.2.3.jar;G:\Development\MavenRepository\org\apache\logging\log4j\log4j-to-slf4j\2.10.0\log4j-to-slf4j-2.10.0.jar;G:\Development\MavenRepository\org\apache\logging\log4j\log4j-api\2.10.0\log4j-api-2.10.0.jar;G:\Development\MavenRepository\org\slf4j\jul-to-slf4j\1.7.25\jul-to-slf4j-1.7.25.jar;G:\Development\MavenRepository\javax\annotation\javax.annotation-api\1.3.2\javax.annotation-api-1.3.2.jar;G:\Development\MavenRepository\org\yaml\snakeyaml\1.19\snakeyaml-1.19.jar;G:\Development\MavenRepository\org\springframework\boot\spring-boot-starter-json\2.0.0.BUILD-SNAPSHOT\spring-boot-starter-json-2.0.0.BUILD-SNAPSHOT.jar;G:\Development\MavenRepository\com\fasterxml\jackson\core\jackson-databind\2.9.4\jackson-databind-2.9.4.jar;G:\Development\MavenRepository\com\fasterxml\jackson\core\jackson-annotations\2.9.0\jackson-annotations-2.9.0.jar;G:\Development\MavenRepository\com\fasterxml\jackson\core\jackson-core\2.9.4\jackson-core-2.9.4.jar;G:\Development\MavenRepository\com\fasterxml\jackson\datatype\jackson-datatype-jdk8\2.9.4\jackson-datatype-jdk8-2.9.4.jar;G:\Development\MavenRepository\com\fasterxml\jackson\datatype\jackson-datatype-jsr310\2.9.4\jackson-datatype-jsr310-2.9.4.jar;G:\Development\MavenRepository\com\fasterxml\jackson\module\jackson-module-parameter-names\2.9.4\jackson-module-parameter-names-2.9.4.jar;G:\Development\MavenRepository\org\springframework\boot\spring-boot-starter-tomcat\2.0.0.BUILD-SNAPSHOT\spring-boot-starter-tomcat-2.0.0.BUILD-SNAPSHOT.jar;G:\Development\MavenRepository\org\apache\tomcat\embed\tomcat-embed-core\8.5.28\tomcat-embed-core-8.5.28.jar;G:\Development\MavenRepository\org\apache\tomcat\embed\tomcat-embed-el\8.5.28\tomcat-embed-el-8.5.28.jar;G:\Development\MavenRepository\org\apache\tomcat\embed\tomcat-embed-websocket\8.5.28\tomcat-embed-websocket-8.5.28.jar;G:\Development\MavenRepository\org\hibernate\validator\hibernate-validator\6.0.7.Final\hibernate-validator-6.0.7.Final.jar;G:\Development\MavenRepository\javax\validation\validation-api\2.0.1.Final\validation-api-2.0.1.Final.jar;G:\Development\MavenRepository\org\jboss\logging\jboss-logging\3.3.2.Final\jboss-logging-3.3.2.Final.jar;G:\Development\MavenRepository\com\fasterxml\classmate\1.3.4\classmate-1.3.4.jar;G:\Development\MavenRepository\org\springframework\spring-web\5.0.4.RELEASE\spring-web-5.0.4.RELEASE.jar;G:\Development\MavenRepository\org\springframework\spring-beans\5.0.4.RELEASE\spring-beans-5.0.4.RELEASE.jar;G:\Development\MavenRepository\org\springframework\spring-webmvc\5.0.4.RELEASE\spring-webmvc-5.0.4.RELEASE.jar;G:\Development\MavenRepository\org\springframework\spring-aop\5.0.4.RELEASE\spring-aop-5.0.4.RELEASE.jar;G:\Development\MavenRepository\org\springframework\spring-context\5.0.4.RELEASE\spring-context-5.0.4.RELEASE.jar;G:\Development\MavenRepository\org\springframework\spring-expression\5.0.4.RELEASE\spring-expression-5.0.4.RELEASE.jar;G:\Development\MavenRepository\org\springframework\boot\spring-boot-starter-data-jpa\2.0.0.BUILD-SNAPSHOT\spring-boot-starter-data-jpa-2.0.0.BUILD-SNAPSHOT.jar;G:\Development\MavenRepository\org\springframework\boot\spring-boot-starter-aop\2.0.0.BUILD-SNAPSHOT\spring-boot-starter-aop-2.0.0.BUILD-SNAPSHOT.jar;G:\Development\MavenRepository\org\aspectj\aspectjweaver\1.8.13\aspectjweaver-1.8.13.jar;G:\Development\MavenRepository\org\springframework\boot\spring-boot-starter-jdbc\2.0.0.BUILD-SNAPSHOT\spring-boot-starter-jdbc-2.0.0.BUILD-SNAPSHOT.jar;G:\Development\MavenRepository\com\zaxxer\HikariCP\2.7.8\HikariCP-2.7.8.jar;G:\Development\MavenRepository\org\springframework\spring-jdbc\5.0.4.RELEASE\spring-jdbc-5.0.4.RELEASE.jar;G:\Development\MavenRepository\org\hibernate\hibernate-core\5.2.14.Final\hibernate-core-5.2.14.Final.jar;G:\Development\MavenRepository\org\hibernate\javax\persistence\hibernate-jpa-2.1-api\1.0.0.Final\hibernate-jpa-2.1-api-1.0.0.Final.jar;G:\Development\MavenRepository\org\javassist\javassist\3.22.0-GA\javassist-3.22.0-GA.jar;G:\Development\MavenRepository\antlr\antlr\2.7.7\antlr-2.7.7.jar;G:\Development\MavenRepository\org\jboss\jandex\2.0.3.Final\jandex-2.0.3.Final.jar;G:\Development\MavenRepository\dom4j\dom4j\1.6.1\dom4j-1.6.1.jar;G:\Development\MavenRepository\org\hibernate\common\hibernate-commons-annotations\5.0.1.Final\hibernate-commons-annotations-5.0.1.Final.jar;G:\Development\MavenRepository\javax\transaction\javax.transaction-api\1.2\javax.transaction-api-1.2.jar;G:\Development\MavenRepository\org\springframework\data\spring-data-jpa\2.0.5.RELEASE\spring-data-jpa-2.0.5.RELEASE.jar;G:\Development\MavenRepository\org\springframework\data\spring-data-commons\2.0.5.RELEASE\spring-data-commons-2.0.5.RELEASE.jar;G:\Development\MavenRepository\org\springframework\spring-orm\5.0.4.RELEASE\spring-orm-5.0.4.RELEASE.jar;G:\Development\MavenRepository\org\springframework\spring-tx\5.0.4.RELEASE\spring-tx-5.0.4.RELEASE.jar;G:\Development\MavenRepository\org\slf4j\slf4j-api\1.7.25\slf4j-api-1.7.25.jar;G:\Development\MavenRepository\org\springframework\spring-aspects\5.0.4.RELEASE\spring-aspects-5.0.4.RELEASE.jar;G:\Development\MavenRepository\com\h2database\h2\1.4.196\h2-1.4.196.jar;G:\Development\MavenRepository\org\springframework\boot\spring-boot-starter-test\2.0.0.BUILD-SNAPSHOT\spring-boot-starter-test-2.0.0.BUILD-SNAPSHOT.jar;G:\Development\MavenRepository\org\springframework\boot\spring-boot-test\2.0.0.BUILD-SNAPSHOT\spring-boot-test-2.0.0.BUILD-SNAPSHOT.jar;G:\Development\MavenRepository\org\springframework\boot\spring-boot-test-autoconfigure\2.0.0.BUILD-SNAPSHOT\spring-boot-test-autoconfigure-2.0.0.BUILD-SNAPSHOT.jar;G:\Development\MavenRepository\com\jayway\jsonpath\json-path\2.4.0\json-path-2.4.0.jar;G:\Development\MavenRepository\net\minidev\json-smart\2.3\json-smart-2.3.jar;G:\Development\MavenRepository\net\minidev\accessors-smart\1.2\accessors-smart-1.2.jar;G:\Development\MavenRepository\org\ow2\asm\asm\5.0.4\asm-5.0.4.jar;G:\Development\MavenRepository\junit\junit\4.12\junit-4.12.jar;G:\Development\MavenRepository\org\assertj\assertj-core\3.9.1\assertj-core-3.9.1.jar;G:\Development\MavenRepository\org\mockito\mockito-core\2.15.0\mockito-core-2.15.0.jar;G:\Development\MavenRepository\net\bytebuddy\byte-buddy\1.7.10\byte-buddy-1.7.10.jar;G:\Development\MavenRepository\net\bytebuddy\byte-buddy-agent\1.7.10\byte-buddy-agent-1.7.10.jar;G:\Development\MavenRepository\org\objenesis\objenesis\2.6\objenesis-2.6.jar;G:\Development\MavenRepository\org\hamcrest\hamcrest-core\1.3\hamcrest-core-1.3.jar;G:\Development\MavenRepository\org\hamcrest\hamcrest-library\1.3\hamcrest-library-1.3.jar;G:\Development\MavenRepository\org\skyscreamer\jsonassert\1.5.0\jsonassert-1.5.0.jar;G:\Development\MavenRepository\com\vaadin\external\google\android-json\0.0.20131108.vaadin1\android-json-0.0.20131108.vaadin1.jar;G:\Development\MavenRepository\org\springframework\spring-core\5.0.4.RELEASE\spring-core-5.0.4.RELEASE.jar;G:\Development\MavenRepository\org\springframework\spring-jcl\5.0.4.RELEASE\spring-jcl-5.0.4.RELEASE.jar;G:\Development\MavenRepository\org\springframework\spring-test\5.0.4.RELEASE\spring-test-5.0.4.RELEASE.jar;G:\Development\MavenRepository\org\xmlunit\xmlunit-core\2.5.1\xmlunit-core-2.5.1.jar;, sun.cpu.endian=little, user.home=C:\Users\sunee, user.language=en, java.specification.vendor=Oracle Corporation, java.home=C:\Program Files\Java\jdk-9.0.1, file.separator=\, basedir=G:\Development\GitHub\JavaDevelopment\SpringH2Application, java.vm.compressedOopsMode=Zero based, line.separator= +, java.vm.specification.vendor=Oracle Corporation, java.specification.name=Java Platform API Specification, java.awt.graphicsenv=sun.awt.Win32GraphicsEnvironment, surefire.real.class.path=C:\Users\sunee\AppData\Local\Temp\surefire11253842243414686282\surefirebooter9590102627159498564.jar, user.script=, sun.management.compiler=HotSpot 64-Bit Tiered Compilers, java.runtime.version=9.0.1+11, user.name=sunee, path.separator=;, os.version=10.0, java.runtime.name=Java(TM) SE Runtime Environment, file.encoding=Cp1252, java.vm.name=Java HotSpot(TM) 64-Bit Server VM, localRepository=G:\Development\MavenRepository, java.vendor.url.bug=http://bugreport.java.com/bugreport/, java.io.tmpdir=C:\Users\sunee\AppData\Local\Temp\, java.version=9.0.1, user.dir=G:\Development\GitHub\JavaDevelopment\SpringH2Application, os.arch=amd64, java.vm.specification.name=Java Virtual Machine Specification, java.awt.printerjob=sun.awt.windows.WPrinterJob, sun.os.patch.level=, java.library.path=C:\Program Files\Java\jdk-9.0.1\bin;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\Users\sunee\bin;G:\Development\Git\mingw64\bin;G:\Development\Git\usr\local\bin;G:\Development\Git\usr\bin;G:\Development\Git\usr\bin;G:\Development\Git\mingw64\bin;G:\Development\Git\usr\bin;C:\Users\sunee\bin;C:\ProgramData\DockerDesktop\version-bin;C:\Program Files\Docker\Docker\Resources\bin;G:\My Software\Python3.7.1\Scripts;G:\My Software\Python3.7.1;C:\Program Files\Java\jdk-9.0.1\bin;C:\Program Files (x86)\Intel\iCLS Client;C:\Program Files\Intel\iCLS Client;C:\Program Files\Broadcom\Broadcom 802.11 Network Adapter;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0;C:\Program Files\WIDCOMM\Bluetooth Software;C:\Program Files\WIDCOMM\Bluetooth Software\syswow64;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0;G:\Mining\build_monero\CMake\bin;G:\Development\putty;G:\Development\Cmake\bin;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0;C:\WINDOWS\System32\OpenSSH;G:\Development\apache-maven-3.6.0\bin;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\Users\sunee\AppData\Local\Microsoft\WindowsApps;G:\Mining\build_monero\CMake\bin;C:\Users\sunee\AppData\Local\GitHubDesktop\bin;C:\Users\sunee\AppData\Local\Microsoft\WindowsApps;G:\Development\Git\cmd;C:\Users\sunee\AppData\Local\Programs\Microsoft VS Code\bin;G:\Development\Git\usr\bin\vendor_perl;G:\Development\Git\usr\bin\core_perl;., java.vm.info=mixed mode, java.vendor=Oracle Corporation, java.vm.version=9.0.1+11, sun.io.unicode.encoding=UnicodeLittle, java.class.version=53.0}}, SystemEnvironmentPropertySource@2090991873 {name='systemEnvironment', properties={PATH=C:\Users\sunee\bin;G:\Development\Git\mingw64\bin;G:\Development\Git\usr\local\bin;G:\Development\Git\usr\bin;G:\Development\Git\usr\bin;G:\Development\Git\mingw64\bin;G:\Development\Git\usr\bin;C:\Users\sunee\bin;C:\ProgramData\DockerDesktop\version-bin;C:\Program Files\Docker\Docker\Resources\bin;G:\My Software\Python3.7.1\Scripts;G:\My Software\Python3.7.1;C:\Program Files\Java\jdk-9.0.1\bin;C:\Program Files (x86)\Intel\iCLS Client;C:\Program Files\Intel\iCLS Client;C:\Program Files\Broadcom\Broadcom 802.11 Network Adapter;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0;C:\Program Files\WIDCOMM\Bluetooth Software;C:\Program Files\WIDCOMM\Bluetooth Software\syswow64;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0;G:\Mining\build_monero\CMake\bin;G:\Development\putty;G:\Development\Cmake\bin;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0;C:\WINDOWS\System32\OpenSSH;G:\Development\apache-maven-3.6.0\bin;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\Users\sunee\AppData\Local\Microsoft\WindowsApps;G:\Mining\build_monero\CMake\bin;C:\Users\sunee\AppData\Local\GitHubDesktop\bin;C:\Users\sunee\AppData\Local\Microsoft\WindowsApps;G:\Development\Git\cmd;C:\Users\sunee\AppData\Local\Programs\Microsoft VS Code\bin;G:\Development\Git\usr\bin\vendor_perl;G:\Development\Git\usr\bin\core_perl, USERDOMAIN_ROAMINGPROFILE=JOSHIS-DESKTOP, PKG_CONFIG_PATH=G:\Development\Git\mingw64\lib\pkgconfig;G:\Development\Git\mingw64\share\pkgconfig, MSYSTEM_PREFIX=G:/Development/Git/mingw64, PROCESSOR_LEVEL=6, SYSTEMDRIVE=C:, CONFIG_SITE=G:/Development/Git/mingw64/etc/config.site, VS140COMNTOOLS=C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Tools\, SESSIONNAME=Console, ALLUSERSPROFILE=C:\ProgramData, DEFAULT_CPY_DIR=G:\CPY_SAVES, ETHEREUM_SOCKET=\\.\pipe\geth.ipc, PROCESSOR_ARCHITECTURE=AMD64, DRIVERDATA=C:\Windows\System32\Drivers\DriverData, MSYSTEM_CHOST=x86_64-w64-mingw32, MAVEN_HOME=G:/Development/apache-maven-3.6.0, ORIGINAL_TEMP=C:/Users/sunee/AppData/Local/Temp, PROGRAMFILES=C:\Program Files, PSMODULEPATH=C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules\;C:\Program Files\Intel\;C:\Program Files\Intel\Wired Networking\, PROGRAMDATA=C:\ProgramData, USERNAME=sunee, PWD=G:/Development/GitHub/JavaDevelopment/SpringH2Application, GPU_USE_SYNC_OBJECTS=1, INFOPATH=G:\Development\Git\usr\local\info;G:\Development\Git\usr\share\info;G:\Development\Git\usr\info;G:\Development\Git\share\info, ADS_LANGUAGE=52, GPU_MAX_ALLOC_PERCENT=100, ONEDRIVE=C:\Users\sunee\OneDrive, PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC;.PY;.PYW, SHELL=G:\Development\Git\usr\bin\bash.exe, ORIGINAL_TMP=C:/Users/sunee/AppData/Local/Temp, OLDPWD=G:/Development/GitHub/JavaDevelopment/SpringH2Application, TMPDIR=C:\Users\sunee\AppData\Local\Temp, WINDIR=C:\WINDOWS, SSH_ASKPASS=G:/Development/Git/mingw64/libexec/git-core/git-gui--askpass, HOMEPATH=\Users\sunee, PROCESSOR_IDENTIFIER=Intel64 Family 6 Model 94 Stepping 3, GenuineIntel, M2_HOME=G:\Development\apache-maven-3.6.0, PUBLIC=C:\Users\Public, MINGW_CHOST=x86_64-w64-mingw32, =::=::\, EXEPATH=G:\Development\Git, SHLVL=1, GPU_MAX_HEAP_SIZE=100, LOCALAPPDATA=C:\Users\sunee\AppData\Local, ORIGINAL_PATH=G:\Development\Git\mingw64\bin;G:\Development\Git\usr\bin;C:\Users\sunee\bin;C:\ProgramData\DockerDesktop\version-bin;C:\Program Files\Docker\Docker\Resources\bin;G:\My Software\Python3.7.1\Scripts;G:\My Software\Python3.7.1;C:\Program Files\Java\jdk-9.0.1\bin;C:\Program Files (x86)\Intel\iCLS Client;C:\Program Files\Intel\iCLS Client;C:\Program Files\Broadcom\Broadcom 802.11 Network Adapter;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0;C:\Program Files\WIDCOMM\Bluetooth Software;C:\Program Files\WIDCOMM\Bluetooth Software\syswow64;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0;G:\Mining\build_monero\CMake\bin;G:\Development\putty;G:\Development\Cmake\bin;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0;C:\WINDOWS\System32\OpenSSH;G:\Development\apache-maven-3.6.0\bin;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\Users\sunee\AppData\Local\Microsoft\WindowsApps;G:\Mining\build_monero\CMake\bin;C:\Users\sunee\AppData\Local\GitHubDesktop\bin;C:\Users\sunee\AppData\Local\Microsoft\WindowsApps;G:\Development\Git\cmd;C:\Users\sunee\AppData\Local\Programs\Microsoft VS Code\bin, GPU_SINGLE_ALLOC_PERCENT=100, MANPATH=G:\Development\Git\mingw64\local\man;G:\Development\Git\mingw64\share\man;G:\Development\Git\usr\local\man;G:\Development\Git\usr\share\man;G:\Development\Git\usr\man;G:\Development\Git\share\man, COMMONPROGRAMFILES(X86)=C:\Program Files (x86)\Common Files, MINGW_PACKAGE_PREFIX=mingw-w64-x86_64, GPU_FORCE_64BIT_PTR=0, USERDOMAIN=JOSHIS-DESKTOP, LOGONSERVER=\\JOSHIS-DESKTOP, JAVA_HOME=C:/Program Files/Java/jdk-9.0.1, PLINK_PROTOCOL=ssh, PROMPT=$P$G, PROGRAMFILES(X86)=C:\Program Files (x86), TERM=xterm, ASL.LOG=Destination=file, LANG=en_GB.UTF-8, =G:=G:\Development\GitHub\JavaDevelopment\SpringH2Application, MINGW_PREFIX=G:/Development/Git/mingw64, DISPLAY=needs-to-be-defined, MSYSTEM=MINGW64, APPDATA=C:\Users\sunee\AppData\Roaming, PROGRAMW6432=C:\Program Files, SYSTEMROOT=C:\WINDOWS, GPU_USE_SYNC_OBJETCS=1, MAVEN_CMD_LINE_ARGS= -U clean install, OS=Windows_NT, COMMONPROGRAMW6432=C:\Program Files\Common Files, COMPUTERNAME=JOSHIS-DESKTOP, COMMONPROGRAMFILES=C:\Program Files\Common Files, COMSPEC=C:\WINDOWS\system32\cmd.exe, MAVEN_PROJECTBASEDIR=G:/Development/GitHub/JavaDevelopment/SpringH2Application, PROCESSOR_REVISION=5e03, ACLOCAL_PATH=G:\Development\Git\mingw64\share\aclocal;G:\Development\Git\usr\share\aclocal, MSYSTEM_CARCH=x86_64, TEMP=C:\Users\sunee\AppData\Local\Temp, HOSTNAME=JOSHIs-DESKTOP, HOMEDRIVE=C:, USERPROFILE=C:\Users\sunee, TMP=C:\Users\sunee\AppData\Local\Temp, NUMBER_OF_PROCESSORS=8, HOME=C:\Users\sunee}}] +23:21:32.857 [main] DEBUG org.springframework.test.context.support.TestPropertySourceUtils - Adding inlined properties to environment: {spring.jmx.enabled=false, org.springframework.boot.test.context.SpringBootTestContextBootstrapper=true, server.port=-1} +23:21:32.858 [main] DEBUG org.springframework.core.env.StandardEnvironment - Adding PropertySource 'Inlined Test Properties' with highest search precedence + + . ____ _ __ _ _ + /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \ +( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \ + \\/ ___)| |_)| | | | | || (_| | ) ) ) ) + ' |____| .__|_| |_|_| |_\__, | / / / / + =========|_|==============|___/=/_/_/_/ + :: Spring Boot :: (v2.0.0.BUILD-SNAPSHOT) + +2020-01-19 23:21:33.183 INFO 4744 --- [ main] c.s.h2.H2InMemoryDbDemoApplicationTests : Starting H2InMemoryDbDemoApplicationTests on JOSHIs-DESKTOP with PID 4744 (started by sunee in G:\Development\GitHub\JavaDevelopment\SpringH2Application) +2020-01-19 23:21:33.184 INFO 4744 --- [ main] c.s.h2.H2InMemoryDbDemoApplicationTests : No active profile set, falling back to default profiles: default +2020-01-19 23:21:33.218 INFO 4744 --- [ main] o.s.w.c.s.GenericWebApplicationContext : Refreshing org.springframework.web.context.support.GenericWebApplicationContext@75ed9710: startup date [Sun Jan 19 23:21:33 GMT 2020]; root of context hierarchy +2020-01-19 23:21:34.450 INFO 4744 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$e5b06b61] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) +2020-01-19 23:21:34.651 INFO 4744 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting... +2020-01-19 23:21:34.779 INFO 4744 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed. +2020-01-19 23:21:34.846 INFO 4744 --- [ main] j.LocalContainerEntityManagerFactoryBean : Building JPA container EntityManagerFactory for persistence unit 'default' +2020-01-19 23:21:34.864 WARN 4744 --- [ main] o.s.w.c.s.GenericWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: javax/transaction/SystemException +2020-01-19 23:21:34.865 INFO 4744 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown initiated... +2020-01-19 23:21:34.873 INFO 4744 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown completed. +2020-01-19 23:21:34.886 INFO 4744 --- [ main] ConditionEvaluationReportLoggingListener : + +Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled. +2020-01-19 23:21:34.894 ERROR 4744 --- [ main] o.s.boot.SpringApplication : Application run failed + +org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: javax/transaction/SystemException + at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1710) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE] + at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:583) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE] + at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:502) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE] + at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:312) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE] + at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE] + at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:310) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE] + at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE] + at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1085) ~[spring-context-5.0.4.RELEASE.jar:5.0.4.RELEASE] + at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:858) ~[spring-context-5.0.4.RELEASE.jar:5.0.4.RELEASE] + at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:549) ~[spring-context-5.0.4.RELEASE.jar:5.0.4.RELEASE] + at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:752) ~[spring-boot-2.0.0.BUILD-SNAPSHOT.jar:2.0.0.BUILD-SNAPSHOT] + at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:388) ~[spring-boot-2.0.0.BUILD-SNAPSHOT.jar:2.0.0.BUILD-SNAPSHOT] + at org.springframework.boot.SpringApplication.run(SpringApplication.java:327) ~[spring-boot-2.0.0.BUILD-SNAPSHOT.jar:2.0.0.BUILD-SNAPSHOT] + at org.springframework.boot.test.context.SpringBootContextLoader.loadContext(SpringBootContextLoader.java:138) [spring-boot-test-2.0.0.BUILD-SNAPSHOT.jar:2.0.0.BUILD-SNAPSHOT] + at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContextInternal(DefaultCacheAwareContextLoaderDelegate.java:99) [spring-test-5.0.4.RELEASE.jar:5.0.4.RELEASE] + at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:117) [spring-test-5.0.4.RELEASE.jar:5.0.4.RELEASE] + at org.springframework.test.context.support.DefaultTestContext.getApplicationContext(DefaultTestContext.java:107) [spring-test-5.0.4.RELEASE.jar:5.0.4.RELEASE] + at org.springframework.test.context.web.ServletTestExecutionListener.setUpRequestContextIfNecessary(ServletTestExecutionListener.java:190) [spring-test-5.0.4.RELEASE.jar:5.0.4.RELEASE] + at org.springframework.test.context.web.ServletTestExecutionListener.prepareTestInstance(ServletTestExecutionListener.java:132) [spring-test-5.0.4.RELEASE.jar:5.0.4.RELEASE] + at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:242) [spring-test-5.0.4.RELEASE.jar:5.0.4.RELEASE] + at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:227) [spring-test-5.0.4.RELEASE.jar:5.0.4.RELEASE] + at org.springframework.test.context.junit4.SpringJUnit4ClassRunner$1.runReflectiveCall(SpringJUnit4ClassRunner.java:289) [spring-test-5.0.4.RELEASE.jar:5.0.4.RELEASE] + at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) [junit-4.12.jar:4.12] + at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.methodBlock(SpringJUnit4ClassRunner.java:291) [spring-test-5.0.4.RELEASE.jar:5.0.4.RELEASE] + at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:246) [spring-test-5.0.4.RELEASE.jar:5.0.4.RELEASE] + at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:97) [spring-test-5.0.4.RELEASE.jar:5.0.4.RELEASE] + at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) [junit-4.12.jar:4.12] + at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) [junit-4.12.jar:4.12] + at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) [junit-4.12.jar:4.12] + at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) [junit-4.12.jar:4.12] + at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) [junit-4.12.jar:4.12] + at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61) [spring-test-5.0.4.RELEASE.jar:5.0.4.RELEASE] + at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70) [spring-test-5.0.4.RELEASE.jar:5.0.4.RELEASE] + at org.junit.runners.ParentRunner.run(ParentRunner.java:363) [junit-4.12.jar:4.12] + at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:190) [spring-test-5.0.4.RELEASE.jar:5.0.4.RELEASE] + at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:369) [surefire-junit4-2.20.1.jar:2.20.1] + at org.apache.maven.surefire.junit4.JUnit4Provider.executeWithRerun(JUnit4Provider.java:275) [surefire-junit4-2.20.1.jar:2.20.1] + at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:239) [surefire-junit4-2.20.1.jar:2.20.1] + at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:160) [surefire-junit4-2.20.1.jar:2.20.1] + at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:373) [surefire-booter-2.20.1.jar:2.20.1] + at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:334) [surefire-booter-2.20.1.jar:2.20.1] + at org.apache.maven.surefire.booter.ForkedBooter.execute(ForkedBooter.java:119) [surefire-booter-2.20.1.jar:2.20.1] + at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:407) [surefire-booter-2.20.1.jar:2.20.1] +Caused by: java.lang.NoClassDefFoundError: javax/transaction/SystemException + at java.base/java.lang.Class.forName0(Native Method) ~[na:na] + at java.base/java.lang.Class.forName(Class.java:375) ~[na:na] + at org.jboss.logging.Logger$1.run(Logger.java:2554) ~[jboss-logging-3.3.2.Final.jar:3.3.2.Final] + at java.base/java.security.AccessController.doPrivileged(Native Method) ~[na:na] + at org.jboss.logging.Logger.getMessageLogger(Logger.java:2529) ~[jboss-logging-3.3.2.Final.jar:3.3.2.Final] + at org.jboss.logging.Logger.getMessageLogger(Logger.java:2516) ~[jboss-logging-3.3.2.Final.jar:3.3.2.Final] + at org.hibernate.internal.HEMLogging.messageLogger(HEMLogging.java:28) ~[hibernate-core-5.2.14.Final.jar:5.2.14.Final] + at org.hibernate.internal.HEMLogging.messageLogger(HEMLogging.java:24) ~[hibernate-core-5.2.14.Final.jar:5.2.14.Final] + at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.(EntityManagerFactoryBuilderImpl.java:116) ~[hibernate-core-5.2.14.Final.jar:5.2.14.Final] + at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:51) ~[spring-orm-5.0.4.RELEASE.jar:5.0.4.RELEASE] + at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:365) ~[spring-orm-5.0.4.RELEASE.jar:5.0.4.RELEASE] + at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:388) ~[spring-orm-5.0.4.RELEASE.jar:5.0.4.RELEASE] + at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:377) ~[spring-orm-5.0.4.RELEASE.jar:5.0.4.RELEASE] + at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.afterPropertiesSet(LocalContainerEntityManagerFactoryBean.java:341) ~[spring-orm-5.0.4.RELEASE.jar:5.0.4.RELEASE] + at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1769) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE] + at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1706) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE] + ... 42 common frames omitted +Caused by: java.lang.ClassNotFoundException: javax.transaction.SystemException + at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:582) ~[na:na] + at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:185) ~[na:na] + at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:496) ~[na:na] + ... 58 common frames omitted + +2020-01-19 23:21:34.897 ERROR 4744 --- [ main] o.s.test.context.TestContextManager : Caught exception while allowing TestExecutionListener [org.springframework.test.context.web.ServletTestExecutionListener@5d066c7d] to prepare test instance [com.suneesh.h2.H2InMemoryDbDemoApplicationTests@4db60246] + +java.lang.IllegalStateException: Failed to load ApplicationContext + at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:125) ~[spring-test-5.0.4.RELEASE.jar:5.0.4.RELEASE] + at org.springframework.test.context.support.DefaultTestContext.getApplicationContext(DefaultTestContext.java:107) ~[spring-test-5.0.4.RELEASE.jar:5.0.4.RELEASE] + at org.springframework.test.context.web.ServletTestExecutionListener.setUpRequestContextIfNecessary(ServletTestExecutionListener.java:190) ~[spring-test-5.0.4.RELEASE.jar:5.0.4.RELEASE] + at org.springframework.test.context.web.ServletTestExecutionListener.prepareTestInstance(ServletTestExecutionListener.java:132) ~[spring-test-5.0.4.RELEASE.jar:5.0.4.RELEASE] + at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:242) ~[spring-test-5.0.4.RELEASE.jar:5.0.4.RELEASE] + at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:227) [spring-test-5.0.4.RELEASE.jar:5.0.4.RELEASE] + at org.springframework.test.context.junit4.SpringJUnit4ClassRunner$1.runReflectiveCall(SpringJUnit4ClassRunner.java:289) [spring-test-5.0.4.RELEASE.jar:5.0.4.RELEASE] + at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) [junit-4.12.jar:4.12] + at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.methodBlock(SpringJUnit4ClassRunner.java:291) [spring-test-5.0.4.RELEASE.jar:5.0.4.RELEASE] + at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:246) [spring-test-5.0.4.RELEASE.jar:5.0.4.RELEASE] + at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:97) [spring-test-5.0.4.RELEASE.jar:5.0.4.RELEASE] + at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) [junit-4.12.jar:4.12] + at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) [junit-4.12.jar:4.12] + at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) [junit-4.12.jar:4.12] + at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) [junit-4.12.jar:4.12] + at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) [junit-4.12.jar:4.12] + at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61) [spring-test-5.0.4.RELEASE.jar:5.0.4.RELEASE] + at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70) [spring-test-5.0.4.RELEASE.jar:5.0.4.RELEASE] + at org.junit.runners.ParentRunner.run(ParentRunner.java:363) [junit-4.12.jar:4.12] + at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:190) [spring-test-5.0.4.RELEASE.jar:5.0.4.RELEASE] + at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:369) [surefire-junit4-2.20.1.jar:2.20.1] + at org.apache.maven.surefire.junit4.JUnit4Provider.executeWithRerun(JUnit4Provider.java:275) [surefire-junit4-2.20.1.jar:2.20.1] + at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:239) [surefire-junit4-2.20.1.jar:2.20.1] + at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:160) [surefire-junit4-2.20.1.jar:2.20.1] + at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:373) [surefire-booter-2.20.1.jar:2.20.1] + at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:334) [surefire-booter-2.20.1.jar:2.20.1] + at org.apache.maven.surefire.booter.ForkedBooter.execute(ForkedBooter.java:119) [surefire-booter-2.20.1.jar:2.20.1] + at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:407) [surefire-booter-2.20.1.jar:2.20.1] +Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: javax/transaction/SystemException + at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1710) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE] + at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:583) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE] + at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:502) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE] + at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:312) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE] + at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE] + at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:310) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE] + at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE] + at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1085) ~[spring-context-5.0.4.RELEASE.jar:5.0.4.RELEASE] + at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:858) ~[spring-context-5.0.4.RELEASE.jar:5.0.4.RELEASE] + at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:549) ~[spring-context-5.0.4.RELEASE.jar:5.0.4.RELEASE] + at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:752) ~[spring-boot-2.0.0.BUILD-SNAPSHOT.jar:2.0.0.BUILD-SNAPSHOT] + at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:388) ~[spring-boot-2.0.0.BUILD-SNAPSHOT.jar:2.0.0.BUILD-SNAPSHOT] + at org.springframework.boot.SpringApplication.run(SpringApplication.java:327) ~[spring-boot-2.0.0.BUILD-SNAPSHOT.jar:2.0.0.BUILD-SNAPSHOT] + at org.springframework.boot.test.context.SpringBootContextLoader.loadContext(SpringBootContextLoader.java:138) ~[spring-boot-test-2.0.0.BUILD-SNAPSHOT.jar:2.0.0.BUILD-SNAPSHOT] + at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContextInternal(DefaultCacheAwareContextLoaderDelegate.java:99) ~[spring-test-5.0.4.RELEASE.jar:5.0.4.RELEASE] + at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:117) ~[spring-test-5.0.4.RELEASE.jar:5.0.4.RELEASE] + ... 27 common frames omitted +Caused by: java.lang.NoClassDefFoundError: javax/transaction/SystemException + at java.base/java.lang.Class.forName0(Native Method) ~[na:na] + at java.base/java.lang.Class.forName(Class.java:375) ~[na:na] + at org.jboss.logging.Logger$1.run(Logger.java:2554) ~[jboss-logging-3.3.2.Final.jar:3.3.2.Final] + at java.base/java.security.AccessController.doPrivileged(Native Method) ~[na:na] + at org.jboss.logging.Logger.getMessageLogger(Logger.java:2529) ~[jboss-logging-3.3.2.Final.jar:3.3.2.Final] + at org.jboss.logging.Logger.getMessageLogger(Logger.java:2516) ~[jboss-logging-3.3.2.Final.jar:3.3.2.Final] + at org.hibernate.internal.HEMLogging.messageLogger(HEMLogging.java:28) ~[hibernate-core-5.2.14.Final.jar:5.2.14.Final] + at org.hibernate.internal.HEMLogging.messageLogger(HEMLogging.java:24) ~[hibernate-core-5.2.14.Final.jar:5.2.14.Final] + at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.(EntityManagerFactoryBuilderImpl.java:116) ~[hibernate-core-5.2.14.Final.jar:5.2.14.Final] + at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:51) ~[spring-orm-5.0.4.RELEASE.jar:5.0.4.RELEASE] + at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:365) ~[spring-orm-5.0.4.RELEASE.jar:5.0.4.RELEASE] + at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:388) ~[spring-orm-5.0.4.RELEASE.jar:5.0.4.RELEASE] + at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:377) ~[spring-orm-5.0.4.RELEASE.jar:5.0.4.RELEASE] + at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.afterPropertiesSet(LocalContainerEntityManagerFactoryBean.java:341) ~[spring-orm-5.0.4.RELEASE.jar:5.0.4.RELEASE] + at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1769) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE] + at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1706) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE] + ... 42 common frames omitted +Caused by: java.lang.ClassNotFoundException: javax.transaction.SystemException + at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:582) ~[na:na] + at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:185) ~[na:na] + at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:496) ~[na:na] + ... 58 common frames omitted + +]]> + + \ No newline at end of file diff --git a/SpringH2Application/target/surefire-reports/TEST-com.suneesh.h2.UserRepositoryTest.xml b/SpringH2Application/target/surefire-reports/TEST-com.suneesh.h2.UserRepositoryTest.xml new file mode 100644 index 0000000..b8f0d6b --- /dev/null +++ b/SpringH2Application/target/surefire-reports/TEST-com.suneesh.h2.UserRepositoryTest.xml @@ -0,0 +1,288 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + java.lang.IllegalStateException: Failed to load ApplicationContext +Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: Could not initialize class org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl +Caused by: java.lang.NoClassDefFoundError: Could not initialize class org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl + + + + \ No newline at end of file diff --git a/SpringH2Application/target/surefire-reports/com.suneesh.h2.H2InMemoryDbDemoApplicationTests.txt b/SpringH2Application/target/surefire-reports/com.suneesh.h2.H2InMemoryDbDemoApplicationTests.txt new file mode 100644 index 0000000..b7c8677 --- /dev/null +++ b/SpringH2Application/target/surefire-reports/com.suneesh.h2.H2InMemoryDbDemoApplicationTests.txt @@ -0,0 +1,10 @@ +------------------------------------------------------------------------------- +Test set: com.suneesh.h2.H2InMemoryDbDemoApplicationTests +------------------------------------------------------------------------------- +Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 2.674 s <<< FAILURE! - in com.suneesh.h2.H2InMemoryDbDemoApplicationTests +contextLoads(com.suneesh.h2.H2InMemoryDbDemoApplicationTests) Time elapsed: 0.001 s <<< ERROR! +java.lang.IllegalStateException: Failed to load ApplicationContext +Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: javax/transaction/SystemException +Caused by: java.lang.NoClassDefFoundError: javax/transaction/SystemException +Caused by: java.lang.ClassNotFoundException: javax.transaction.SystemException + diff --git a/SpringH2Application/target/surefire-reports/com.suneesh.h2.UserRepositoryTest.txt b/SpringH2Application/target/surefire-reports/com.suneesh.h2.UserRepositoryTest.txt new file mode 100644 index 0000000..0abbacb --- /dev/null +++ b/SpringH2Application/target/surefire-reports/com.suneesh.h2.UserRepositoryTest.txt @@ -0,0 +1,9 @@ +------------------------------------------------------------------------------- +Test set: com.suneesh.h2.UserRepositoryTest +------------------------------------------------------------------------------- +Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 1.255 s <<< FAILURE! - in com.suneesh.h2.UserRepositoryTest +check_todo_count(com.suneesh.h2.UserRepositoryTest) Time elapsed: 0 s <<< ERROR! +java.lang.IllegalStateException: Failed to load ApplicationContext +Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: Could not initialize class org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl +Caused by: java.lang.NoClassDefFoundError: Could not initialize class org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl + diff --git a/SpringH2Application/target/test-classes/com/suneesh/h2/H2InMemoryDbDemoApplicationTests.class b/SpringH2Application/target/test-classes/com/suneesh/h2/H2InMemoryDbDemoApplicationTests.class new file mode 100644 index 0000000..c7b056c Binary files /dev/null and b/SpringH2Application/target/test-classes/com/suneesh/h2/H2InMemoryDbDemoApplicationTests.class differ diff --git a/SpringH2Application/target/test-classes/com/suneesh/h2/UserRepositoryTest.class b/SpringH2Application/target/test-classes/com/suneesh/h2/UserRepositoryTest.class new file mode 100644 index 0000000..de824ad Binary files /dev/null and b/SpringH2Application/target/test-classes/com/suneesh/h2/UserRepositoryTest.class differ diff --git a/Trading/.idea/$PRODUCT_WORKSPACE_FILE$ b/Trading/.idea/$PRODUCT_WORKSPACE_FILE$ new file mode 100644 index 0000000..1e3a4ad --- /dev/null +++ b/Trading/.idea/$PRODUCT_WORKSPACE_FILE$ @@ -0,0 +1,19 @@ + + + + + + + 9 + + + + + + + + \ No newline at end of file diff --git a/Trading/.idea/.name b/Trading/.idea/.name new file mode 100644 index 0000000..5d834b9 --- /dev/null +++ b/Trading/.idea/.name @@ -0,0 +1 @@ +autoBinary \ No newline at end of file diff --git a/Trading/.idea/codeStyles/Project.xml b/Trading/.idea/codeStyles/Project.xml new file mode 100644 index 0000000..3cdc6ae --- /dev/null +++ b/Trading/.idea/codeStyles/Project.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Trading/.idea/compiler.xml b/Trading/.idea/compiler.xml new file mode 100644 index 0000000..179cc16 --- /dev/null +++ b/Trading/.idea/compiler.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Trading/.idea/dbnavigator.xml b/Trading/.idea/dbnavigator.xml new file mode 100644 index 0000000..3f4b56c --- /dev/null +++ b/Trading/.idea/dbnavigator.xml @@ -0,0 +1,456 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Trading/.idea/dictionaries/sunee.xml b/Trading/.idea/dictionaries/sunee.xml new file mode 100644 index 0000000..b13029d --- /dev/null +++ b/Trading/.idea/dictionaries/sunee.xml @@ -0,0 +1,7 @@ + + + + postgre + + + \ No newline at end of file diff --git a/Trading/.idea/encodings.xml b/Trading/.idea/encodings.xml new file mode 100644 index 0000000..63e9001 --- /dev/null +++ b/Trading/.idea/encodings.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Trading/.idea/jarRepositories.xml b/Trading/.idea/jarRepositories.xml new file mode 100644 index 0000000..c397865 --- /dev/null +++ b/Trading/.idea/jarRepositories.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/Trading/.idea/libraries/Maven__antlr_antlr_2_7_7.xml b/Trading/.idea/libraries/Maven__antlr_antlr_2_7_7.xml new file mode 100644 index 0000000..b8d93d8 --- /dev/null +++ b/Trading/.idea/libraries/Maven__antlr_antlr_2_7_7.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/Trading/.idea/libraries/Maven__ch_qos_logback_logback_classic_1_2_3.xml b/Trading/.idea/libraries/Maven__ch_qos_logback_logback_classic_1_2_3.xml new file mode 100644 index 0000000..6fec8f4 --- /dev/null +++ b/Trading/.idea/libraries/Maven__ch_qos_logback_logback_classic_1_2_3.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/Trading/.idea/libraries/Maven__ch_qos_logback_logback_core_1_2_3.xml b/Trading/.idea/libraries/Maven__ch_qos_logback_logback_core_1_2_3.xml new file mode 100644 index 0000000..9eb8596 --- /dev/null +++ b/Trading/.idea/libraries/Maven__ch_qos_logback_logback_core_1_2_3.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/Trading/.idea/libraries/Maven__com_fasterxml_classmate_1_4_0.xml b/Trading/.idea/libraries/Maven__com_fasterxml_classmate_1_4_0.xml new file mode 100644 index 0000000..bbd3a88 --- /dev/null +++ b/Trading/.idea/libraries/Maven__com_fasterxml_classmate_1_4_0.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/Trading/.idea/libraries/Maven__com_google_code_gson_gson_2_8_6.xml b/Trading/.idea/libraries/Maven__com_google_code_gson_gson_2_8_6.xml new file mode 100644 index 0000000..82a9f20 --- /dev/null +++ b/Trading/.idea/libraries/Maven__com_google_code_gson_gson_2_8_6.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/Trading/.idea/libraries/Maven__com_jayway_jsonpath_json_path_2_4_0.xml b/Trading/.idea/libraries/Maven__com_jayway_jsonpath_json_path_2_4_0.xml new file mode 100644 index 0000000..f19f6eb --- /dev/null +++ b/Trading/.idea/libraries/Maven__com_jayway_jsonpath_json_path_2_4_0.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/Trading/.idea/libraries/Maven__com_squareup_okhttp3_okhttp_4_2_2.xml b/Trading/.idea/libraries/Maven__com_squareup_okhttp3_okhttp_4_2_2.xml new file mode 100644 index 0000000..74fcb62 --- /dev/null +++ b/Trading/.idea/libraries/Maven__com_squareup_okhttp3_okhttp_4_2_2.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/Trading/.idea/libraries/Maven__com_squareup_okio_okio_2_2_2.xml b/Trading/.idea/libraries/Maven__com_squareup_okio_okio_2_2_2.xml new file mode 100644 index 0000000..4fca8f7 --- /dev/null +++ b/Trading/.idea/libraries/Maven__com_squareup_okio_okio_2_2_2.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/Trading/.idea/libraries/Maven__com_vaadin_external_google_android_json_0_0_20131108_vaadin1.xml b/Trading/.idea/libraries/Maven__com_vaadin_external_google_android_json_0_0_20131108_vaadin1.xml new file mode 100644 index 0000000..b8581a6 --- /dev/null +++ b/Trading/.idea/libraries/Maven__com_vaadin_external_google_android_json_0_0_20131108_vaadin1.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/Trading/.idea/libraries/Maven__com_zaxxer_HikariCP_3_2_0.xml b/Trading/.idea/libraries/Maven__com_zaxxer_HikariCP_3_2_0.xml new file mode 100644 index 0000000..8f760a2 --- /dev/null +++ b/Trading/.idea/libraries/Maven__com_zaxxer_HikariCP_3_2_0.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/Trading/.idea/libraries/Maven__io_reactivex_rxjava2_rxjava_2_2_16.xml b/Trading/.idea/libraries/Maven__io_reactivex_rxjava2_rxjava_2_2_16.xml new file mode 100644 index 0000000..b21f4a0 --- /dev/null +++ b/Trading/.idea/libraries/Maven__io_reactivex_rxjava2_rxjava_2_2_16.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/Trading/.idea/libraries/Maven__javax_activation_javax_activation_api_1_2_0.xml b/Trading/.idea/libraries/Maven__javax_activation_javax_activation_api_1_2_0.xml new file mode 100644 index 0000000..ff49512 --- /dev/null +++ b/Trading/.idea/libraries/Maven__javax_activation_javax_activation_api_1_2_0.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/Trading/.idea/libraries/Maven__javax_annotation_javax_annotation_api_1_3_2.xml b/Trading/.idea/libraries/Maven__javax_annotation_javax_annotation_api_1_3_2.xml new file mode 100644 index 0000000..e74f3ab --- /dev/null +++ b/Trading/.idea/libraries/Maven__javax_annotation_javax_annotation_api_1_3_2.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/Trading/.idea/libraries/Maven__javax_persistence_javax_persistence_api_2_2.xml b/Trading/.idea/libraries/Maven__javax_persistence_javax_persistence_api_2_2.xml new file mode 100644 index 0000000..b7d39c6 --- /dev/null +++ b/Trading/.idea/libraries/Maven__javax_persistence_javax_persistence_api_2_2.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/Trading/.idea/libraries/Maven__javax_transaction_javax_transaction_api_1_3.xml b/Trading/.idea/libraries/Maven__javax_transaction_javax_transaction_api_1_3.xml new file mode 100644 index 0000000..8f5f3c6 --- /dev/null +++ b/Trading/.idea/libraries/Maven__javax_transaction_javax_transaction_api_1_3.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/Trading/.idea/libraries/Maven__javax_xml_bind_jaxb_api_2_3_1.xml b/Trading/.idea/libraries/Maven__javax_xml_bind_jaxb_api_2_3_1.xml new file mode 100644 index 0000000..059f88f --- /dev/null +++ b/Trading/.idea/libraries/Maven__javax_xml_bind_jaxb_api_2_3_1.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/Trading/.idea/libraries/Maven__junit_junit_4_12.xml b/Trading/.idea/libraries/Maven__junit_junit_4_12.xml new file mode 100644 index 0000000..d411041 --- /dev/null +++ b/Trading/.idea/libraries/Maven__junit_junit_4_12.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/Trading/.idea/libraries/Maven__net_bytebuddy_byte_buddy_1_9_7.xml b/Trading/.idea/libraries/Maven__net_bytebuddy_byte_buddy_1_9_7.xml new file mode 100644 index 0000000..742b745 --- /dev/null +++ b/Trading/.idea/libraries/Maven__net_bytebuddy_byte_buddy_1_9_7.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/Trading/.idea/libraries/Maven__net_bytebuddy_byte_buddy_agent_1_9_7.xml b/Trading/.idea/libraries/Maven__net_bytebuddy_byte_buddy_agent_1_9_7.xml new file mode 100644 index 0000000..d4e13b8 --- /dev/null +++ b/Trading/.idea/libraries/Maven__net_bytebuddy_byte_buddy_agent_1_9_7.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/Trading/.idea/libraries/Maven__net_minidev_accessors_smart_1_2.xml b/Trading/.idea/libraries/Maven__net_minidev_accessors_smart_1_2.xml new file mode 100644 index 0000000..b3d3858 --- /dev/null +++ b/Trading/.idea/libraries/Maven__net_minidev_accessors_smart_1_2.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/Trading/.idea/libraries/Maven__net_minidev_json_smart_2_3.xml b/Trading/.idea/libraries/Maven__net_minidev_json_smart_2_3.xml new file mode 100644 index 0000000..1083023 --- /dev/null +++ b/Trading/.idea/libraries/Maven__net_minidev_json_smart_2_3.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/Trading/.idea/libraries/Maven__org_apache_commons_commons_collections4_4_4.xml b/Trading/.idea/libraries/Maven__org_apache_commons_commons_collections4_4_4.xml new file mode 100644 index 0000000..5871c95 --- /dev/null +++ b/Trading/.idea/libraries/Maven__org_apache_commons_commons_collections4_4_4.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/Trading/.idea/libraries/Maven__org_apache_logging_log4j_log4j_api_2_11_1.xml b/Trading/.idea/libraries/Maven__org_apache_logging_log4j_log4j_api_2_11_1.xml new file mode 100644 index 0000000..c27223f --- /dev/null +++ b/Trading/.idea/libraries/Maven__org_apache_logging_log4j_log4j_api_2_11_1.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/Trading/.idea/libraries/Maven__org_apache_logging_log4j_log4j_core_2_11_1.xml b/Trading/.idea/libraries/Maven__org_apache_logging_log4j_log4j_core_2_11_1.xml new file mode 100644 index 0000000..ddbd23d --- /dev/null +++ b/Trading/.idea/libraries/Maven__org_apache_logging_log4j_log4j_core_2_11_1.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/Trading/.idea/libraries/Maven__org_apache_logging_log4j_log4j_slf4j_impl_2_13_0.xml b/Trading/.idea/libraries/Maven__org_apache_logging_log4j_log4j_slf4j_impl_2_13_0.xml new file mode 100644 index 0000000..504611e --- /dev/null +++ b/Trading/.idea/libraries/Maven__org_apache_logging_log4j_log4j_slf4j_impl_2_13_0.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/Trading/.idea/libraries/Maven__org_apache_logging_log4j_log4j_to_slf4j_2_11_1.xml b/Trading/.idea/libraries/Maven__org_apache_logging_log4j_log4j_to_slf4j_2_11_1.xml new file mode 100644 index 0000000..bd733be --- /dev/null +++ b/Trading/.idea/libraries/Maven__org_apache_logging_log4j_log4j_to_slf4j_2_11_1.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/Trading/.idea/libraries/Maven__org_aspectj_aspectjweaver_1_9_2.xml b/Trading/.idea/libraries/Maven__org_aspectj_aspectjweaver_1_9_2.xml new file mode 100644 index 0000000..a1f3d90 --- /dev/null +++ b/Trading/.idea/libraries/Maven__org_aspectj_aspectjweaver_1_9_2.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/Trading/.idea/libraries/Maven__org_assertj_assertj_core_3_11_1.xml b/Trading/.idea/libraries/Maven__org_assertj_assertj_core_3_11_1.xml new file mode 100644 index 0000000..4d16d46 --- /dev/null +++ b/Trading/.idea/libraries/Maven__org_assertj_assertj_core_3_11_1.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/Trading/.idea/libraries/Maven__org_dom4j_dom4j_2_1_1.xml b/Trading/.idea/libraries/Maven__org_dom4j_dom4j_2_1_1.xml new file mode 100644 index 0000000..6c8b371 --- /dev/null +++ b/Trading/.idea/libraries/Maven__org_dom4j_dom4j_2_1_1.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/Trading/.idea/libraries/Maven__org_hamcrest_hamcrest_core_1_3.xml b/Trading/.idea/libraries/Maven__org_hamcrest_hamcrest_core_1_3.xml new file mode 100644 index 0000000..f58bbc1 --- /dev/null +++ b/Trading/.idea/libraries/Maven__org_hamcrest_hamcrest_core_1_3.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/Trading/.idea/libraries/Maven__org_hamcrest_hamcrest_library_1_3.xml b/Trading/.idea/libraries/Maven__org_hamcrest_hamcrest_library_1_3.xml new file mode 100644 index 0000000..78dbe45 --- /dev/null +++ b/Trading/.idea/libraries/Maven__org_hamcrest_hamcrest_library_1_3.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/Trading/.idea/libraries/Maven__org_hibernate_common_hibernate_commons_annotations_5_0_4_Final.xml b/Trading/.idea/libraries/Maven__org_hibernate_common_hibernate_commons_annotations_5_0_4_Final.xml new file mode 100644 index 0000000..c4d0340 --- /dev/null +++ b/Trading/.idea/libraries/Maven__org_hibernate_common_hibernate_commons_annotations_5_0_4_Final.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/Trading/.idea/libraries/Maven__org_hibernate_hibernate_core_5_3_7_Final.xml b/Trading/.idea/libraries/Maven__org_hibernate_hibernate_core_5_3_7_Final.xml new file mode 100644 index 0000000..3924ff1 --- /dev/null +++ b/Trading/.idea/libraries/Maven__org_hibernate_hibernate_core_5_3_7_Final.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/Trading/.idea/libraries/Maven__org_javassist_javassist_3_23_1_GA.xml b/Trading/.idea/libraries/Maven__org_javassist_javassist_3_23_1_GA.xml new file mode 100644 index 0000000..7f1d521 --- /dev/null +++ b/Trading/.idea/libraries/Maven__org_javassist_javassist_3_23_1_GA.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/Trading/.idea/libraries/Maven__org_jboss_jandex_2_0_5_Final.xml b/Trading/.idea/libraries/Maven__org_jboss_jandex_2_0_5_Final.xml new file mode 100644 index 0000000..34e9ada --- /dev/null +++ b/Trading/.idea/libraries/Maven__org_jboss_jandex_2_0_5_Final.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/Trading/.idea/libraries/Maven__org_jboss_logging_jboss_logging_3_3_2_Final.xml b/Trading/.idea/libraries/Maven__org_jboss_logging_jboss_logging_3_3_2_Final.xml new file mode 100644 index 0000000..5f7dd01 --- /dev/null +++ b/Trading/.idea/libraries/Maven__org_jboss_logging_jboss_logging_3_3_2_Final.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/Trading/.idea/libraries/Maven__org_jetbrains_annotations_13_0.xml b/Trading/.idea/libraries/Maven__org_jetbrains_annotations_13_0.xml new file mode 100644 index 0000000..e2c8297 --- /dev/null +++ b/Trading/.idea/libraries/Maven__org_jetbrains_annotations_13_0.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/Trading/.idea/libraries/Maven__org_jetbrains_kotlin_kotlin_stdlib_1_2_71.xml b/Trading/.idea/libraries/Maven__org_jetbrains_kotlin_kotlin_stdlib_1_2_71.xml new file mode 100644 index 0000000..8ba847a --- /dev/null +++ b/Trading/.idea/libraries/Maven__org_jetbrains_kotlin_kotlin_stdlib_1_2_71.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/Trading/.idea/libraries/Maven__org_jetbrains_kotlin_kotlin_stdlib_common_1_2_71.xml b/Trading/.idea/libraries/Maven__org_jetbrains_kotlin_kotlin_stdlib_common_1_2_71.xml new file mode 100644 index 0000000..f01feb7 --- /dev/null +++ b/Trading/.idea/libraries/Maven__org_jetbrains_kotlin_kotlin_stdlib_common_1_2_71.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/Trading/.idea/libraries/Maven__org_json_json_20190722.xml b/Trading/.idea/libraries/Maven__org_json_json_20190722.xml new file mode 100644 index 0000000..0f42bad --- /dev/null +++ b/Trading/.idea/libraries/Maven__org_json_json_20190722.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/Trading/.idea/libraries/Maven__org_mockito_mockito_core_2_23_4.xml b/Trading/.idea/libraries/Maven__org_mockito_mockito_core_2_23_4.xml new file mode 100644 index 0000000..159204f --- /dev/null +++ b/Trading/.idea/libraries/Maven__org_mockito_mockito_core_2_23_4.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/Trading/.idea/libraries/Maven__org_objenesis_objenesis_2_6.xml b/Trading/.idea/libraries/Maven__org_objenesis_objenesis_2_6.xml new file mode 100644 index 0000000..af41e3b --- /dev/null +++ b/Trading/.idea/libraries/Maven__org_objenesis_objenesis_2_6.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/Trading/.idea/libraries/Maven__org_ow2_asm_asm_5_0_4.xml b/Trading/.idea/libraries/Maven__org_ow2_asm_asm_5_0_4.xml new file mode 100644 index 0000000..0bf8cf2 --- /dev/null +++ b/Trading/.idea/libraries/Maven__org_ow2_asm_asm_5_0_4.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/Trading/.idea/libraries/Maven__org_postgresql_postgresql_42_2_5.xml b/Trading/.idea/libraries/Maven__org_postgresql_postgresql_42_2_5.xml new file mode 100644 index 0000000..b0b7ad4 --- /dev/null +++ b/Trading/.idea/libraries/Maven__org_postgresql_postgresql_42_2_5.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/Trading/.idea/libraries/Maven__org_projectlombok_lombok_1_18_10.xml b/Trading/.idea/libraries/Maven__org_projectlombok_lombok_1_18_10.xml new file mode 100644 index 0000000..0ce7ba6 --- /dev/null +++ b/Trading/.idea/libraries/Maven__org_projectlombok_lombok_1_18_10.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/Trading/.idea/libraries/Maven__org_reactivestreams_reactive_streams_1_0_2.xml b/Trading/.idea/libraries/Maven__org_reactivestreams_reactive_streams_1_0_2.xml new file mode 100644 index 0000000..457c7b7 --- /dev/null +++ b/Trading/.idea/libraries/Maven__org_reactivestreams_reactive_streams_1_0_2.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/Trading/.idea/libraries/Maven__org_skyscreamer_jsonassert_1_5_0.xml b/Trading/.idea/libraries/Maven__org_skyscreamer_jsonassert_1_5_0.xml new file mode 100644 index 0000000..c4c54d6 --- /dev/null +++ b/Trading/.idea/libraries/Maven__org_skyscreamer_jsonassert_1_5_0.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/Trading/.idea/libraries/Maven__org_slf4j_jul_to_slf4j_1_7_25.xml b/Trading/.idea/libraries/Maven__org_slf4j_jul_to_slf4j_1_7_25.xml new file mode 100644 index 0000000..6073e53 --- /dev/null +++ b/Trading/.idea/libraries/Maven__org_slf4j_jul_to_slf4j_1_7_25.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/Trading/.idea/libraries/Maven__org_slf4j_slf4j_api_1_7_25.xml b/Trading/.idea/libraries/Maven__org_slf4j_slf4j_api_1_7_25.xml new file mode 100644 index 0000000..20e8163 --- /dev/null +++ b/Trading/.idea/libraries/Maven__org_slf4j_slf4j_api_1_7_25.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/Trading/.idea/libraries/Maven__org_springframework_boot_spring_boot_2_1_2_RELEASE.xml b/Trading/.idea/libraries/Maven__org_springframework_boot_spring_boot_2_1_2_RELEASE.xml new file mode 100644 index 0000000..52dffb0 --- /dev/null +++ b/Trading/.idea/libraries/Maven__org_springframework_boot_spring_boot_2_1_2_RELEASE.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/Trading/.idea/libraries/Maven__org_springframework_boot_spring_boot_autoconfigure_2_1_2_RELEASE.xml b/Trading/.idea/libraries/Maven__org_springframework_boot_spring_boot_autoconfigure_2_1_2_RELEASE.xml new file mode 100644 index 0000000..50096a1 --- /dev/null +++ b/Trading/.idea/libraries/Maven__org_springframework_boot_spring_boot_autoconfigure_2_1_2_RELEASE.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/Trading/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_2_1_2_RELEASE.xml b/Trading/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_2_1_2_RELEASE.xml new file mode 100644 index 0000000..307d733 --- /dev/null +++ b/Trading/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_2_1_2_RELEASE.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/Trading/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_aop_2_1_2_RELEASE.xml b/Trading/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_aop_2_1_2_RELEASE.xml new file mode 100644 index 0000000..8dbca18 --- /dev/null +++ b/Trading/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_aop_2_1_2_RELEASE.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/Trading/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_data_jpa_2_1_2_RELEASE.xml b/Trading/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_data_jpa_2_1_2_RELEASE.xml new file mode 100644 index 0000000..96bf3fb --- /dev/null +++ b/Trading/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_data_jpa_2_1_2_RELEASE.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/Trading/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_jdbc_2_1_2_RELEASE.xml b/Trading/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_jdbc_2_1_2_RELEASE.xml new file mode 100644 index 0000000..200c563 --- /dev/null +++ b/Trading/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_jdbc_2_1_2_RELEASE.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/Trading/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_logging_2_1_2_RELEASE.xml b/Trading/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_logging_2_1_2_RELEASE.xml new file mode 100644 index 0000000..363334e --- /dev/null +++ b/Trading/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_logging_2_1_2_RELEASE.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/Trading/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_test_2_1_2_RELEASE.xml b/Trading/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_test_2_1_2_RELEASE.xml new file mode 100644 index 0000000..9bd17bb --- /dev/null +++ b/Trading/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_test_2_1_2_RELEASE.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/Trading/.idea/libraries/Maven__org_springframework_boot_spring_boot_test_2_1_2_RELEASE.xml b/Trading/.idea/libraries/Maven__org_springframework_boot_spring_boot_test_2_1_2_RELEASE.xml new file mode 100644 index 0000000..73cd53c --- /dev/null +++ b/Trading/.idea/libraries/Maven__org_springframework_boot_spring_boot_test_2_1_2_RELEASE.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/Trading/.idea/libraries/Maven__org_springframework_boot_spring_boot_test_autoconfigure_2_1_2_RELEASE.xml b/Trading/.idea/libraries/Maven__org_springframework_boot_spring_boot_test_autoconfigure_2_1_2_RELEASE.xml new file mode 100644 index 0000000..e4c79a7 --- /dev/null +++ b/Trading/.idea/libraries/Maven__org_springframework_boot_spring_boot_test_autoconfigure_2_1_2_RELEASE.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/Trading/.idea/libraries/Maven__org_springframework_data_spring_data_commons_2_1_4_RELEASE.xml b/Trading/.idea/libraries/Maven__org_springframework_data_spring_data_commons_2_1_4_RELEASE.xml new file mode 100644 index 0000000..8a62db2 --- /dev/null +++ b/Trading/.idea/libraries/Maven__org_springframework_data_spring_data_commons_2_1_4_RELEASE.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/Trading/.idea/libraries/Maven__org_springframework_data_spring_data_jpa_2_1_4_RELEASE.xml b/Trading/.idea/libraries/Maven__org_springframework_data_spring_data_jpa_2_1_4_RELEASE.xml new file mode 100644 index 0000000..6afabea --- /dev/null +++ b/Trading/.idea/libraries/Maven__org_springframework_data_spring_data_jpa_2_1_4_RELEASE.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/Trading/.idea/libraries/Maven__org_springframework_spring_aop_5_1_4_RELEASE.xml b/Trading/.idea/libraries/Maven__org_springframework_spring_aop_5_1_4_RELEASE.xml new file mode 100644 index 0000000..b38621b --- /dev/null +++ b/Trading/.idea/libraries/Maven__org_springframework_spring_aop_5_1_4_RELEASE.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/Trading/.idea/libraries/Maven__org_springframework_spring_aspects_5_1_4_RELEASE.xml b/Trading/.idea/libraries/Maven__org_springframework_spring_aspects_5_1_4_RELEASE.xml new file mode 100644 index 0000000..5ed8a18 --- /dev/null +++ b/Trading/.idea/libraries/Maven__org_springframework_spring_aspects_5_1_4_RELEASE.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/Trading/.idea/libraries/Maven__org_springframework_spring_beans_5_1_4_RELEASE.xml b/Trading/.idea/libraries/Maven__org_springframework_spring_beans_5_1_4_RELEASE.xml new file mode 100644 index 0000000..9116913 --- /dev/null +++ b/Trading/.idea/libraries/Maven__org_springframework_spring_beans_5_1_4_RELEASE.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/Trading/.idea/libraries/Maven__org_springframework_spring_context_5_1_4_RELEASE.xml b/Trading/.idea/libraries/Maven__org_springframework_spring_context_5_1_4_RELEASE.xml new file mode 100644 index 0000000..05c3535 --- /dev/null +++ b/Trading/.idea/libraries/Maven__org_springframework_spring_context_5_1_4_RELEASE.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/Trading/.idea/libraries/Maven__org_springframework_spring_core_5_1_4_RELEASE.xml b/Trading/.idea/libraries/Maven__org_springframework_spring_core_5_1_4_RELEASE.xml new file mode 100644 index 0000000..3110ace --- /dev/null +++ b/Trading/.idea/libraries/Maven__org_springframework_spring_core_5_1_4_RELEASE.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/Trading/.idea/libraries/Maven__org_springframework_spring_expression_5_1_4_RELEASE.xml b/Trading/.idea/libraries/Maven__org_springframework_spring_expression_5_1_4_RELEASE.xml new file mode 100644 index 0000000..8dc00ae --- /dev/null +++ b/Trading/.idea/libraries/Maven__org_springframework_spring_expression_5_1_4_RELEASE.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/Trading/.idea/libraries/Maven__org_springframework_spring_jcl_5_1_4_RELEASE.xml b/Trading/.idea/libraries/Maven__org_springframework_spring_jcl_5_1_4_RELEASE.xml new file mode 100644 index 0000000..8b3738f --- /dev/null +++ b/Trading/.idea/libraries/Maven__org_springframework_spring_jcl_5_1_4_RELEASE.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/Trading/.idea/libraries/Maven__org_springframework_spring_jdbc_5_1_4_RELEASE.xml b/Trading/.idea/libraries/Maven__org_springframework_spring_jdbc_5_1_4_RELEASE.xml new file mode 100644 index 0000000..9d18ad6 --- /dev/null +++ b/Trading/.idea/libraries/Maven__org_springframework_spring_jdbc_5_1_4_RELEASE.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/Trading/.idea/libraries/Maven__org_springframework_spring_orm_5_1_4_RELEASE.xml b/Trading/.idea/libraries/Maven__org_springframework_spring_orm_5_1_4_RELEASE.xml new file mode 100644 index 0000000..b9b3f65 --- /dev/null +++ b/Trading/.idea/libraries/Maven__org_springframework_spring_orm_5_1_4_RELEASE.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/Trading/.idea/libraries/Maven__org_springframework_spring_test_5_1_4_RELEASE.xml b/Trading/.idea/libraries/Maven__org_springframework_spring_test_5_1_4_RELEASE.xml new file mode 100644 index 0000000..fd9a0ef --- /dev/null +++ b/Trading/.idea/libraries/Maven__org_springframework_spring_test_5_1_4_RELEASE.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/Trading/.idea/libraries/Maven__org_springframework_spring_tx_5_1_4_RELEASE.xml b/Trading/.idea/libraries/Maven__org_springframework_spring_tx_5_1_4_RELEASE.xml new file mode 100644 index 0000000..b93a666 --- /dev/null +++ b/Trading/.idea/libraries/Maven__org_springframework_spring_tx_5_1_4_RELEASE.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/Trading/.idea/libraries/Maven__org_xmlunit_xmlunit_core_2_6_2.xml b/Trading/.idea/libraries/Maven__org_xmlunit_xmlunit_core_2_6_2.xml new file mode 100644 index 0000000..9f44657 --- /dev/null +++ b/Trading/.idea/libraries/Maven__org_xmlunit_xmlunit_core_2_6_2.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/Trading/.idea/libraries/Maven__org_yaml_snakeyaml_1_23.xml b/Trading/.idea/libraries/Maven__org_yaml_snakeyaml_1_23.xml new file mode 100644 index 0000000..7e63769 --- /dev/null +++ b/Trading/.idea/libraries/Maven__org_yaml_snakeyaml_1_23.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/Trading/.idea/misc.xml b/Trading/.idea/misc.xml new file mode 100644 index 0000000..ef36dab --- /dev/null +++ b/Trading/.idea/misc.xml @@ -0,0 +1,13 @@ + + + + + + + + + \ No newline at end of file diff --git a/Trading/.idea/modules.xml b/Trading/.idea/modules.xml new file mode 100644 index 0000000..8bebd2a --- /dev/null +++ b/Trading/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/Trading/.idea/uiDesigner.xml b/Trading/.idea/uiDesigner.xml new file mode 100644 index 0000000..e96534f --- /dev/null +++ b/Trading/.idea/uiDesigner.xml @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Trading/.idea/vcs.xml b/Trading/.idea/vcs.xml new file mode 100644 index 0000000..6c0b863 --- /dev/null +++ b/Trading/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Trading/.idea/workspace.xml b/Trading/.idea/workspace.xml new file mode 100644 index 0000000..19422ad --- /dev/null +++ b/Trading/.idea/workspace.xml @@ -0,0 +1,62 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1578862180649 + + + + \ No newline at end of file diff --git a/Trading/autoBinary.iml b/Trading/autoBinary.iml new file mode 100644 index 0000000..913fc60 --- /dev/null +++ b/Trading/autoBinary.iml @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Trading/pom.xml b/Trading/pom.xml new file mode 100644 index 0000000..63457a7 --- /dev/null +++ b/Trading/pom.xml @@ -0,0 +1,112 @@ + + + 4.0.0 + + com.suneesh.trading + autoBinary + 1.0-SNAPSHOT + + + org.springframework.boot + spring-boot-starter-parent + 2.1.2.RELEASE + + + + 1.8 + 1.8 + + + + + + org.springframework.boot + spring-boot-starter-data-jpa + + + + + org.postgresql + postgresql + + + + org.springframework.boot + spring-boot-starter-test + test + + + + com.google.code.gson + gson + 2.8.6 + + + + io.reactivex.rxjava2 + rxjava + 2.2.16 + + + com.squareup.okhttp3 + okhttp + 4.2.2 + + + org.apache.commons + commons-math3 + 3.6.1 + + + org.projectlombok + lombok + 1.18.10 + provided + + + + org.apache.logging.log4j + log4j-slf4j-impl + 2.13.0 + + + + org.json + json + 20190722 + + + org.apache.commons + commons-collections4 + 4.4 + + + + junit + junit + 4.12 + test + + + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + org.apache.maven.plugins + maven-surefire-plugin + 2.22.0 + + + + + + \ No newline at end of file diff --git a/Trading/src/main/java/com/suneesh/trading/BinaryMainApplication.java b/Trading/src/main/java/com/suneesh/trading/BinaryMainApplication.java new file mode 100644 index 0000000..c32a03e --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/BinaryMainApplication.java @@ -0,0 +1,61 @@ +package com.suneesh.trading; + +import com.suneesh.trading.core.BinaryWebServiceConnector; +import com.suneesh.trading.models.requests.*; +import com.suneesh.trading.utils.AutoTradingUtility; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +import java.util.concurrent.BlockingQueue; +import java.util.concurrent.LinkedBlockingQueue; + +public class BinaryMainApplication { + private static Logger logger = LogManager.getLogger(); + + private static String applicationId; + private static String applicationAuthorizeToken; + private static String databaseServer; + private static String dbURL; + private static String dbName; + private static BlockingQueue inputMessageQueue = new LinkedBlockingQueue<>(); + private static final String symbolToTrade ="R_50"; + private static boolean backTestingMode; + + private static void init(){ + String databaseNamePropertyToUse; + applicationId = AutoTradingUtility.getPropertyFromPropertyFile("ApplicationId"); + applicationAuthorizeToken = AutoTradingUtility.getPropertyFromPropertyFile("ApplicationAuthorizeToken"); + databaseServer=AutoTradingUtility.getPropertyFromPropertyFile("DatabaseServerEngine"); + dbURL=AutoTradingUtility.getPropertyFromPropertyFile("DatabaseURL"); + backTestingMode=Boolean.parseBoolean(AutoTradingUtility.getPropertyFromPropertyFile("BackTesting")); + if(backTestingMode){ + databaseNamePropertyToUse="BackTestingDatabaseName"; + }else{ + databaseNamePropertyToUse="DatabaseName"; + } + + dbName=AutoTradingUtility.getPropertyFromPropertyFile(databaseNamePropertyToUse); + } + + public static void main(String[] args) { + init(); + if(backTestingMode){ + logger.info("\n\n"); + logger.info("***************************************************"); + logger.info("ALERT! RUNNING IN BACK TESTING MODE."); + logger.info("MANY NORMAL FEATURES DISABLED, IN BACKTESTING MODE."); + logger.info("***************************************************\n\n"); + } + + String completeDatabaseURL=dbURL+"/"+dbName; + BinaryWebServiceConnector binaryWebServiceConnector = new BinaryWebServiceConnector(inputMessageQueue, + applicationId, + applicationAuthorizeToken, + databaseServer, + completeDatabaseURL, + symbolToTrade, + backTestingMode); + binaryWebServiceConnector.init(); + } + +} diff --git a/Trading/src/main/java/com/suneesh/trading/core/AbstractCommandGenerator.java b/Trading/src/main/java/com/suneesh/trading/core/AbstractCommandGenerator.java new file mode 100644 index 0000000..d5c233f --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/core/AbstractCommandGenerator.java @@ -0,0 +1,28 @@ +package com.suneesh.trading.core; + +import com.suneesh.trading.models.requests.RequestBase; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +import java.util.concurrent.BlockingQueue; + +public abstract class AbstractCommandGenerator { + private static final Logger LOGGER = LogManager.getLogger(); + protected BlockingQueue commandQueue = null; + + public AbstractCommandGenerator(BlockingQueue inputMessageQueue) { + this.commandQueue = inputMessageQueue; + } + + public void sendRequest(RequestBase requestObject){ + try { + LOGGER.info("Sending message on Command Queue ... {}", String.valueOf(requestObject)); + commandQueue.put(requestObject); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + + abstract public void process(); + +} diff --git a/Trading/src/main/java/com/suneesh/trading/core/ApiWrapper.java b/Trading/src/main/java/com/suneesh/trading/core/ApiWrapper.java new file mode 100644 index 0000000..27c3523 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/core/ApiWrapper.java @@ -0,0 +1,167 @@ +package com.suneesh.trading.core; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.suneesh.trading.database.DatabaseConnection; +import com.suneesh.trading.models.WebsocketEvent; +import com.suneesh.trading.models.requests.RequestBase; +import com.suneesh.trading.models.responses.AssetIndex; +import com.suneesh.trading.models.responses.ResponseBase; +import com.suneesh.trading.utils.AssetIndexDeserializer; +import com.suneesh.trading.utils.ClassUtils; +import io.reactivex.Observable; +import io.reactivex.subjects.BehaviorSubject; +import io.reactivex.subjects.PublishSubject; +import lombok.Data; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.WebSocket; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + + +import java.io.IOException; + +/** + * Created by morteza on 7/19/2017. + */ +@Data +public class ApiWrapper { + + Logger logger = LogManager.getLogger(); + + private static ApiWrapper instance; + + private OkHttpClient client; + private WebSocket webSocket; + private WebsocketListener websocketListener; + private String websocketUrl; + public BehaviorSubject websocketEmitter = BehaviorSubject.create(); + private PublishSubject responseEmitter = PublishSubject.create(); + private PublishSubject requestEmitter = PublishSubject.create(); + protected String applicationId; + + protected DatabaseConnection databaseConnection; + + + private ApiWrapper(String applicationId, String language, String url, DatabaseConnection dbConnection){ + this.databaseConnection = dbConnection; + this.websocketUrl = url + String.format("?app_id=%s&l=%s", applicationId, language); + this.applicationId = applicationId; + + try { + logger.info("Attempting to connect to Binary WebSocket, url = {}", websocketUrl); + this.connect(); + } catch (IOException e) { + logger.debug(e.getMessage()); + } + + this.websocketEmitter.subscribe(e -> { + + logger.info("Connection status = {}", e.isOpened()); + if(!e.isOpened()) { + final int maxAttemptCount = 100; + int attemptCount = 1; + while (!e.isOpened() && attemptCount < maxAttemptCount) { + logger.info("Attempting to connect to Binary WebSocket, url = {}. Attempt : {}", websocketUrl, attemptCount); + this.connect(); + Thread.sleep(500); + attemptCount++; + } + + if (attemptCount >= maxAttemptCount) { + logger.info("ERROR ! Unable to connect to remote Binary WebSocket. url = {}", websocketUrl); + + } + } + }); + + } + + public static ApiWrapper build(String applicationId, DatabaseConnection databaseConnection) { + return build(applicationId, "en", "wss://ws.binaryws.com/websockets/v3", databaseConnection); + } + + + private void connect() throws IOException { + if (this.client != null) { + client.connectionPool().evictAll(); + client.dispatcher().executorService().shutdown(); + } + this.client = new OkHttpClient.Builder() + .retryOnConnectionFailure(true) + .build(); + final Request request = new Request.Builder() + .url(websocketUrl) + .build(); + + this.websocketListener = new WebsocketListener(this.websocketEmitter, + this.responseEmitter, this.requestEmitter, this.databaseConnection); + + this.webSocket = this.client.newWebSocket(request, websocketListener); + } + + public static ApiWrapper build(String applicationId){ + return build(applicationId, "en", "wss://ws.binaryws.com/websockets/v3",null); + } + + /** + * Create or retrieve an instance of ApiWrapper class + * @param applicationId + * @param language + * @param url + * @return An Instance of ApiWrapper class + */ + public static ApiWrapper build(String applicationId, String language, String url, DatabaseConnection dbConnection){ + if (instance == null) { + instance = new ApiWrapper(applicationId, language, url, dbConnection); + } + return instance; + } + + /** + * Send a request to the server + * @param request + * @return An observale + */ + public Observable sendRequest(RequestBase request){ + GsonBuilder gsonBuilder = new GsonBuilder(); + gsonBuilder.registerTypeAdapter(AssetIndex.class, new AssetIndexDeserializer()); + Gson gson = gsonBuilder.create(); + this.websocketEmitter + .filter(o -> { + return o.isOpened(); + }) + .take(1) + .subscribe( + o -> { + if(o.isOpened()) { + this.requestEmitter.onNext(gson.toJson(request)); + + } + } + ); + + return instance.responseEmitter + .filter((String o) -> { + ResponseBase response = gson.fromJson(o, request.getResponseType()); + + //FIXME Add req_id to the condition if it is exist + return request.getResponseType() == ClassUtils.getClassType(response.getType()); + }) + .map(o -> { +// ResponseBase response = gson.fromJson(o, request.getResponseType()); + return gson.fromJson(o, request.getResponseType()); + }); + } + + + public void closeConnection() { + this.requestEmitter.onComplete(); + this.responseEmitter.onComplete(); + this.websocketEmitter.onComplete(); + this.webSocket.cancel(); + instance = null; + } + +} diff --git a/Trading/src/main/java/com/suneesh/trading/core/BackTestingEngine.java b/Trading/src/main/java/com/suneesh/trading/core/BackTestingEngine.java new file mode 100644 index 0000000..a8bf946 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/core/BackTestingEngine.java @@ -0,0 +1,221 @@ +package com.suneesh.trading.core; + +import com.suneesh.trading.core.calculations.Engine; +import com.suneesh.trading.core.calculations.Utility; +import com.suneesh.trading.core.strategy.StrategyFactory; +import com.suneesh.trading.core.strategy.StrategyImplementationInterface; +import com.suneesh.trading.database.DatabaseConnection; +import com.suneesh.trading.models.Strategy; +import com.suneesh.trading.models.enums.TickStyles; +import com.suneesh.trading.models.requests.BuyContractRequest; +import com.suneesh.trading.models.requests.RequestBase; +import com.suneesh.trading.models.requests.TickHistoryRequest; +import com.suneesh.trading.utils.AutoTradingUtility; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.collections4.MapUtils; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.concurrent.BlockingQueue; + + +public class BackTestingEngine extends Engine { + private static final Logger logger = LogManager.getLogger(); + private String symbol; + StrategyFactory strategyFactory; + Utility calculationUtility; + Boolean isBackTestingMode; + + private DatabaseConnection databaseConnection; + final int CANDLE_DATA_POINTS=1440; + final int CANDLE_DATA_DELAY_MILLISECONDS=10000; + + public BackTestingEngine(BlockingQueue inputMessageQueue, DatabaseConnection dbConnection, String symbol, boolean isBackTestingMode) { + super(inputMessageQueue, dbConnection, symbol, isBackTestingMode); + this.databaseConnection = dbConnection; + this.symbol = symbol; + this.calculationUtility = new Utility(dbConnection); + this.isBackTestingMode = isBackTestingMode; + } + + public DatabaseConnection getDatabaseConnection() { + return databaseConnection; + } + + public void init(){ + calculationUtility.loadAllStrategies(); + strategyFactory = new StrategyFactory(databaseConnection, calculationUtility, isBackTestingMode); + getCandleDetailsFromBinaryWS(symbol,CANDLE_DATA_POINTS); + } + + public void getCandleDetailsFromBinaryWS(String symbol, int candleDataPoints) { + TickHistoryRequest tickHistoryRequest = new TickHistoryRequest(symbol, "latest"); + tickHistoryRequest.setStyle(TickStyles.CANDLES); + tickHistoryRequest.setCount(candleDataPoints); + tickHistoryRequest.setGranularity(60); + sendRequest(tickHistoryRequest); + } + + public void process(){ + init(); + logger.info("Waiting to receive data from Binary WS ..."); + AutoTradingUtility.sleep(CANDLE_DATA_DELAY_MILLISECONDS); + + List> candleDataFromDB = calculationUtility.getCandles(Optional.empty(), Optional.empty()); + logger.info("Received {} candle data points", candleDataFromDB.size()); + + int test_run_id = getTestRunId(); + + // Simulate different max_steps in the backtesting strategy. +// for(int simulate_max_steps_count = 1; simulate_max_steps_count <= 10; ++simulate_max_steps_count){ + + // Defaulting to 5 steps. + for(int simulate_max_steps_count = 5; simulate_max_steps_count <= 5; ++simulate_max_steps_count){ + logger.info("Setting Backtesting strategy's MAX Step = {}",simulate_max_steps_count); + + simulateAndReport(candleDataFromDB, test_run_id, simulate_max_steps_count); + test_run_id++; + } + + System.exit(-1); + } + + private void simulateAndReport(List> candleDataFromDB, int test_run_id, int simulate_max_steps_count){ + Engine calculationEngine = new Engine(null, databaseConnection, symbol,isBackTestingMode); + Strategy backTestingStrategy = calculationUtility.getBackTestingStrategy(); + backTestingStrategy.setMaxSteps(simulate_max_steps_count); + + // Checking till Size - 1, as we are going to use 2 rows simultaneously + for(int i=0;i row = candleDataFromDB.get(i); + Map nextRow = candleDataFromDB.get(i+1); + + createDummyTrade(calculationEngine, backTestingStrategy, row, nextRow); + + } + + generateReportFromTradeData(test_run_id, simulate_max_steps_count); + } + + private void createDummyTrade(Engine calculationEngine, Strategy backTestingStrategy, Map candleData, Map nextCandleData){ + try { + boolean debug = false; + String currency = calculationUtility.getCurrency(); + + Map lastTrade = calculationUtility.getLastTrade(); + long lastTradeId = 0L; + if(!MapUtils.isEmpty(lastTrade)){ + lastTradeId = Long.valueOf(lastTrade.get("identifier")); + } + + Map lastCandle = candleData; + NextTradeDetails nextTradeDetails = new NextTradeDetails(lastTradeId); + + // Get Present Strategy's details for booking trade + StrategyImplementationInterface strategyImplementation = strategyFactory.getStrategyImplementation(backTestingStrategy); + + BuyContractRequest buyContractRequest = calculationEngine.createTrade(backTestingStrategy, strategyImplementation, nextTradeDetails, currency, lastCandle, lastTrade, debug); + if(buyContractRequest!=null && debug==true){ + logger.info("Dummy Trade Booked."); + } + + //Get Result of the Dummy booked trade + getSimulatedTradeResult(candleData, nextCandleData, nextTradeDetails); + + } + catch (Exception e ){ + logger.info("Exception caught while create new trade. {}",e.getMessage()); + e.printStackTrace(); + } + + } + + private void getSimulatedTradeResult(Map candleData, Map nextCandleData, NextTradeDetails nextTradeDetails){ + String presentCandleDirection = candleData.get("direction"); + String nextCandleDirection = nextCandleData.get("direction"); + + String tradeResult=null; + if(!presentCandleDirection.equalsIgnoreCase(nextCandleDirection)){ + tradeResult="FAIL"; + } + else{ + tradeResult="SUCCESS"; + } + + String tradeResultString = "UPDATE trade SET result ='"+tradeResult+"', contract_id=identifier*100 "; + String whereString = " WHERE identifier = "+nextTradeDetails.getTradeId(); + if( tradeResult.equalsIgnoreCase("SUCCESS") ){ + tradeResultString = tradeResultString+", amount_won = "+nextTradeDetails.getAmount()*1.95; + } + + tradeResultString = tradeResultString+whereString; +// logger.info("UPDATING trade result / amount / contract_id... {}",tradeResultString); + databaseConnection.executeNoResultSet(tradeResultString); + + } + + + private void generateReportFromTradeData(int test_run_id, int simulate_max_steps_count) { + List> distinctStrategyIdList = (List>)databaseConnection.executeQuery("SELECT distinct(strategy_id) FROM trade"); + if (CollectionUtils.isNotEmpty(distinctStrategyIdList)) { + for(Map row : distinctStrategyIdList) { + writeTradeReportToDB(row, test_run_id, simulate_max_steps_count); + } + } + } + + + private int getTestRunId(){ + int test_run_id=1; + List> lastTestRunIdResult = (List>)databaseConnection.executeQuery("select max(test_run_id) From amount_result"); + if (CollectionUtils.isNotEmpty(lastTestRunIdResult)) { + Map row = lastTestRunIdResult.get(0); + if(MapUtils.isNotEmpty(row)){ + String query_result = row.get("query_result"); + if(query_result!=null && !query_result.equalsIgnoreCase("null")){ + test_run_id = Integer.valueOf(query_result) + 1; + } + } + } + return test_run_id; + } + + + private void writeTradeReportToDB(Map row, int test_run_id, int simulate_max_steps_count){ + String strategyId = row.get("strategy_id"); + String maxSteps = String.valueOf(simulate_max_steps_count); + + String totalBidAmountQuery = "select sum(bid_amount) from trade where trade.strategy_id="+strategyId; + String totalAmountWonQuery = "select sum(amount_won) from trade where trade.strategy_id="+strategyId; + String totalSuccessfulTradesQuery="select count(*) from trade where result='SUCCESS' AND trade.strategy_id="+strategyId; + String totalFailedTradesQuery="select count(*) from trade where result='FAIL' AND trade.strategy_id="+strategyId; + String maxFailedStepsQuery = "select max(step_count) from trade where trade.strategy_id = "+strategyId; + + double totalBidAmount = Double.parseDouble(databaseConnection.getFirstElementFromDBQuery(totalBidAmountQuery)); + double totalAmountWon = Double.parseDouble(databaseConnection.getFirstElementFromDBQuery(totalAmountWonQuery)); + double totalSuccessfulTrades = Double.parseDouble(databaseConnection.getFirstElementFromDBQuery(totalSuccessfulTradesQuery)); + double totalFailedTrades = Double.parseDouble(databaseConnection.getFirstElementFromDBQuery(totalFailedTradesQuery)); + double diff = totalAmountWon - totalBidAmount; + double totalTrades = totalSuccessfulTrades + totalFailedTrades; + double maxFailedSteps = Double.parseDouble(databaseConnection.getFirstElementFromDBQuery(maxFailedStepsQuery)); + + String insertQuery = "INSERT INTO amount_result (test_run_id, strategy_id, total_bid_amount ,total_amount_won ,net_amount_diff,total_trades ,total_successful_trades, total_failed_trades, max_steps, max_failed_steps) VALUES( "; + insertQuery = insertQuery + + test_run_id + ","+ + strategyId + ","+ + totalBidAmount + ","+ + totalAmountWon + ","+ + diff + ","+ + totalTrades + ","+ + totalSuccessfulTrades + ","+ + totalFailedTrades + "," + + maxSteps + "," + + maxFailedSteps + ");"; + + databaseConnection.executeNoResultSet(insertQuery); + } + +} diff --git a/Trading/src/main/java/com/suneesh/trading/core/BinaryWebServiceConnector.java b/Trading/src/main/java/com/suneesh/trading/core/BinaryWebServiceConnector.java new file mode 100644 index 0000000..b9054f2 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/core/BinaryWebServiceConnector.java @@ -0,0 +1,129 @@ +package com.suneesh.trading.core; + +import com.suneesh.trading.database.DatabaseConnection; +import com.suneesh.trading.database.PostgreSQLDatabaseConnection; +import com.suneesh.trading.core.calculations.Engine; +import com.suneesh.trading.models.requests.*; +import com.suneesh.trading.models.responses.AuthorizeResponse; +import com.suneesh.trading.utils.AutoTradingUtility; +import lombok.Data; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +import java.util.concurrent.*; + +@Data +public class BinaryWebServiceConnector { + + private static final Logger logger = (Logger) LogManager.getLogger(); + private ApiWrapper api; + private String applicationId; + private String applicationAuthorizeToken; + private BlockingQueue commandQueue = new LinkedBlockingQueue<>(); + private DatabaseConnection databaseConnection; + private String databaseServer; + private String databaseURL; + protected ErrorManager errorManager; + protected CommandProcessor commandProcessor; + protected Engine calculationEngine; + protected String symbolToTrade; + protected boolean backTestingMode; + + public BinaryWebServiceConnector(BlockingQueue inputCommandQueue, String appId, String appAuthToken, String dbServer, String dbURL, String symbolToTrade, boolean backTestingMode) { + this.commandQueue = inputCommandQueue; + this.backTestingMode = backTestingMode; + this.applicationId = appId; + this.applicationAuthorizeToken = appAuthToken; + this.symbolToTrade = symbolToTrade; + this.databaseServer = dbServer; + this.databaseURL = dbURL; + this.databaseConnection = getDatabaseConnection(databaseServer); + this.api = ApiWrapper.build(applicationId, databaseConnection); + } + + DatabaseConnection getDatabaseConnection(String databaseServer) { + DatabaseConnection result = null; + switch(databaseServer.toLowerCase()){ + case "postgres" : result = new PostgreSQLDatabaseConnection(databaseURL); + break; + default: logger.error("Database Server not supported."); + } + return result; + } + + public void init() { + logger.info("Creating WebConnection to Binary.com ...."); + logger.info("Application ID = {}", this::getApplicationId); + logger.info("Application Authorize Token = {}", this::getApplicationAuthorizeToken); + logger.info("Database URL = {}", this::getDatabaseURL); + logger.info("SymbolToTrade = {}", this::getSymbolToTrade); + + logger.info("Checking Database Schema, if not present creating schema..."); + databaseConnection.init(isBackTestingMode()); + + commandProcessor = new CommandProcessor(commandQueue,api); + errorManager = new ErrorManager(commandQueue,api); + calculationEngine = new Engine(commandQueue, databaseConnection, symbolToTrade, false); + threadCreation(); + sendInitialSetupRequest(); + } + + + public void sendInitialSetupRequest(){ + AuthorizeRequest authorizeRequest = new AuthorizeRequest(applicationAuthorizeToken); + api.sendRequest(authorizeRequest).subscribe(response -> { + AuthorizeResponse auth = (AuthorizeResponse) response; + // Authorised. + if (auth.getAuthorize() != null) { + api.sendRequest(new BalanceRequest(true)); + api.sendRequest(new TransactionsStreamRequest()); + api.sendRequest(new PortfolioRequest()); + } + }); + } + + //------------- + public void threadCreation(){ + logger.info("Timed threads..."); + + ExecutorService commandProcessorThread = Executors.newFixedThreadPool(1); + commandProcessorThread.submit(()->{ + Thread.currentThread().setName("CommandProcessorThread"); + logger.info("{} started ... ", Thread.currentThread().getName()); + commandProcessor.threadWork(); + }); + + ExecutorService errorManagerThread = Executors.newFixedThreadPool(1); + errorManagerThread.submit(()->{ + Thread.currentThread().setName("ErrorManagerThread"); + logger.info("{} started ... ", Thread.currentThread().getName()); + errorManager.threadWork(); + }); + + if(!isBackTestingMode()){ + ExecutorService commandGeneratorThread = Executors.newFixedThreadPool(1); + commandGeneratorThread.submit(()->{ + Thread.currentThread().setName("Engine"); + logger.info("{} started ... ", Thread.currentThread().getName()); + calculationEngine.process(); + }); + + ScheduledExecutorService pingServiceThread = Executors.newSingleThreadScheduledExecutor(); + pingServiceThread.scheduleAtFixedRate(()->{ + Thread.currentThread().setName("PingServiceThread"); + new ConnectionMonitor(commandQueue).process(); + },0, Integer.valueOf(AutoTradingUtility.getPropertyFromPropertyFile("PingIntervalInSeconds")),TimeUnit.SECONDS); + + } + else{ + ExecutorService commandGeneratorThread = Executors.newFixedThreadPool(1); + commandGeneratorThread.submit(()->{ + Thread.currentThread().setName("BackTestingEngine"); + logger.info("{} started ... ", Thread.currentThread().getName()); + new BackTestingEngine(commandQueue, databaseConnection, symbolToTrade, true).process(); + }); + } + + + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/core/CommandProcessor.java b/Trading/src/main/java/com/suneesh/trading/core/CommandProcessor.java new file mode 100644 index 0000000..716b4a4 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/core/CommandProcessor.java @@ -0,0 +1,64 @@ +package com.suneesh.trading.core; + +import com.suneesh.trading.models.requests.*; +import com.suneesh.trading.models.responses.AuthorizeResponse; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + + +import java.util.List; +import java.util.Map; +import java.util.concurrent.BlockingQueue; +import java.util.concurrent.LinkedBlockingQueue; +import java.util.concurrent.TimeUnit; + +public class CommandProcessor { + private static final Logger logger = LogManager.getLogger(); + private BlockingQueue commandQueue = new LinkedBlockingQueue<>(); + private float startValue; + private ApiWrapper api; + + public CommandProcessor(BlockingQueue inputMessageQueue, ApiWrapper apiWrapper) { + this.commandQueue = inputMessageQueue; + this.api = apiWrapper; + } + + private void checkAndSendAuthorisationTokenIfRequired(){ + List> authorizationErrorList = api.getDatabaseConnection().executeQuery("SELECT * from error_table WHERE status = 'ACTIVE' and error_message = 'AuthorizationRequired' and fix_time is null"); + if(!CollectionUtils.isEmpty(authorizationErrorList)){ + + AuthorizeRequest authorizeRequest = new AuthorizeRequest(api.getApplicationId()); + api.sendRequest(authorizeRequest).subscribe(response -> { + AuthorizeResponse auth = (AuthorizeResponse) response; + // Authorised. + if (auth.getAuthorize() != null) { + api.sendRequest(new BalanceRequest(true)); + api.sendRequest(new TransactionsStreamRequest()); + api.sendRequest(new PortfolioRequest()); + } + }); + + api.getDatabaseConnection().executeNoResultSet("UPDATE error_table SET status ='FIXED' AND fix_time = now() WHERE status = 'ACTIVE' and error_message = 'AuthorizationRequired' and fix_time is null"); + } + } + + public void threadWork(){ + logger.info("Thread work ... "); + while(true){ + try { + boolean allowedToSendRequest = false; + RequestBase request = commandQueue.poll(100, TimeUnit.MILLISECONDS); + if(request!=null){ + checkAndSendAuthorisationTokenIfRequired(); + logger.info("Sending message to Binary.com ... {}", String.valueOf(request)); + api.sendRequest(request); + } + } catch (Exception e) { + e.printStackTrace(); + } + + } + } + +} diff --git a/Trading/src/main/java/com/suneesh/trading/core/ConnectionMonitor.java b/Trading/src/main/java/com/suneesh/trading/core/ConnectionMonitor.java new file mode 100644 index 0000000..3997999 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/core/ConnectionMonitor.java @@ -0,0 +1,23 @@ +package com.suneesh.trading.core; + +import com.suneesh.trading.models.requests.PingRequest; +import com.suneesh.trading.models.requests.RequestBase; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +import java.util.concurrent.BlockingQueue; + +public class ConnectionMonitor extends AbstractCommandGenerator { + private static final Logger LOGGER = LogManager.getLogger(); + + private String symbol; + + public ConnectionMonitor(BlockingQueue inputMessageQueue) { + super(inputMessageQueue); + } + + public void process(){ + sendRequest( new PingRequest()); + } + +} diff --git a/Trading/src/main/java/com/suneesh/trading/core/ErrorManager.java b/Trading/src/main/java/com/suneesh/trading/core/ErrorManager.java new file mode 100644 index 0000000..2b08ac8 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/core/ErrorManager.java @@ -0,0 +1,52 @@ +package com.suneesh.trading.core; + +import com.suneesh.trading.database.DatabaseConnection; +import com.suneesh.trading.models.requests.*; +import com.suneesh.trading.models.responses.AuthorizeResponse; +import com.suneesh.trading.utils.AutoTradingUtility; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +import java.util.List; +import java.util.Map; +import java.util.concurrent.BlockingQueue; +import java.util.concurrent.LinkedBlockingQueue; + +public class ErrorManager { + private static final Logger logger = LogManager.getLogger(); + private BlockingQueue commandQueue = new LinkedBlockingQueue<>(); + private float startValue; + private ApiWrapper api; + + public ErrorManager(BlockingQueue inputMessageQueue, ApiWrapper apiWrapper) { + this.commandQueue = inputMessageQueue; + this.api = apiWrapper; + } + + private void checkErrorsRecordedInDbTable(){ + DatabaseConnection dbConnection = api.getDatabaseConnection(); + String dbErrorMessage="WrongResponse"; + String updateString = null; + List> wrongResponseErrorList = dbConnection.executeQuery("SELECT * from error_table WHERE status = 'ACTIVE' and error_message = "+AutoTradingUtility.quotedString(dbErrorMessage)+" and fix_time is null"); + if(!CollectionUtils.isEmpty(wrongResponseErrorList)){ + updateString= "UPDATE trade SET result='OPEN' WHERE result is null"; + dbConnection.executeNoResultSet(updateString); + dbConnection.executeNoResultSet("UPDATE error_table SET status ='FIXED' AND fix_time = now() WHERE status = 'ACTIVE' and error_message = "+AutoTradingUtility.quotedString(dbErrorMessage)+" and fix_time is null"); + } + } + + public void threadWork(){ + logger.info("Thread work ... "); + while(true){ + try { + checkErrorsRecordedInDbTable(); + AutoTradingUtility.sleep(100); + } catch (Exception e) { + e.printStackTrace(); + } + + } + } + +} diff --git a/Trading/src/main/java/com/suneesh/trading/core/NextTradeDetails.java b/Trading/src/main/java/com/suneesh/trading/core/NextTradeDetails.java new file mode 100644 index 0000000..f93cdc2 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/core/NextTradeDetails.java @@ -0,0 +1,18 @@ +package com.suneesh.trading.core; + +import lombok.Data; + +@Data +public class NextTradeDetails { + long tradeId; + double amount; + double strikePrice; + long strategyId; + String callOrPut ; + long contractDuration; + int nextStepCount; + + public NextTradeDetails(long lastTradeId){ + setTradeId(lastTradeId+1); + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/core/WebsocketListener.java b/Trading/src/main/java/com/suneesh/trading/core/WebsocketListener.java new file mode 100644 index 0000000..68da031 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/core/WebsocketListener.java @@ -0,0 +1,390 @@ +package com.suneesh.trading.core; + +import com.google.gson.Gson; +import com.suneesh.trading.database.DatabaseConnection; +import com.suneesh.trading.core.calculations.Signals; +import com.suneesh.trading.core.calculations.Utility; +import com.suneesh.trading.models.WebsocketEvent; + +import com.suneesh.trading.models.responses.*; +import com.suneesh.trading.utils.AutoTradingUtility; +import io.reactivex.subjects.BehaviorSubject; +import io.reactivex.subjects.PublishSubject; +import lombok.Data; +import okhttp3.Response; +import okhttp3.WebSocket; +import okhttp3.WebSocketListener; +import org.json.JSONArray; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.json.JSONObject; + +import java.math.BigDecimal; +import java.util.*; +import java.util.concurrent.atomic.AtomicInteger; + +/** + * Created by morteza on 7/18/2017. + */ + +@Data +public class +WebsocketListener extends WebSocketListener { + + Logger logger = LoggerFactory.getLogger(WebsocketListener.class); + + private BehaviorSubject websocketEmitter; + private PublishSubject responseEmitter; + private PublishSubject requestEmitter; + protected DatabaseConnection databaseConnection; + + private void writeToDatabase(ResponseBase objectToWrite, boolean debug){ + objectToWrite.databaseInsertStringList().forEach(f->{ + if(debug) { + logger.debug(f); + } + databaseConnection.executeNoResultSet(f); + }); + } + + private void writeToDatabase(ResponseBase objectToWrite, boolean debug, String queryMode){ + if(queryMode.equalsIgnoreCase("INSERT")) { + objectToWrite.databaseInsertStringList().forEach(f -> { + if (debug) { + logger.debug(f); + } + databaseConnection.executeNoResultSet(f); + }); + } + + if(queryMode.equalsIgnoreCase("UPDATE")) { + objectToWrite.databaseUpdateStringList().forEach(f -> { + if (debug) { + logger.debug((String) f); + } + databaseConnection.executeNoResultSet((String) f); + }); + } + + } + + public WebsocketListener(BehaviorSubject wsEmitter, + PublishSubject responseEmitter, + PublishSubject requestEmitter, + DatabaseConnection dbConnection){ + this.websocketEmitter = wsEmitter; + this.responseEmitter = responseEmitter; + this.requestEmitter = requestEmitter; + this.databaseConnection = dbConnection; + + // Calculate and write Bolling Bands for the received Candle data. + Utility calculationEngineUtility = new Utility(databaseConnection); + + // Calculate and write Bolling Bands for the received Candle data. + Signals signals = new Signals(databaseConnection); + + AtomicInteger ohlcCount = new AtomicInteger(0); + + final Candle[] previousCandle = {new Candle()}; + + this.responseEmitter.subscribe( + o -> { +// logger.info("Received Message: {}", o); + Gson gson = new Gson(); + JSONObject jsonObject = new JSONObject(o); + JSONObject echo_req = (JSONObject) jsonObject.get("echo_req"); + + // Write to a DB Table , and then add details in CommonDprocessor's checkAuthorisation() +// {"code":"AuthorizationRequired","message":"Please log in."} + if(jsonObject.has("code") ) { + String message = jsonObject.getString("code"); + + if(message.equalsIgnoreCase("AuthorizationRequired")){ + databaseConnection.executeNoResultSet("insert into error_table (error_message , status, creation_time) VALUES ("+AutoTradingUtility.quotedString(message)+", 'ACTIVE', now())"); + } + + if(message.equalsIgnoreCase("WrongResponse")){ + databaseConnection.executeNoResultSet("insert into error_table (error_message , status, creation_time) VALUES ("+AutoTradingUtility.quotedString(message)+", 'ACTIVE', now())"); + } + } + + if(!jsonObject.has("error") ){ + String msg_type = jsonObject.getString("msg_type"); + + switch (msg_type) { + case "tick": + TickResponse tickResponse = new TickResponse(); + JSONObject tickData = (JSONObject) jsonObject.get("tick"); + if (tickData != null) { + tickResponse.setTick(gson.fromJson(String.valueOf(tickData), Tick.class)); +// logger.info(String.valueOf(tickResponse.getTick())); + writeToDatabase(tickResponse, false); + } + + break; + case "authorize": + AuthorizeResponse authorizeResponse = new AuthorizeResponse(); + JSONObject authorizeData = (JSONObject) jsonObject.get("authorize"); + if (authorizeData != null) { + authorizeResponse.setAuthorize(gson.fromJson(String.valueOf(authorizeData), Authorize.class)); +// logger.info(String.valueOf(authorizeResponse.getAuthorize())); + writeToDatabase(authorizeResponse, false); + } + + break; + case "balance": + BalanceResponse balanceResponse = new BalanceResponse(); + JSONObject balanceData = (JSONObject) jsonObject.get("balance"); + if (balanceData != null) { + balanceResponse.setBalance(gson.fromJson(String.valueOf(balanceData), Balance.class)); +// logger.info(String.valueOf(balanceResponse.getBalance())); + writeToDatabase(balanceResponse, false); + } + + + break; + case "candles": + JSONArray candleArray = (JSONArray) jsonObject.get("candles"); + ArrayList candleArrayList = new ArrayList<>(); + TickHistoryResponse tickHistoryResponse = new TickHistoryResponse(); + if (candleArray != null) { + candleArray.forEach(f -> { + Candle candle = gson.fromJson(String.valueOf(f), Candle.class); + candle.setGranularity(echo_req.getInt("granularity")); + candle.setSymbol(echo_req.getString("ticks_history")); + candleArrayList.add(candle); + }); + tickHistoryResponse.setCandles(candleArrayList); +// logger.info(String.valueOf(tickHistoryResponse.getCandles())); + + writeToDatabase(tickHistoryResponse, false); + } + + signals.calculateBollingerBands(calculationEngineUtility.getCandles(Optional.of("DESC"), Optional.empty()), Optional.of("CANDLES")); + + break; + case "ohlc": + TickHistoryResponse ohlcTickHistoryResponse = new TickHistoryResponse(); + Candle newOHLCObject = new Candle(); + JSONObject OHLCData = (JSONObject) jsonObject.get("ohlc"); + Candle prevCandle = previousCandle[0]; + + if (OHLCData != null && prevCandle.getOpen()!=null ) { + newOHLCObject = gson.fromJson(String.valueOf(OHLCData), Candle.class); + BigDecimal prevOpen = previousCandle[0].getOpen(); + BigDecimal newOpen = newOHLCObject.getOpen(); + if(newOpen.compareTo(prevOpen)!=0){ + Candle updatedPreviousCandle = prevCandle; + ArrayList candles = new ArrayList<>(); + candles.add(updatedPreviousCandle); + ohlcTickHistoryResponse.setCandles(candles); +// logger.info(String.valueOf(ohlcTickHistoryResponse.getCandles())); + + // If this is the first OHLC candle received, then we will have a duplicate candle record + // all the candles received in "CANDLE" message contais an incomplete last candle , which this OHLC candle is completing + if(ohlcCount.get()==0){ + databaseConnection.executeNoResultSet("DELETE FROM candle WHERE epoch = "+updatedPreviousCandle.getOpen_time()); + } + writeToDatabase(ohlcTickHistoryResponse, false); + signals.calculateBollingerBands(calculationEngineUtility.getCandles(Optional.of("DESC"),Optional.of(20)) , Optional.empty()); + ohlcCount.incrementAndGet(); + } + } + + previousCandle[0] = gson.fromJson(String.valueOf(OHLCData), Candle.class); + + break; + case "transaction": + logger.info("Received Message: {}", o); + + TransactionsStreamResponse transactionsStreamResponse = new TransactionsStreamResponse(); + JSONObject transactionData = (JSONObject) jsonObject.get("transaction"); + + if( (transactionData != null) && ( transactionData.has("transaction_id")) ) { + + processTransaction(msg_type, transactionData, null); + + transactionsStreamResponse.setTransaction(gson.fromJson(String.valueOf(transactionData), Transaction.class)); + logger.info(String.valueOf(transactionsStreamResponse.getTransaction())); + writeToDatabase(transactionsStreamResponse, true); + } + + break; + + // Returns the complete contract details of an open trade contract, which is required for calculating Realtime Delta Percentage. + case "proposal_open_contract": + ProposalOpenContractResponse proposalOpenContractResponse = new ProposalOpenContractResponse(); + JSONObject proposalOpenContractData = (JSONObject) jsonObject.get("proposal_open_contract"); + + if(proposalOpenContractData != null) { + OpenContract openContract = gson.fromJson(String.valueOf(proposalOpenContractData), OpenContract.class); +// logger.info(openContract.toString()); + + proposalOpenContractResponse.setOpenContract(openContract); + + String checkContractIdExistsQuery = "select 1 from open_contract WHERE contractId = " + AutoTradingUtility.quotedString(openContract.getContractId()); + String dbQueryType = "INSERT"; + if(databaseConnection.executeQuery(checkContractIdExistsQuery).size()>0){ + dbQueryType="UPDATE"; + } + + writeToDatabase(proposalOpenContractResponse, false,dbQueryType); + } + + break; + case "buy": + BuyContractResponse buyContractResponse = new BuyContractResponse(); + JSONObject buyData = (JSONObject) jsonObject.get("buy"); + + if( (buyData != null) && ( buyData.has("contract_id")) ) { + Integer req_id = (Integer) jsonObject.get("req_id"); + + processTransaction(msg_type, buyData, req_id); + + BuyContractResponse buyContractResponse1 = gson.fromJson(String.valueOf(buyData), BuyContractResponse.class); + logger.info("BuyContractResponse = {}",buyContractResponse1.toString()); + } + + break; + + case "sell": +// logger.info("Received Message: {}", o); +// SellContractResponse sellContractResponse = new SellContractResponse(); +// JSONObject sellData = (JSONObject) jsonObject.get("sell"); +// +// if( (sellData != null) && ( sellData.has("contract_id")) ) { +// Integer req_id = (Integer) jsonObject.get("req_id"); +// +// processTransaction(msg_type, sellData, req_id); +// +// SellContractResponse sellContractResponse1 = gson.fromJson(String.valueOf(sellData), SellContractResponse.class); +// logger.info("SellContractResponse = {}",sellContractResponse1.toString()); +// } +// + break; + + case "portfolio": + PortfolioResponse portfolioResponse = new PortfolioResponse(); + JSONObject portfolioObject = (JSONObject) jsonObject.get("portfolio"); + + JSONArray contractArray = (JSONArray) portfolioObject.get("contracts"); + ArrayList contractArrayList = new ArrayList<>(); + + ArrayList portfolioTransactionList = new ArrayList<>(); + + if (contractArray != null) { + contractArray.forEach(f -> { + contractArrayList.add(gson.fromJson(String.valueOf(f), Contract.class)); + portfolioTransactionList.add(gson.fromJson(String.valueOf(f), PortfolioTransaction.class)); + }); + + Portfolio portfolio = new Portfolio(); + portfolio.setContracts(portfolioTransactionList); + portfolioResponse.setPortfolio(portfolio); +// logger.info(String.valueOf(portfolioResponse.getPortfolio())); + writeToDatabase(portfolioResponse, false); + } + + break; + + case "ping": + logger.info("PING Response received from Binary Websocket."); + break; + + default: + logger.info("Case not implemented."); + for (Map.Entry entry : jsonObject.toMap().entrySet()) { + logger.info("{} - {}", entry.getKey(), String.valueOf(entry.getValue())); + } + } + } + else{ + Object jsonException = jsonObject.get("error"); + logger.error(String.valueOf(jsonException)); + } + } + ); + } + + private void processTransaction(String msg_type, JSONObject jsonData, Integer req_id) { + String tradeIdentifier = null; + String updateString = null; + long contract_id = jsonData.getLong("contract_id"); + + if(req_id!=null){ + tradeIdentifier = String.valueOf(req_id); + if (tradeIdentifier == null) { + logger.error("ERROR! req_id field not having data in transaction Response. Reverting to using 'contract is NULL & result is NULL clause'"); + } + } + + switch(msg_type){ + case "buy": + if(tradeIdentifier==null){ + updateString= "UPDATE trade SET contract_id = '"+String.valueOf(contract_id)+"', result='OPEN' WHERE contract_id is null AND result is null"; + } + else { + updateString = "UPDATE trade SET contract_id = '" + String.valueOf(contract_id) + "', result='OPEN' WHERE identifier = " + tradeIdentifier; + } + break; + case "transaction": + String action = jsonData.getString("action"); + if(action.equalsIgnoreCase("sell")) { + BigDecimal amount = jsonData.getBigDecimal("amount"); + String tradeResult = amount.doubleValue() > 0 ? "SUCCESS" : "FAIL"; + if (tradeIdentifier == null) { + + String firstElementFromDBQuery = databaseConnection.getFirstElementFromDBQuery("SELECT result from trade where contract_id = " + AutoTradingUtility.quotedString(contract_id)); + if(firstElementFromDBQuery.equalsIgnoreCase("SELL_CONTRACT_SENT")){ + updateString = "UPDATE trade SET result='" + tradeResult + "', amount_won = '" + amount.toPlainString() + "', close_type='PROFIT_THRESHOLD_TRIGGERED' WHERE contract_id ='" + String.valueOf(contract_id) + "' AND result IN ( 'OPEN' , 'PROPOSAL_OPEN_CONTRACT_SENT', 'SELL_CONTRACT_SENT') "; + + } + else{ + updateString = "UPDATE trade SET result='" + tradeResult + "', amount_won = '" + amount.toPlainString() + "', close_type = 'CLOSE_AT_EXPIRY' WHERE contract_id ='" + String.valueOf(contract_id) + "' AND result IN ( 'OPEN' , 'PROPOSAL_OPEN_CONTRACT_SENT', 'SELL_CONTRACT_SENT') "; + } + + + } else { + updateString = "UPDATE trade SET result='" + tradeResult + "', amount_won = '" + amount.toPlainString() + "', close_type = 'CLOSE_AT_EXPIRY' WHERE identifier = " + tradeIdentifier; + } + } + break; + default : logger.info("Unhandled action . action = {}",msg_type); + } + + if(updateString!=null && !updateString.isEmpty()){ + logger.info("action / Command = {} / {}", msg_type, updateString); + databaseConnection.executeNoResultSet(updateString); + } + } + + @Override + public void onOpen(WebSocket webSocket, Response response) { + logger.info("Connection is opened!"); + WebsocketEvent wse = new WebsocketEvent(true, null); + this.requestEmitter.subscribe( request -> { + webSocket.send(request); + }); + this.websocketEmitter.onNext(wse); + } + + @Override + public void onMessage(WebSocket webSocket, String message) { + + this.responseEmitter.onNext(message); + + } + + @Override + public void onClosed(WebSocket webSocket, int code, String reason) { + logger.info("Connection closed: {}", reason); + this.websocketEmitter.onNext(new WebsocketEvent(false, reason)); + } + + @Override + public void onFailure(WebSocket webSocket, Throwable t, Response response) { + logger.info("Connection failed: {}", response != null ? response.message() : ""); + this.websocketEmitter.onNext(new WebsocketEvent(false, response != null ? response.message() : "")); + } + +} diff --git a/Trading/src/main/java/com/suneesh/trading/core/calculations/BlackScholes.java b/Trading/src/main/java/com/suneesh/trading/core/calculations/BlackScholes.java new file mode 100644 index 0000000..ce80870 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/core/calculations/BlackScholes.java @@ -0,0 +1,47 @@ +package com.suneesh.trading.core.calculations; + +import org.apache.commons.math3.distribution.NormalDistribution; + +import java.util.HashMap; + + /** + * Created by Adrian on 12/10/2018. + */ + +public class BlackScholes implements PricingType { + + private double stock; // initial asset price + private double strike; // strike price + private double volatility; // volatility + private double interest; // interest rate + private double timehorizon; // half a year + private double d1; + private double d2; + private final NormalDistribution distribution = new NormalDistribution(0, 1); + + public BlackScholes(HashMap hashMap) { + stock = hashMap.get("stock"); + strike = hashMap.get("strike"); + volatility = hashMap.get("volatility"); + interest = hashMap.get("interest"); + timehorizon = hashMap.get("timehorizon"); + + d1 = ( Math.log(stock / strike) + + (interest + (Math.pow(volatility, 2) / 2)) * timehorizon) + / (volatility * Math.sqrt(timehorizon)); + + d2 = d1 - (volatility * Math.sqrt(timehorizon)); + } + + public double getCall() { + return (stock * distribution.cumulativeProbability(d1)) + - (strike * Math.exp(-interest * timehorizon) + * distribution.cumulativeProbability(d2)); + } + public double getPut() { + return strike * Math.exp(-interest * timehorizon) + * distribution.cumulativeProbability(-d2) + - stock * distribution.cumulativeProbability(-d1); + } + +} diff --git a/Trading/src/main/java/com/suneesh/trading/core/calculations/DeltaPercentage.java b/Trading/src/main/java/com/suneesh/trading/core/calculations/DeltaPercentage.java new file mode 100644 index 0000000..9fd3929 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/core/calculations/DeltaPercentage.java @@ -0,0 +1,35 @@ +package com.suneesh.trading.core.calculations; + +import lombok.Data; +import lombok.extern.slf4j.Slf4j; + +import java.util.HashMap; + +@Data +@Slf4j +public class DeltaPercentage { + HashMap inputMap; + final double epsilon = 0.0000001D; + double delta; + + public DeltaPercentage(HashMap inputMap) { + this.inputMap = inputMap; + } + + public double calculate(){ + BlackScholes bs1 = new BlackScholes(inputMap); + double callPrice1 = bs1.getCall(); + + HashMap inputMap2 = new HashMap<>(inputMap); + inputMap2.put("stock", inputMap.get("stock")+epsilon); + + BlackScholes bs2 = new BlackScholes(inputMap2); + double callPrice2 = bs2.getCall(); + + double priceDiff = callPrice2 - callPrice1; + delta = priceDiff/epsilon; + + double deltaPercentage = ((delta*2)*100) - 100; + return deltaPercentage; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/core/calculations/Engine.java b/Trading/src/main/java/com/suneesh/trading/core/calculations/Engine.java new file mode 100644 index 0000000..4008fab --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/core/calculations/Engine.java @@ -0,0 +1,215 @@ +package com.suneesh.trading.core.calculations; + +import com.suneesh.trading.core.strategy.StrategyFactory; +import com.suneesh.trading.core.strategy.StrategyImplementationInterface; +import com.suneesh.trading.database.DatabaseConnection; +import com.suneesh.trading.core.AbstractCommandGenerator; +import com.suneesh.trading.core.NextTradeDetails; +import com.suneesh.trading.models.Strategy; +import com.suneesh.trading.models.enums.TickStyles; +import com.suneesh.trading.models.requests.*; +import com.suneesh.trading.utils.AutoTradingUtility; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.collections4.MapUtils; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +import java.math.BigDecimal; +import java.util.*; +import java.util.concurrent.BlockingQueue; +import java.util.stream.Collectors; + +public class Engine extends AbstractCommandGenerator { + private static final Logger logger = LogManager.getLogger(); + private String symbol; + DatabaseConnection databaseConnection; + Utility calculationUtility; + Signals calculateSignals; + StrategyFactory strategyFactory; + Boolean isBackTestingMode; + + final int TRADE_SIGNAL_CHECKS_DELAY_IN_MILLISECONDS=500; + final int NUMBER_OF_INITIAL_CANDLES_TO_READ=25; + final int CANDLE_60_SECOND_GRANULARITY=60; + final int CANDLE_300_SECOND_GRANULARITY=300; + + public Engine(BlockingQueue inputMessageQueue, DatabaseConnection dbConnection, String symbol, Boolean isBackTestingMode) { + super(inputMessageQueue); + this.databaseConnection = dbConnection; + this.symbol = symbol; + this.calculationUtility = new Utility(dbConnection); + this.calculateSignals = new Signals(dbConnection); + this.isBackTestingMode = isBackTestingMode; + this.strategyFactory = new StrategyFactory(databaseConnection, calculationUtility,isBackTestingMode); + } + + public Signals getCalculateSignals() { + return calculateSignals; + } + + public Utility getCalculationUtility() { + return calculationUtility; + } + + public void init(){ + getTickDetail(symbol); + getCandleDetailsFromBinaryWS(symbol); + } + + public void getTickDetail(String symbol) { + sendRequest(new TickRequest(symbol)); + } + + public void getCandleDetailsFromBinaryWS(String symbol) { + TickHistoryRequest tickHistoryRequest = new TickHistoryRequest(symbol, "latest"); + tickHistoryRequest.setStyle(TickStyles.CANDLES); + tickHistoryRequest.setSubscribe(1); + tickHistoryRequest.setCount(NUMBER_OF_INITIAL_CANDLES_TO_READ); + tickHistoryRequest.setGranularity(CANDLE_60_SECOND_GRANULARITY); + sendRequest(tickHistoryRequest); + } + + public void process(){ + int tradeCount =1; + + init(); + + logger.info("Sleeping for the start of next minute."); + calculationUtility.sleepTillStartOfNextMinuteMinusSeconds(5); + + logger.info("\n\n"); + logger.info("*************************************************************************************************************************************"); + logger.info("*** Sleeping for another minute to stabilise last candle values, and to ensure its recorded completely and accurately for trading. ***"); + logger.info("*************************************************************************************************************************************\n\n"); +// calculationEngineUtility.sleepTillStartOfNextMinute(); + + // Keep booking trades + while(true) { + if (createAndSendTrade(tradeCount)) { + + // waiting till last trade is completed. + while (calculationUtility.waitToBookNextTrade()) { + + sendProposalOpenContract(); + + SellContractRequest sellContractRequest = calculationUtility.checkPotentialProfit(); + if (sellContractRequest != null) { + sellContract(sellContractRequest, tradeCount); + } else { + AutoTradingUtility.sleep(2000); + } + } + logger.info("Trade {} : COMPLETED.", tradeCount); + tradeCount++; + } + else{ + logger.info("Trade booking Signal not received. Sleeping for {} milliseconds",TRADE_SIGNAL_CHECKS_DELAY_IN_MILLISECONDS); + AutoTradingUtility.sleep(TRADE_SIGNAL_CHECKS_DELAY_IN_MILLISECONDS); + } + } + + } + + private void sellContract(SellContractRequest sellContractRequest, int tradeCount){ + logger.info("Going to sell Trade number {}, as Threshold value reached.", tradeCount); + + List> proposalOpenContractSent = calculationUtility.getTradesByResult("PROPOSAL_OPEN_CONTRACT_SENT"); + if(CollectionUtils.isNotEmpty(proposalOpenContractSent)){ + // Get list of all trades with result PROPOSAL_OPEN_CONTRACT_SENT + List contractIds = proposalOpenContractSent.stream().map(ele -> ele.get("contract_id")).collect(Collectors.toList()); + + // If present contract is defined as PROPOSAL_OPEN_CONTRACT_SENT send the SELL_REQUEST and will then be changing its Result state too. + if(contractIds.contains(String.valueOf(sellContractRequest.getContractId()))) { + sendRequest(sellContractRequest); + String resultStates =AutoTradingUtility.quotedString("PROPOSAL_OPEN_CONTRACT_SENT") +","+AutoTradingUtility.quotedString("OPEN"); + + calculationUtility.updateTradeResult(Optional.empty(), Optional.ofNullable(sellContractRequest.getContractId()), Optional.ofNullable(resultStates), Optional.ofNullable("SELL_CONTRACT_SENT"), true); + logger.info("Going to sleep till the remaining time in the present candle"); + calculationUtility.sleepTillStartOfNextMinuteMinusSeconds(5); + + } + } + } + + private void sendSellContractRequest(SellContractRequest sellContractRequest) { + databaseConnection.executeNoResultSet("UPDATE "); + } + + private void sendProposalOpenContract() { + List> openContractsList = databaseConnection.executeQuery("select contract_id From trade where result ='OPEN'"); + openContractsList.parallelStream().forEach(openContract->{ + String contract_id = openContract.get("contract_id"); + logger.info("Sending ProposalOpenContract request for {}", contract_id); + sendRequest(new ProposalOpenContractRequest(Long.valueOf(contract_id), true) ); + databaseConnection.executeNoResultSet("UPDATE trade SET result ='PROPOSAL_OPEN_CONTRACT_SENT' WHERE contract_id = " +AutoTradingUtility.quotedString(contract_id)); + }); + } + + + private boolean createAndSendTrade(int tradeCount){ + boolean bookTrade = false; + try { + long lastTradeId = 0L; + Map lastTrade = calculationUtility.getLastTrade(); + if (!MapUtils.isEmpty(lastTrade)) { + lastTradeId = Long.valueOf(lastTrade.get("identifier")); + } + + String currency = calculationUtility.getCurrency(); + Map lastCandle = calculationUtility.getLastCandle(); + NextTradeDetails nextTradeDetails = new NextTradeDetails(lastTradeId); + Strategy strategyToUse = calculationUtility.getStrategyToUse(); + + // Get Present Strategy's details for booking trade + StrategyImplementationInterface strategyImplementation = strategyFactory.getStrategyImplementation(strategyToUse); + + logger.info("Checking if we should be booking a trade using Strategy = {}", strategyImplementation.getClass().getSimpleName()); + // Check if signal received for generating trade as per the given strategy + bookTrade = strategyImplementation.bookTrade(lastTrade, lastCandle); + if(bookTrade){ + // Create Trade + logger.info("Trade {} : SIGNALLED",tradeCount); + BuyContractRequest buyContractRequest = createTrade(strategyToUse, strategyImplementation, nextTradeDetails, currency, lastCandle, lastTrade, true); + + logger.info("Trade {} : CREATED",tradeCount); + // Send trade + sendRequest(buyContractRequest); + logger.info("Trade {} : SENT",tradeCount); + } + + } + catch(Exception e) { + logger.info("Exception caught while creating new trade. {}",e.getMessage()); + e.printStackTrace(); + } + return bookTrade; + } + + public BuyContractRequest createTrade(Strategy strategyToUse, StrategyImplementationInterface strategyImplementation, NextTradeDetails nextTradeDetails, String currency, Map lastCandle, Map lastTrade, boolean debug) { + BuyContractRequest buyContractRequest = null; + try{ + + strategyImplementation.getCallOrPut(nextTradeDetails, lastCandle); + strategyImplementation.getContractDuration(nextTradeDetails); + strategyImplementation.getNextStepCount(nextTradeDetails, lastTrade); + strategyImplementation.getNextTradeStrategyId(nextTradeDetails, lastTrade); + strategyImplementation.getBidAmount(nextTradeDetails, lastCandle); + BuyContractParameters parameters = calculationUtility.getParameters(symbol, nextTradeDetails, currency); + nextTradeDetails.setStrikePrice(calculationUtility.getTickForEpochTime(Optional.empty(),symbol)); + String tradeInsertStatement = calculationUtility.getTradeDatabaseInsertString(parameters, nextTradeDetails); + if(debug) { + logger.debug(tradeInsertStatement); + } + databaseConnection.executeNoResultSet(tradeInsertStatement); + buyContractRequest = new BuyContractRequest(new BigDecimal(nextTradeDetails.getAmount()), parameters, nextTradeDetails.getTradeId()); + + } + catch (Exception e ){ + logger.info("Exception caught while create new trade. {}",e.getMessage()); + e.printStackTrace(); + } + return buyContractRequest; + } + + +} diff --git a/Trading/src/main/java/com/suneesh/trading/core/calculations/PricingType.java b/Trading/src/main/java/com/suneesh/trading/core/calculations/PricingType.java new file mode 100644 index 0000000..6d16527 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/core/calculations/PricingType.java @@ -0,0 +1,12 @@ +package com.suneesh.trading.core.calculations; + + +/** + * Created by Adrian on 12/10/2018. + */ +public interface PricingType { + + double getCall(); + double getPut(); + +} diff --git a/Trading/src/main/java/com/suneesh/trading/core/calculations/Signals.java b/Trading/src/main/java/com/suneesh/trading/core/calculations/Signals.java new file mode 100644 index 0000000..ea1abf7 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/core/calculations/Signals.java @@ -0,0 +1,51 @@ +package com.suneesh.trading.core.calculations; + +import com.suneesh.trading.database.DatabaseConnection; +import com.suneesh.trading.core.technical.BollingerBand; +import lombok.Data; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.CollectionUtils; + +import java.util.List; +import java.util.Map; +import java.util.Optional; + +@Data +@Slf4j +public class Signals { + final int BOLLINGER_BAND_DATA_COUNT=20; + private DatabaseConnection databaseConnection; + + public Signals(DatabaseConnection databaseConnection){ + this.databaseConnection = databaseConnection; + } + + public void calculateBollingerBands(List> candleDataFromDB, Optional candleSource) { + String source = candleSource.isPresent()?candleSource.get():""; + + if(CollectionUtils.isNotEmpty(candleDataFromDB)) { + if(candleDataFromDB.size()>=BOLLINGER_BAND_DATA_COUNT) { + int lastElementCounter = candleDataFromDB.size(); + if(source.equalsIgnoreCase("CANDLES")) { + lastElementCounter = candleDataFromDB.size()-1; + } + + for(int i=lastElementCounter;i>=BOLLINGER_BAND_DATA_COUNT; --i){ + int start = i-BOLLINGER_BAND_DATA_COUNT ; + int end = i; +// log.info("start : end = {} : {} ", start, end); + + List> candleSubList = candleDataFromDB.subList(start, end); + + BollingerBand bollingerBand = new BollingerBand(candleSubList); + bollingerBand.calculate(); +// log.info(bollingerBand.toString()); + + bollingerBand.writeToDB(databaseConnection); + } + } + } + log.debug("Bollinger Band calculations done."); + } + +} diff --git a/Trading/src/main/java/com/suneesh/trading/core/calculations/Utility.java b/Trading/src/main/java/com/suneesh/trading/core/calculations/Utility.java new file mode 100644 index 0000000..c7e1006 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/core/calculations/Utility.java @@ -0,0 +1,361 @@ +package com.suneesh.trading.core.calculations; + +import com.google.gson.Gson; +import com.suneesh.trading.database.DatabaseConnection; +import com.suneesh.trading.core.NextTradeDetails; +import com.suneesh.trading.models.Strategy; +import com.suneesh.trading.models.StrategySteps; +import com.suneesh.trading.models.requests.BuyContractParameters; +import com.suneesh.trading.models.requests.SellContractRequest; +import com.suneesh.trading.utils.AutoTradingUtility; +import lombok.Data; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.collections4.MapUtils; + +import java.math.BigDecimal; +import java.time.LocalDateTime; +import java.time.ZoneOffset; +import java.util.*; +import java.util.stream.Collectors; + +@Data +@Slf4j +public class Utility { + private DatabaseConnection databaseConnection; + final static String ACCOUNT_CURRENCY="AccountCurrency"; + List allStrategies; + + public Utility(DatabaseConnection databaseConnection) { + this.databaseConnection = databaseConnection; + loadAllStrategies(); + } + + public String getCurrency(){ + String applicationMode = AutoTradingUtility.getPropertyFromPropertyFile("ApplicationMode"); + String currencyProperty = applicationMode+ACCOUNT_CURRENCY; + String currency = AutoTradingUtility.getPropertyFromPropertyFile(currencyProperty); + if(currency.isEmpty()){ + log.error("FATAL ERROR! No Currency detail found. Cannot book trade.\nExiting application."); + System.exit(-1); + } + return currency; + } + + void sleepTillStartOfNextMinuteMinusSeconds(int seconds){ + int secondsToNextMinute = 60 - getPresentEpochtime()%60 ; + int secondsToNextMinute2 = secondsToNextMinute - seconds; + + if(secondsToNextMinute2<0){ + secondsToNextMinute2+=60; + } + + log.info("Going to sleep for {} seconds.", secondsToNextMinute2); + AutoTradingUtility.sleep(secondsToNextMinute2*1000); + } + + Map getLastCandle(){ + Map result =null; + List> allCandles = getCandles(Optional.of("DESC"), Optional.of(1)); + if(CollectionUtils.isNotEmpty(allCandles)){ + result = allCandles.get(0); + } + return result; + } + + public List> getCandles(Optional sortOrder, Optional numberOfRows){ + String querySortOrder = sortOrder.isPresent()?sortOrder.get():"ASC"; + int queryResultLimit = numberOfRows.isPresent()?numberOfRows.get():99999; + + return databaseConnection.executeQuery("select * from candle order by identifier "+querySortOrder+" limit "+queryResultLimit); + } + + public String getTradeDatabaseInsertString(BuyContractParameters parameters, NextTradeDetails nextTradeDetails) { + + return + "INSERT INTO public.trade " + + "(bid_amount, strike_price, call_or_put, symbol, step_count, strategy_id, trade_time, trade_time_string, amount_won) " + + " VALUES (" + + AutoTradingUtility.quotedString(parameters.getAmount())+", " + + AutoTradingUtility.quotedString(nextTradeDetails.getStrikePrice())+", " + + AutoTradingUtility.quotedString(parameters.getContractType())+", " + + AutoTradingUtility.quotedString(parameters.getSymbol())+", " + + AutoTradingUtility.quotedString(nextTradeDetails.getNextStepCount())+", " + + AutoTradingUtility.quotedString(nextTradeDetails.getStrategyId())+"," + + "extract(epoch from now()) ," + + "now()::timestamp ," + +"0.00 );"; + } + + + + public Map getLastTrade(){ + Map result = null; + List> list = databaseConnection.executeQuery("select * from trade order by identifier desc limit 1"); + if(!CollectionUtils.isEmpty(list)){ + result = list.get(0); + } + return result; + } + + public List> getTradesByResult(String resultString){ + return databaseConnection.executeQuery("select * from trade WHERE RESULT = "+AutoTradingUtility.quotedString(resultString)); + } + + + boolean waitToBookNextTrade(){ + boolean result = true; + Map lastTrade = getLastTrade(); + if(!MapUtils.isEmpty(lastTrade)){ + String tradeResult = lastTrade.get("result"); + + if(!tradeResult.isEmpty() && tradeResult!=null ) + if( tradeResult.equalsIgnoreCase("SUCCESS") || + tradeResult.equalsIgnoreCase("FAIL") ){ + result=false; + } + } + return result; + } + + + public BuyContractParameters getParameters(String symbol, NextTradeDetails nextTradeDetails, String currency) { + String json = "{\n" + + " \"amount\": \""+ nextTradeDetails.getAmount() +"\",\n" + + " \"basis\": \"stake\",\n" + + " \"contract_type\": \""+nextTradeDetails.getCallOrPut()+"\",\n" + + " \"currency\": \""+currency+"\",\n" + + " \"duration\": \""+nextTradeDetails.getContractDuration()+"\",\n" + + " \"duration_unit\": \"s\",\n" + + " \"symbol\": \""+symbol+"\"\n" + + "}"; + + Gson gson = new Gson(); + return gson.fromJson(json, BuyContractParameters.class); + } + + + public double getTickForEpochTime(Optional epochTimeObj, String symbol){ + int epochTime = epochTimeObj.isPresent()?epochTimeObj.get():getPresentEpochtime(); + + BigDecimal quote= new BigDecimal(-1); + List> tickResult = databaseConnection.executeQuery( + "select quote from tick t where t.symbol = '"+symbol+"' AND t.epoch = " + String.valueOf(epochTime)); + if(!CollectionUtils.isEmpty(tickResult)){ + Map tickRow = tickResult.get(0); + quote = new BigDecimal(tickRow.get("quote")); + } + else{ + // Get all the tick prices for the last 10 seconds + tickResult = databaseConnection.executeQuery( + "select quote from tick t where t.symbol = '"+symbol+"' AND t.epoch > " + String.valueOf(epochTime - 10) +" order by identifier desc limit 1"); + if(!CollectionUtils.isEmpty(tickResult)){ + Map tickRow = tickResult.get(0); + quote = new BigDecimal(tickRow.get("quote")); + } + } + return quote.doubleValue(); + } + + public void loadAllStrategies(){ + Gson gson = new Gson(); + List jsonResultDBQuery = databaseConnection.getJsonResultDBQuery("select * from strategy"); + if(CollectionUtils.isNotEmpty(jsonResultDBQuery)) { + allStrategies = jsonResultDBQuery.stream().map(ele -> gson.fromJson(ele, Strategy.class)).collect(Collectors.toList()); + + List jsonResultDBQuery2 = databaseConnection.getJsonResultDBQuery("select * from strategy_steps"); + List allStrategySteps = jsonResultDBQuery2.stream().map(ele -> gson.fromJson(ele, StrategySteps.class)).collect(Collectors.toList()); + + allStrategies.stream().forEach( + strategy -> { + strategy.setStepValueMap(allStrategySteps.stream().filter(f -> f.getStrategyId() == strategy.getIdentifier()).collect(Collectors.toList())); + } + ); + } + } + + public Strategy getStrategyToUse() { + List activeStrategies = allStrategies.stream().filter(s -> s.isActiveStrategy()).collect(Collectors.toList()); + if(activeStrategies.size()>1){ + log.error("ERROR! Multiple strategies marked as active. ONLY ONE STRATEGY can be active at a given time."); + System.exit(-2); + } + + Strategy strategy = activeStrategies.get(0); + + if (strategy==null){ + strategy=getStrategy(Optional.empty(), Optional.of(true)); + } + return strategy; + } + + + public Strategy getStrategy(Optional strategyId, Optional defaultStrategy){ + Strategy strategy= null; + final int INVALID_STRATEGY_ID = -1; + + boolean defaultStrategyToUse=defaultStrategy.isPresent()?defaultStrategy.get():false; + long strategyIdToUse=strategyId.isPresent()?strategyId.get():INVALID_STRATEGY_ID; + try { + // incase a number lower than -1 is passed. + if (strategyIdToUse < 0) { + strategyIdToUse = INVALID_STRATEGY_ID; + } + if (defaultStrategyToUse) { + List defaultStrategies = allStrategies.stream().filter(ele -> ele.isDefaultStrategy()).collect(Collectors.toList()); + if (defaultStrategies.size() > 1) { + log.error("ERROR! Multiple strategies marked as default. ONLY ONE STRATEGY can be default at a given time."); + System.exit(-3); + } + strategy = defaultStrategies.get(0); + } else { + if (strategyIdToUse != INVALID_STRATEGY_ID) { + long finalStrategyIdToUse = strategyIdToUse; + List filteredStrategies = allStrategies.stream().filter(ele -> ele.getIdentifier() == finalStrategyIdToUse).collect(Collectors.toList()); + if (filteredStrategies.size() > 1) { + log.error("ERROR! Multiple strategies have same identifier. ALL STRATEGIES MUST HAVE UNIQUE Identifier."); + System.exit(-4); + } + strategy = filteredStrategies.get(0); + } + if (strategy == null) { + List defaultStrategies = allStrategies.stream().filter(ele -> ele.isDefaultStrategy()).collect(Collectors.toList()); + if (defaultStrategies.size() > 1) { + log.error("ERROR! Multiple strategies marked as default. ONLY ONE STRATEGY can be default at a given time."); + System.exit(-3); + } + strategy = defaultStrategies.get(0); + } + } + } + catch(Exception e){ + e.printStackTrace(); + } + + return strategy; + } + + public Strategy getBackTestingStrategy() { + Strategy strategy = null; + List backTestigStrategies = getAllStrategies().stream().filter(f -> f.isBacktestingStrategy()).collect(Collectors.toList()); + if (backTestigStrategies.size() > 1) { + log.info("ERROR! Only one strategy can be allowed to be a backtest strategy. Exiting."); + System.exit(-1); + } + + if (CollectionUtils.isEmpty(backTestigStrategies)) { + log.info("ERROR! No strategy defined as backtesting strategy. Exiting."); + System.exit(-1); + } + + return backTestigStrategies.get(0); + } + + public void checkDeltaPercentageToCloseTrade() { + HashMap inputMap = new HashMap<>(); + final double VOLATILITY = 0.03D; + final double INTEREST = 0.01D; + final double TRADE_DURATION = 60D; + + try { + ArrayList> list = + (ArrayList>) databaseConnection.executeQuery("select identifier, CAST( ( extract(epoch from now() ) - trade_time) as BIGINT) as time_since_trade_booked , strike_price ,symbol from trade where result = 'OPEN'"); + + if (list.size() > 1) { + log.error("#######################################################################################"); + log.error("ERROR ! more than one trades open. Expected to have only one trade open at a given time."); + log.error("#######################################################################################"); + } + + for (HashMap row : list) { + double timeSinceTradeBooked = Long.valueOf(row.get("time_since_trade_booked")); + double strikePrice = Double.valueOf(row.get("strike_price")); + String symbol = row.get("symbol"); + + double timeLeftOnTrade = TRADE_DURATION - timeSinceTradeBooked; + double timeHorizon = (timeLeftOnTrade / 365) / 365; + + double tickForEpochTime = getTickForEpochTime(Optional.empty(), symbol); + + inputMap.put("stock", tickForEpochTime); + inputMap.put("strike", strikePrice); + inputMap.put("volatility", VOLATILITY); + inputMap.put("interest", INTEREST); + inputMap.put("timehorizon", timeHorizon); + + log.info(inputMap.toString()); + + DeltaPercentage dp = new DeltaPercentage(inputMap); + double tradeDeltaPercentage = dp.calculate(); + log.info("Trade's Delta Percentage = {}", tradeDeltaPercentage); + } + } + catch(Exception e){ + e.printStackTrace(); + } + } + + public int getPresentEpochtime(){ + return Math.toIntExact(LocalDateTime.now().toEpochSecond(ZoneOffset.UTC)); + } + + public SellContractRequest checkPotentialProfit() { + SellContractRequest sellContractRequest = null; + + List> proposalOpenContractSentTradeList = getTradesByResult("PROPOSAL_OPEN_CONTRACT_SENT"); + for(Map trade : proposalOpenContractSentTradeList){ + long tradeId = Long.valueOf(trade.get("identifier")); + long contractId = Long.valueOf(trade.get("contract_id")); + long strategyId = Long.valueOf(trade.get("strategy_id")); + Strategy strategy = getStrategy(Optional.of(strategyId), Optional.empty()); + HashMap stepToStrategyStepsMap1 = strategy.getStepToStrategyStepsMap(); + + int step_count = Integer.valueOf(trade.get("step_count")); + StrategySteps strategyStepsForGivenStepCount = stepToStrategyStepsMap1.get(step_count); + + double profitPercentageThreshold = strategyStepsForGivenStepCount.getProfit_percentage_threshold(); + + double tradeInstantaneousProfitPercentage = 0; + + String tradeQuery = "select oc.profit_percentage from trade t JOIN open_contract oc on ( t.contract_id = oc.contractId) WHERE t.result = 'PROPOSAL_OPEN_CONTRACT_SENT' AND t.identifier = " + tradeId; + List> tradeProfitPercentageResult = databaseConnection.executeQuery(tradeQuery); + + if(CollectionUtils.isEmpty(tradeProfitPercentageResult)){ + log.error("ERROR! Unable to get profit_percentage for trade {} -> strategy {} -> step_count {}.",tradeId, strategyId, step_count); + } + else{ + tradeInstantaneousProfitPercentage = Double.parseDouble(tradeProfitPercentageResult.get(0).get("profit_percentage")); +// log.debug("Trade {} has profit percentage of {} , which is >= {}. [ strategyID {} -> step_count {} profit threshold {} ] ",tradeId,tradeInstantaneousProfitPercentage,profitPercentageThreshold,strategyId,step_count,profitPercentageThreshold); + if(tradeInstantaneousProfitPercentage > profitPercentageThreshold){ + log.info("Trade {} has profit percentage of {} , which is >= {}. [ strategyID {} -> step_count {} profit threshold {} ] ",tradeId,tradeInstantaneousProfitPercentage,profitPercentageThreshold,strategyId,step_count,profitPercentageThreshold); + sellContractRequest = new SellContractRequest(contractId,new BigDecimal(0.0)); + } + } + + } + return sellContractRequest; + } + + public void updateTradeResult(Optional tradeIdentifier, Optional contractIdentifier, Optional oldResultState, Optional newResultState, boolean debug){ + long tradeId = tradeIdentifier.isPresent()?tradeIdentifier.get():-1; + long contractId = contractIdentifier.isPresent()?contractIdentifier.get():-1; + String oldResultString = oldResultState.isPresent()?oldResultState.get():null; + String newResultString = newResultState.isPresent()?newResultState.get():null; + + String queryString = ""; + switch (newResultString){ + case "SELL_CONTRACT_SENT": + queryString = "UPDATE trade SET result = "+AutoTradingUtility.quotedString(newResultString)+" WHERE result IN ("+oldResultString+") AND contract_id = "+contractId; + break; + default: + + } + + if(debug) { + log.debug(queryString); + } + databaseConnection.executeNoResultSet(queryString); + + } + +} diff --git a/Trading/src/main/java/com/suneesh/trading/core/strategy/AbstractStrategyClass.java b/Trading/src/main/java/com/suneesh/trading/core/strategy/AbstractStrategyClass.java new file mode 100644 index 0000000..84d9c23 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/core/strategy/AbstractStrategyClass.java @@ -0,0 +1,118 @@ +package com.suneesh.trading.core.strategy; + +import com.suneesh.trading.core.NextTradeDetails; +import com.suneesh.trading.core.calculations.Utility; +import com.suneesh.trading.database.DatabaseConnection; +import com.suneesh.trading.models.Strategy; +import com.suneesh.trading.models.StrategySteps; +import lombok.Data; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.MapUtils; + +import java.util.Map; +import java.util.Optional; + +@Data +@Slf4j +public abstract class AbstractStrategyClass implements StrategyImplementationInterface { + + final static long CONTRACT_DURATION_IN_SECONDS = 60L; +// final static long CONTRACT_DURATION_IN_SECONDS = 58L; + // This should be the same as the granularity of the candle +// final static long CONTRACT_DURATION_IN_SECONDS = 300L; + final static double INITIAL_BID_AMOUNT = 1.00D; + DatabaseConnection databaseConnection; + Strategy strategy; + Utility calculationUtility; + Boolean isBackTestingMode; + + public AbstractStrategyClass(DatabaseConnection databaseConnection, Strategy strategy, Utility calculationUtility, Boolean isBackTestingMode) { + this.databaseConnection = databaseConnection; + this.strategy = strategy; + this.calculationUtility = calculationUtility; + this.isBackTestingMode= isBackTestingMode; + } + + + public void getContractDuration(NextTradeDetails nextTradeDetails) { + nextTradeDetails.setContractDuration(CONTRACT_DURATION_IN_SECONDS); + } + + public void getCallOrPut(NextTradeDetails nextTradeDetails, Map lastCandle){ + String callOrPutResult = "CALL"; + if(!MapUtils.isEmpty(lastCandle)) { + String previousCandleDirection = lastCandle.get("direction"); + callOrPutResult = previousCandleDirection.equalsIgnoreCase("UP") ? "CALL" : "PUT"; + } + nextTradeDetails.setCallOrPut(callOrPutResult); + } + + public void getBidAmount(NextTradeDetails nextTradeDetails, Map lastCandle) { + double amount = INITIAL_BID_AMOUNT; + int nextStepCount = nextTradeDetails.getNextStepCount(); + StrategySteps strategyStep = strategy.getStepToStrategyStepsMap().get(nextStepCount); + amount = strategyStep.getValue(); + + nextTradeDetails.setAmount(amount); + } + + public void getNextStepCount(NextTradeDetails nextTradeDetails, Map lastTrade) { + int stepCount = 1; + + if(!MapUtils.isEmpty(lastTrade)){ + String previousTradeResult = String.valueOf(lastTrade.get("result")); + long previousTradeStrategyID = Long.valueOf(lastTrade.get("strategy_id")); + int previousStepCount = Integer.parseInt(lastTrade.get("step_count")); + + Strategy previousTradeStrategy = calculationUtility.getStrategy(Optional.of(previousTradeStrategyID), Optional.of(false)); + boolean reset_step_count_on_success = previousTradeStrategy.isResetStepCountOnSuccess(); + + if(previousTradeResult.equalsIgnoreCase("SUCCESS") ){ + if(reset_step_count_on_success) { + stepCount = 1; + } + else{ + stepCount=previousStepCount+1; + } + } + + if(previousTradeResult.equalsIgnoreCase("FAIL")){ + stepCount=previousStepCount+1; + } + } + nextTradeDetails.setNextStepCount(stepCount); + } + + public void getNextTradeStrategyId(NextTradeDetails nextTradeDetails, Map lastTrade) { + long nextTradeStrategyId = -1; + + if( !MapUtils.isEmpty(lastTrade)) { + // Lowest amount possible. + long previousTradeStrategyId = Long.valueOf(lastTrade.getOrDefault("strategy_id","1")); + Strategy previousTradeStrategy = calculationUtility.getStrategy(Optional.of(previousTradeStrategyId), Optional.of(false)); + + int maxSteps = strategy.getMaxSteps(); + if (nextTradeDetails.getNextStepCount() > maxSteps) { + nextTradeStrategyId = strategy.getNextStrategyIdLink(); + + // Resetting step_count to 1 + nextTradeDetails.setNextStepCount(1); + } + else{ + nextTradeStrategyId = previousTradeStrategyId; + } + } + else{ + if(isBackTestingMode){ + Strategy strategy = calculationUtility.getBackTestingStrategy(); + } + else{ + Strategy strategy = calculationUtility.getStrategy(Optional.empty(),Optional.of(true)); + } + nextTradeStrategyId = strategy.getIdentifier(); + + } + nextTradeDetails.setStrategyId(nextTradeStrategyId); + } + +} diff --git a/Trading/src/main/java/com/suneesh/trading/core/strategy/BollingerStrategyImplementation.java b/Trading/src/main/java/com/suneesh/trading/core/strategy/BollingerStrategyImplementation.java new file mode 100644 index 0000000..05a7a75 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/core/strategy/BollingerStrategyImplementation.java @@ -0,0 +1,86 @@ +package com.suneesh.trading.core.strategy; + +import com.google.gson.Gson; +import com.suneesh.trading.core.NextTradeDetails; +import com.suneesh.trading.core.calculations.Utility; +import com.suneesh.trading.core.technical.BollingerBand; +import com.suneesh.trading.database.DatabaseConnection; +import com.suneesh.trading.models.Strategy; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.MapUtils; + +import java.util.ArrayList; +import java.util.ListIterator; +import java.util.Map; +import java.util.stream.Collectors; + +@Slf4j +public class BollingerStrategyImplementation extends AbstractStrategyClass { + + public BollingerStrategyImplementation(DatabaseConnection databaseConnection, Strategy strategy, Utility calculationUtility, Boolean isBackTestingMode) { + super(databaseConnection, strategy, calculationUtility, isBackTestingMode); + } + + @Override + public boolean bookTrade(Map lastTrade, Map lastCandle){ + boolean result = false; + Double candleClose = Double.valueOf(lastCandle.get("close")); + String candleDirection = lastCandle.get("direction"); + Gson gson = new Gson(); + + ArrayList jsonResultDBQuery = databaseConnection.getJsonResultDBQuery("select * from bollinger_band"); + ArrayList bollingerBands = (ArrayList) jsonResultDBQuery.stream().map(ele -> gson.fromJson(String.valueOf(ele), BollingerBand.class)).collect(Collectors.toList()); + +// bollingerBands.stream().forEach(bollingerBand -> log.debug("{} : {} : {}", candleClose, candleDirection, bollingerBand.toString())); + + BollingerBand lastBollingerBand = bollingerBands.get(bollingerBands.size()-1); + + + if( candleDirection.equalsIgnoreCase("DOWN")){ + if(candleClose < lastBollingerBand.getLowerBand() ) { + log.info("LOWER BOLLINGER BAND BREACHED."); + result = true; + } + } + + if( candleDirection.equalsIgnoreCase("HIGH")){ + if(candleClose > lastBollingerBand.getUpperBand() ) { + log.info("UPPER BOLLINGER BAND BREACHED."); + result = true; + } + } + return result; + } + + @Override + public void getCallOrPut(NextTradeDetails nextTradeDetails, Map lastCandle) { + String callOrPutResult = "NONE"; + + + if(!MapUtils.isEmpty(lastCandle)) { + String previousCandleDirection = lastCandle.get("direction"); + callOrPutResult = previousCandleDirection.equalsIgnoreCase("UP") ? "CALL" : "PUT"; + } + nextTradeDetails.setCallOrPut(callOrPutResult); + } + + @Override + public void getContractDuration(NextTradeDetails nextTradeDetails) { + + } + + @Override + public void getNextStepCount(NextTradeDetails nextTradeDetails, Map lastTrade) { + + } + + @Override + public void getNextTradeStrategyId(NextTradeDetails nextTradeDetails, Map lastTrade) { + + } + + @Override + public void getBidAmount(NextTradeDetails nextTradeDetails, Map lastCandle) { + + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/core/strategy/CandleFollowWithIncreaseStrategyImplementation.java b/Trading/src/main/java/com/suneesh/trading/core/strategy/CandleFollowWithIncreaseStrategyImplementation.java new file mode 100644 index 0000000..56e1ce5 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/core/strategy/CandleFollowWithIncreaseStrategyImplementation.java @@ -0,0 +1,16 @@ +package com.suneesh.trading.core.strategy; + +import com.suneesh.trading.core.NextTradeDetails; +import com.suneesh.trading.core.calculations.Utility; +import com.suneesh.trading.database.DatabaseConnection; +import com.suneesh.trading.models.Strategy; + +import java.util.Map; + +public class CandleFollowWithIncreaseStrategyImplementation extends AbstractStrategyClass{ + + public CandleFollowWithIncreaseStrategyImplementation(DatabaseConnection databaseConnection, Strategy strategy, Utility calculationUtility, Boolean isBackTestingMode) { + super(databaseConnection, strategy, calculationUtility, isBackTestingMode); + } + +} diff --git a/Trading/src/main/java/com/suneesh/trading/core/strategy/ClosePriceHighLowStrategyImplementation.java b/Trading/src/main/java/com/suneesh/trading/core/strategy/ClosePriceHighLowStrategyImplementation.java new file mode 100644 index 0000000..0694f29 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/core/strategy/ClosePriceHighLowStrategyImplementation.java @@ -0,0 +1,70 @@ +package com.suneesh.trading.core.strategy; + +import com.google.gson.Gson; +import com.suneesh.trading.core.NextTradeDetails; +import com.suneesh.trading.core.calculations.Utility; +import com.suneesh.trading.core.technical.BollingerBand; +import com.suneesh.trading.database.DatabaseConnection; +import com.suneesh.trading.models.Strategy; +import com.suneesh.trading.models.StrategySteps; +import lombok.Data; +import lombok.extern.slf4j.Slf4j; + +import java.util.ArrayList; +import java.util.Map; +import java.util.stream.Collectors; + +@Data +@Slf4j +public class ClosePriceHighLowStrategyImplementation extends AbstractStrategyClass{ + + public ClosePriceHighLowStrategyImplementation(DatabaseConnection databaseConnection, Strategy strategy, Utility calculationUtility, Boolean isBackTestingMode) { + super(databaseConnection, strategy, calculationUtility, isBackTestingMode); + } + + + @Override + public boolean bookTrade(Map lastTrade, Map lastCandle){ + boolean result = false; + // if the close value of the candle is high or low , then the chance of next candle going in similar direction is higher + if(lastCandle!=null){ + double high = Double.parseDouble(lastCandle.get("high")); + double low = Double.parseDouble(lastCandle.get("low")); + double open = Double.parseDouble(lastCandle.get("open")); + double close = Double.parseDouble(lastCandle.get("close")); + String direction = lastCandle.get("direction"); + + if(direction.equalsIgnoreCase("UP")){ + if(close==high ){ + result= true; + } + } + + if(direction.equalsIgnoreCase("DOWN")){ + if(close==low ){ + result= true; + } + } + } + return result; + } + + public void getBidAmount(NextTradeDetails nextTradeDetails, Map lastCandle) { + double amount = INITIAL_BID_AMOUNT; + final double INCREASED_MOMENTUM_FACTOR= 1.0; + boolean increaseAmount = false; + + int nextStepCount = nextTradeDetails.getNextStepCount(); + StrategySteps strategyStep = strategy.getStepToStrategyStepsMap().get(nextStepCount); + amount = strategyStep.getValue(); + + nextTradeDetails.setAmount(amount); + + increaseAmount = bookTrade(null,lastCandle); + if(increaseAmount){ + nextTradeDetails.setAmount(nextTradeDetails.getAmount() * INCREASED_MOMENTUM_FACTOR); + } + nextTradeDetails.setAmount(amount); + } + +} diff --git a/Trading/src/main/java/com/suneesh/trading/core/strategy/FixedAmountFixedCountNoResetStrategyImplementation.java b/Trading/src/main/java/com/suneesh/trading/core/strategy/FixedAmountFixedCountNoResetStrategyImplementation.java new file mode 100644 index 0000000..6fbb66e --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/core/strategy/FixedAmountFixedCountNoResetStrategyImplementation.java @@ -0,0 +1,12 @@ +package com.suneesh.trading.core.strategy; + +import com.suneesh.trading.core.calculations.Utility; +import com.suneesh.trading.database.DatabaseConnection; +import com.suneesh.trading.models.Strategy; + +public class FixedAmountFixedCountNoResetStrategyImplementation extends AbstractStrategyClass { + public FixedAmountFixedCountNoResetStrategyImplementation(DatabaseConnection databaseConnection, Strategy strategy, Utility calculationUtility, Boolean isBackTestingMode) { + super(databaseConnection, strategy, calculationUtility, isBackTestingMode); + } +} + diff --git a/Trading/src/main/java/com/suneesh/trading/core/strategy/StrategyFactory.java b/Trading/src/main/java/com/suneesh/trading/core/strategy/StrategyFactory.java new file mode 100644 index 0000000..4c1f6d3 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/core/strategy/StrategyFactory.java @@ -0,0 +1,38 @@ +package com.suneesh.trading.core.strategy; + +import com.suneesh.trading.core.calculations.Utility; +import com.suneesh.trading.database.DatabaseConnection; +import com.suneesh.trading.models.Strategy; +import lombok.extern.slf4j.Slf4j; + +import java.util.List; +import java.util.stream.Collectors; + +@Slf4j +public class StrategyFactory { + DatabaseConnection databaseConnection; + Utility calculationUtility; + Boolean isBackTestingMode; + + public StrategyFactory(DatabaseConnection databaseConnection, Utility calculationUtility, Boolean isBackTestingMode) { + this.databaseConnection = databaseConnection; + this.calculationUtility = calculationUtility; + this.isBackTestingMode = isBackTestingMode; + } + + public StrategyImplementationInterface getStrategyImplementation(Strategy strategyObj){ + AbstractStrategyClass strategyImplementation = null; + long strategyAlgorithmId = strategyObj.getStrategyAlgorithmId(); + + switch(Math.toIntExact(strategyAlgorithmId)){ + case 1: strategyImplementation = new CandleFollowWithIncreaseStrategyImplementation(databaseConnection, strategyObj, calculationUtility, isBackTestingMode); break; + case 2: strategyImplementation = new FixedAmountFixedCountNoResetStrategyImplementation(databaseConnection, strategyObj, calculationUtility, isBackTestingMode); break; + case 3: strategyImplementation = new ClosePriceHighLowStrategyImplementation(databaseConnection, strategyObj, calculationUtility, isBackTestingMode); break; + case 4: strategyImplementation = new BollingerStrategyImplementation(databaseConnection, strategyObj, calculationUtility, isBackTestingMode); break; + default : log.error("ERROR ! Unknown Strategy implementation requested. Strategy Implementation not found. Exiting"); + System.exit(-1); + } + return strategyImplementation; + + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/core/strategy/StrategyImplementationInterface.java b/Trading/src/main/java/com/suneesh/trading/core/strategy/StrategyImplementationInterface.java new file mode 100644 index 0000000..170f64d --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/core/strategy/StrategyImplementationInterface.java @@ -0,0 +1,17 @@ +package com.suneesh.trading.core.strategy; + +import com.suneesh.trading.core.NextTradeDetails; +import com.suneesh.trading.models.Strategy; +import lombok.Data; + +import java.util.Map; + +public interface StrategyImplementationInterface { + void getCallOrPut(NextTradeDetails nextTradeDetails, Map lastCandle); + void getContractDuration(NextTradeDetails nextTradeDetails); + void getNextStepCount(NextTradeDetails nextTradeDetails, Map lastTrade); + void getNextTradeStrategyId(NextTradeDetails nextTradeDetails, Map lastTrade); + void getBidAmount(NextTradeDetails nextTradeDetails, Map lastCandle); + + default boolean bookTrade(Map lastTrade, Map lastCandle){return true;} +} diff --git a/Trading/src/main/java/com/suneesh/trading/core/technical/BollingerBand.java b/Trading/src/main/java/com/suneesh/trading/core/technical/BollingerBand.java new file mode 100644 index 0000000..54996c1 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/core/technical/BollingerBand.java @@ -0,0 +1,96 @@ +package com.suneesh.trading.core.technical; + +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; +import com.suneesh.trading.database.DatabaseConnection; +import com.suneesh.trading.utils.AutoTradingUtility; +import lombok.Data; +import lombok.extern.slf4j.Slf4j; + +import java.util.*; +import java.util.stream.Collectors; + +@Slf4j +@Data +public class BollingerBand { + @SerializedName("identifier") + @Expose + long identifier; + + @SerializedName("average") + @Expose + double average; + + @SerializedName("standard_deviation") + @Expose + double standardDeviation; + + @SerializedName("upper_band") + @Expose + double upperBand; + + @SerializedName("lower_band") + @Expose + double lowerBand; + + @SerializedName("bandwidth") + @Expose + double bandWidth; + + @SerializedName("candle_id") + @Expose + long candleIdentifier; + + @SerializedName("candle_epoch_string") + @Expose + String candle_epoch_string; + + List> candleList; + + final int bandMultiple=2; + + public BollingerBand(List> subList){ + this.candleList = subList; + } + + public void calculate(){ + List closeList = candleList.stream().map(ele->Double.parseDouble(ele.get("close"))).collect(Collectors.toList()); + setAverage(Arrays.stream(closeList.toArray()).mapToDouble(f-> (double)f).average().orElse(Double.NaN)); + + if(average!=Double.NaN){ + double stdDevTempSum=0D; + for(double element : closeList){ + stdDevTempSum+= Math.pow(element-average,2); + } + standardDeviation = Math.sqrt(stdDevTempSum/ candleList.size()); + upperBand = average+(bandMultiple*standardDeviation); + lowerBand = average-(bandMultiple*standardDeviation); + bandWidth = upperBand-lowerBand; + } + +// candleList has to be in descending order + candleIdentifier = Integer.parseInt(candleList.get(0).get("identifier")); + candle_epoch_string = candleList.get(0).get("epoch_string"); + + } + + public void writeToDB(DatabaseConnection databaseConnection){ + databaseInsertStringList().forEach(f->{ + databaseConnection.executeNoResultSet(f); + }); + } + + public List databaseInsertStringList(){ + String query = "INSERT INTO bollinger_band ( average, standard_deviation, upper_band, lower_band, bandwidth, candle_id, candle_epoch_string) VALUES " + + "(" + getAverage() + "," + + getStandardDeviation() + "," + + getUpperBand() + "," + + getLowerBand() + "," + + getBandWidth() + "," + + getCandleIdentifier() + "," + + AutoTradingUtility.quotedString(getCandle_epoch_string()) +");"; + +// log.info("query = {}",query); + return Arrays.asList(query); + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/database/Cache.java b/Trading/src/main/java/com/suneesh/trading/database/Cache.java new file mode 100644 index 0000000..99f3ce4 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/database/Cache.java @@ -0,0 +1,40 @@ +package com.suneesh.trading.database; + +import com.suneesh.trading.models.responses.*; + +import java.util.LinkedHashMap; +import java.util.Map; + +public class Cache { + protected static Map tickCache; + protected static Map tickHistoryCache; + protected static Map authorizeResponseCache; + protected static Map balanceResponseCache; + protected static Map transactionsStreamResponseCache; + protected static Map portfolioResponseCache; + protected static Map accountStatusResponseCache; + + public static void writeToCache(Long epochTime, Object response) { + switch(response.getClass().getSimpleName()){ + case "TickResponse": tickCache.put(epochTime, (TickResponse) response); break; + case "AuthorizeResponse": authorizeResponseCache.put(epochTime, (AuthorizeResponse) response); break; + case "BalanceResponse": balanceResponseCache.put(epochTime, (BalanceResponse) response); break; + case "TransactionsStreamResponse": transactionsStreamResponseCache.put(epochTime, (TransactionsStreamResponse) response); break; + case "PortfolioResponse": portfolioResponseCache.put(epochTime, (PortfolioResponse) response); break; + case "AccountStatusResponse": accountStatusResponseCache.put(epochTime, (AccountStatusResponse) response); break; + case "TickHistoryResponse": tickHistoryCache.put(epochTime, (TickHistoryResponse) response); break; + } + } + + public static void initialize(){ + tickCache = new LinkedHashMap<>(); + tickHistoryCache = new LinkedHashMap<>(); + authorizeResponseCache = new LinkedHashMap<>(); + balanceResponseCache = new LinkedHashMap<>(); + transactionsStreamResponseCache = new LinkedHashMap<>(); + portfolioResponseCache = new LinkedHashMap<>(); + accountStatusResponseCache = new LinkedHashMap<>(); + } + + +} diff --git a/Trading/src/main/java/com/suneesh/trading/database/DatabaseConnection.java b/Trading/src/main/java/com/suneesh/trading/database/DatabaseConnection.java new file mode 100644 index 0000000..5a34bb8 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/database/DatabaseConnection.java @@ -0,0 +1,34 @@ +package com.suneesh.trading.database; + +import java.sql.Connection; +import java.util.ArrayList; +import java.util.List; + +public interface DatabaseConnection { + String URL = null; + Connection connection = null; + List listOfTables = null; + List tablesToPopulate = null; + List tablesToDrop = null; + + Connection createConnection(); + String getUrl(); + Connection getConnection(); + + void executeNoResultSet(String createStatement); + + List executeQuery(String statement); + boolean checkTableExists(String tableName); + + void dropTables(); + + void createDBSchema(); + + void checkAndPopulateTables(); + + void init(boolean backTestingMode); + + String getFirstElementFromDBQuery(String Query); + + ArrayList getJsonResultDBQuery(String query); +} diff --git a/Trading/src/main/java/com/suneesh/trading/database/PostgreSQLDatabaseConnection.java b/Trading/src/main/java/com/suneesh/trading/database/PostgreSQLDatabaseConnection.java new file mode 100644 index 0000000..e45b61b --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/database/PostgreSQLDatabaseConnection.java @@ -0,0 +1,225 @@ +package com.suneesh.trading.database; + +import com.suneesh.trading.utils.AutoTradingUtility; +import lombok.Data; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +import java.io.File; +import java.io.IOException; +import java.sql.*; +import java.sql.Statement; +import java.util.*; +import java.util.stream.Collectors; + +@Data +public class PostgreSQLDatabaseConnection implements DatabaseConnection { + private static Logger logger = LogManager.getLogger(); + + String URL; + Connection connection; + private List listOfTables; + private List tablesToPopulate; + private List tablesToDrop; + private boolean dropDbTables; + + + public PostgreSQLDatabaseConnection(String url) { + this.URL =url; + this.connection = createConnection(); + + this.listOfTables = AutoTradingUtility.readListFromPropertyFile("ListOfDatabaseTablesToCreate"); + this.tablesToPopulate = AutoTradingUtility.readListFromPropertyFile("ListOfDatabaseTablesToPopulate"); + this.dropDbTables = Boolean.parseBoolean(AutoTradingUtility.getPropertyFromPropertyFile("DropDatabaseTables")); + + String listToDrop = AutoTradingUtility.getPropertyFromPropertyFile("ListOfDatabaseTablesToDrop"); + if(!listToDrop.isEmpty()) { + this.tablesToDrop = AutoTradingUtility.readListFromPropertyFile(listToDrop); + } + } + + @Override + public Connection createConnection() { + Connection conn = null; + Properties props = new Properties(); + props.setProperty("user", AutoTradingUtility.getPropertyFromPropertyFile("DatabaseUsername")); + props.setProperty("password", AutoTradingUtility.getPropertyFromPropertyFile("DatabasePassword")); + try { + conn = DriverManager.getConnection(getUrl(), props); + } catch (SQLException e) { + e.printStackTrace(); + } + return conn; + } + + @Override + public String getUrl() { + return this.URL; + } + + @Override + public Connection getConnection() { + return connection; + } + + @Override + public void executeNoResultSet(String createStatement) { + Statement st = null; + ArrayList list = new ArrayList(50); + try { + st = getConnection().createStatement(); + st.execute(createStatement); + st.close(); + } catch (SQLException e) { + e.printStackTrace(); + } + } + + @Override + public List> executeQuery(String statement) { + Statement st = null; + ResultSet rs = null; + ArrayList> list = new ArrayList<>(50); + try { + st = getConnection().createStatement(); +// logger.info("Statement = {}", statement); + rs = st.executeQuery(statement); + if (rs != null) { + ResultSetMetaData md = rs.getMetaData(); + int columns = md.getColumnCount(); + while (rs.next()){ + HashMap row = new HashMap<>(columns); + for(int i=1; i<=columns; ++i){ + row.put(md.getColumnName(i),String.valueOf(rs.getObject(i))); + } + list.add(row); + } + } + rs.close(); + st.close(); + } catch (SQLException e) { + e.printStackTrace(); + } + return list; + } + + @Override + public boolean checkTableExists(String tableName){ + DatabaseMetaData dbm = null; + boolean result = false; + try { + dbm = getConnection().getMetaData(); + ResultSet tables = dbm.getTables(null, null, tableName, null); + if (tables.next()) { + result = true; + } + else { + result = false; + } + } catch (SQLException e) { + e.printStackTrace(); + } + return result; + } + + @Override + public void dropTables(){ + if(dropDbTables){ + logger.info("DROPPING DATABASE TABLES."); + if(CollectionUtils.isNotEmpty(tablesToDrop)){ + tablesToDrop.stream().forEach(table -> { + logger.info("Dropping table, {}", table); + executeNoResultSet("DROP TABLE "+table); + }); + } + else{ + logger.info("No Tables defined to be dropped."); + } + } + else{ + logger.info("NOT DROPPING DATABASE TABLES."); + } + } + + @Override + public void createDBSchema() { + listOfTables.stream().forEach(table -> { + if(checkTableExists(table)){ + logger.info("Table {} Exists.", table); + } + else{ + logger.info("Table {} does not Exist.", table); + File file = AutoTradingUtility.getFileFromResources(table+".sql"); + try { + executeNoResultSet(AutoTradingUtility.readFile(file)); + } catch (IOException e) { + e.printStackTrace(); + } + + logger.info("Checking after Create table query..."); + if(checkTableExists(table)){ + logger.info("Table {} Exists.", table); + } + else { + logger.info("Table {} still does not Exists.", table); + } + } + }); + + } + + @Override + public void checkAndPopulateTables(){ + tablesToPopulate.forEach(table->{ + List> result = (List>)executeQuery("select * from "+table); + + if(CollectionUtils.isEmpty(result)){ + logger.info("{} Table not populated.", table); + File file = AutoTradingUtility.getFileFromResources("populate_"+table+".sql"); + try { + executeNoResultSet(AutoTradingUtility.readFile(file)); + if( !CollectionUtils.isEmpty(executeQuery("select * from "+table) )) + { + logger.info("{} tables populated.", table); + } + else{ + logger.error("ERROR! {} tables NOT populated.",table); + } + } catch (IOException e) { + e.printStackTrace(); + } + } + else { + logger.info("{} table already populated.",table); + } + }); + } + + public void init(boolean backTestingMode){ + dropTables(); + createDBSchema(); + checkAndPopulateTables(); + } + + public String getFirstElementFromDBQuery(String query) { + String result = null; + List> dbResultList = executeQuery(query); + if (CollectionUtils.isNotEmpty(dbResultList)) { + result = dbResultList.get(0).entrySet().iterator().next().getValue(); + } + return result; + } + + @Override + public ArrayList getJsonResultDBQuery(String query) { + ArrayList result = new ArrayList<>(); + List> dbResultList = executeQuery("select row_to_json(t) as json_result from (" + query + " ) t"); + if (CollectionUtils.isNotEmpty(dbResultList)) { + result = (ArrayList) dbResultList.stream().map(ele -> ele.get("json_result")).collect(Collectors.toList()); + + } + return result; + } + +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/Strategy.java b/Trading/src/main/java/com/suneesh/trading/models/Strategy.java new file mode 100644 index 0000000..1dc4d63 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/Strategy.java @@ -0,0 +1,68 @@ +package com.suneesh.trading.models; + +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.CollectionUtils; + +import java.util.HashMap; +import java.util.List; + +@Data +@Slf4j +public class Strategy { + @SerializedName("identifier") + @Expose + long identifier ; + + @SerializedName("strategy_name") + @Expose + String strategyName ; + + @SerializedName("strategy_algorithm_id") + @Expose + long strategyAlgorithmId; + + @SerializedName("creation_date") + @Expose + String creationDate; + + @SerializedName("max_steps") + @Expose + int maxSteps; + + @SerializedName("next_strategy_id_link") + @Expose + int nextStrategyIdLink; + + @SerializedName("is_backtesting_strategy") + @Expose + boolean isBacktestingStrategy; + + @SerializedName("is_default_strategy") + @Expose + boolean isDefaultStrategy; + + @SerializedName("reset_step_count_on_success") + @Expose + boolean resetStepCountOnSuccess; + + + @SerializedName("active_strategy") + @Expose + boolean activeStrategy; + + HashMap stepToStrategyStepsMap = new HashMap<>(); + + public void setStepValueMap(List strategyStepsList){ + try { + if (CollectionUtils.isNotEmpty(strategyStepsList)) { + strategyStepsList.stream().forEach(ele -> stepToStrategyStepsMap.putIfAbsent(Integer.valueOf(ele.getStepCount()), ele)); + } + } + catch(Exception e){ + e.printStackTrace(); + } + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/StrategySteps.java b/Trading/src/main/java/com/suneesh/trading/models/StrategySteps.java new file mode 100644 index 0000000..ab71c64 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/StrategySteps.java @@ -0,0 +1,30 @@ +package com.suneesh.trading.models; + +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.extern.slf4j.Slf4j; + +@Data +@Slf4j +public class StrategySteps { + @SerializedName("identifier") + @Expose + long identifier ; + + @SerializedName("strategy_id") + @Expose + int strategyId ; + + @SerializedName("step_count") + @Expose + int stepCount; + + @SerializedName("value") + @Expose + double value; + + @SerializedName("profit_percentage_threshold") + @Expose + double profit_percentage_threshold; +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/WebsocketEvent.java b/Trading/src/main/java/com/suneesh/trading/models/WebsocketEvent.java new file mode 100644 index 0000000..cf27fb3 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/WebsocketEvent.java @@ -0,0 +1,41 @@ +package com.suneesh.trading.models; + +/** + * Created by morteza on 7/19/2017. + */ + +public class WebsocketEvent { + private boolean isOpened = false; + private boolean hasError = false; + private String errorMessage; + + public WebsocketEvent(boolean isOpened, String message){ + this.isOpened = isOpened; + this.errorMessage = message; + this.hasError = !isOpened; + } + + public boolean isOpened() { + return isOpened; + } + + public void setOpened(boolean opened) { + isOpened = opened; + } + + public boolean isHasError() { + return hasError; + } + + public void setHasError(boolean hasError) { + this.hasError = hasError; + } + + public String getErrorMessage() { + return errorMessage; + } + + public void setErrorMessage(String errorMessage) { + this.errorMessage = errorMessage; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/enums/AccountOpeningReasons.java b/Trading/src/main/java/com/suneesh/trading/models/enums/AccountOpeningReasons.java new file mode 100644 index 0000000..1a62751 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/enums/AccountOpeningReasons.java @@ -0,0 +1,23 @@ +package com.suneesh.trading.models.enums; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 9/3/2017 + */ +public enum AccountOpeningReasons { + SPECULATIVE("Speculative"), + INCOME_EARNING("Income Earning"), + HEDGING("Earning Hedging"); + + private final String _value; + + AccountOpeningReasons(String value) { + this._value = value; + } + + @Override + public String toString() { + return this._value; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/enums/BasisTypes.java b/Trading/src/main/java/com/suneesh/trading/models/enums/BasisTypes.java new file mode 100644 index 0000000..15f77e2 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/enums/BasisTypes.java @@ -0,0 +1,22 @@ +package com.suneesh.trading.models.enums; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/2/2017 + */ +public enum BasisTypes { + PAYOUT("payout"), + STAKE("stake"); + + private final String value; + + BasisTypes(String value) { + this.value = value; + } + + @Override + public String toString(){ + return this.value; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/enums/CashierProviders.java b/Trading/src/main/java/com/suneesh/trading/models/enums/CashierProviders.java new file mode 100644 index 0000000..7a7bd83 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/enums/CashierProviders.java @@ -0,0 +1,22 @@ +package com.suneesh.trading.models.enums; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 9/14/2017 + */ +public enum CashierProviders { + DOUGHFLOW("doughflow"), + EPG("epg"); + + private final String _value; + + CashierProviders(String value) { + this._value = value; + } + + @Override + public String toString() { + return this._value; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/enums/CashierTypes.java b/Trading/src/main/java/com/suneesh/trading/models/enums/CashierTypes.java new file mode 100644 index 0000000..4d00488 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/enums/CashierTypes.java @@ -0,0 +1,22 @@ +package com.suneesh.trading.models.enums; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 9/14/2017 + */ +public enum CashierTypes { + DEPOSIT("deposit"), + WITHDRAW("withdraw"); + + private final String _value; + + CashierTypes(String value) { + this._value = value; + } + + @Override + public String toString() { + return this._value; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/enums/DurationUnits.java b/Trading/src/main/java/com/suneesh/trading/models/enums/DurationUnits.java new file mode 100644 index 0000000..436c76d --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/enums/DurationUnits.java @@ -0,0 +1,25 @@ +package com.suneesh.trading.models.enums; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/2/2017 + */ +public enum DurationUnits { + DAYS("d"), + HOURS("h"), + MINUTES("m"), + SECONDS("s"), + TICKS("t"); + + private final String value; + + DurationUnits(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/enums/EducationLevels.java b/Trading/src/main/java/com/suneesh/trading/models/enums/EducationLevels.java new file mode 100644 index 0000000..7f14963 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/enums/EducationLevels.java @@ -0,0 +1,25 @@ +package com.suneesh.trading.models.enums; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 9/3/2017 + */ +public enum EducationLevels { + + PRIMARY("Primary"), + SECONDARY("Secondary"), + TERTIARY("Tertiary"); + + private final String _value; + + EducationLevels(String value) { + this._value = value; + } + + @Override + public String toString() { + return this._value; + } + +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/enums/EmailVerificationReasons.java b/Trading/src/main/java/com/suneesh/trading/models/enums/EmailVerificationReasons.java new file mode 100644 index 0000000..d8ad432 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/enums/EmailVerificationReasons.java @@ -0,0 +1,13 @@ +package com.suneesh.trading.models.enums; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/3/2017 + */ +public enum EmailVerificationReasons { + ACCOUNT_OPENING, + RESET_PASSWORD, + PAYMENTAGENT_WITHDRAW, + PAYMENT_WITHDRAW; +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/enums/EmploymentIndustries.java b/Trading/src/main/java/com/suneesh/trading/models/enums/EmploymentIndustries.java new file mode 100644 index 0000000..4cc4fd1 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/enums/EmploymentIndustries.java @@ -0,0 +1,27 @@ +package com.suneesh.trading.models.enums; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 9/3/2017 + */ +public enum EmploymentIndustries { + + CONSTRUCTION("Construction"), + EDUCATION("Education"), + FINANCE("Finance"), + HEALTH("Health"), + TOURISM("Tourism"), + OTHER("Other"); + + private final String _value; + + EmploymentIndustries(String value) { + this._value = value; + } + + @Override + public String toString() { + return this._value; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/enums/EmploymentStatuses.java b/Trading/src/main/java/com/suneesh/trading/models/enums/EmploymentStatuses.java new file mode 100644 index 0000000..feeeb06 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/enums/EmploymentStatuses.java @@ -0,0 +1,26 @@ +package com.suneesh.trading.models.enums; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 9/3/2017 + */ +public enum EmploymentStatuses { + + EMPLOYED("Employed"), + PENSIONER("Pensioner"), + SELF_EMPLOYED("Self-Employed"), + STUDENT("Student"), + UNEMPLOYED("Unemployed"); + + private final String _value; + + EmploymentStatuses(String value) { + this._value = value; + } + + @Override + public String toString() { + return this._value; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/enums/EstimatedWorth.java b/Trading/src/main/java/com/suneesh/trading/models/enums/EstimatedWorth.java new file mode 100644 index 0000000..50427dd --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/enums/EstimatedWorth.java @@ -0,0 +1,25 @@ +package com.suneesh.trading.models.enums; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 9/11/2017 + */ +public enum EstimatedWorth { + LESS_THAN_ONE_HUNDRED("Less than $100,000"), + ONE_HUNDRED_TO_TWO_HUNDREDS_FIFTY("$100,000 - $250,000"), + TWO_HUNDRED_FIFTY_TO_FIVE_HUNDREDS("$250,001 - $500,000"), + FIVE_HUNDREDS_TO_ONE_MILLION("$500,001 - $1,000,000"), + OVER_ONE_MILLION("Over $1,000,000"); + + private final String _value; + + EstimatedWorth(String _value) { + this._value = _value; + } + + @Override + public String toString() { + return this._value; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/enums/ExperienceDuration.java b/Trading/src/main/java/com/suneesh/trading/models/enums/ExperienceDuration.java new file mode 100644 index 0000000..b88a87e --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/enums/ExperienceDuration.java @@ -0,0 +1,24 @@ +package com.suneesh.trading.models.enums; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 9/3/2017 + */ +public enum ExperienceDuration { + + ZERO_TO_ONE_YEAR("0-1 year"), + ONE_TO_TWO_YEARS("1-2 years"), + OVER_THREE_YEARS("Over 3 years"); + + private final String _value; + + ExperienceDuration(String value) { + this._value = value; + } + + @Override + public String toString() { + return this._value; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/enums/Gender.java b/Trading/src/main/java/com/suneesh/trading/models/enums/Gender.java new file mode 100644 index 0000000..a48d9b5 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/enums/Gender.java @@ -0,0 +1,11 @@ +package com.suneesh.trading.models.enums; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/4/2017 + */ +public enum Gender { + MALE, + FEMALE; +} \ No newline at end of file diff --git a/Trading/src/main/java/com/suneesh/trading/models/enums/HedgeAssets.java b/Trading/src/main/java/com/suneesh/trading/models/enums/HedgeAssets.java new file mode 100644 index 0000000..c030fcf --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/enums/HedgeAssets.java @@ -0,0 +1,24 @@ +package com.suneesh.trading.models.enums; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 9/14/2017 + */ +public enum HedgeAssets { + + FOREIGN_CURRENCY_DEPOSIT("Foreign currency deposit"), + MARGIN_FX("Margin FX"), + OTHER("Other"); + + private final String _value; + + HedgeAssets(String value){ + this._value = value; + } + + @Override + public String toString() { + return this._value; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/enums/IncomeSources.java b/Trading/src/main/java/com/suneesh/trading/models/enums/IncomeSources.java new file mode 100644 index 0000000..69e990f --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/enums/IncomeSources.java @@ -0,0 +1,26 @@ +package com.suneesh.trading.models.enums; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 9/3/2017 + */ +public enum IncomeSources { + + SALARIED_EMPLOYEE("Salaried Employee"), + SELF_EMPLOYED("Self-Employed"), + INVESTMENTS_AND_DIVIDENDS("Investments & Dividends"), + PENSION("Pension"), + OTHER("Other"); + + private final String _value; + + IncomeSources(String value) { + this._value = value; + } + + @Override + public String toString() { + return this._value; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/enums/JPAnnualIncomes.java b/Trading/src/main/java/com/suneesh/trading/models/enums/JPAnnualIncomes.java new file mode 100644 index 0000000..a5d33c8 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/enums/JPAnnualIncomes.java @@ -0,0 +1,28 @@ +package com.suneesh.trading.models.enums; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/4/2017 + */ +public enum JPAnnualIncomes { + LESS_THAN_1_MILLION_JPY("Less than 1 million JPY"), + ONE_TO_THREE_MILLION_JPY("1-3 million JPY"), + THREE_TO_FIVE_MILLION_JPY("3-5 million JPY"), + FIVE_TO_TEN_MILLION_JPY("5-10 million JPY"), + TEN_TO_THIRTY_MILLION_JPY("10-30 million JPY"), + THIRTY_TO_FIFTY_MILLION_JPY("30-50 million JPY"), + FIFTY_TO_HUNDRED_MILLION_JPY("50-100 million JPY"), + OVER_HUNDRED_MILLION_JPY("Over 100 million JPY"); + + private final String _value; + + JPAnnualIncomes(String value) { + this._value = value; + } + + public String toString() { + return this._value; + } + +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/enums/JPOccupations.java b/Trading/src/main/java/com/suneesh/trading/models/enums/JPOccupations.java new file mode 100644 index 0000000..b6cdec4 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/enums/JPOccupations.java @@ -0,0 +1,29 @@ +package com.suneesh.trading.models.enums; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/4/2017 + */ +public enum JPOccupations { + OFFICE_WORKER("Office worker"), + DIRECTOR("Director"), + PUBLIC_WORKER("Public worker"), + SELF_EMPLOYED("Self-employed"), + HOUSEWIFE_HOUSEHUSBAND("Housewife / Househusband"), + CONTRACT_TEMPORARY_PART_TIME("Contract / Temporary / Part Time"), + STUDENT("Student"), + UNEMPLOYED("Unemployed"), + OTHERS("Others"); + + private final String _value; + + JPOccupations(String _value) { + this._value = _value; + } + + @Override + public String toString() { + return this._value; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/enums/JPStatus.java b/Trading/src/main/java/com/suneesh/trading/models/enums/JPStatus.java new file mode 100644 index 0000000..ac34378 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/enums/JPStatus.java @@ -0,0 +1,14 @@ +package com.suneesh.trading.models.enums; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/4/2017 + */ +public enum JPStatus { + ACTIVATED, + JP_KNOWLEDGE_TEST_PENDING, + JP_KNOWLEDGE_TEST_FAIL, + JP_ACTIVATION_PENDING, + DISABLED; +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/enums/JPTradingExperiences.java b/Trading/src/main/java/com/suneesh/trading/models/enums/JPTradingExperiences.java new file mode 100644 index 0000000..ba05a81 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/enums/JPTradingExperiences.java @@ -0,0 +1,25 @@ +package com.suneesh.trading.models.enums; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/4/2017 + */ +public enum JPTradingExperiences { + NO_EXPERIENCE("No experience"), + LESS_THAN_SIX_MONTHS("Less than 6 months"), + SIX_MONTHS_TO_ONE_YEAR("6 months to 1 year"), + ONE_TO_THREE_YEARS("1-3 years"), + THREE_TO_FIVE_YEARS("3-5 years"), + OVER_FIVE_YEARS("Over 5 years"); + + private final String _value; + + JPTradingExperiences(String _value) { + this._value = _value; + } + + public String toString() { + return this._value; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/enums/JPTradingPurposes.java b/Trading/src/main/java/com/suneesh/trading/models/enums/JPTradingPurposes.java new file mode 100644 index 0000000..782e8be --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/enums/JPTradingPurposes.java @@ -0,0 +1,23 @@ +package com.suneesh.trading.models.enums; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/4/2017 + */ +public enum JPTradingPurposes { + SHORT_TERM_PROFITS("Targeting short-term profits"), + MEDIUM_TERM_LONG_TERM_PROFITS("Targeting medium-term / long-term profits"), + BOTH("Both the above"), + HEDGING("Hedging"); + + private final String _value; + + JPTradingPurposes(String _value) { + this._value = _value; + } + + public String toString() { + return this._value; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/enums/Occupations.java b/Trading/src/main/java/com/suneesh/trading/models/enums/Occupations.java new file mode 100644 index 0000000..4168a71 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/enums/Occupations.java @@ -0,0 +1,35 @@ +package com.suneesh.trading.models.enums; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 9/3/2017 + */ +public enum Occupations { + + CHIEF_EXECUTIVES("Chief Executives, Senior Officials and Legislators"), + MANAGERS("Managers"), + PROFESSIONALS("Professionals"), + CLERKS("Clerks"), + PERSONAL_CARE_SALES_SERVICE_WORKERS("Personal Care, Sales and Service Workers"), + AGRICULTURAL_FORESTRY_FISHERY_WORKERS("Agricultural, Forestry and Fishery Workers"), + CRAFT_METAL_ELECTRICAL_ELECTRONICS_WORKERS("Craft, Metal, Electrical and Electronics Workers"), + PLANT_MACHINE_OPERATORS_ASSEMBLERS("Plant and Machine Operators and Assemblers"), + CLEANERS_HELPERS("Cleaners and Helpers"), + MINING_CONSTRUCTION_MANUFACTURING_TRANSPORT_WORKERS("Mining, Construction, Manufacturing and Transport Workers"), + ARMED_FORCES("Armed Forces"), + GOVERNMENT_OFFICERS("Government Officers"), + OTHERS("Others"); + + private final String _value; + + Occupations(String value) { + this._value = value; + } + + @Override + public String toString() { + return this._value; + } + +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/enums/Salutation.java b/Trading/src/main/java/com/suneesh/trading/models/enums/Salutation.java new file mode 100644 index 0000000..80a3a43 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/enums/Salutation.java @@ -0,0 +1,25 @@ +package com.suneesh.trading.models.enums; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/31/2017 + */ +public enum Salutation { + MR("Mr"), + MRS("Mrs"), + MS("Ms"), + MISS("Miss"); + + private final String _value; + + Salutation(String value) { + this._value = value; + } + + @Override + public String toString() { + return this._value; + } + +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/enums/Scopes.java b/Trading/src/main/java/com/suneesh/trading/models/enums/Scopes.java new file mode 100644 index 0000000..5a36ad0 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/enums/Scopes.java @@ -0,0 +1,25 @@ +package com.suneesh.trading.models.enums; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/9/2017 + */ +public enum Scopes { + READ("read"), + TRADE("trade"), + PAYMENTS("payments"), + ADMIN("admin"); + + private final String value; + + Scopes(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/enums/SecretQuestions.java b/Trading/src/main/java/com/suneesh/trading/models/enums/SecretQuestions.java new file mode 100644 index 0000000..6ab176f --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/enums/SecretQuestions.java @@ -0,0 +1,28 @@ +package com.suneesh.trading.models.enums; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 9/3/2017 + */ +public enum SecretQuestions { + MOTHER_MAIDEN_NAME("Mother's maiden name"), + NAME_OF_PET("Name of your pet"), + NAME_OF_LOVE("Name of first love"), + MEMORABLE_CITY("Memorable town/city"), + MEMORABLE_DATE("Memorable date"), + FAVOURITE_DISH("Favourite dish"), + BRAND_OF_CAR("Brand of first car"), + FAVOURITE_ARTIST("Favourite artist"); + + private final String _value; + + SecretQuestions(String value) { + this._value = value; + } + + @Override + public String toString() { + return this._value; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/enums/SortTypes.java b/Trading/src/main/java/com/suneesh/trading/models/enums/SortTypes.java new file mode 100644 index 0000000..2358e8b --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/enums/SortTypes.java @@ -0,0 +1,11 @@ +package com.suneesh.trading.models.enums; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/8/2017 + */ +public enum SortTypes { + ASC, + DESC; +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/enums/StreamTypes.java b/Trading/src/main/java/com/suneesh/trading/models/enums/StreamTypes.java new file mode 100644 index 0000000..b4f8572 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/enums/StreamTypes.java @@ -0,0 +1,17 @@ +package com.suneesh.trading.models.enums; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/1/2017 + */ +public enum StreamTypes { + ticks, + candles, + proposal, + protfolio, + proposal_open_contract, + balance, + transaction, + proposal_array; +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/enums/TestResult.java b/Trading/src/main/java/com/suneesh/trading/models/enums/TestResult.java new file mode 100644 index 0000000..bfb9b7e --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/enums/TestResult.java @@ -0,0 +1,22 @@ +package com.suneesh.trading.models.enums; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/30/2017 + */ +public enum TestResult { + PASS("pass"), + FAIL("fail"); + + private final String _value; + + TestResult(String value) { + _value = value; + } + + @Override + public String toString() { + return this._value; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/enums/TickStyles.java b/Trading/src/main/java/com/suneesh/trading/models/enums/TickStyles.java new file mode 100644 index 0000000..e278008 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/enums/TickStyles.java @@ -0,0 +1,11 @@ +package com.suneesh.trading.models.enums; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/3/2017 + */ +public enum TickStyles { + CANDLES, + TICKS; +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/enums/TradeFrequency.java b/Trading/src/main/java/com/suneesh/trading/models/enums/TradeFrequency.java new file mode 100644 index 0000000..bb21131 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/enums/TradeFrequency.java @@ -0,0 +1,24 @@ +package com.suneesh.trading.models.enums; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 9/3/2017 + */ +public enum TradeFrequency { + + ZERO_TO_FIVE_TRANSACTIONS("0-5 transactions in the past 12 months"), + SIX_TO_TEN_TRANSACTIONS("6-10 transactions in the past 12 months"), + OVER_FORTY_TRANSACTIONS("40 transactions or more in the past 12 months"); + + private final String _value; + + TradeFrequency(String value) { + this._value = value; + } + + @Override + public String toString() { + return this._value; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/enums/TransactionType.java b/Trading/src/main/java/com/suneesh/trading/models/enums/TransactionType.java new file mode 100644 index 0000000..4b9410d --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/enums/TransactionType.java @@ -0,0 +1,23 @@ +package com.suneesh.trading.models.enums; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/7/2017 + */ +public enum TransactionType { + BUY("buy"), + SELL("sell"), + DEPOSIT("deposit"), + WITHDRAWAL("withdrawal"); + + private final String value; + + TransactionType(String value) { + this.value = value; + } + + public String toString() { + return this.value; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/enums/TurnoverRanges.java b/Trading/src/main/java/com/suneesh/trading/models/enums/TurnoverRanges.java new file mode 100644 index 0000000..d8a2f9c --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/enums/TurnoverRanges.java @@ -0,0 +1,26 @@ +package com.suneesh.trading.models.enums; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 9/3/2017 + */ +public enum TurnoverRanges { + + LESS_THAN_TWENTY_FIVE("Less than $25,000"), + TWENTY_FIVE_TO_FIFTY("$25,000 - $50,000"), + FIFTY_TO_ONE_HUNDRED("$50,001 - $100,000"), + ONE_HUNDRED_TO_FIVE_HUNDRED("$100,001 - $500,000"), + OVER_FIVE_HUNDRED("Over $500,000"); + + private final String _value; + + TurnoverRanges(String value) { + this._value = value; + } + + @Override + public String toString() { + return this._value; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/enums/WealthSources.java b/Trading/src/main/java/com/suneesh/trading/models/enums/WealthSources.java new file mode 100644 index 0000000..03249b8 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/enums/WealthSources.java @@ -0,0 +1,29 @@ +package com.suneesh.trading.models.enums; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 9/3/2017 + */ +public enum WealthSources { + + ACCUMULATION_INCOME_SAVINGS("Accumulation of Income/Savings"), + CASH_BUSINESS("Cash Business"), + COMPANY_OWNERSHIP("Company Ownership"), + DIVORCE_SETTLEMENT("Divorce Settlement"), + INHERITANCE("Inheritance"), + INVESTMENT_INCOME("Investment Income"), + SALE_PROPERTY("Sale of Property"), + OTHER("Other"); + + private final String _value; + + WealthSources(String value) { + this._value = value; + } + + @Override + public String toString() { + return this._value; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/enums/WorthRanges.java b/Trading/src/main/java/com/suneesh/trading/models/enums/WorthRanges.java new file mode 100644 index 0000000..916fe4e --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/enums/WorthRanges.java @@ -0,0 +1,27 @@ +package com.suneesh.trading.models.enums; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 9/3/2017 + */ +public enum WorthRanges { + + LESS_THAN_ONE_HUNDRED("Less than $100,000"), + ONE_HUNDRED_TO_TWO_HUNDRED_FIFTY("$100,000 - $250,000"), + TWO_HUNDRED_FIFTY_TO_FIVE_HUNDRED("$250,001 - $500,000"), + FIVE_HUNDRED_TO_ONE_MILLION("$500,001 - $1,000,000"), + OVER_ONE_MILLION("Over $1,000,000"); + + private final String _value; + + WorthRanges(String value) { + this._value = value; + } + + @Override + public String toString() { + return this._value; + } + +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/requests/AccountLimitsRequest.java b/Trading/src/main/java/com/suneesh/trading/models/requests/AccountLimitsRequest.java new file mode 100644 index 0000000..56d1a48 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/requests/AccountLimitsRequest.java @@ -0,0 +1,24 @@ +package com.suneesh.trading.models.requests; + +import com.suneesh.trading.models.responses.AccountLimitsResponse; +import com.google.gson.annotations.SerializedName; + +/** + *

AccountLimitsRequest

+ * + *

Get Limits Send

+ *

Trading and Withdrawal Limits for a given user

+ * + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/3/2017 + */ +public class AccountLimitsRequest extends RequestBase { + + @SerializedName("get_limits") + private final int getLimits = 1; + + public AccountLimitsRequest() { + this.responseType = AccountLimitsResponse.class; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/requests/AccountSettingsRequest.java b/Trading/src/main/java/com/suneesh/trading/models/requests/AccountSettingsRequest.java new file mode 100644 index 0000000..eccf20b --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/requests/AccountSettingsRequest.java @@ -0,0 +1,26 @@ +package com.suneesh.trading.models.requests; + +import com.suneesh.trading.models.responses.AccountSettingsResponse; +import com.google.gson.annotations.SerializedName; + +/** + *

AccountSettingsRequest

+ *

+ *

Get User Settings Send

+ *

+ * Get User Settings (email, date of birth, address etc) + *

+ * + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/4/2017 + */ +public class AccountSettingsRequest extends RequestBase { + + @SerializedName("get_settings") + private final int getSettings = 1; + + public AccountSettingsRequest() { + this.responseType = AccountSettingsResponse.class; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/requests/AccountStatusRequest.java b/Trading/src/main/java/com/suneesh/trading/models/requests/AccountStatusRequest.java new file mode 100644 index 0000000..6df6839 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/requests/AccountStatusRequest.java @@ -0,0 +1,24 @@ +package com.suneesh.trading.models.requests; + +import com.suneesh.trading.models.responses.AccountStatusResponse; +import com.google.gson.annotations.SerializedName; + +/** + *

AccountStatusRequest

+ * + *

Get Account Status Send

+ *

Get Account Status

+ * + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/4/2017 + */ +public class AccountStatusRequest extends RequestBase { + + @SerializedName("get_account_status") + private final int status = 1; + + public AccountStatusRequest() { + this.responseType = AccountStatusResponse.class; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/requests/ActiveSymbolRequest.java b/Trading/src/main/java/com/suneesh/trading/models/requests/ActiveSymbolRequest.java new file mode 100644 index 0000000..221a288 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/requests/ActiveSymbolRequest.java @@ -0,0 +1,79 @@ +package com.suneesh.trading.models.requests; + +import com.suneesh.trading.models.responses.ActiveSymbolResponse; +import com.google.gson.annotations.SerializedName; +import io.reactivex.annotations.Nullable; + +/** + *

Active Symbol Request

+ * + *

Request list of active symbols

+ *

+ * Retrieve a list of all active symbols (underlying markets upon which contracts are available for trading). + *

+ * + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 7/31/2017 + */ +public class ActiveSymbolRequest extends RequestBase { + + @SerializedName("active_symbols") + private String activeSymbols; + + @SerializedName("landing_company") + private String landingCompany; + + @SerializedName("product_type") + @Nullable + private String productType; + + public ActiveSymbolRequest(){ + this(false); + } + + public ActiveSymbolRequest(boolean isFull){ + this.responseType = ActiveSymbolResponse.class; + if(isFull) { + this.activeSymbols = "Full"; + } + else + { + this.activeSymbols = "brief"; + } + } + + public ActiveSymbolRequest(boolean isFull, String landingCompany) { + this(isFull); + this.landingCompany = landingCompany; + } + + public ActiveSymbolRequest(String landingCompany) { + this(); + this.landingCompany = landingCompany; + } + + public String getActiveSymbols() { + return activeSymbols; + } + + public void setActiveSymbols(String activeSymbols) { + this.activeSymbols = activeSymbols; + } + + public String getLandingCompany() { + return landingCompany; + } + + public void setLandingCompany(String landingCompany) { + this.landingCompany = landingCompany; + } + + public String getProductType() { + return productType; + } + + public void setProductType(String productType) { + this.productType = productType; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/requests/ApiTokenManagementRequest.java b/Trading/src/main/java/com/suneesh/trading/models/requests/ApiTokenManagementRequest.java new file mode 100644 index 0000000..03451f4 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/requests/ApiTokenManagementRequest.java @@ -0,0 +1,122 @@ +package com.suneesh.trading.models.requests; + +import com.suneesh.trading.models.enums.Scopes; +import com.suneesh.trading.models.responses.ApiTokenManagementResponse; +import com.suneesh.trading.utils.Validator; +import com.google.gson.annotations.SerializedName; +import com.google.gson.internal.ObjectConstructor; + +import java.util.List; +import java.util.stream.Collectors; + +/** + *

ApiTokenManagementRequest

+ * + *

API Token Request

+ *

+ * This call manages API tokens + *

+ * + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/9/2017 + */ +public class ApiTokenManagementRequest extends RequestBase { + + @SerializedName("api_token") + private final int apiToken = 1; + + /** + * The name of the created token + */ + @SerializedName("new_token") + private String newToken; + + + @SerializedName("new_token_scopes") + private List newTokenScopes; + + /** + * Optional field, if you set this parameter during token creation, + * then the token created will only work for the IP address that was used to create the token + */ + @SerializedName("valid_for_current_ip_only") + private int isValidForCurrentIpOnly; + + /** + * The token to remove + */ + @SerializedName("delete_token") + private String deleteToken; + + /** + * [For omnibus accounts only] Loginid of sub account. + * If this field is present then it will create token for this sub account. + */ + @SerializedName("sub_account") + private String subAccount; + + public ApiTokenManagementRequest() { + this.responseType = ApiTokenManagementResponse.class; + } + + public ApiTokenManagementRequest(String newToken, List scopes) { + this(); + this.setNewToken(newToken); + this.setNewTokenScopes(scopes); + } + + public ApiTokenManagementRequest(String newToken, List scopes, String subAccount) { + this(); + this.setNewToken(newToken); + this.setNewTokenScopes(scopes); + this.setSubAccount(subAccount); + } + + public ApiTokenManagementRequest(String deleteToken) { + this(); + this.setDeleteToken(deleteToken); + } + + public String getNewToken() { + return newToken; + } + + public void setNewToken(String newToken) { + Validator.checkPattern("^[\\w\\s]+$", newToken, + "New Token name does not match the regex pattern /^[\\w\\s]+$/"); + this.newToken = newToken; + } + + public List getNewTokenScopes() { + return newTokenScopes; + } + + public void setNewTokenScopes(List newTokenScopes) { + this.newTokenScopes = newTokenScopes.stream().map(Object::toString).collect(Collectors.toList()); + } + + public int getIsValidForCurrentIpOnly() { + return isValidForCurrentIpOnly; + } + + public void setIsValidForCurrentIpOnly(int isValidForCurrentIpOnly) { + this.isValidForCurrentIpOnly = isValidForCurrentIpOnly; + } + + public String getDeleteToken() { + return deleteToken; + } + + public void setDeleteToken(String deleteToken) { + this.deleteToken = deleteToken; + } + + public String getSubAccount() { + return subAccount; + } + + public void setSubAccount(String subAccount) { + this.subAccount = subAccount; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/requests/ApplicationDeletionRequest.java b/Trading/src/main/java/com/suneesh/trading/models/requests/ApplicationDeletionRequest.java new file mode 100644 index 0000000..a4e86fe --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/requests/ApplicationDeletionRequest.java @@ -0,0 +1,39 @@ +package com.suneesh.trading.models.requests; + +import com.suneesh.trading.models.responses.ApplicationDeletionResponse; +import com.suneesh.trading.utils.Validator; +import com.google.gson.annotations.SerializedName; +import io.reactivex.annotations.Nullable; + +/** + *

ApplicationDeletionRequest

+ * + *

App Delete Send

+ * + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/20/2017 + */ +public class ApplicationDeletionRequest extends RequestBase { + + /** + * Framework app_id + */ + @SerializedName("app_delete") + @Nullable + private Long appId; + + public ApplicationDeletionRequest(Long appId) { + this.responseType = ApplicationDeletionResponse.class; + this.setAppId(appId); + } + + public Long getAppId() { + return appId; + } + + public void setAppId(Long appId) { + Validator.checkPattern("^\\d{1,20}$", appId.toString(), "Applicaiton ID does not match the regex pattern /^\\d{1,20}$/"); + this.appId = appId; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/requests/ApplicationDetailsRequest.java b/Trading/src/main/java/com/suneesh/trading/models/requests/ApplicationDetailsRequest.java new file mode 100644 index 0000000..0570e08 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/requests/ApplicationDetailsRequest.java @@ -0,0 +1,33 @@ +package com.suneesh.trading.models.requests; + +import com.suneesh.trading.models.responses.ApplicationDetailsResponse; +import com.google.gson.annotations.SerializedName; + +/** + *

ApplicationDetailsRequest

+ * + *

App Get Send

+ *

get created OAuth application by app_id

+ * + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/27/2017 + */ +public class ApplicationDetailsRequest extends RequestBase { + + @SerializedName("app_get") + private Long applicationId; + + public ApplicationDetailsRequest(Long applicationId) { + this.responseType = ApplicationDetailsResponse.class; + this.setApplicationId(applicationId); + } + + public Long getApplicationId() { + return applicationId; + } + + public void setApplicationId(Long applicationId) { + this.applicationId = applicationId; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/requests/ApplicationListRequest.java b/Trading/src/main/java/com/suneesh/trading/models/requests/ApplicationListRequest.java new file mode 100644 index 0000000..d53fc60 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/requests/ApplicationListRequest.java @@ -0,0 +1,28 @@ +package com.suneesh.trading.models.requests; + +import com.suneesh.trading.models.responses.ApplicationListResponse; +import com.google.gson.annotations.SerializedName; + +/** + *

ApplicationListRequest

+ * + *

App List Send

+ *

List all my OAuth application

+ * + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/24/2017 + */ +public class ApplicationListRequest extends RequestBase { + + @SerializedName("app_list") + private final int appList = 1; + + public ApplicationListRequest() { + this.responseType = ApplicationListResponse.class; + } + + public int getAppList() { + return appList; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/requests/ApplicationRegistrationRequest.java b/Trading/src/main/java/com/suneesh/trading/models/requests/ApplicationRegistrationRequest.java new file mode 100644 index 0000000..3bc4fdc --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/requests/ApplicationRegistrationRequest.java @@ -0,0 +1,208 @@ +package com.suneesh.trading.models.requests; + +import com.suneesh.trading.models.enums.Scopes; +import com.suneesh.trading.models.responses.ApplicationRegistrationResponse; +import com.suneesh.trading.utils.Validator; +import com.google.gson.annotations.SerializedName; + +import java.math.BigDecimal; +import java.util.List; +import java.util.stream.Collectors; + +/** + *

ApplicationRegistrationRequest

+ * + *

Framework Register Send

+ *

+ * Register a new OAuth application + *

+ * + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/9/2017 + */ +public class ApplicationRegistrationRequest extends RequestBase { + + /** + * Must be 1 + * + */ + @SerializedName("app_register") + private final int appRegister = 1; + + /** + * Framework name + * + */ + @SerializedName("name") + private String name; + + @SerializedName("scopes") + private List scopes = null; + + /** + * Framework's homepage + * + */ + @SerializedName("homepage") + private String homepageUrl; + + /** + * Framework's GitHub page (for open-source projects) + * + */ + @SerializedName("github") + private String githubUrl; + + /** + * Framework's App Store URL (if applicable) + * + */ + @SerializedName("appstore") + private String appStoreUrl; + + /** + * Framework's Google Play URL (if applicable) + * + */ + @SerializedName("googleplay") + private String googlePlayUrl; + + /** + * Framework redirect_uri + * + */ + @SerializedName("redirect_uri") + private String redirectUri; + + /** + * Framework verification_uri + * + */ + @SerializedName("verification_uri") + private String verificationUri; + + /** + * Markup to be added to contract prices (as a percentage of contract payout). Min: 0, Max: 5 + * + */ + @SerializedName("app_markup_percentage") + private BigDecimal appMarkupPercentage; + + private ApplicationRegistrationRequest() { + this.responseType = ApplicationRegistrationResponse.class; + } + + public ApplicationRegistrationRequest(String name, List scopes, String redirectUri) { + this(); + this.setName(name); + this.setScopes(scopes); + this.setRedirectUri(redirectUri); + } + + public ApplicationRegistrationRequest(String name, List scopes, String homepageUrl, + String githubUrl, String appStoreUrl, String googlePlayUrl, + String redirectUri, String verificationUri, + BigDecimal appMarkupPercentage) { + this(); + this.setName(name); + this.setScopes(scopes); + this.setHomepageUrl(homepageUrl); + this.setGithubUrl(githubUrl); + this.setAppStoreUrl(appStoreUrl); + this.setGooglePlayUrl(googlePlayUrl); + this.setRedirectUri(redirectUri); + this.setVerificationUri(verificationUri); + this.setAppMarkupPercentage(appMarkupPercentage); + } + + public String getName() { + return name; + } + + public void setName(String name) { + Validator.checkPattern("^[\\w\\s-]{1,48}$", name, + "Name does not match the regex pattern /^[\\w\\s-]{1,48}$/"); + this.name = name; + } + + public List getScopes() { + return scopes; + } + + public void setScopes(List scopes) { + this.scopes = scopes.stream().map(Object::toString).collect(Collectors.toList()); + } + + public String getHomepageUrl() { + return homepageUrl; + } + + public void setHomepageUrl(String homepageUrl) { + Validator.checkPattern("^https?://[0-9a-zA-Z\\.-]+[\\%\\/\\w \\.-]*$", homepageUrl, + "Homepage Url does not match the regex pattern /^https?://[0-9a-zA-Z\\.-]+[\\%\\/\\w \\.-]*$/"); + this.homepageUrl = homepageUrl; + } + + public String getGithubUrl() { + Validator.checkPattern("^https?://[0-9a-zA-Z\\.-]+[\\%\\/\\w \\.-]*$", githubUrl, + "Github Url does not match the regex pattern /^https?://[0-9a-zA-Z\\.-]+[\\%\\/\\w \\.-]*$/"); + return githubUrl; + } + + public void setGithubUrl(String githubUrl) { + Validator.checkPattern("^https?://[0-9a-zA-Z\\.-]+[\\%\\/\\w \\.-]*$", githubUrl, + "Github Url does not match the regex pattern /^https?://[0-9a-zA-Z\\.-]+[\\%\\/\\w \\.-]*$/"); + this.githubUrl = githubUrl; + } + + public String getAppStoreUrl() { + return appStoreUrl; + } + + public void setAppStoreUrl(String appStoreUrl) { + Validator.checkPattern("^https?://[0-9a-zA-Z\\.-]+[\\%\\/\\w \\.-]*$", appStoreUrl, + "AppStore Url does not match the regex pattern /^https?://[0-9a-zA-Z\\.-]+[\\%\\/\\w \\.-]*$/"); + this.appStoreUrl = appStoreUrl; + } + + public String getGooglePlayUrl() { + return googlePlayUrl; + } + + public void setGooglePlayUrl(String googlePlayUrl) { + Validator.checkPattern("^https?://[0-9a-zA-Z\\.-]+[\\%\\/\\w \\.-]*$", googlePlayUrl, + "GooglePlay Url does not match the regex pattern /^https?://[0-9a-zA-Z\\.-]+[\\%\\/\\w \\.-]*$/"); + this.googlePlayUrl = googlePlayUrl; + } + + public String getRedirectUri() { + return redirectUri; + } + + public void setRedirectUri(String redirectUri) { + Validator.checkPattern("^https?://[0-9a-zA-Z\\.-]+[\\%\\/\\w \\.-]*$", redirectUri, + "Redirect Uri does not match the regex pattern /^https?://[0-9a-zA-Z\\.-]+[\\%\\/\\w \\.-]*$/"); + this.redirectUri = redirectUri; + } + + public String getVerificationUri() { + return verificationUri; + } + + public void setVerificationUri(String verificationUri) { + Validator.checkPattern("^https?://[0-9a-zA-Z\\.-]+[\\%\\/\\w \\.-]*$", githubUrl, + "Verification Uri does not match the regex pattern /^https?://[0-9a-zA-Z\\.-]+[\\%\\/\\w \\.-]*$/"); + this.verificationUri = verificationUri; + } + + public BigDecimal getAppMarkupPercentage() { + return appMarkupPercentage; + } + + public void setAppMarkupPercentage(BigDecimal appMarkupPercentage) { + Validator.checkPattern("^([0-4](\\.[0-9][0-9]?)?|5(\\.00?)?)$", appMarkupPercentage.toString(), + "App Markup Percentage does not match the regex"); + this.appMarkupPercentage = appMarkupPercentage; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/requests/ApplicationUpdateRequest.java b/Trading/src/main/java/com/suneesh/trading/models/requests/ApplicationUpdateRequest.java new file mode 100644 index 0000000..f1aca0e --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/requests/ApplicationUpdateRequest.java @@ -0,0 +1,188 @@ +package com.suneesh.trading.models.requests; + +import com.suneesh.trading.models.enums.Scopes; +import com.suneesh.trading.models.responses.ApplicationUpdateResponse; +import com.google.gson.annotations.SerializedName; + +import java.math.BigDecimal; +import java.util.List; +import java.util.stream.Collectors; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/27/2017 + */ +public class ApplicationUpdateRequest extends RequestBase { + + @SerializedName("app_update") + private Long applicationId; + + /** + * Framework name + * + */ + @SerializedName("name") + private String name; + + @SerializedName("scopes") + private List scopes = null; + + /** + * Framework's homepage + * + */ + @SerializedName("homepage") + private String homepageUrl; + + /** + * Framework's GitHub page (for open-source projects) + * + */ + @SerializedName("github") + private String githubUrl; + + /** + * Framework's App Store URL (if applicable) + * + */ + @SerializedName("appstore") + private String appStoreUrl; + + /** + * Framework's Google Play URL (if applicable) + * + */ + @SerializedName("googleplay") + private String googlePlayUrl; + + /** + * Framework redirect_uri + * + */ + @SerializedName("redirect_uri") + private String redirectUri; + + /** + * Framework verification_uri + * + */ + @SerializedName("verification_uri") + private String verificationUri; + + /** + * Markup to be added to contract prices (as a percentage of contract payout). Min: 0, Max: 5 + * + */ + @SerializedName("app_markup_percentage") + private BigDecimal appMarkupPercentage; + + private ApplicationUpdateRequest() { + this.responseType = ApplicationUpdateResponse.class; + } + + public ApplicationUpdateRequest(Long applicationId, String name, List scopes, String redirectUri) { + this(); + this.setApplicationId(applicationId); + this.setName(name); + this.setScopes(scopes); + this.setRedirectUri(redirectUri); + } + + public ApplicationUpdateRequest(Long applicationId, String name, List scopes, String homepageUrl, + String githubUrl, String appStoreUrl, String googlePlayUrl, + String redirectUri, String verificationUri, + BigDecimal appMarkupPercentage) { + this(); + this.setApplicationId(applicationId); + this.setName(name); + this.setScopes(scopes); + this.setHomepageUrl(homepageUrl); + this.setGithubUrl(githubUrl); + this.setAppStoreUrl(appStoreUrl); + this.setGooglePlayUrl(googlePlayUrl); + this.setRedirectUri(redirectUri); + this.setVerificationUri(verificationUri); + this.setAppMarkupPercentage(appMarkupPercentage); + } + + public Long getApplicationId() { + return applicationId; + } + + public void setApplicationId(Long applicationId) { + this.applicationId = applicationId; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public List getScopes() { + return scopes; + } + + public void setScopes(List scopes) { + this.scopes = scopes.stream().map(Object::toString).collect(Collectors.toList()); + } + + public String getHomepageUrl() { + return homepageUrl; + } + + public void setHomepageUrl(String homepageUrl) { + this.homepageUrl = homepageUrl; + } + + public String getGithubUrl() { + return githubUrl; + } + + public void setGithubUrl(String githubUrl) { + this.githubUrl = githubUrl; + } + + public String getAppStoreUrl() { + return appStoreUrl; + } + + public void setAppStoreUrl(String appStoreUrl) { + this.appStoreUrl = appStoreUrl; + } + + public String getGooglePlayUrl() { + return googlePlayUrl; + } + + public void setGooglePlayUrl(String googlePlayUrl) { + this.googlePlayUrl = googlePlayUrl; + } + + public String getRedirectUri() { + return redirectUri; + } + + public void setRedirectUri(String redirectUri) { + this.redirectUri = redirectUri; + } + + public String getVerificationUri() { + return verificationUri; + } + + public void setVerificationUri(String verificationUri) { + this.verificationUri = verificationUri; + } + + public BigDecimal getAppMarkupPercentage() { + return appMarkupPercentage; + } + + public void setAppMarkupPercentage(BigDecimal appMarkupPercentage) { + this.appMarkupPercentage = appMarkupPercentage; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/requests/AssetIndexRequest.java b/Trading/src/main/java/com/suneesh/trading/models/requests/AssetIndexRequest.java new file mode 100644 index 0000000..c7ab0c1 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/requests/AssetIndexRequest.java @@ -0,0 +1,53 @@ +package com.suneesh.trading.models.requests; + +import com.suneesh.trading.models.responses.AssetIndexResponse; +import com.google.gson.annotations.SerializedName; +import io.reactivex.annotations.Nullable; + +/** + *

AssetIndexRequest

+ * + *

Asset Index Send

+ *

Retrieve the Asset Index: a list of all available markets and a summary of the contracts available thereupon.

+ * + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 7/31/2017 + */ +public class AssetIndexRequest extends RequestBase { + + @SerializedName("asset_index") + private final int assetIndex = 1; + + /** + * Optional landing company field. If specified, will return only the markets + * and contracts that this landing company can trade. + */ + @SerializedName("landing_company") + @Nullable + private String landingCompany; + + public AssetIndexRequest(){ + this.responseType = AssetIndexResponse.class; + } + + public AssetIndexRequest(String landingCompany) { + this(); + this.landingCompany = landingCompany; + } + + /** + * {@link AssetIndexRequest#landingCompany} + */ + public String getLandingCompany() { + return landingCompany; + } + + /** + * {@link AssetIndexRequest#landingCompany} + * @param landingCompany + */ + public void setLandingCompany(String landingCompany) { + this.landingCompany = landingCompany; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/requests/AuthorizeRequest.java b/Trading/src/main/java/com/suneesh/trading/models/requests/AuthorizeRequest.java new file mode 100644 index 0000000..f4b97cd --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/requests/AuthorizeRequest.java @@ -0,0 +1,45 @@ +package com.suneesh.trading.models.requests; + +import com.suneesh.trading.models.responses.AuthorizeResponse; +import com.google.gson.annotations.SerializedName; + +/** + * Created by morteza on 7/28/2017. + */ +public class AuthorizeRequest extends RequestBase { + @SerializedName("authorize") + private String authorize; + + @SerializedName("add_to_login_history") + private int addToLoginHistory; + + private AuthorizeRequest(){ + this.responseType = AuthorizeResponse.class; + } + + public AuthorizeRequest(String token){ + this(token, false); + } + + public AuthorizeRequest(String token, boolean addToLoginHistoy){ + this(); + this.authorize = token; + this.addToLoginHistory = addToLoginHistoy ? 1 : 0; + } + + public String getAuthorize() { + return authorize; + } + + public void setAuthorize(String authorize) { + this.authorize = authorize; + } + + public int getAddToLoginHistory() { + return addToLoginHistory; + } + + public void setAddToLoginHistory(int addToLoginHistory) { + this.addToLoginHistory = addToLoginHistory; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/requests/BalanceRequest.java b/Trading/src/main/java/com/suneesh/trading/models/requests/BalanceRequest.java new file mode 100644 index 0000000..3e77ddb --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/requests/BalanceRequest.java @@ -0,0 +1,45 @@ +package com.suneesh.trading.models.requests; + +import com.suneesh.trading.models.responses.BalanceResponse; +import com.google.gson.annotations.SerializedName; +import io.reactivex.annotations.Nullable; + +/** + *

BalanceRequest

+ * + *

Balance Send

+ *

Get user account balance

+ * + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/4/2017 + */ +public class BalanceRequest extends RequestBase { + + @SerializedName("balance") + private final int balance = 1; + + /** + * Optional field, used to pass data through the websocket, which may be retrieved via the echo_req output field. + */ + @SerializedName("subscribe") + @Nullable + private Integer subscribe; + + public BalanceRequest() { + this.responseType = BalanceResponse.class; + } + + public BalanceRequest(boolean subscribe){ + this(); + this.setSubscribe(subscribe); + } + + public boolean getSubscribe() { + return subscribe == 1 ? true : false; + } + + public void setSubscribe(boolean subscribe) { + this.subscribe = subscribe ? 1 : null; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/requests/BuyContractForMultipleAccountsRequest.java b/Trading/src/main/java/com/suneesh/trading/models/requests/BuyContractForMultipleAccountsRequest.java new file mode 100644 index 0000000..89aa6ea --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/requests/BuyContractForMultipleAccountsRequest.java @@ -0,0 +1,96 @@ +package com.suneesh.trading.models.requests; + +import com.suneesh.trading.models.responses.BuyContractForMultipleAccountsResponse; +import com.suneesh.trading.utils.Validator; +import com.google.gson.annotations.SerializedName; + +import java.math.BigDecimal; +import java.util.List; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/8/2017 + */ +public class BuyContractForMultipleAccountsRequest extends RequestBase { + + /** + * Either the id received from a Price Proposal (proposal) call, or 1 if contract buy parameters are passed in the parameters field + */ + @SerializedName("buy_contract_for_multiple_accounts") + private String proposalId; + + /** + * Maximum price at which to purchase the contract. + */ + @SerializedName("price") + private BigDecimal price; + + /** + * API tokens identifying the accounts for which the contract is bought. + * Note, if the same token appears multiple times or if multiple tokens designate the same account, the contract is bought multiple times for this account. + */ + @SerializedName("tokens") + private List tokens; + + /** + * Optional field, used to pass the parameters for contract buy + */ + @SerializedName("parameters") + private BuyContractParameters parameters; + + private BuyContractForMultipleAccountsRequest() { + this.responseType = BuyContractForMultipleAccountsResponse.class; + } + + public BuyContractForMultipleAccountsRequest(BigDecimal price , + BuyContractParameters parameters, List tokens) { + this(); + this.proposalId = "1"; + this.setPrice(price); + this.setTokens(tokens); + this.setParameters(parameters); + } + + public BuyContractForMultipleAccountsRequest(String proposalId, BigDecimal price, List tokens) { + this(); + this.setProposalId(proposalId); + this.setPrice(price); + this.setTokens(tokens); + + } + + public String getProposalId() { + return proposalId; + } + + public void setProposalId(String proposalId) { + Validator.checkPattern("^(?:[\\w-]{32,128}|1)$", proposalId, + "Proposal Id does not match the regex pattern /^(?:[\\w-]{32,128}|1)$/"); + this.proposalId = proposalId; + } + + public BigDecimal getPrice() { + return price; + } + + public void setPrice(BigDecimal price) { + this.price = price; + } + + public List getTokens() { + return tokens; + } + + public void setTokens(List tokens) { + this.tokens = tokens; + } + + public BuyContractParameters getParameters() { + return parameters; + } + + public void setParameters(BuyContractParameters parameters) { + this.parameters = parameters; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/requests/BuyContractParameters.java b/Trading/src/main/java/com/suneesh/trading/models/requests/BuyContractParameters.java new file mode 100644 index 0000000..e3208ff --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/requests/BuyContractParameters.java @@ -0,0 +1,205 @@ +package com.suneesh.trading.models.requests; + +import com.suneesh.trading.models.enums.BasisTypes; +import com.suneesh.trading.models.enums.DurationUnits; +import com.suneesh.trading.utils.Validator; +import com.google.gson.annotations.SerializedName; + +import java.math.BigDecimal; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/8/2017 + */ +public class BuyContractParameters { + + /** + * Proposed payout or stake value + * + */ + @SerializedName("amount") + private BigDecimal amount; + + /** + * Indicate whether amount is 'payout' or 'stake' + * + */ + @SerializedName("basis") + private String basis; + + /** + * A valid contract-type + * + */ + @SerializedName("contract_type") + private String contractType; + + /** + * This can only be the account-holder's currency + * + */ + @SerializedName("currency") + private String currency; + + /** + * For forward-starting contracts, epoch value of the starting time of the contract. + * + */ + @SerializedName("date_start") + private Long dateStart; + + /** + * Epoch value of the expiry time of the contract. You must either specify date_expiry or duration. + * + */ + @SerializedName("date_expiry") + private Long dateExpiry; + + /** + * Duration quantity + * + */ + @SerializedName("duration") + private Integer duration; + + /** + * Duration unit is s(seconds), m(minutes), h(hours), d(days), t(ticks) + */ + @SerializedName("duration_unit") + private String durationUnit; + + /** + * Symbol code + * + */ + @SerializedName("symbol") + private String symbol; + + /** + * Barrier for the contract (or last digit prediction for digit contracts). Contracts less than 24 hours in duration would need a relative barrier (barriers which need +/-), meaning that the entry spot would be adjusted accordingly with that amount to define a barrier. + * + */ + @SerializedName("barrier") + private String barrier; + + /** + * Low barrier for the contract (for contracts with two barriers). Contracts less than 24 hours in duration would need a relative barrier (barriers which need +/-), meaning that the entry spot would be adjusted accordingly with that amount to define a barrier. + * + */ + @SerializedName("barrier2") + private String barrier2; + + /** + * [For japan only] An epoch value of a predefined trading period start time + * + */ + @SerializedName("trading_period_start") + private Long tradingPeriodStart; + + public BigDecimal getAmount() { + return amount; + } + + public void setAmount(BigDecimal amount) { + this.amount = amount; + } + + public String getBasis() { + return basis; + } + + public void setBasis(BasisTypes basis) { + this.basis = basis.toString(); + } + + public String getContractType() { + return contractType; + } + + public void setContractType(String contractType) { + Validator.checkPattern("^\\w{2,30}$", contractType, + "Contract Type does not match the regex pattern /^\\w{2,30}$/"); + this.contractType = contractType; + } + + public String getCurrency() { + return currency; + } + + public void setCurrency(String currency) { + Validator.checkPattern("^[A-Z]{3}$", contractType, + "Currency does not match the regex pattern /^[A-Z]{3}$/"); + this.currency = currency; + } + + public Long getDateStart() { + return dateStart; + } + + public void setDateStart(Long dateStart) { + this.dateStart = dateStart; + } + + public Long getDateExpiry() { + return dateExpiry; + } + + public void setDateExpiry(Long dateExpiry) { + this.dateExpiry = dateExpiry; + } + + public Integer getDuration() { + return duration; + } + + public void setDuration(Integer duration) { + this.duration = duration; + } + + public String getDurationUnit() { + return durationUnit; + } + + public void setDurationUnit(DurationUnits durationUnit) { + this.durationUnit = durationUnit.toString(); + } + + public String getSymbol() { + return symbol; + } + + public void setSymbol(String symbol) { + Validator.checkPattern("^\\w{2,30}", contractType, + "Symbol does not match the regex pattern /^\\w{2,30}/"); + this.symbol = symbol; + } + + public String getBarrier() { + return barrier; + } + + public void setBarrier(String barrier) { + Validator.checkPattern("^[+-]?\\d+\\.?\\d*$", contractType, + "Barrier does not match the regex pattern /^[+-]?\\d+\\.?\\d*$/"); + this.barrier = barrier; + } + + public String getBarrier2() { + return barrier2; + } + + public void setBarrier2(String barrier2) { + Validator.checkPattern("^[+-]?\\d+\\.?\\d*$", contractType, + "Barrier2 does not match the regex pattern /^[+-]?\\d+\\.?\\d*$/"); + this.barrier2 = barrier2; + } + + public Long getTradingPeriodStart() { + return tradingPeriodStart; + } + + public void setTradingPeriodStart(Long tradingPeriodStart) { + this.tradingPeriodStart = tradingPeriodStart; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/requests/BuyContractRequest.java b/Trading/src/main/java/com/suneesh/trading/models/requests/BuyContractRequest.java new file mode 100644 index 0000000..d47a0ff --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/requests/BuyContractRequest.java @@ -0,0 +1,95 @@ +package com.suneesh.trading.models.requests; + +import com.suneesh.trading.models.responses.BuyContractResponse; +import com.suneesh.trading.utils.Validator; +import com.google.gson.annotations.SerializedName; +import lombok.Data; + +import java.math.BigDecimal; + +/** + *

BuyContractRequest

+ * + *

Buy a Contract Send

+ *

+ * Buy a Contract + *

+ * + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/8/2017 + */ +@Data +public class BuyContractRequest extends RequestBase { + + /** + * Either the id received from a Price Proposal (proposal) call, or 1 if contract proposalId parameters are passed in the parameters field + */ + @SerializedName("buy") + private String proposalId; + + /** + * Maximum price at which to purchase the contract. + */ + @SerializedName("price") + private BigDecimal price; + + /** + * Optional field, used to pass the parameters for contract proposalId + */ + @SerializedName("parameters") + private BuyContractParameters parameters; + + + private BuyContractRequest() { + this.responseType = BuyContractResponse.class; + } + + public BuyContractRequest(BigDecimal price , BuyContractParameters parameters, Long req_id) { + this(); + this.proposalId = "1"; + this.setPrice(price); + this.setParameters(parameters); + id = Integer.valueOf(Math.toIntExact(req_id)); + } + + public BuyContractRequest(BigDecimal price , BuyContractParameters parameters) { + this(); + this.proposalId = "1"; + this.setPrice(price); + this.setParameters(parameters); + } + + public BuyContractRequest(String proposalId, BigDecimal price) { + this(); + this.setProposalId(proposalId); + this.setPrice(price); + + } + + public String getProposalId() { + return proposalId; + } + + public void setProposalId(String proposalId) { + Validator.checkPattern("^(?:[\\w-]{32,128}|1)$", proposalId, + "Proposal Id does not match the regex pattern /^(?:[\\w-]{32,128}|1)$/"); + this.proposalId = proposalId; + } + + public BigDecimal getPrice() { + return price; + } + + public void setPrice(BigDecimal price) { + this.price = price; + } + + public BuyContractParameters getParameters() { + return parameters; + } + + public void setParameters(BuyContractParameters parameters) { + this.parameters = parameters; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/requests/CashierPasswordRequest.java b/Trading/src/main/java/com/suneesh/trading/models/requests/CashierPasswordRequest.java new file mode 100644 index 0000000..93a0371 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/requests/CashierPasswordRequest.java @@ -0,0 +1,51 @@ +package com.suneesh.trading.models.requests; + +import com.suneesh.trading.models.responses.CashierPasswordResponse; +import com.google.gson.annotations.SerializedName; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 9/14/2017 + */ +public class CashierPasswordRequest extends RequestBase { + + /** + * if neither lock_password nor unlock_password is passed, we'll just return the status for cashier + */ + @SerializedName("cashier_password") + private final String password = "1"; + + /** + * old password to unlock cashier, required for unlock + * (length within 6-25 chars, accepts any printable ASCII character) + */ + @SerializedName("unlock_password") + private String unlockPassword; + + /** + * new password to lock cashier, required for lock (length within 6-25 chars, accepts any printable ASCII character) + */ + @SerializedName("lock_password") + private String lockPassword; + + public CashierPasswordRequest() { + this.responseType = CashierPasswordResponse.class; + } + + public String getUnlockPassword() { + return unlockPassword; + } + + public void setUnlockPassword(String unlockPassword) { + this.unlockPassword = unlockPassword; + } + + public String getLockPassword() { + return lockPassword; + } + + public void setLockPassword(String lockPassword) { + this.lockPassword = lockPassword; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/requests/CashierURLRequest.java b/Trading/src/main/java/com/suneesh/trading/models/requests/CashierURLRequest.java new file mode 100644 index 0000000..f84942e --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/requests/CashierURLRequest.java @@ -0,0 +1,61 @@ +package com.suneesh.trading.models.requests; + +import com.suneesh.trading.models.enums.CashierProviders; +import com.suneesh.trading.models.enums.CashierTypes; +import com.suneesh.trading.models.responses.CashierURLResponse; +import com.google.gson.annotations.SerializedName; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 9/14/2017 + */ +public class CashierURLRequest extends RequestBase { + + /** + * either deposit or withdraw, default to deposit + */ + @SerializedName("cashier") + private String cashier; + + /** + * Note only doughflow is supported currently, epg is only for test. + */ + @SerializedName("provider") + private String provider; + + /** + * Email verification code (received from a verify_email call, which must be done first) + */ + @SerializedName("verification_code") + private String verificationCode; + + public CashierURLRequest(CashierTypes type) { + this.responseType = CashierURLResponse.class; + this.setCashier(type); + } + + public String getCashier() { + return cashier; + } + + public void setCashier(CashierTypes cashier) { + this.cashier = cashier.toString(); + } + + public String getProvider() { + return provider; + } + + public void setProvider(CashierProviders provider) { + this.provider = provider.toString(); + } + + public String getVerificationCode() { + return verificationCode; + } + + public void setVerificationCode(String verificationCode) { + this.verificationCode = verificationCode; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/requests/ContractsForSymbolRequest.java b/Trading/src/main/java/com/suneesh/trading/models/requests/ContractsForSymbolRequest.java new file mode 100644 index 0000000..b98b597 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/requests/ContractsForSymbolRequest.java @@ -0,0 +1,99 @@ +package com.suneesh.trading.models.requests; + +import com.suneesh.trading.models.responses.ContractsForSymbolResponse; +import com.suneesh.trading.utils.Validator; +import com.google.gson.annotations.SerializedName; +import io.reactivex.annotations.Nullable; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/1/2017 + */ +public class ContractsForSymbolRequest extends RequestBase { + + /** + * The short symbol name + */ + @SerializedName("contracts_for") + private String symbol; + + /** + * Currency for the contracts stake and payout. Optional field, defaults to USD if not passed in. + */ + @SerializedName("currency") + @Nullable + private String currency; + + /** + * Set to 'multi_barrier' to get a list of contracts with predefined trading windows and barriers for a given symbol. + * Default to 'basic' + */ + @SerializedName("product_type") + @Nullable + private String productType; + + /** + * Optional landing_company field. Set to a specific landing company + * if you want to get a list of contracts for a specific landing company. Default to costarica. + + */ + @SerializedName("landing_company") + @Nullable + private String landingCompany; + + public ContractsForSymbolRequest(String symbol) { + this.symbol = symbol; + this.responseType = ContractsForSymbolResponse.class; + } + + public ContractsForSymbolRequest(String symbol, String landingCompany){ + this(symbol); + this.landingCompany = landingCompany; + } + + public ContractsForSymbolRequest(String symbol, String landingCompany, String currency){ + this(symbol, landingCompany); + this.currency = currency; + } + + public ContractsForSymbolRequest(String symbol, String landingCompany, String currency, String productType){ + this(symbol, landingCompany, currency); + this.productType = productType; + } + + public String getSymbol() { + return symbol; + } + + public void setSymbol(String symbol) { + Validator.checkPattern("^\\w{2,30}$", symbol,"Symbol does not match the regex pattern \\^\\w{2,30}$\\"); + this.symbol = symbol; + } + + public String getCurrency() { + return currency; + } + + public void setCurrency(String currency) { + Validator.checkPattern("^[A-Z]{3}$", symbol,"Currency does not match the regex pattern \\^[A-Z]{3}$\\"); + this.currency = currency; + } + + public String getProductType() { + return productType; + } + + public void setProductType(String productType) { + Validator.checkPattern("^(basic|multi_barrier)$", symbol,"ProductType does not match the regex pattern \\^[A-Z]{3}$\\"); + this.productType = productType; + } + + public String getLandingCompany() { + return landingCompany; + } + + public void setLandingCompany(String landingCompany) { + this.landingCompany = landingCompany; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/requests/CreateMaltaAccountRequest.java b/Trading/src/main/java/com/suneesh/trading/models/requests/CreateMaltaAccountRequest.java new file mode 100644 index 0000000..3500288 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/requests/CreateMaltaAccountRequest.java @@ -0,0 +1,594 @@ +package com.suneesh.trading.models.requests; + +import com.suneesh.trading.models.enums.*; +import com.suneesh.trading.models.responses.CreateMaltaAccountResponse; +import com.google.gson.annotations.SerializedName; +import com.suneesh.trading.models.enums.*; +import io.reactivex.annotations.Nullable; + +/** + *

CreateMaltaAccountRequest

+ * + *

Create maltainvest account Send

+ *

+ * This call opens a new real-money account with the 'maltainvest' Landing Company. + * Note: you must be authenticated to Binary (Europe) Ltd or virtual-money account to call this function. + *

+ * + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/31/2017 + */ +public class CreateMaltaAccountRequest extends RequestBase { + + @SerializedName("new_account_maltainvest") + private final int newAccountMaltaInvest = 1; + + /** + * Accept any value in enum list. + */ + @SerializedName("salutation") + private String salutation; + + /** + * Within 2-30 characters, use only letters, spaces, hyphens, full-stops or apostrophes. + */ + @SerializedName("first_name") + private String firstName; + + /** + * Within 2-30 characters, use only letters, spaces, hyphens, full-stops or apostrophes. + */ + @SerializedName("last_name") + private String lastName; + + /** + * Date of birth format: yyyy-mm-dd. + */ + @SerializedName("data_of_birth") + private String dateOfBirth; + + /** + * 2-letter country code, possible value receive from residence_list call. + */ + @SerializedName("residence") + private String residence; + + /** + * Place of birth, 2-letter country code. + */ + private String placeOfBirth; + + /** + * Within 70 characters. + */ + @SerializedName("address_line_1") + private String firstAddressLine; + + /** + * Optional field, within 70 characters. + */ + @SerializedName("address_line_2") + @Nullable + private String secondAddressLine; + + /** + * Within 35 characters + */ + @SerializedName("address_city") + private String city; + + /** + * Optional field, possible value receive from states_list call. + */ + @SerializedName("address_state") + @Nullable + private String state; + + /** + * Optional field, within 20 characters and may not contain '+'. + */ + @SerializedName("address_postcode") + @Nullable + private String postcode; + + /** + * Within 6-35 digits, allowing '+' in front, numbers or space. + */ + @SerializedName("phone") + private String phone; + + /** + * Accept any value in enum list. + */ + @SerializedName("secret_question") + private String secretQuestion; + + /** + * Answer to secret question, within 4-50 characters. + */ + @SerializedName("secret_answer") + private String secretAnswer; + + /** + * Affiliate token, within 32 characters. + */ + @SerializedName("affiliate_token") + @Nullable + private String affiliateToken; + + /** + * Residence for tax purpose. Comma separated iso country code if multiple jurisdictions. + * Only applicable for real money account. Required for maltainvest landing company. + */ + @SerializedName("tax_residence") + private String taxResidence; + + /** + * Tax identification number. Only applicable for real money account. Required for maltainvest landing company. + */ + @SerializedName("tax_identification_number") + private String taxIdentificationNumber; + + /** + * Forex trading experience + */ + @SerializedName("forex_trading_experience") + private String forexTradingExperience; + + /** + * Forex trading frequency + */ + @SerializedName("forex_trading_frequency") + private String forexTradingFrequency; + + /** + * Indices trading experience + */ + @SerializedName("indices_trading_experience") + private String indicesTradingExperience; + + /** + * Indices trading frequency + */ + @SerializedName("indices_trading_frequency") + private String indicesTradingFrequency; + + /** + * Commodities trading experience + */ + @SerializedName("commodities_trading_experience") + private String commoditiesTradingExperience; + + /** + * Commodities trading frequency + */ + @SerializedName("commodities_trading_frequency") + private String commoditiesTradingFrequency; + + /** + * Stocks trading experience + */ + @SerializedName("stocks_trading_experience") + private String stocksTradingExperience; + + /** + * Stocks trading frequency + */ + @SerializedName("stocks_trading_frequency") + private String stocksTradingFrequency; + + /** + * Binary options or other financial derivatives trading experience + */ + @SerializedName("other_derivatives_trading_experience") + private String otherDerivativesTradingExperience; + + /** + * Binary options or other financial derivatives trading frequency + */ + @SerializedName("other_derivatives_trading_frequency") + private String otherDerivativesTradingFrequency; + + /** + * Other financial instruments trading experience + */ + @SerializedName("other_instruments_trading_experience") + private String otherInstrumentsTradingExperience; + + /** + * Other financial instruments trading frequency + */ + @SerializedName("other_instruments_trading_frequency") + private String otherInstrumentsTradingFrequency; + + /** + * Purpose and reason for requesting the account opening + */ + @SerializedName("account_opening_reason") + private String accountOpeningReason; + + /** + * The anticipated account turnover + */ + @SerializedName("account_turnover") + private String accountTurnover; + + /** + * Industry of Employment + */ + @SerializedName("employment_industry") + private String employmentIndustry; + + /** + * Level of Education + */ + @SerializedName("education_level") + private String educationLevel; + + /** + * Income Source + */ + @SerializedName("income_source") + private String incomeSource; + + /** + * Net Annual Income + */ + @SerializedName("net_income") + private String netIncome; + + /** + * Estimated Net Worth + */ + @SerializedName("estimated_worth") + private String estimatedWorth; + + /** + * Occupation + */ + @SerializedName("occupation") + private String occupation; + + /** + * Employment Status + */ + @SerializedName("employment_status") + private String employmentStatus; + + /** + * Source of wealth + */ + @SerializedName("source_of_wealth") + private String sourceOfWealth; + + /** + * Show whether client has accepted risk disclaimer, boolean value 1 or 0 + */ + @SerializedName("accept_risk") + private Integer acceptRisk; + + public CreateMaltaAccountRequest() { + this.responseType = CreateMaltaAccountResponse.class; + } + + public String getSalutation() { + return salutation; + } + + public void setSalutation(Salutation salutation) { + this.salutation = salutation.toString(); + } + + public String getFirstName() { + return firstName; + } + + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + public String getLastName() { + return lastName; + } + + public void setLastName(String lastName) { + this.lastName = lastName; + } + + public String getDateOfBirth() { + return dateOfBirth; + } + + public void setDateOfBirth(String dateOfBirth) { + this.dateOfBirth = dateOfBirth; + } + + public String getResidence() { + return residence; + } + + public void setResidence(String residence) { + this.residence = residence; + } + + public String getPlaceOfBirth() { + return placeOfBirth; + } + + public void setPlaceOfBirth(String placeOfBirth) { + this.placeOfBirth = placeOfBirth; + } + + public String getFirstAddressLine() { + return firstAddressLine; + } + + public void setFirstAddressLine(String firstAddressLine) { + this.firstAddressLine = firstAddressLine; + } + + public String getSecondAddressLine() { + return secondAddressLine; + } + + public void setSecondAddressLine(String secondAddressLine) { + this.secondAddressLine = secondAddressLine; + } + + public String getCity() { + return city; + } + + public void setCity(String city) { + this.city = city; + } + + public String getState() { + return state; + } + + public void setState(String state) { + this.state = state; + } + + public String getPostcode() { + return postcode; + } + + public void setPostcode(String postcode) { + this.postcode = postcode; + } + + public String getPhone() { + return phone; + } + + public void setPhone(String phone) { + this.phone = phone; + } + + public String getSecretQuestion() { + return secretQuestion; + } + + public void setSecretQuestion(SecretQuestions secretQuestion) { + this.secretQuestion = secretQuestion.toString(); + } + + public String getSecretAnswer() { + return secretAnswer; + } + + public void setSecretAnswer(String secretAnswer) { + this.secretAnswer = secretAnswer; + } + + public String getAffiliateToken() { + return affiliateToken; + } + + public void setAffiliateToken(String affiliateToken) { + this.affiliateToken = affiliateToken; + } + + public String getTaxResidence() { + return taxResidence; + } + + public void setTaxResidence(String taxResidence) { + this.taxResidence = taxResidence; + } + + public String getTaxIdentificationNumber() { + return taxIdentificationNumber; + } + + public void setTaxIdentificationNumber(String taxIdentificationNumber) { + this.taxIdentificationNumber = taxIdentificationNumber; + } + + public String getForexTradingExperience() { + return forexTradingExperience; + } + + public void setForexTradingExperience(ExperienceDuration forexTradingExperience) { + this.forexTradingExperience = forexTradingExperience.toString(); + } + + public String getForexTradingFrequency() { + return forexTradingFrequency; + } + + public void setForexTradingFrequency(TradeFrequency forexTradingFrequency) { + this.forexTradingFrequency = forexTradingFrequency.toString(); + } + + public String getIndicesTradingExperience() { + return indicesTradingExperience; + } + + public void setIndicesTradingExperience(ExperienceDuration indicesTradingExperience) { + this.indicesTradingExperience = indicesTradingExperience.toString(); + } + + public String getIndicesTradingFrequency() { + return indicesTradingFrequency; + } + + public void setIndicesTradingFrequency(TradeFrequency indicesTradingFrequency) { + this.indicesTradingFrequency = indicesTradingFrequency.toString(); + } + + public String getCommoditiesTradingExperience() { + return commoditiesTradingExperience; + } + + public void setCommoditiesTradingExperience(ExperienceDuration commoditiesTradingExperience) { + this.commoditiesTradingExperience = commoditiesTradingExperience.toString(); + } + + public String getCommoditiesTradingFrequency() { + return commoditiesTradingFrequency; + } + + public void setCommoditiesTradingFrequency(TradeFrequency commoditiesTradingFrequency) { + this.commoditiesTradingFrequency = commoditiesTradingFrequency.toString(); + } + + public String getStocksTradingExperience() { + return stocksTradingExperience; + } + + public void setStocksTradingExperience(ExperienceDuration stocksTradingExperience) { + this.stocksTradingExperience = stocksTradingExperience.toString(); + } + + public String getStocksTradingFrequency() { + return stocksTradingFrequency; + } + + public void setStocksTradingFrequency(TradeFrequency stocksTradingFrequency) { + this.stocksTradingFrequency = stocksTradingFrequency.toString(); + } + + public String getOtherDerivativesTradingExperience() { + return otherDerivativesTradingExperience; + } + + public void setOtherDerivativesTradingExperience(ExperienceDuration otherDerivativesTradingExperience) { + this.otherDerivativesTradingExperience = otherDerivativesTradingExperience.toString(); + } + + public String getOtherDerivativesTradingFrequency() { + return otherDerivativesTradingFrequency; + } + + public void setOtherDerivativesTradingFrequency(TradeFrequency otherDerivativesTradingFrequency) { + this.otherDerivativesTradingFrequency = otherDerivativesTradingFrequency.toString(); + } + + public String getOtherInstrumentsTradingExperience() { + return otherInstrumentsTradingExperience; + } + + public void setOtherInstrumentsTradingExperience(ExperienceDuration otherInstrumentsTradingExperience) { + this.otherInstrumentsTradingExperience = otherInstrumentsTradingExperience.toString(); + } + + public String getOtherInstrumentsTradingFrequency() { + return otherInstrumentsTradingFrequency; + } + + public void setOtherInstrumentsTradingFrequency(TradeFrequency otherInstrumentsTradingFrequency) { + this.otherInstrumentsTradingFrequency = otherInstrumentsTradingFrequency.toString(); + } + + public String getAccountOpeningReason() { + return accountOpeningReason; + } + + public void setAccountOpeningReason(AccountOpeningReasons accountOpeningReason) { + this.accountOpeningReason = accountOpeningReason.toString(); + } + + public String getAccountTurnover() { + return accountTurnover; + } + + public void setAccountTurnover(TurnoverRanges accountTurnover) { + this.accountTurnover = accountTurnover.toString(); + } + + public String getEmploymentIndustry() { + return employmentIndustry; + } + + public void setEmploymentIndustry(EmploymentIndustries employmentIndustry) { + this.employmentIndustry = employmentIndustry.toString(); + } + + public String getEducationLevel() { + return educationLevel; + } + + public void setEducationLevel(EducationLevels educationLevel) { + this.educationLevel = educationLevel.toString(); + } + + public String getIncomeSource() { + return incomeSource; + } + + public void setIncomeSource(IncomeSources incomeSource) { + this.incomeSource = incomeSource.toString(); + } + + public String getNetIncome() { + return netIncome; + } + + public void setNetIncome(TurnoverRanges netIncome) { + this.netIncome = netIncome.toString(); + } + + public String getEstimatedWorth() { + return estimatedWorth; + } + + public void setEstimatedWorth(WorthRanges estimatedWorth) { + this.estimatedWorth = estimatedWorth.toString(); + } + + public String getOccupation() { + return occupation; + } + + public void setOccupation(Occupations occupation) { + this.occupation = occupation.toString(); + } + + public String getEmploymentStatus() { + return employmentStatus; + } + + public void setEmploymentStatus(EmploymentStatuses employmentStatus) { + this.employmentStatus = employmentStatus.toString(); + } + + public String getSourceOfWealth() { + return sourceOfWealth; + } + + public void setSourceOfWealth(WealthSources sourceOfWealth) { + this.sourceOfWealth = sourceOfWealth.toString(); + } + + public boolean getAcceptRisk() { + return acceptRisk == 1 ? true : false; + } + + public void setAcceptRisk(Boolean acceptRisk) { + this.acceptRisk = acceptRisk ? 1 : 0; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/requests/CreateRealAccountRequest.java b/Trading/src/main/java/com/suneesh/trading/models/requests/CreateRealAccountRequest.java new file mode 100644 index 0000000..30564ed --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/requests/CreateRealAccountRequest.java @@ -0,0 +1,315 @@ +package com.suneesh.trading.models.requests; + +import com.suneesh.trading.models.enums.AccountOpeningReasons; +import com.suneesh.trading.models.enums.Salutation; +import com.suneesh.trading.models.enums.SecretQuestions; +import com.suneesh.trading.models.enums.TurnoverRanges; +import com.suneesh.trading.models.responses.CreateRealAccountResponse; +import com.google.gson.annotations.SerializedName; + +/** + *

CreateRealAccountRequest

+ * + *

Create real account Send

+ *

+ * This call opens a new real-money account. + * Note: you must be authenticated to a virtual-money account to call this function. + *

+ * + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 9/3/2017 + */ +public class CreateRealAccountRequest extends RequestBase { + + @SerializedName("new_account_real") + private final int newAccountReal = 1; + + /** + * Accept any value in enum list. + */ + @SerializedName("salutation") + private String salutation; + + /** + * Within 2-30 characters, use only letters, spaces, hyphens, full-stops or apostrophes. + */ + @SerializedName("first_name") + private String firstName; + + /** + * Within 2-30 characters, use only letters, spaces, hyphens, full-stops or apostrophes. + */ + @SerializedName("last_name") + private String lastName; + + /** + * Date of birth format: yyyy-mm-dd. + */ + @SerializedName("date_of_birth") + private String dateOfBirth; + + /** + * 2-letter country code, possible value receive from residence_list call. + */ + @SerializedName("residence") + private String residence; + + /** + * Place of birth, 2-letter country code. + */ + @SerializedName("place_of_birth") + private String placeOfBirth; + + /** + * First line of address + */ + @SerializedName("address_line_1") + private String firstAddressLine; + + /** + * Optional field, within 70 characters. + */ + @SerializedName("address_line_2") + private String secondAddressLine; + + /** + * Within 35 characters + */ + @SerializedName("address_city") + private String city; + + /** + * Optional field, possible value receive from states_list call. + */ + @SerializedName("address_state") + private String state; + + /** + * Optional field, within 20 characters and may not contain '+'. + */ + @SerializedName("address_postcode") + private String postcode; + + /** + * Within 6-35 digits, allowing '+' in front, numbers or space. + */ + @SerializedName("phone") + private String phone; + + /** + * Accept any value in enum list. + * Required for new account and existing client details will be used if client open another account. + */ + @SerializedName("secret_question") + private String secretQuestion; + + /** + * Answer to secret question, within 4-50 characters. + * Required for new account and existing client details will be used if client open another account. + */ + @SerializedName("secret_answer") + private String secretAnswer; + + /** + * Affiliate token, within 32 characters. + */ + @SerializedName("affiliate_token") + private String affiliateToken; + + /** + * Residence for tax purpose. Comma separated iso country code if multiple jurisdictions. + * Only applicable for real money account. Required for maltainvest landing company. + */ + @SerializedName("tax_residence") + private String taxResidence; + + /** + * Tax identification number. Only applicable for real money account. Required for maltainvest landing company. + */ + @SerializedName("tax_identification_number") + private String taxIdentificationNumber; + + /** + * Purpose and reason for requesting the account opening + */ + @SerializedName("account_opening_reason") + private String accountOpeningReason; + + /** + * The anticipated account turnover + */ + @SerializedName("account_turnover") + private String accountTurnover; + + /** + * Optional field to set currency of the account. + * List of supported currencies can be acquired with 'payout_currencies' call + */ + @SerializedName("currency") + private String currency; + + public CreateRealAccountRequest() { + this.responseType = CreateRealAccountResponse.class; + } + + public String getSalutation() { + return salutation; + } + + public void setSalutation(Salutation salutation) { + this.salutation = salutation.toString(); + } + + public String getFirstName() { + return firstName; + } + + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + public String getLastName() { + return lastName; + } + + public void setLastName(String lastName) { + this.lastName = lastName; + } + + public String getDateOfBirth() { + return dateOfBirth; + } + + public void setDateOfBirth(String dateOfBirth) { + this.dateOfBirth = dateOfBirth; + } + + public String getResidence() { + return residence; + } + + public void setResidence(String residence) { + this.residence = residence; + } + + public String getPlaceOfBirth() { + return placeOfBirth; + } + + public void setPlaceOfBirth(String placeOfBirth) { + this.placeOfBirth = placeOfBirth; + } + + public String getFirstAddressLine() { + return firstAddressLine; + } + + public void setFirstAddressLine(String firstAddressLine) { + this.firstAddressLine = firstAddressLine; + } + + public String getSecondAddressLine() { + return secondAddressLine; + } + + public void setSecondAddressLine(String secondAddressLine) { + this.secondAddressLine = secondAddressLine; + } + + public String getCity() { + return city; + } + + public void setCity(String city) { + this.city = city; + } + + public String getState() { + return state; + } + + public void setState(String state) { + this.state = state; + } + + public String getPostcode() { + return postcode; + } + + public void setPostcode(String postcode) { + this.postcode = postcode; + } + + public String getPhone() { + return phone; + } + + public void setPhone(String phone) { + this.phone = phone; + } + + public String getSecretQuestion() { + return secretQuestion; + } + + public void setSecretQuestion(SecretQuestions secretQuestion) { + this.secretQuestion = secretQuestion.toString(); + } + + public String getSecretAnswer() { + return secretAnswer; + } + + public void setSecretAnswer(String secretAnswer) { + this.secretAnswer = secretAnswer; + } + + public String getAffiliateToken() { + return affiliateToken; + } + + public void setAffiliateToken(String affiliateToken) { + this.affiliateToken = affiliateToken; + } + + public String getTaxResidence() { + return taxResidence; + } + + public void setTaxResidence(String taxResidence) { + this.taxResidence = taxResidence; + } + + public String getTaxIdentificationNumber() { + return taxIdentificationNumber; + } + + public void setTaxIdentificationNumber(String taxIdentificationNumber) { + this.taxIdentificationNumber = taxIdentificationNumber; + } + + public String getAccountOpeningReason() { + return accountOpeningReason; + } + + public void setAccountOpeningReason(AccountOpeningReasons accountOpeningReason) { + this.accountOpeningReason = accountOpeningReason.toString(); + } + + public String getAccountTurnover() { + return accountTurnover; + } + + public void setAccountTurnover(TurnoverRanges accountTurnover) { + this.accountTurnover = accountTurnover.toString(); + } + + public String getCurrency() { + return currency; + } + + public void setCurrency(String currency) { + this.currency = currency; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/requests/CreateRealSubAccountRequest.java b/Trading/src/main/java/com/suneesh/trading/models/requests/CreateRealSubAccountRequest.java new file mode 100644 index 0000000..851bd96 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/requests/CreateRealSubAccountRequest.java @@ -0,0 +1,240 @@ +package com.suneesh.trading.models.requests; + +import com.suneesh.trading.models.enums.Salutation; +import com.suneesh.trading.models.enums.SecretQuestions; +import com.suneesh.trading.models.responses.CreateRealSubAccountResponse; +import com.google.gson.annotations.SerializedName; + +/** + *

CreateRealSubAccountRequest

+ * + *

Create real sub account

+ *

+ * Binary.com provides an Omnibus account facility for corporate partners. + * This call opens a new sub account [available for omnibus accounts only] + *

+ * @author Morteza Tavanarad + * @version 1.0.0 + * @since 9/4/2017 + */ +public class CreateRealSubAccountRequest extends RequestBase { + + @SerializedName("new_sub_account") + private final int newSubAccount = 1; + + /** + * Accept any value in enum list. + */ + @SerializedName("salutation") + private String salutation; + + /** + * Within 2-30 characters, use only letters, spaces, hyphens, full-stops or apostrophes. + */ + @SerializedName("first_name") + private String firstName; + + /** + * Within 2-30 characters, use only letters, spaces, hyphens, full-stops or apostrophes. + */ + @SerializedName("last_name") + private String lastName; + + /** + * Date of birth format: yyyy-mm-dd. + */ + @SerializedName("date_of_birth") + private String dateOfBirth; + + /** + * 2-letter country code, possible value receive from residence_list call. + */ + @SerializedName("residence") + private String residence; + + /** + * Place of birth, 2-letter country code. + */ + @SerializedName("place_of_birth") + private String placeOfBirth; + + /** + * First line of address + */ + @SerializedName("address_line_1") + private String firstAddressLine; + + /** + * Optional field, within 70 characters. + */ + @SerializedName("address_line_2") + private String secondAddressLine; + + /** + * Within 35 characters + */ + @SerializedName("address_city") + private String city; + + /** + * Optional field, possible value receive from states_list call. + */ + @SerializedName("address_state") + private String state; + + /** + * Optional field, within 20 characters and may not contain '+'. + */ + @SerializedName("address_postcode") + private String postcode; + + /** + * Within 6-35 digits, allowing '+' in front, numbers or space. + */ + @SerializedName("phone") + private String phone; + + /** + * Accept any value in enum list. + * Required for new account and existing client details will be used if client open another account. + */ + @SerializedName("secret_question") + private String secretQuestion; + + /** + * Answer to secret question, within 4-50 characters. + * Required for new account and existing client details will be used if client open another account. + */ + @SerializedName("secret_answer") + private String secretAnswer; + + /** + * Affiliate token, within 32 characters. + */ + @SerializedName("affiliate_token") + private String affiliateToken; + + public CreateRealSubAccountRequest() { + this.responseType = CreateRealSubAccountResponse.class; + } + + public String getSalutation() { + return salutation; + } + + public void setSalutation(Salutation salutation) { + this.salutation = salutation.toString(); + } + + public String getFirstName() { + return firstName; + } + + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + public String getLastName() { + return lastName; + } + + public void setLastName(String lastName) { + this.lastName = lastName; + } + + public String getDateOfBirth() { + return dateOfBirth; + } + + public void setDateOfBirth(String dateOfBirth) { + this.dateOfBirth = dateOfBirth; + } + + public String getResidence() { + return residence; + } + + public void setResidence(String residence) { + this.residence = residence; + } + + public String getPlaceOfBirth() { + return placeOfBirth; + } + + public void setPlaceOfBirth(String placeOfBirth) { + this.placeOfBirth = placeOfBirth; + } + + public String getFirstAddressLine() { + return firstAddressLine; + } + + public void setFirstAddressLine(String firstAddressLine) { + this.firstAddressLine = firstAddressLine; + } + + public String getSecondAddressLine() { + return secondAddressLine; + } + + public void setSecondAddressLine(String secondAddressLine) { + this.secondAddressLine = secondAddressLine; + } + + public String getCity() { + return city; + } + + public void setCity(String city) { + this.city = city; + } + + public String getState() { + return state; + } + + public void setState(String state) { + this.state = state; + } + + public String getPostcode() { + return postcode; + } + + public void setPostcode(String postcode) { + this.postcode = postcode; + } + + public String getPhone() { + return phone; + } + + public void setPhone(String phone) { + this.phone = phone; + } + + public String getSecretQuestion() { + return secretQuestion; + } + + public void setSecretQuestion(SecretQuestions secretQuestion) { + this.secretQuestion = secretQuestion.toString(); + } + + public String getSecretAnswer() { + return secretAnswer; + } + + public void setSecretAnswer(String secretAnswer) { + this.secretAnswer = secretAnswer; + } + + public String getAffiliateToken() { + return affiliateToken; + } + + public void setAffiliateToken(String affiliateToken) { + this.affiliateToken = affiliateToken; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/requests/EmailVerificationRequest.java b/Trading/src/main/java/com/suneesh/trading/models/requests/EmailVerificationRequest.java new file mode 100644 index 0000000..29dfb92 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/requests/EmailVerificationRequest.java @@ -0,0 +1,57 @@ +package com.suneesh.trading.models.requests; + +import com.suneesh.trading.models.enums.EmailVerificationReasons; +import com.suneesh.trading.models.responses.EmailVerificationResponse; +import com.google.gson.annotations.SerializedName; + +/** + *

EmailVerificationRequest

+ * + *

Verify Email Send

+ *

Verify an email address before new account signup. + * The system will send an email to the address containing a security code to verify the address.

+ * + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/3/2017 + */ +public class EmailVerificationRequest extends RequestBase { + + /** + * Email address to be verified + */ + @SerializedName("verify_email") + private String email; + + /** + * Purpose of the email verification call + */ + @SerializedName("type") + private String type; + + public EmailVerificationRequest() { + this.responseType = EmailVerificationResponse.class; + } + + public EmailVerificationRequest(String email, EmailVerificationReasons reason) { + this(); + this.setEmail(email); + this.setType(reason); + } + + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } + + public String getType() { + return type; + } + + public void setType(EmailVerificationReasons type) { + this.type = type.toString().toLowerCase(); + } +} \ No newline at end of file diff --git a/Trading/src/main/java/com/suneesh/trading/models/requests/ForgetAllRequest.java b/Trading/src/main/java/com/suneesh/trading/models/requests/ForgetAllRequest.java new file mode 100644 index 0000000..8adf02f --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/requests/ForgetAllRequest.java @@ -0,0 +1,30 @@ +package com.suneesh.trading.models.requests; + +import com.suneesh.trading.models.enums.StreamTypes; +import com.google.gson.annotations.SerializedName; + +/** + *

ForgetAllRequest

+ * + *

Cancel Incoming Streams Based on Type

+ * Immediately cancel the real-time streams of messages of given type + * + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/1/2017 + */ +public class ForgetAllRequest extends RequestBase { + + /** + * Cancel all streams of a given type (which should be 'ticks', 'proposal', 'proposal_open_contract', etc) + */ + @SerializedName("forget_all") + private String stream; + + public ForgetAllRequest(StreamTypes stream){ + this.responseType = ForgetAllResponse.class; + this.stream = stream.toString(); + } + + +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/requests/ForgetAllResponse.java b/Trading/src/main/java/com/suneesh/trading/models/requests/ForgetAllResponse.java new file mode 100644 index 0000000..6609b3b --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/requests/ForgetAllResponse.java @@ -0,0 +1,23 @@ +package com.suneesh.trading.models.requests; + +import com.suneesh.trading.models.responses.ResponseBase; +import com.google.gson.annotations.SerializedName; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/1/2017 + */ +public class ForgetAllResponse extends ResponseBase { + + @SerializedName("forget_all") + private String[] streams; + + public String[] getStreams() { + return streams; + } + + public void setStreams(String[] streams) { + this.streams = streams; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/requests/ForgetRequest.java b/Trading/src/main/java/com/suneesh/trading/models/requests/ForgetRequest.java new file mode 100644 index 0000000..7c352b5 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/requests/ForgetRequest.java @@ -0,0 +1,28 @@ +package com.suneesh.trading.models.requests; + +import com.suneesh.trading.models.responses.ForgetResponse; +import com.google.gson.annotations.SerializedName; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/1/2017 + */ +public class ForgetRequest extends RequestBase { + + @SerializedName("forget") + private String forget; + + public ForgetRequest(String forget){ + this.responseType = ForgetResponse.class; + this.forget = forget; + } + + public String getForget() { + return forget; + } + + public void setForget(String forget) { + this.forget = forget; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/requests/GetFinancialAssessmentRequest.java b/Trading/src/main/java/com/suneesh/trading/models/requests/GetFinancialAssessmentRequest.java new file mode 100644 index 0000000..ad92b23 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/requests/GetFinancialAssessmentRequest.java @@ -0,0 +1,29 @@ +package com.suneesh.trading.models.requests; + +import com.suneesh.trading.models.responses.GetFinancialAssessmentResponse; +import com.google.gson.annotations.SerializedName; + +/** + *

GetFinancialAssessmentRequest

+ * + *

Get financial assessment details

+ *

+ * This call gets the financial assessement details. + * The 'financial assessment' is a questionnaire that clients of certain Landing Companies need to complete, + * due to regulatory and KYC (know your client) requirements. + * Not applicable for Japan landing company. + *

+ * + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/29/2017 + */ +public class GetFinancialAssessmentRequest extends RequestBase { + + @SerializedName("get_financial_assessment") + private final int getFinancialAssessment = 1; + + public GetFinancialAssessmentRequest() { + this.responseType = GetFinancialAssessmentResponse.class; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/requests/GetSelfExclusionRequest.java b/Trading/src/main/java/com/suneesh/trading/models/requests/GetSelfExclusionRequest.java new file mode 100644 index 0000000..f7731f2 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/requests/GetSelfExclusionRequest.java @@ -0,0 +1,28 @@ +package com.suneesh.trading.models.requests; + +import com.suneesh.trading.models.responses.GetSelfExclusionResponse; +import com.google.gson.annotations.SerializedName; + +/** + *

GetSelfExclusionRequest

+ * + *

Get User Self-Exclusion Send

+ *

+ * Binary.com allows users to exclude themselves from the website for certain periods of time, + * or to set limits on their trading activities. + * This facility is a regulatory requirement for certain Landing Companies. + *

+ * + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/4/2017 + */ +public class GetSelfExclusionRequest extends RequestBase { + + @SerializedName("get_self_exclusion") + private final int selfExclusion = 1; + + public GetSelfExclusionRequest() { + this.responseType = GetSelfExclusionResponse.class; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/requests/JapanAccountSetting.java b/Trading/src/main/java/com/suneesh/trading/models/requests/JapanAccountSetting.java new file mode 100644 index 0000000..79a0c75 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/requests/JapanAccountSetting.java @@ -0,0 +1,200 @@ +package com.suneesh.trading.models.requests; + +import com.suneesh.trading.models.enums.*; +import com.google.gson.annotations.SerializedName; +import com.suneesh.trading.models.enums.*; +import io.reactivex.annotations.Nullable; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 9/13/2017 + */ +public class JapanAccountSetting { + + /** + * Occupation (note: only set for Japan real-money accounts) + */ + @SerializedName("occupation") + private String occupation; + + /** + * Annual income (note: only set for Japan real-money accounts) + */ + @SerializedName("annual_income") + private String annualIncome; + + /** + * Financial asset (note: only set for Japan real-money accounts) + */ + @SerializedName("financial_asset") + private String financialAsset; + + /** + * Equities trading experience (note: only set for Japan real-money accounts) + */ + @SerializedName("trading_experience_equities") + private String tradingExperienceEquities; + + /** + * Commodities trading experience (note: only set for Japan real-money accounts) + */ + @SerializedName("trading_experience_commodities") + private String tradingExperienceCommodities; + + /** + * Foreign currency deposit trading experience (note: only set for Japan real-money accounts) + */ + @SerializedName("trading_experience_foreign_currency_deposit") + private String tradingExperienceForeignCurrencyDeposit; + + /** + * Margin FX trading experience (note: only set for Japan real-money accounts) + */ + @SerializedName("trading_experience_margin_fx") + private String tradingExperienceMarginFX; + + /** + * Investment trust trading experience (note: only set for Japan real-money accounts) + */ + @SerializedName("trading_experience_investment_trust") + private String tradingExperienceInvestmentTrust; + + /** + * Public and corporation bond trading experience (note: only set for Japan real-money accounts) + */ + @SerializedName("trading_experience_public_bond") + private String tradingExperiencePublicBond; + + /** + * OTC Derivative (Option) trading experience (note: only set for Japan real-money accounts) + */ + @SerializedName("trading_experience_option_trading") + private String tradingExperienceOptionTrading; + + /** + * Trading purpose (note: only set for Japan real-money accounts) + */ + @SerializedName("trading_purpose") + private String tradingPurpose; + + /** + * Classification of assets requiring hedge + * (note: only set for Japan real-money accounts, if 'Hedging' is selected for 'Trading purpose') + */ + @SerializedName("hedge_asset") + @Nullable + private String hedgeAsset; + + /** + * Hedge asset amount in JPY + * (note: only set for Japan real-money accounts, if 'Hedging' is selected for 'Trading purpose') + */ + @SerializedName("hedge_asset_amount") + @Nullable + private Long hedgeAssetAmount; + + public String getOccupation() { + return occupation; + } + + public void setOccupation(JPOccupations occupation) { + this.occupation = occupation.toString(); + } + + public String getAnnualIncome() { + return annualIncome; + } + + public void setAnnualIncome(JPAnnualIncomes annualIncome) { + this.annualIncome = annualIncome.toString(); + } + + public String getFinancialAsset() { + return financialAsset; + } + + public void setFinancialAsset(JPAnnualIncomes financialAsset) { + this.financialAsset = financialAsset.toString(); + } + + public String getTradingExperienceEquities() { + return tradingExperienceEquities; + } + + public void setTradingExperienceEquities(JPTradingExperiences tradingExperienceEquities) { + this.tradingExperienceEquities = tradingExperienceEquities.toString(); + } + + public String getTradingExperienceCommodities() { + return tradingExperienceCommodities; + } + + public void setTradingExperienceCommodities(JPTradingExperiences tradingExperienceCommodities) { + this.tradingExperienceCommodities = tradingExperienceCommodities.toString(); + } + + public String getTradingExperienceForeignCurrencyDeposit() { + return tradingExperienceForeignCurrencyDeposit; + } + + public void setTradingExperienceForeignCurrencyDeposit(JPTradingExperiences tradingExperienceForeignCurrencyDeposit) { + this.tradingExperienceForeignCurrencyDeposit = tradingExperienceForeignCurrencyDeposit.toString(); + } + + public String getTradingExperienceMarginFX() { + return tradingExperienceMarginFX; + } + + public void setTradingExperienceMarginFX(JPTradingExperiences tradingExperienceMarginFX) { + this.tradingExperienceMarginFX = tradingExperienceMarginFX.toString(); + } + + public String getTradingExperienceInvestmentTrust() { + return tradingExperienceInvestmentTrust; + } + + public void setTradingExperienceInvestmentTrust(JPTradingExperiences tradingExperienceInvestmentTrust) { + this.tradingExperienceInvestmentTrust = tradingExperienceInvestmentTrust.toString(); + } + + public String getTradingExperiencePublicBond() { + return tradingExperiencePublicBond; + } + + public void setTradingExperiencePublicBond(JPTradingExperiences tradingExperiencePublicBond) { + this.tradingExperiencePublicBond = tradingExperiencePublicBond.toString(); + } + + public String getTradingExperienceOptionTrading() { + return tradingExperienceOptionTrading; + } + + public void setTradingExperienceOptionTrading(JPTradingExperiences tradingExperienceOptionTrading) { + this.tradingExperienceOptionTrading = tradingExperienceOptionTrading.toString(); + } + + public String getTradingPurpose() { + return tradingPurpose; + } + + public void setTradingPurpose(JPTradingPurposes tradingPurpose) { + this.tradingPurpose = tradingPurpose.toString(); + } + + public String getHedgeAsset() { + return hedgeAsset; + } + + public void setHedgeAsset(HedgeAssets hedgeAsset) { + this.hedgeAsset = hedgeAsset.toString(); + } + + public Long getHedgeAssetAmount() { + return hedgeAssetAmount; + } + + public void setHedgeAssetAmount(Long hedgeAssetAmount) { + this.hedgeAssetAmount = hedgeAssetAmount; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/requests/JapanKnowledgeTestQuestion.java b/Trading/src/main/java/com/suneesh/trading/models/requests/JapanKnowledgeTestQuestion.java new file mode 100644 index 0000000..cb2d053 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/requests/JapanKnowledgeTestQuestion.java @@ -0,0 +1,41 @@ +package com.suneesh.trading.models.requests; + +import com.google.gson.annotations.SerializedName; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/30/2017 + */ +public class JapanKnowledgeTestQuestion { + + /** + * question id + */ + @SerializedName("id") + private Integer id; + + /** + * The question + */ + @SerializedName("question") + private String question; + + /** + * Given answer + */ + @SerializedName("answer") + private Integer answer; + + /** + * Whether given answer is correct + */ + @SerializedName("pass") + private Integer pass; + + /** + * Category of the question + */ + @SerializedName("category") + private Integer category; +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/requests/JapanKnowledgeTestRequest.java b/Trading/src/main/java/com/suneesh/trading/models/requests/JapanKnowledgeTestRequest.java new file mode 100644 index 0000000..9ad719c --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/requests/JapanKnowledgeTestRequest.java @@ -0,0 +1,67 @@ +package com.suneesh.trading.models.requests; + +import com.suneesh.trading.models.enums.TestResult; +import com.suneesh.trading.models.responses.JapanKnowledgeTestResponse; +import com.google.gson.annotations.SerializedName; + +import java.util.List; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/30/2017 + */ +public class JapanKnowledgeTestRequest extends RequestBase { + + @SerializedName("jp_knowledge_test") + private final int jpKnowledgeTest = 1; + + /** + * Total score for knowledge test. + */ + @SerializedName("score") + private Integer score; + + /** + * Result status of knowledge test, whether pass / fail. + */ + @SerializedName("status") + private String status; + + @SerializedName("questions") + private List questions; + + private JapanKnowledgeTestRequest() { + this.responseType = JapanKnowledgeTestResponse.class; + } + + public JapanKnowledgeTestRequest(Integer score, TestResult status){ + this(); + this.setScore(score); + this.setStatus(status); + } + + public Integer getScore() { + return score; + } + + public void setScore(Integer score) { + this.score = score; + } + + public String getStatus() { + return status; + } + + public void setStatus(TestResult status) { + this.status = status.toString(); + } + + public List getQuestions() { + return questions; + } + + public void setQuestions(List questions) { + this.questions = questions; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/requests/LandingCompanyDetailsRequest.java b/Trading/src/main/java/com/suneesh/trading/models/requests/LandingCompanyDetailsRequest.java new file mode 100644 index 0000000..d94a7f7 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/requests/LandingCompanyDetailsRequest.java @@ -0,0 +1,41 @@ +package com.suneesh.trading.models.requests; + +import com.suneesh.trading.models.responses.LandingCompanyDetailsResponse; +import com.suneesh.trading.utils.Validator; +import com.google.gson.annotations.SerializedName; + +/** + *

LandingCompanyDetailsRequest

+ * + *

Landing Company Details Send

+ * + *

Binary.com has a number of licensed subsidiaries in various jurisidictions, + * which are called Landing Companies (and which are wholly owned subsidiaries of the Binary Group). + * This call provides information about each Landing Company.

+ * + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/2/2017 + */ +public class LandingCompanyDetailsRequest extends RequestBase { + /** + * Landing company shortcode (for example: costarica, malta, maltainvest, iom) + */ + @SerializedName("landing_company_details") + private String landingCompanyCode; + + public LandingCompanyDetailsRequest(String landingCompanyCode){ + this.responseType = LandingCompanyDetailsResponse.class; + this.setLandingCompanyCode(landingCompanyCode); + } + + public String getLandingCompanyCode() { + return landingCompanyCode; + } + + public void setLandingCompanyCode(String landingCompanyCode) { + Validator.checkPattern("^(\\w|-){3,20}$", landingCompanyCode, + "Landing Company Code does not match the regex pattern /^(\\w|-){3,20}$/"); + this.landingCompanyCode = landingCompanyCode; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/requests/LandingCompanyRequest.java b/Trading/src/main/java/com/suneesh/trading/models/requests/LandingCompanyRequest.java new file mode 100644 index 0000000..ace4e18 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/requests/LandingCompanyRequest.java @@ -0,0 +1,41 @@ +package com.suneesh.trading.models.requests; + +import com.suneesh.trading.models.responses.LandingCompanyResponse; +import com.suneesh.trading.utils.Validator; +import com.google.gson.annotations.SerializedName; + +/** + *

LandingCompanyRequest

+ * + *

Landing Company Send

+ * Binary.com has a number of licensed subsidiaries in various jurisidictions, which are called Landing Companies. + * This call will return the appropriate Landing Company for clients of a given country. + * The landing company may differ for gaming contracts (Volatility Indices) + * and financial contracts (forex, stock indices, commodities) + * + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/1/2017 + */ +public class LandingCompanyRequest extends RequestBase { + + /** + * Client country + */ + @SerializedName("landing_company") + private String landingCompany; + + public LandingCompanyRequest(String landingCompany){ + this.responseType = LandingCompanyResponse.class; + this.landingCompany = landingCompany; + } + + public String getLandingCompany() { + return landingCompany; + } + + public void setLandingCompany(String landingCompany) { + Validator.checkPattern("^\\w{2}$", landingCompany, "LandingCompany value does not match the regex pattern \\^\\w{2}$\\"); + this.landingCompany = landingCompany; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/requests/LoginHistoryRequest.java b/Trading/src/main/java/com/suneesh/trading/models/requests/LoginHistoryRequest.java new file mode 100644 index 0000000..78ac810 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/requests/LoginHistoryRequest.java @@ -0,0 +1,47 @@ +package com.suneesh.trading.models.requests; + +import com.suneesh.trading.models.responses.LoginHistoryResponse; +import com.google.gson.annotations.SerializedName; +import io.reactivex.annotations.Nullable; + +/** + *

LoginHistoryRequest

+ * + *

Login History

+ *

+ * Retrieve a summary of login history for user. + *

+ * + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/7/2017 + */ +public class LoginHistoryRequest extends RequestBase { + + @SerializedName("login_history") + private final int loginHistory = 1; + + /** + * Apply limit to count of login history records, default to 10. Max:50 + */ + @SerializedName("limit") + @Nullable + private Integer limit; + + public LoginHistoryRequest() { + this.responseType = LoginHistoryResponse.class; + } + + public LoginHistoryRequest(Integer limit) { + this(); + this.setLimit(limit); + } + + public Integer getLimit() { + return limit; + } + + public void setLimit(Integer limit) { + this.limit = limit; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/requests/LogoutRequest.java b/Trading/src/main/java/com/suneesh/trading/models/requests/LogoutRequest.java new file mode 100644 index 0000000..4040093 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/requests/LogoutRequest.java @@ -0,0 +1,25 @@ +package com.suneesh.trading.models.requests; + +import com.suneesh.trading.models.responses.LogoutResponse; +import com.google.gson.annotations.SerializedName; + +/** + *

LogoutReques

+ * + *

Logout Request

+ *

+ * Logout the session + *

+ * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/7/2017 + */ +public class LogoutRequest extends RequestBase { + + @SerializedName("logout") + private final int logout = 1; + + public LogoutRequest() { + this.responseType = LogoutResponse.class; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/requests/NewVirtualAccountRequest.java b/Trading/src/main/java/com/suneesh/trading/models/requests/NewVirtualAccountRequest.java new file mode 100644 index 0000000..502f799 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/requests/NewVirtualAccountRequest.java @@ -0,0 +1,182 @@ +package com.suneesh.trading.models.requests; + +import com.suneesh.trading.models.responses.NewVirtualAccountResponse; +import com.suneesh.trading.utils.Validator; +import com.google.gson.annotations.SerializedName; +import io.reactivex.annotations.Nullable; + +/** + *

NewVirtualAccountRequest

+ * + *

Create virtual account Send

+ *

Create a new virtual-money account

+ * + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/2/2017 + */ +public class NewVirtualAccountRequest extends RequestBase { + + @SerializedName("new_account_virtual") + private final int newAccountVirtual = 1; + + /** + * Email verification code (received from a verify_email call, which must be done first) + */ + @SerializedName("verification_code") + private String verficationCode; + + /** + * Password (length within 6-25 chars, accepts any printable ASCII character) + */ + @SerializedName("client_password") + private String clientPassword; + + /** + * 2-letter country code (value received from residence_list call) + */ + @SerializedName("residence") + private String residence; + + /** + * Affiliate token, within 32 characters. + */ + @SerializedName("affiliate_token") + @Nullable + private String affiliateToken; + + /** + * Optional field to identify the source of traffic such as: search engine, newsletter, or other referral + */ + @SerializedName("utm_source") + @Nullable + private String utmSource; + + /** + * Optional field to identify the medium the link was used upon such as: email, CPC, or other methods of sharing + */ + @SerializedName("utm_medium") + @Nullable + private String utmMedium; + + /** + * Optional field to identify a specific product promotion or + * strategic campaign such as a spring sale or other promotions + */ + @SerializedName("utm_campaign") + @Nullable + private String utmCampaign; + + /** + * Boolean value 1 or 0, indicating permission to use email address for any contact which may include marketing + */ + @SerializedName("email_consent") + @Nullable + private Integer emailConsent; + + /** + * (Google Click Identifier) to track source + */ + @SerializedName("gclid_url") + @Nullable + private String googleClickId; + + public NewVirtualAccountRequest(String verficationCode, String clientPassword, String residence){ + this.responseType = NewVirtualAccountResponse.class; + this.setVerficationCode(verficationCode); + this.setClientPassword(clientPassword); + this.setResidence(residence); + } + + public int getNewAccountVirtual() { + return newAccountVirtual; + } + + public String getVerficationCode() { + return verficationCode; + } + + public void setVerficationCode(String verficationCode) { + Validator.checkPattern("^\\w{8,128}$", verficationCode, + "Verification Code does not match the regex pattern /^\\w{8,128}$/"); + this.verficationCode = verficationCode; + } + + public String getClientPassword() { + return clientPassword; + } + + public void setClientPassword(String clientPassword) { + Validator.checkPattern("^[ -~]{6,25}$", clientPassword, + "Client Password does not match the regex pattern /^[ -~]{6,25}$/"); + this.clientPassword = clientPassword; + } + + public String getResidence() { + return residence; + } + + public void setResidence(String residence) { + Validator.checkPattern("^[a-z]{2}$", residence, "Residence does not match the regex pattern /^[a-z]{2}$/"); + this.residence = residence; + } + + public String getAffiliateToken() { + return affiliateToken; + } + + public void setAffiliateToken(String affiliateToken) { + Validator.checkPattern("^[\\w-]{0,32}$", affiliateToken, + "Affiliate Token does not match the regex pattern /^[\\w-]{0,32}$/"); + this.affiliateToken = affiliateToken; + } + + public String getUtmSource() { + return utmSource; + } + + public void setUtmSource(String utmSource) { + Validator.checkPattern("^[a-zA-Z0-9\\s\\-\\.\\_]{0,100}$", utmSource, + "UTM Source does not match the regex pattern /^[a-zA-Z0-9\\s\\-\\.\\_]{0,100}$/"); + this.utmSource = utmSource; + } + + public String getUtmMedium() { + return utmMedium; + } + + public void setUtmMedium(String utmMedium) { + Validator.checkPattern("^[a-zA-Z0-9\\s\\-\\.\\_]{0,100}$", utmMedium, + "UTM Medium does not match the regex pattern /^[a-zA-Z0-9\\s\\-\\.\\_]{0,100}$/"); + this.utmMedium = utmMedium; + } + + public String getUtmCampaign() { + return utmCampaign; + } + + public void setUtmCampaign(String utmCampaign) { + Validator.checkPattern("^[a-zA-Z0-9\\s\\-\\.\\_]{0,100}$", utmCampaign, + "UTM Campaign does not match the regex pattern /^[a-zA-Z0-9\\s\\-\\.\\_]{0,100}$/"); + this.utmCampaign = utmCampaign; + } + + public Integer getEmailConsent() { + return emailConsent; + } + + public void setEmailConsent(Integer emailConsent) { + Validator.checkPattern("^(0|1)$", emailConsent.toString(), "Email Conset doesn't match the regex patter /^(0|1)$/"); + this.emailConsent = emailConsent; + } + + public String getGoogleClickId() { + return googleClickId; + } + + public void setGoogleClickId(String googleClickId) { + Validator.checkPattern("^[a-zA-Z0-9\\s\\-\\.\\_]{0,100}$", googleClickId, + "Google Click Identifier URL does not match the regex pattern /^[a-zA-Z0-9\\s\\-\\.\\_]{0,100}$/"); + this.googleClickId = googleClickId; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/requests/OAuthApplicationsRequest.java b/Trading/src/main/java/com/suneesh/trading/models/requests/OAuthApplicationsRequest.java new file mode 100644 index 0000000..b2d1495 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/requests/OAuthApplicationsRequest.java @@ -0,0 +1,26 @@ +package com.suneesh.trading.models.requests; + +import com.suneesh.trading.models.responses.OAuthApplicationResponse; +import com.google.gson.annotations.SerializedName; + +/** + *

OAuthApplicationsRequest

+ * + *

OAuth Applications Send

+ *

+ * List all my used OAuth applications. + *

+ * + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/7/2017 + */ +public class OAuthApplicationsRequest extends RequestBase { + + @SerializedName("oauth_apps") + private final int oauthApps = 1; + + public OAuthApplicationsRequest() { + this.responseType = OAuthApplicationResponse.class; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/requests/PaymentAgentListRequest.java b/Trading/src/main/java/com/suneesh/trading/models/requests/PaymentAgentListRequest.java new file mode 100644 index 0000000..4adbdd8 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/requests/PaymentAgentListRequest.java @@ -0,0 +1,42 @@ +package com.suneesh.trading.models.requests; + +import com.suneesh.trading.models.responses.PaymentAgentListResponse; +import com.suneesh.trading.utils.Validator; +import com.google.gson.annotations.SerializedName; + +/** + *

PaymentAgentListRequest

+ * + *

Payment Agent List Send

+ * + *

Will return a list of Payment Agents for a given country. + * Payment agents allow Binary.com users to deposit and withdraw funds using local payment methods + * that might not be available via the main Binary.com cashier system.

+ * + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/2/2017 + */ +public class PaymentAgentListRequest extends RequestBase { + + /** + * Client country (2-letter country code). + */ + @SerializedName("paymentagent_list") + private String countryCode; + + public PaymentAgentListRequest(String countryCode) { + this.responseType = PaymentAgentListResponse.class; + this.setCountryCode(countryCode); + } + + public String getCountryCode() { + return countryCode; + } + + public void setCountryCode(String countryCode) { + Validator.checkPattern("^\\w\\w$", countryCode, + "Country Code does not match the regex pattern /^\\w\\w$/"); + this.countryCode = countryCode; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/requests/PaymentAgentTransferRequest.java b/Trading/src/main/java/com/suneesh/trading/models/requests/PaymentAgentTransferRequest.java new file mode 100644 index 0000000..311e180 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/requests/PaymentAgentTransferRequest.java @@ -0,0 +1,82 @@ +package com.suneesh.trading.models.requests; + +import com.suneesh.trading.models.responses.PaymentAgentTransferResponse; +import com.google.gson.annotations.SerializedName; + +import java.math.BigDecimal; + +/** + *

PaymentAgentTransferRequest

+ * + *

Payment Agent Transfer Request

+ *

Payment Agent Transfer - this call is available only to accounts that are approved Payment Agents.

+ * + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 9/15/2017 + */ +public class PaymentAgentTransferRequest extends RequestBase { + + @SerializedName("paymentagent_transfer") + private final int paymentAgentTransfer = 1; + + /** + * The transfer_to loginid + */ + @SerializedName("transfer_to") + private String transferTo; + + /** + * Currency + */ + @SerializedName("currency") + private String currency; + + /** + * Amount + */ + @SerializedName("amount") + private BigDecimal amount; + + /** + * If 1, just do validation + */ + @SerializedName("dry_run") + private Integer dryRun; + + public PaymentAgentTransferRequest() { + this.responseType = PaymentAgentTransferResponse.class; + } + + public String getTransferTo() { + return transferTo; + } + + public void setTransferTo(String transferTo) { + this.transferTo = transferTo; + } + + public String getCurrency() { + return currency; + } + + public void setCurrency(String currency) { + this.currency = currency; + } + + public BigDecimal getAmount() { + return amount; + } + + public void setAmount(BigDecimal amount) { + this.amount = amount; + } + + public boolean getDryRun() { + return dryRun == 1 ? true : false; + } + + public void setDryRun(boolean dryRun) { + this.dryRun = dryRun ? 1 : 0; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/requests/PaymentAgentWithdrawalRequest.java b/Trading/src/main/java/com/suneesh/trading/models/requests/PaymentAgentWithdrawalRequest.java new file mode 100644 index 0000000..328c0bb --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/requests/PaymentAgentWithdrawalRequest.java @@ -0,0 +1,110 @@ +package com.suneesh.trading.models.requests; + +import com.suneesh.trading.models.responses.PaymentAgentWithdrawalResponse; +import com.google.gson.annotations.SerializedName; + +import java.math.BigDecimal; + +/** + *

PaymentAgentWithdrawalRequest

+ * + *

Payment Agent Withdrawal Request

+ *

Initiate a withdrawal to an approved Payment Agent.

+ * + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 9/15/2017 + */ +public class PaymentAgentWithdrawalRequest extends RequestBase { + + @SerializedName("paymentagent_withdraw") + private final int paymentAgentWithdraw = 1; + + /** + * The payment agent loginid received from the paymentagent_list call + */ + @SerializedName("paymentagent_loginid") + private String loginId; + + /** + * Currency + */ + @SerializedName("currency") + private String currency; + + /** + * Amount + */ + @SerializedName("amount") + private BigDecimal amount; + + /** + * Email verification code (received from a verify_email call, which must be done first) + */ + @SerializedName("verification_code") + private String verificationCode; + + /** + * Optional field for remarks about the withdraw. Only letters, numbers, space, period, comma, - ' are allowed. + */ + @SerializedName("description") + private String description; + + /** + * If 1, just do validation + */ + @SerializedName("dry_run") + private Integer dryRun; + + public PaymentAgentWithdrawalRequest() { + this.responseType = PaymentAgentWithdrawalResponse.class; + } + + public String getLoginId() { + return loginId; + } + + public void setLoginId(String loginId) { + this.loginId = loginId; + } + + public String getCurrency() { + return currency; + } + + public void setCurrency(String currency) { + this.currency = currency; + } + + public BigDecimal getAmount() { + return amount; + } + + public void setAmount(BigDecimal amount) { + this.amount = amount; + } + + public String getVerificationCode() { + return verificationCode; + } + + public void setVerificationCode(String verificationCode) { + this.verificationCode = verificationCode; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public boolean getDryRun() { + return dryRun == 1 ? true : false; + } + + public void setDryRun(boolean dryRun) { + this.dryRun = dryRun ? 1 : 0; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/requests/PayoutCurrenciesRequest.java b/Trading/src/main/java/com/suneesh/trading/models/requests/PayoutCurrenciesRequest.java new file mode 100644 index 0000000..5c004e2 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/requests/PayoutCurrenciesRequest.java @@ -0,0 +1,25 @@ +package com.suneesh.trading.models.requests; + +import com.suneesh.trading.models.responses.PayoutCurrenciesResponse; +import com.google.gson.annotations.SerializedName; + +/** + *

PayoutCurrenciesRequest

+ * + *

Payout Currencies Send

+ *

Retrieve a list of available option payout currencies. + * If a user is logged in, only the currency available for his account will be returned.

+ * + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/2/2017 + */ +public class PayoutCurrenciesRequest extends RequestBase { + + @SerializedName("payout_currencies") + private final int payoutCurrencies = 1; + + public PayoutCurrenciesRequest(){ + this.responseType = PayoutCurrenciesResponse.class; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/requests/PingRequest.java b/Trading/src/main/java/com/suneesh/trading/models/requests/PingRequest.java new file mode 100644 index 0000000..83172a0 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/requests/PingRequest.java @@ -0,0 +1,19 @@ +package com.suneesh.trading.models.requests; + +import com.suneesh.trading.models.responses.PingResponse; +import com.google.gson.annotations.SerializedName; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/2/2017 + */ +public class PingRequest extends RequestBase { + + @SerializedName("ping") + private final int ping = 1; + + public PingRequest(){ + this.responseType = PingResponse.class; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/requests/PortfolioRequest.java b/Trading/src/main/java/com/suneesh/trading/models/requests/PortfolioRequest.java new file mode 100644 index 0000000..8f2b84b --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/requests/PortfolioRequest.java @@ -0,0 +1,26 @@ +package com.suneesh.trading.models.requests; + +import com.suneesh.trading.models.responses.PortfolioResponse; +import com.google.gson.annotations.SerializedName; + +/** + *

PortfolioRequest

+ * + *

Portfolio Send

+ *

+ * Receive information about my current portfolio of outstanding options + *

+ * + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/7/2017 + */ +public class PortfolioRequest extends RequestBase { + + @SerializedName("portfolio") + private final int portfolio = 1; + + public PortfolioRequest() { + this.responseType = PortfolioResponse.class; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/requests/PriceProposalRequest.java b/Trading/src/main/java/com/suneesh/trading/models/requests/PriceProposalRequest.java new file mode 100644 index 0000000..faa5f0f --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/requests/PriceProposalRequest.java @@ -0,0 +1,251 @@ +package com.suneesh.trading.models.requests; + +import com.suneesh.trading.models.enums.BasisTypes; +import com.suneesh.trading.models.enums.DurationUnits; +import com.suneesh.trading.models.responses.PriceProposalResponse; +import com.suneesh.trading.utils.Validator; +import com.google.gson.annotations.SerializedName; +import io.reactivex.annotations.Nullable; + +import java.math.BigDecimal; + +/** + *

PriceProposalRequest

+ * + *

Get latest price for a specific contract

+ *

Get latest price for a specific contract

+ * + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/2/2017 + */ +public class PriceProposalRequest extends RequestBase { + + @SerializedName("proposal") + private final int proposal = 1; + + /** + * 1 - to initiate a realtime stream of prices. + * Note that tick trades, digit trades and less than 24 hours at-the-money contracts for + * the following underlying symbols are not streamed: R_100 R_50 R_25 R_75 RDBULL RDBEAR + * (this is because their price is constant). + */ + @SerializedName("subscribe") + @Nullable + private Integer subscribe = null; + + /** + * Proposed contract payout or stake value + */ + @SerializedName("amount") + private BigDecimal amount; + + /** + * Indicate whether amount is 'payout' or 'stake' + */ + @SerializedName("basis") + private String basis; + + /** + * A valid contract-type + */ + @SerializedName("contract_type") + private String contractType; + + /** + * This can only be the account-holder's currency + */ + @SerializedName("currency") + private String currency; + + /** + * For forward-starting contracts, epoch value of the starting time of the contract. + */ + @SerializedName("date_start") + @Nullable + private Integer dateStart; + + /** + * Epoch value of the expiry time of the contract. You must either specify date_expiry or duration. + */ + @SerializedName("date_expiry") + @Nullable + private Integer dateExpiry; + + /** + * Duration quantity + */ + @SerializedName("duration") + private int duration; + + /** + * Duration unit is s(seconds), m(minutes), h(hours), d(days), t(ticks). + * If this parameter is not set then duration will be counted as seconds. + */ + @SerializedName("duration_unit") + private String durationUnit; + + /** + * Symbol code + */ + @SerializedName("symbol") + private String symbol; + + /** + * Barrier for the contract (or last digit prediction for digit contracts). + * Contracts less than 24 hours in duration would need a relative barrier (barriers which need +/-), + * meaning that the entry spot would be adjusted accordingly with that amount to define a barrier. + */ + @SerializedName("barrier") + private String barrier; + + /** + * Low barrier for the contract (for contracts with two barriers). + * Contracts less than 24 hours in duration would need a relative barrier (barriers which need +/-), + * meaning that the entry spot would be adjusted accordingly with that amount to define a barrier. + */ + @SerializedName("barrier2") + private String barrier2; + + /** + * [For japan only] An epoch value of a predefined trading period start time + */ + @SerializedName("trading_period_start") + private String tradingPeriodStart; + + public PriceProposalRequest() { + this.responseType = PriceProposalResponse.class; + } + + public PriceProposalRequest(String symbol, BigDecimal amount, BasisTypes basis, String contractType, + String currency, int duration, DurationUnits durationUnit) { + this(); + this.setSymbol(symbol); + this.setAmount(amount); + this.setBasis(basis); + this.setContractType(contractType); + this.setCurrency(currency); + this.setDuration(duration); + this.setDurationUnit(durationUnit); + } + + public Integer getSubscribe() { + return subscribe; + } + + public void setSubscribe(Integer subscribe) { + this.subscribe = subscribe; + } + + public BigDecimal getAmount() { + return amount; + } + + public void setAmount(BigDecimal amount) { + Validator.checkPattern("^[0-9]+([.][0-9]+)?$", amount.toString(), + "Amount does not match the regex pattern /^[0-9]+([.][0-9]+)?$/"); + this.amount = amount; + } + + public String getBasis() { + return basis; + } + + public void setBasis(BasisTypes basis) { + this.basis = basis.toString().toLowerCase(); + } + + public String getContractType() { + return contractType; + } + + public void setContractType(String contractType) { + Validator.checkPattern("^\\w{2,30}$", contractType, + "ContractType does not match regex pattern /^\\w{2,30}$/"); + this.contractType = contractType; + } + + public String getCurrency() { + return currency; + } + + public void setCurrency(String currency) { + Validator.checkPattern("^[A-Z]{3}$", currency, + "Currency does not match the regex pattern /^[A-Z]{3}$/"); + this.currency = currency; + } + + public int getDateStart() { + return dateStart; + } + + public void setDateStart(int dateStart) { + Validator.checkPattern("^\\d{1,10}$", Integer.toString(dateStart), + "Date Start does not match the regex pattern /^\\d{1,10}$/"); + this.dateStart = dateStart; + } + + public int getDateExpiry() { + return dateExpiry; + } + + public void setDateExpiry(int dateExpiry) { + Validator.checkPattern("^\\d{1,10}$", Integer.toString(dateStart), + "Date Expiry does not match the regex pattern /^\\d{1,10}$/"); + this.dateExpiry = dateExpiry; + } + + public int getDuration() { + return duration; + } + + public void setDuration(int duration) { + this.duration = duration; + } + + public String getDurationUnit() { + return durationUnit; + } + + public void setDurationUnit(DurationUnits durationUnit) { + this.durationUnit = durationUnit.toString().toLowerCase().substring(0, 1); + } + + public String getSymbol() { + return symbol; + } + + public void setSymbol(String symbol) { + Validator.checkPattern("^\\w{2,30}$", symbol, + "Symbol does not match the regex pattern /^\\w{2,30}$/"); + this.symbol = symbol; + } + + public String getBarrier() { + return barrier; + } + + public void setBarrier(String barrier) { + Validator.checkPattern("^[+-]?\\d+\\.?\\d*$", barrier, + "Barrier does not match the regex pattern /^[+-]?\\d+\\.?\\d*$/"); + this.barrier = barrier; + } + + public String getBarrier2() { + return barrier2; + } + + public void setBarrier2(String barrier2) { + Validator.checkPattern("^[+-]?\\d+\\.?\\d*$", barrier, + "Barrier2 does not match the regex pattern /^[+-]?\\d+\\.?\\d*$/"); + this.barrier2 = barrier2; + } + + public String getTradingPeriodStart() { + return tradingPeriodStart; + } + + public void setTradingPeriodStart(String tradingPeriodStart) { + this.tradingPeriodStart = tradingPeriodStart; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/requests/ProfitTableRequest.java b/Trading/src/main/java/com/suneesh/trading/models/requests/ProfitTableRequest.java new file mode 100644 index 0000000..5293cfd --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/requests/ProfitTableRequest.java @@ -0,0 +1,127 @@ +package com.suneesh.trading.models.requests; + +import com.suneesh.trading.models.enums.SortTypes; +import com.suneesh.trading.models.responses.ProfitTableResponse; +import com.suneesh.trading.utils.Validator; +import com.google.gson.annotations.SerializedName; +import io.reactivex.annotations.Nullable; + +/** + *

ProfitTableRequest

+ * + *

Profit Table Send

+ *

+ * Retrieve a summary of account Profit Table, according to given search criteria + *

+ * + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/8/2017 + */ +public class ProfitTableRequest extends RequestBase { + + @SerializedName("profit_table") + private final int profitTable = 1; + + /** + * If set to 1, will return full contracts description. + */ + @SerializedName("description") + @Nullable + private Integer description; + + /** + * Apply upper limit to count of transactions received + */ + @SerializedName("limit") + @Nullable + private Integer limit; + + /** + * Skip this many transactions + */ + @SerializedName("offset") + @Nullable + private Integer offset; + + /** + * Optional start date (epoch or YYYY-MM-DD) + */ + @SerializedName("date_from") + @Nullable + private String date_from; + + /** + * Optional end date (epoch or YYYY-MM-DD) + */ + @SerializedName("date_to") + @Nullable + private String date_to; + + /** + * sort direction, default DESC + */ + @SerializedName("sort") + @Nullable + private String sort; + + public ProfitTableRequest() { + this.responseType = ProfitTableResponse.class; + } + + public boolean getDescription() { + return description == 1 ? true : false; + } + + public void setDescription(boolean description) { + this.description = description ? 1 : null; + } + + public Integer getLimit() { + return limit; + } + + public void setLimit(Integer limit) { + Validator.checkPattern("^\\d{1,3}$", limit.toString(), + "Limit does not match the regex pattern /^\\d{1,3}$/"); + this.limit = limit; + } + + public Integer getOffset() { + return offset; + } + + public void setOffset(Integer offset) { + this.offset = offset; + } + + public String getDate_from() { + return date_from; + } + + public void setDate_from(String date_from) { + Validator.checkPattern("^(\\d{4}-(0?[1-9]|1[012])-(0?[1-9]|[12][0-9]|3[01])|\\d{1,10})$", + date_from, + "DateFrom does not match the regex pattern /^(\\d{4}-(0?[1-9]|1[012])-(0?[1-9]|[12][0-9]|3[01])|\\d{1,10})$/"); + this.date_from = date_from; + } + + public String getDate_to() { + return date_to; + } + + public void setDate_to(String date_to) { + Validator.checkPattern("^(\\d{4}-(0?[1-9]|1[012])-(0?[1-9]|[12][0-9]|3[01])|\\d{1,10})$", + date_to, + "DateTo does not match the regex pattern /^(\\d{4}-(0?[1-9]|1[012])-(0?[1-9]|[12][0-9]|3[01])|\\d{1,10})$/"); + this.date_to = date_to; + } + + public String getSort() { + return sort; + } + + public void setSort(SortTypes sort) { + this.sort = sort.toString(); + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/requests/ProposalOpenContractRequest.java b/Trading/src/main/java/com/suneesh/trading/models/requests/ProposalOpenContractRequest.java new file mode 100644 index 0000000..a3887cb --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/requests/ProposalOpenContractRequest.java @@ -0,0 +1,64 @@ +package com.suneesh.trading.models.requests; + +import com.suneesh.trading.models.responses.ProposalOpenContractResponse; +import com.google.gson.annotations.SerializedName; +import io.reactivex.annotations.Nullable; + +/** + *

ProposalOpenContractRequest

+ * + *

Latest price for an open contract

+ *

+ * Get latest price (and other information) for a contract in the user's portfolio + *

+ * + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/8/2017 + */ +public class ProposalOpenContractRequest extends RequestBase { + + @SerializedName("proposal_open_contract") + private final int proposalOpenContract = 1; + + /** + * Contract id received from a Portfolio request. If not set, you will receive stream of all open contracts. + */ + @SerializedName("contract_id") + private Long contractId; + + /** + * If set to 1, will send updates whenever the price changes + */ + @SerializedName("subscribe") + @Nullable + private Integer subscribe = null; + + + public ProposalOpenContractRequest(Long contractId) { + this.responseType = ProposalOpenContractResponse.class; + this.contractId = contractId; + } + + public ProposalOpenContractRequest(Long contractId, Boolean subscribe) { + this.responseType = ProposalOpenContractResponse.class; + this.contractId = contractId; + this.subscribe = subscribe? 1: null; + } + + public Long getContractId() { + return contractId; + } + + public void setContractId(Long contractId) { + this.contractId = contractId; + } + + public Integer getSubscribe() { + return subscribe; + } + + public void setSubscribe(Integer subscribe) { + this.subscribe = subscribe; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/requests/RealityCheckRequest.java b/Trading/src/main/java/com/suneesh/trading/models/requests/RealityCheckRequest.java new file mode 100644 index 0000000..9bbb801 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/requests/RealityCheckRequest.java @@ -0,0 +1,28 @@ +package com.suneesh.trading.models.requests; + +import com.suneesh.trading.models.responses.RealityCheckResponse; +import com.google.gson.annotations.SerializedName; + +/** + *

RealityCheckRequest

+ * + *

Reality check send

+ *

+ * Retrieve summary of client's trades and account for the Reality Check facility. + * A 'reality check' means a display of time elapsed since the session began, and associated client profit/loss. + * The Reality Check facility is a regulatory requirement for certain landing companies. + *

+ * + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/8/2017 + */ +public class RealityCheckRequest extends RequestBase { + + @SerializedName("reality_check") + private final int realityCheck = 1; + + public RealityCheckRequest() { + this.responseType = RealityCheckResponse.class; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/requests/RequestBase.java b/Trading/src/main/java/com/suneesh/trading/models/requests/RequestBase.java new file mode 100644 index 0000000..e623f3e --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/requests/RequestBase.java @@ -0,0 +1,49 @@ +package com.suneesh.trading.models.requests; + +import com.google.gson.JsonObject; +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; +import io.reactivex.annotations.Nullable; + +import java.lang.reflect.Type; + +/** + * Created by morteza on 7/19/2017. + */ + +public class RequestBase { + @SerializedName("passthrough") + JsonObject passThrough; + + @SerializedName("req_id") + @Nullable + Integer id = null; + + @Expose + transient Type responseType; + + public JsonObject getPassThrough() { + return passThrough; + } + + public void setPassThrough(JsonObject passThrough) { + this.passThrough = passThrough; + } + + @Nullable + public Integer getId() { + return id; + } + + public void setId(@Nullable Integer id) { + this.id = id; + } + + public Type getResponseType() { + return responseType; + } + + public void setResponseType(Type responseType) { + this.responseType = responseType; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/requests/ResidenceListRequest.java b/Trading/src/main/java/com/suneesh/trading/models/requests/ResidenceListRequest.java new file mode 100644 index 0000000..c7edeb1 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/requests/ResidenceListRequest.java @@ -0,0 +1,26 @@ +package com.suneesh.trading.models.requests; + +import com.suneesh.trading.models.responses.ResidenceListResponce; +import com.google.gson.annotations.SerializedName; + +/** + *

ResidenceListRequest

+ * + *

Residence List Send

+ *

+ * This call returns a list of countries and 2-letter country codes, suitable for populating the account opening form. + *

+ * + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/2/2017 + */ +public class ResidenceListRequest extends RequestBase { + + @SerializedName("residence_list") + private final int residentList = 1; + + public ResidenceListRequest(){ + this.responseType = ResidenceListResponce.class; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/requests/RevokeOauthApplicationRequest.java b/Trading/src/main/java/com/suneesh/trading/models/requests/RevokeOauthApplicationRequest.java new file mode 100644 index 0000000..10a71d8 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/requests/RevokeOauthApplicationRequest.java @@ -0,0 +1,27 @@ +package com.suneesh.trading.models.requests; + +import com.suneesh.trading.models.responses.RevokeOauthApplicationResponse; +import com.google.gson.annotations.SerializedName; + +/** + *

RevokeOauthApplicationRequest

+ * + *

Revoke Oauth Framework Send

+ *

+ * Used for revoking access of particular app. + *

+ * + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 9/4/2017 + */ +public class RevokeOauthApplicationRequest extends RequestBase { + + @SerializedName("revoke_oauth_app") + private Long appId; + + public RevokeOauthApplicationRequest(Long appId) { + this.responseType = RevokeOauthApplicationResponse.class; + this.appId = appId; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/requests/SellContractForMultipleAccountsRequest.java b/Trading/src/main/java/com/suneesh/trading/models/requests/SellContractForMultipleAccountsRequest.java new file mode 100644 index 0000000..a8ca4de --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/requests/SellContractForMultipleAccountsRequest.java @@ -0,0 +1,81 @@ +package com.suneesh.trading.models.requests; + +import com.suneesh.trading.models.responses.SellContractForMultipleAccountsResponse; +import com.google.gson.annotations.SerializedName; + +import java.math.BigDecimal; +import java.util.List; + +/** + *

SellContractForMultipleAccounts

+ * + *

Sell multiple contracts

+ *

+ * Sell contracts for multiple accounts simultaneously. Uses the shortcode response from buy_contract_for_multiple_accounts to identify the contract, + * and authorisation tokens to select which accounts to sell those contracts on. Note that only the accounts identified by the tokens will be affected. + * This will not sell the contract on the currently-authorised account unless you include the token for the current account. + *

+ * + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/9/2017 + */ +public class SellContractForMultipleAccountsRequest extends RequestBase { + + @SerializedName("sell_contract_for_multiple_accounts") + private final int sellContractForMultipleAccounts = 1; + + /** + * An internal ID used to identify the contract which was originally bought. + * This is returned from the buy and buy_for_multiple_accounts calls. + */ + @SerializedName("shortcode") + private String shortCode; + + /** + * Authorisation tokens which select the accounts to sell use for the affected accounts + */ + @SerializedName("tokens") + private List tokens; + + /** + * Minimum price at which to sell the contract, or '0' for 'sell at market' + */ + @SerializedName("price") + private BigDecimal price; + + private SellContractForMultipleAccountsRequest() { + this.responseType = SellContractForMultipleAccountsResponse.class; + } + + public SellContractForMultipleAccountsRequest(String shortCode, BigDecimal price, List tokens) { + this(); + this.price = price; + this.tokens = tokens; + this.shortCode = shortCode; + } + + public String getShortCode() { + return shortCode; + } + + public void setShortCode(String shortCode) { + this.shortCode = shortCode; + } + + public List getTokens() { + return tokens; + } + + public void setTokens(List tokens) { + this.tokens = tokens; + } + + public BigDecimal getPrice() { + return price; + } + + public void setPrice(BigDecimal price) { + this.price = price; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/requests/SellContractRequest.java b/Trading/src/main/java/com/suneesh/trading/models/requests/SellContractRequest.java new file mode 100644 index 0000000..9c457d2 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/requests/SellContractRequest.java @@ -0,0 +1,59 @@ +package com.suneesh.trading.models.requests; + +import com.suneesh.trading.models.responses.SellContractResponse; +import com.google.gson.annotations.SerializedName; + +import java.math.BigDecimal; + +/** + *

SellContractRequest

+ * + *

Sell a Contract Send

+ *

+ * Sell a Contract as identified from a previous Portfolio call + *

+ * + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/9/2017 + */ +public class SellContractRequest extends RequestBase { + + /** + * Pass contract_id received from the Portfolio call + */ + @SerializedName("sell") + private Long contractId; + + /** + * Minimum price at which to sell the contract, or '0' for 'sell at market' + */ + @SerializedName("price") + private BigDecimal price; + + private SellContractRequest() { + this.responseType = SellContractResponse.class; + } + + public SellContractRequest(Long contractId, BigDecimal price) { + this(); + this.price = price; + this.contractId = contractId; + } + + public Long getContractId() { + return contractId; + } + + public void setContractId(Long contractId) { + this.contractId = contractId; + } + + public BigDecimal getPrice() { + return price; + } + + public void setPrice(BigDecimal price) { + this.price = price; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/requests/SellExpiredContractsRequest.java b/Trading/src/main/java/com/suneesh/trading/models/requests/SellExpiredContractsRequest.java new file mode 100644 index 0000000..9d1219c --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/requests/SellExpiredContractsRequest.java @@ -0,0 +1,26 @@ +package com.suneesh.trading.models.requests; + +import com.suneesh.trading.models.responses.SellExpiredContractsResponse; +import com.google.gson.annotations.SerializedName; + +/** + *

SellExpiredContractsRequest

+ * + *

Sell expired contracts

+ *

+ * This call will try to sell any expired contracts and return the number of sold contracts. + *

+ * + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/9/2017 + */ +public class SellExpiredContractsRequest extends RequestBase { + + @SerializedName("sell_expired") + private final int sellExpired = 1; + + public SellExpiredContractsRequest() { + this.responseType = SellExpiredContractsResponse.class; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/requests/SetAccountCurrencyRequest.java b/Trading/src/main/java/com/suneesh/trading/models/requests/SetAccountCurrencyRequest.java new file mode 100644 index 0000000..00b212b --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/requests/SetAccountCurrencyRequest.java @@ -0,0 +1,39 @@ +package com.suneesh.trading.models.requests; + +import com.suneesh.trading.models.responses.SetAccountCurrencyResponse; +import com.google.gson.annotations.SerializedName; + +/** + *

SetAccountCurrencyRequest

+ * + *

Set Account Currency

+ *

+ * Set account currency, this will be default currency for your account i.e currency for trading, deposit. + * Please note that account currency can only be set once, and then can never be changed. + *

+ * + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 9/4/2017 + */ +public class SetAccountCurrencyRequest extends RequestBase { + + /** + * Currency of the account. List of supported currencies can be acquired with 'payout_currencies' call + */ + @SerializedName("set_account_currency") + private String accountCurrency; + + public SetAccountCurrencyRequest(String accountCurrency) { + this.responseType = SetAccountCurrencyResponse.class; + this.accountCurrency = accountCurrency; + } + + public String getAccountCurrency() { + return accountCurrency; + } + + public void setAccountCurrency(String accountCurrency) { + this.accountCurrency = accountCurrency; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/requests/SetAccountSettingsRequest.java b/Trading/src/main/java/com/suneesh/trading/models/requests/SetAccountSettingsRequest.java new file mode 100644 index 0000000..5b9dec6 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/requests/SetAccountSettingsRequest.java @@ -0,0 +1,220 @@ +package com.suneesh.trading.models.requests; + +import com.suneesh.trading.models.enums.AccountOpeningReasons; +import com.suneesh.trading.models.responses.SetAccountSettingsResponse; +import com.google.gson.annotations.SerializedName; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 9/13/2017 + */ +public class SetAccountSettingsRequest extends RequestBase { + + @SerializedName("set_settings") + private final int setSettings = 1; + + /** + * Note: not applicable for virtual account. Required field for real money account. + */ + @SerializedName("address_line_1") + private String firstLineAddress; + + /** + * Note: not applicable for virtual account. Required field for real money account. + */ + @SerializedName("address_line_2") + private String secondLineAddress; + + /** + * Note: not applicable for virtual account. Required field for real money account. + */ + @SerializedName("address_city") + private String city; + + /** + * Note: not applicable for virtual account. Required field for real money account. + */ + @SerializedName("address_state") + private String state; + + /** + * Note: not applicable for virtual account. Required field for real money account. + */ + @SerializedName("address_postcode") + private String postcode; + + /** + * Note: not applicable for virtual account. Required field for real money account. + */ + @SerializedName("phone") + private String phone; + + /** + * 2-letter country code. Note: not applicable for real money account. + * Only allow for Virtual account without residence set. + */ + @SerializedName("residence") + private String residence; + + /** + * Boolean value 1 or 0, indicating permission to use email address for any contact which may include marketing + */ + @SerializedName("email_consent") + private Integer emailConsent; + + /** + * Place of birth, 2-letter country code. + */ + @SerializedName("place_of_birth") + private String placeOfBirth; + + /** + * Residence for tax purpose. Comma separated iso country code if multiple jurisdictions. + * Only applicable for real money account. Required for maltainvest landing company. + */ + @SerializedName("tax_residence") + private String taxResidence; + + /** + * Tax identification number. Only applicable for real money account. Required for maltainvest landing company. + */ + @SerializedName("tax_identification_number") + private String taxIdentificationNumber; + + /** + * Purpose and reason for requesting the account opening. + * Only applicable for real money account. Required for clients that have not set it yet. Can only be set once. + */ + @SerializedName("account_opening_reason") + private String accountOpeningReason; + + /** + * Boolean value 1 or 0, indicating permission to allow others to follow your trades. + * Note: not applicable for Virtual account. Only allow for real money account. + */ + @SerializedName("allow_copiers") + private Integer allowCopiers; + + /** + * Japan real money client settings, only applicable for Japan real money account client. + */ + @SerializedName("jp_settings") + private JapanAccountSetting japanAccountSetting; + + public SetAccountSettingsRequest() { + this.responseType = SetAccountSettingsResponse.class; + } + + public String getFirstLineAddress() { + return firstLineAddress; + } + + public void setFirstLineAddress(String firstLineAddress) { + this.firstLineAddress = firstLineAddress; + } + + public String getSecondLineAddress() { + return secondLineAddress; + } + + public void setSecondLineAddress(String secondLineAddress) { + this.secondLineAddress = secondLineAddress; + } + + public String getCity() { + return city; + } + + public void setCity(String city) { + this.city = city; + } + + public String getState() { + return state; + } + + public void setState(String state) { + this.state = state; + } + + public String getPostcode() { + return postcode; + } + + public void setPostcode(String postcode) { + this.postcode = postcode; + } + + public String getPhone() { + return phone; + } + + public void setPhone(String phone) { + this.phone = phone; + } + + public String getResidence() { + return residence; + } + + public void setResidence(String residence) { + this.residence = residence; + } + + public boolean getEmailConsent() { + return emailConsent == 1 ? true : false; + } + + public void setEmailConsent(boolean emailConsent) { + this.emailConsent = emailConsent ? 1 : 0; + } + + public String getPlaceOfBirth() { + return placeOfBirth; + } + + public void setPlaceOfBirth(String placeOfBirth) { + this.placeOfBirth = placeOfBirth; + } + + public String getTaxResidence() { + return taxResidence; + } + + public void setTaxResidence(String taxResidence) { + this.taxResidence = taxResidence; + } + + public String getTaxIdentificationNumber() { + return taxIdentificationNumber; + } + + public void setTaxIdentificationNumber(String taxIdentificationNumber) { + this.taxIdentificationNumber = taxIdentificationNumber; + } + + public String getAccountOpeningReason() { + return accountOpeningReason; + } + + public void setAccountOpeningReason(AccountOpeningReasons accountOpeningReason) { + this.accountOpeningReason = accountOpeningReason.toString(); + } + + public boolean getAllowCopiers() { + return allowCopiers == 1 ? true : false; + } + + public void setAllowCopiers(boolean allowCopiers) { + this.allowCopiers = allowCopiers ? 1 : 0; + } + + public JapanAccountSetting getJapanAccountSetting() { + return japanAccountSetting; + } + + public void setJapanAccountSetting(JapanAccountSetting japanAccountSetting) { + this.japanAccountSetting = japanAccountSetting; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/requests/SetFinancialAssessmentRequest.java b/Trading/src/main/java/com/suneesh/trading/models/requests/SetFinancialAssessmentRequest.java new file mode 100644 index 0000000..b71097c --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/requests/SetFinancialAssessmentRequest.java @@ -0,0 +1,323 @@ +package com.suneesh.trading.models.requests; + +import com.suneesh.trading.models.enums.*; +import com.suneesh.trading.models.responses.SetFinancialAssessmentResponse; +import com.google.gson.annotations.SerializedName; +import com.suneesh.trading.models.enums.*; + +/** + *

SetFinancialAssessmentRequest

+ * + *

Save Financial assessment details send

+ *

+ * This call sets the financial assessement details based on the client's answers to analyse + * whether he possess the experience and knowledge to understand the risks involved with binary options trading. + * Not applicable for Japan landing company. + *

+ * @author Morteza Tavanarad + * @version 1.0.0 + * @since 9/4/2017 + */ +public class SetFinancialAssessmentRequest extends RequestBase { + + @SerializedName("set_financial_assessment") + private final int setFinancialAssessment = 1; + + /** + * Forex trading experience + */ + @SerializedName("forex_trading_experience") + private String forexTradingExperience; + + /** + * Forex trading frequency + */ + @SerializedName("forex_trading_frequency") + private String forexTradingFrequency; + + /** + * Indices trading experience + */ + @SerializedName("indices_trading_experience") + private String indicesTradingExperience; + + /** + * Indices trading frequency + */ + @SerializedName("indices_trading_frequency") + private String indicesTradingFrequency; + + /** + * Commodities trading experience + */ + @SerializedName("commodities_trading_experience") + private String commoditiesTradingExperience; + + /** + * Commodities trading frequency + */ + @SerializedName("commodities_trading_frequency") + private String commoditiesTradingFrequency; + + /** + * Stocks trading experience + */ + @SerializedName("stocks_trading_experience") + private String stocksTradingExperience; + + /** + * Stocks trading frequency + */ + @SerializedName("stocks_trading_frequency") + private String stocksTradingFrequency; + + /** + * Binary options or other financial derivatives trading experience + */ + @SerializedName("other_derivatives_trading_experience") + private String otherDerivativesTradingExperience; + + /** + * Binary options or other derivatives trading frequency + */ + @SerializedName("other_derivatives_trading_frequency") + private String otherDerivativesTradingFrequency; + + /** + * Other financial instruments trading experience + */ + @SerializedName("other_instruments_trading_experience") + private String otherInstrumentsTradingExperience; + + /** + * Other financial instruments trading frequency + */ + @SerializedName("other_instruments_trading_frequency") + private String otherInstrumentsTradingFrequency; + + /** + * Industry of Employment + */ + @SerializedName("employment_industry") + private String employmentIndustry; + + /** + * Level of education + */ + @SerializedName("education_level") + private String educationLevel; + + /** + * Income source + */ + @SerializedName("income_source") + private String incomeSource; + + /** + * Net annual income + */ + @SerializedName("net_income") + private String netIncome; + + /** + * Estimated Net worth + */ + @SerializedName("estimated_worth") + private String estimatedWorth; + + /** + * The anticipated account turnover + */ + @SerializedName("account_turnover") + private String accountTurnover; + + /** + * Occupation + */ + @SerializedName("occupation") + private String occupation; + + /** + * Employment status + */ + @SerializedName("employment_status") + private String employmentStatus; + + /** + * Source of wealth + */ + @SerializedName("source_of_wealth") + private String sourceOfWealth; + + public SetFinancialAssessmentRequest() { + this.responseType = SetFinancialAssessmentResponse.class; + } + + public String getForexTradingExperience() { + return forexTradingExperience; + } + + public void setForexTradingExperience(ExperienceDuration forexTradingExperience) { + this.forexTradingExperience = forexTradingExperience.toString(); + } + + public String getForexTradingFrequency() { + return forexTradingFrequency; + } + + public void setForexTradingFrequency(TradeFrequency forexTradingFrequency) { + this.forexTradingFrequency = forexTradingFrequency.toString(); + } + + public String getIndicesTradingExperience() { + return indicesTradingExperience; + } + + public void setIndicesTradingExperience(ExperienceDuration indicesTradingExperience) { + this.indicesTradingExperience = indicesTradingExperience.toString(); + } + + public String getIndicesTradingFrequency() { + return indicesTradingFrequency; + } + + public void setIndicesTradingFrequency(TradeFrequency indicesTradingFrequency) { + this.indicesTradingFrequency = indicesTradingFrequency.toString(); + } + + public String getCommoditiesTradingExperience() { + return commoditiesTradingExperience; + } + + public void setCommoditiesTradingExperience(ExperienceDuration commoditiesTradingExperience) { + this.commoditiesTradingExperience = commoditiesTradingExperience.toString(); + } + + public String getCommoditiesTradingFrequency() { + return commoditiesTradingFrequency; + } + + public void setCommoditiesTradingFrequency(TradeFrequency commoditiesTradingFrequency) { + this.commoditiesTradingFrequency = commoditiesTradingFrequency.toString(); + } + + public String getStocksTradingExperience() { + return stocksTradingExperience; + } + + public void setStocksTradingExperience(ExperienceDuration stocksTradingExperience) { + this.stocksTradingExperience = stocksTradingExperience.toString(); + } + + public String getStocksTradingFrequency() { + return stocksTradingFrequency; + } + + public void setStocksTradingFrequency(TradeFrequency stocksTradingFrequency) { + this.stocksTradingFrequency = stocksTradingFrequency.toString(); + } + + public String getOtherDerivativesTradingExperience() { + return otherDerivativesTradingExperience; + } + + public void setOtherDerivativesTradingExperience(ExperienceDuration otherDerivativesTradingExperience) { + this.otherDerivativesTradingExperience = otherDerivativesTradingExperience.toString(); + } + + public String getOtherDerivativesTradingFrequency() { + return otherDerivativesTradingFrequency; + } + + public void setOtherDerivativesTradingFrequency(TradeFrequency otherDerivativesTradingFrequency) { + this.otherDerivativesTradingFrequency = otherDerivativesTradingFrequency.toString(); + } + + public String getOtherInstrumentsTradingExperience() { + return otherInstrumentsTradingExperience; + } + + public void setOtherInstrumentsTradingExperience(ExperienceDuration otherInstrumentsTradingExperience) { + this.otherInstrumentsTradingExperience = otherInstrumentsTradingExperience.toString(); + } + + public String getOtherInstrumentsTradingFrequency() { + return otherInstrumentsTradingFrequency; + } + + public void setOtherInstrumentsTradingFrequency(TradeFrequency otherInstrumentsTradingFrequency) { + this.otherInstrumentsTradingFrequency = otherInstrumentsTradingFrequency.toString(); + } + + public String getEmploymentIndustry() { + return employmentIndustry; + } + + public void setEmploymentIndustry(EmploymentIndustries employmentIndustry) { + this.employmentIndustry = employmentIndustry.toString(); + } + + public String getEducationLevel() { + return educationLevel; + } + + public void setEducationLevel(EducationLevels educationLevel) { + this.educationLevel = educationLevel.toString(); + } + + public String getIncomeSource() { + return incomeSource; + } + + public void setIncomeSource(IncomeSources incomeSource) { + this.incomeSource = incomeSource.toString(); + } + + public String getNetIncome() { + return netIncome; + } + + public void setNetIncome(TurnoverRanges netIncome) { + this.netIncome = netIncome.toString(); + } + + public String getEstimatedWorth() { + return estimatedWorth; + } + + public void setEstimatedWorth(EstimatedWorth estimatedWorth) { + this.estimatedWorth = estimatedWorth.toString(); + } + + public String getAccountTurnover() { + return accountTurnover; + } + + public void setAccountTurnover(TurnoverRanges accountTurnover) { + this.accountTurnover = accountTurnover.toString(); + } + + public String getOccupation() { + return occupation; + } + + public void setOccupation(Occupations occupation) { + this.occupation = occupation.toString(); + } + + public String getEmploymentStatus() { + return employmentStatus; + } + + public void setEmploymentStatus(EmploymentStatuses employmentStatus) { + this.employmentStatus = employmentStatus.toString(); + } + + public String getSourceOfWealth() { + return sourceOfWealth; + } + + public void setSourceOfWealth(WealthSources sourceOfWealth) { + this.sourceOfWealth = sourceOfWealth.toString(); + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/requests/SetSelfExclusionSettingsRequest.java b/Trading/src/main/java/com/suneesh/trading/models/requests/SetSelfExclusionSettingsRequest.java new file mode 100644 index 0000000..188b226 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/requests/SetSelfExclusionSettingsRequest.java @@ -0,0 +1,175 @@ +package com.suneesh.trading.models.requests; + +import com.suneesh.trading.models.responses.SetSelfExclusionSettingsResponse; +import com.google.gson.annotations.SerializedName; + +import java.math.BigDecimal; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 9/12/2017 + */ +public class SetSelfExclusionSettingsRequest extends RequestBase { + + @SerializedName("set_self_exclusion") + private final int setSelfExclusion = 1; + + /** + * Maximum account cash balance + */ + @SerializedName("max_balance") + private BigDecimal maxBalance; + + /** + * Daily turnover limit + */ + @SerializedName("max_turnover") + private BigDecimal maxTurnover; + + /** + * Daily limit on losses + */ + @SerializedName("max_losses") + private BigDecimal maxLosses; + + /** + * 7-day turnover limit + */ + @SerializedName("max_7day_turnover") + private BigDecimal maxSevenDayTurnover; + + /** + * 7-day limit on losses + */ + @SerializedName("max_7day_losses") + private BigDecimal maxSevenDayLosses; + + /** + * 30-day turnover limit + */ + @SerializedName("max_30day_turnover") + private BigDecimal maxThirtyDayTurnover; + + /** + * 30-day limit on losses + */ + @SerializedName("max_30day_losses") + private BigDecimal maxThirtyDayLosses; + + /** + * Maximum number of open positions + */ + @SerializedName("max_open_bets") + private Integer maxOpenBets; + + /** + * Session duration limit, in minutes + */ + @SerializedName("session_duration_limit") + private Integer sessionDurationLimit; + + /** + * Exclude me from the website until + */ + @SerializedName("exclude_until") + private String excludeUntil; + + /** + * Exclude me from the website until (epoch time) + */ + @SerializedName("timeout_until") + private Long timeoutUntil; + + public SetSelfExclusionSettingsRequest(){ + this.responseType = SetSelfExclusionSettingsResponse.class; + } + + public BigDecimal getMaxBalance() { + return maxBalance; + } + + public void setMaxBalance(BigDecimal maxBalance) { + this.maxBalance = maxBalance; + } + + public BigDecimal getMaxTurnover() { + return maxTurnover; + } + + public void setMaxTurnover(BigDecimal maxTurnover) { + this.maxTurnover = maxTurnover; + } + + public BigDecimal getMaxLosses() { + return maxLosses; + } + + public void setMaxLosses(BigDecimal maxLosses) { + this.maxLosses = maxLosses; + } + + public BigDecimal getMaxSevenDayTurnover() { + return maxSevenDayTurnover; + } + + public void setMaxSevenDayTurnover(BigDecimal maxSevenDayTurnover) { + this.maxSevenDayTurnover = maxSevenDayTurnover; + } + + public BigDecimal getMaxSevenDayLosses() { + return maxSevenDayLosses; + } + + public void setMaxSevenDayLosses(BigDecimal maxSevenDayLosses) { + this.maxSevenDayLosses = maxSevenDayLosses; + } + + public BigDecimal getMaxThirtyDayTurnover() { + return maxThirtyDayTurnover; + } + + public void setMaxThirtyDayTurnover(BigDecimal maxThirtyDayTurnover) { + this.maxThirtyDayTurnover = maxThirtyDayTurnover; + } + + public BigDecimal getMaxThirtyDayLosses() { + return maxThirtyDayLosses; + } + + public void setMaxThirtyDayLosses(BigDecimal maxThirtyDayLosses) { + this.maxThirtyDayLosses = maxThirtyDayLosses; + } + + public Integer getMaxOpenBets() { + return maxOpenBets; + } + + public void setMaxOpenBets(Integer maxOpenBets) { + this.maxOpenBets = maxOpenBets; + } + + public Integer getSessionDurationLimit() { + return sessionDurationLimit; + } + + public void setSessionDurationLimit(Integer sessionDurationLimit) { + this.sessionDurationLimit = sessionDurationLimit; + } + + public String getExcludeUntil() { + return excludeUntil; + } + + public void setExcludeUntil(String excludeUntil) { + this.excludeUntil = excludeUntil; + } + + public Long getTimeoutUntil() { + return timeoutUntil; + } + + public void setTimeoutUntil(Long timeoutUntil) { + this.timeoutUntil = timeoutUntil; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/requests/StartCopyTradeRequest.java b/Trading/src/main/java/com/suneesh/trading/models/requests/StartCopyTradeRequest.java new file mode 100644 index 0000000..c28d8bd --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/requests/StartCopyTradeRequest.java @@ -0,0 +1,110 @@ +package com.suneesh.trading.models.requests; + +import com.suneesh.trading.models.responses.StartCopyTradeResponse; +import com.suneesh.trading.utils.Validator; +import com.google.gson.annotations.SerializedName; + +import java.math.BigDecimal; +import java.util.List; + +/** + *

StartCopyTradeRequest

+ * + *

Copy Start Send

+ *

+ * Start copy trader bets + *

+ * + * + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/9/2017 + */ +public class StartCopyTradeRequest extends RequestBase { + + /** + * API tokens identifying the accounts of trader which will be used to copy trades + * + */ + @SerializedName("copy_start") + private String traderToken; + + /** + * Optional field, used to set minimal trade stake to be copied + * + */ + @SerializedName("min_trade_stake") + private BigDecimal minTradeStake; + + /** + * Optional field, used to set maximum trade stake to be copied + * + */ + @SerializedName("max_trade_stake") + private BigDecimal maxTradeStake; + + /** + * Optional field, used to set assets to be copied. E.x ["frxUSDJPY", "R_50"] + * + */ + @SerializedName("assets") + private List assets; + + /** + * Optional field, used to set trade types to be copied. E.x ["CALL", "PUT"] + * + */ + @SerializedName("trade_types") + private List tradeTypes; + + private StartCopyTradeRequest() { + this.responseType = StartCopyTradeResponse.class; + } + + public StartCopyTradeRequest(String traderToken) { + this(); + this.setTraderToken(traderToken); + } + + public String getTraderToken() { + return traderToken; + } + + public void setTraderToken(String traderToken) { + Validator.checkPattern("^[\\w\\s-]{15,32}$", traderToken, + "Trader Token does not match the regex pattern /^[\\w\\s-]{15,32}$/"); + this.traderToken = traderToken; + } + + public BigDecimal getMinTradeStake() { + return minTradeStake; + } + + public void setMinTradeStake(BigDecimal minTradeStake) { + this.minTradeStake = minTradeStake; + } + + public BigDecimal getMaxTradeStake() { + return maxTradeStake; + } + + public void setMaxTradeStake(BigDecimal maxTradeStake) { + this.maxTradeStake = maxTradeStake; + } + + public List getAssets() { + return assets; + } + + public void setAssets(List assets) { + this.assets = assets; + } + + public List getTradeTypes() { + return tradeTypes; + } + + public void setTradeTypes(List tradeTypes) { + this.tradeTypes = tradeTypes; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/requests/StatementRequest.java b/Trading/src/main/java/com/suneesh/trading/models/requests/StatementRequest.java new file mode 100644 index 0000000..c0930d8 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/requests/StatementRequest.java @@ -0,0 +1,125 @@ +package com.suneesh.trading.models.requests; + +import com.suneesh.trading.models.enums.TransactionType; +import com.suneesh.trading.models.responses.StatementResponse; +import com.suneesh.trading.utils.Validator; +import com.google.gson.annotations.SerializedName; +import io.reactivex.annotations.Nullable; + +/** + *

StatementRequest

+ *

+ *

Statement Send

+ *

+ * Retrieve a summary of account transactions, according to given search criteria + *

+ * + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/7/2017 + */ +public class StatementRequest extends RequestBase { + + @SerializedName("statement") + private final int statement = 1; + + /** + * If set to 1, will return full contracts description. + */ + @SerializedName("description") + @Nullable + private Integer description; + + /** + * Apply upper limit to count of transactions received + */ + @SerializedName("limit") + @Nullable + private Integer limit; + + /** + * Skip this many transactions + */ + @SerializedName("offset") + @Nullable + private Integer offset; + + /** + * Optional start date (epoch) + */ + @SerializedName("date_from") + @Nullable + private Integer dateFrom; + + /** + * Optional end date (epoch) + */ + @SerializedName("date_end") + @Nullable + private Integer dateEnd; + + /** + * Optional filter for statement (deposit,withdrawal,buy,sell) + */ + @SerializedName("action_type") + @Nullable + private String actionType; + + public StatementRequest() { + this.responseType = StatementResponse.class; + } + + public boolean getDescription() { + return description == 1 ? true : false; + } + + public void setDescription(boolean description) { + this.description = description ? 1 : 0; + } + + public Integer getLimit() { + return limit; + } + + public void setLimit(Integer limit) { + this.limit = limit; + } + + public Integer getOffset() { + return offset; + } + + public void setOffset(Integer offset) { + Validator.checkPattern("^\\d{1,3}$", offset.toString(), + "Offset does not match the regex pattern /^\\d{1,3}/"); + this.offset = offset; + } + + public Integer getDateFrom() { + return dateFrom; + } + + public void setDateFrom(Integer dateFrom) { + Validator.checkPattern("^\\d{1,10}$", dateFrom.toString(), + "DateFrom does not match the regex pattern /^\\d{1,10}/"); + this.dateFrom = dateFrom; + } + + public Integer getDateEnd() { + return dateEnd; + } + + public void setDateEnd(Integer dateEnd) { + Validator.checkPattern("^\\d{1,10}$", dateEnd.toString(), + "DateEnd does not match the regex pattern /^\\d{1,10}/"); + this.dateEnd = dateEnd; + } + + public String getActionType() { + return actionType; + } + + public void setActionType(TransactionType actionType) { + this.actionType = actionType.toString(); + } +} \ No newline at end of file diff --git a/Trading/src/main/java/com/suneesh/trading/models/requests/StatesListRequest.java b/Trading/src/main/java/com/suneesh/trading/models/requests/StatesListRequest.java new file mode 100644 index 0000000..62a437e --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/requests/StatesListRequest.java @@ -0,0 +1,39 @@ +package com.suneesh.trading.models.requests; + +import com.suneesh.trading.models.responses.StatesListResponse; +import com.suneesh.trading.utils.Validator; +import com.google.gson.annotations.SerializedName; + +/** + *

StatesListRequest

+ * + *

States List Send

+ *

For a given country, returns a list of States of that country. This is useful to populate the account opening form.

+ * + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/2/2017 + */ +public class StatesListRequest extends RequestBase { + + /** + * Two letter country code. + */ + @SerializedName("states_list") + private String countyCode; + + public StatesListRequest(String countyCode) { + this.responseType = StatesListResponse.class; + this.setCountyCode(countyCode); + } + + public String getCountyCode() { + return countyCode; + } + + public void setCountyCode(String countyCode) { + Validator.checkPattern("^\\w\\w$", countyCode, + "Country Code does not match the regex pattern /^\\w\\w$/"); + this.countyCode = countyCode; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/requests/StopCopyTradeRequest.java b/Trading/src/main/java/com/suneesh/trading/models/requests/StopCopyTradeRequest.java new file mode 100644 index 0000000..5b44283 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/requests/StopCopyTradeRequest.java @@ -0,0 +1,45 @@ +package com.suneesh.trading.models.requests; + +import com.suneesh.trading.models.responses.StopCopyTradeResponse; +import com.suneesh.trading.utils.Validator; +import com.google.gson.annotations.SerializedName; + +/** + *

StopCopyTradeRequest

+ * + *

Copy Stop Send

+ *

+ * Stop copy trader bets + *

+ * + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/9/2017 + */ +public class StopCopyTradeRequest extends RequestBase { + + /** + * API tokens identifying the accounts which needs not to be copied + */ + @SerializedName("copy_stop") + private String traderToken; + + private StopCopyTradeRequest(){ + this.responseType = StopCopyTradeResponse.class; + } + + public StopCopyTradeRequest(String traderToken) { + this(); + this.setTraderToken(traderToken); + } + + public String getTraderToken() { + return traderToken; + } + + public void setTraderToken(String traderToken) { + Validator.checkPattern("^[\\w\\s-]{15,32}$", traderToken, + "Trader Token does not match the regex pattern /^[\\w\\s-]{15,32}$/"); + this.traderToken = traderToken; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/requests/TNCApprovalRequest.java b/Trading/src/main/java/com/suneesh/trading/models/requests/TNCApprovalRequest.java new file mode 100644 index 0000000..4b7f787 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/requests/TNCApprovalRequest.java @@ -0,0 +1,37 @@ +package com.suneesh.trading.models.requests; + +import com.suneesh.trading.models.responses.TNCApprovalResponse; +import com.google.gson.annotations.SerializedName; + +/** + *

TNCApprovalRequest

+ * + *

T&C Approval Send

+ * + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 9/4/2017 + */ +public class TNCApprovalRequest extends RequestBase { + + @SerializedName("tnc_approval") + private final int tcApproval = 1; + + /** + * for ASK_UK_FUNDS_PROTECTION in cashier + */ + @SerializedName("ukgc_funds_protection") + private Integer askUKFundsProtection; + + public TNCApprovalRequest() { + this.responseType = TNCApprovalResponse.class; + } + + public Integer getAskUKFundsProtection() { + return askUKFundsProtection; + } + + public void setAskUKFundsProtection(Integer askUKFundsProtection) { + this.askUKFundsProtection = askUKFundsProtection; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/requests/TickHistoryRequest.java b/Trading/src/main/java/com/suneesh/trading/models/requests/TickHistoryRequest.java new file mode 100644 index 0000000..8ca693f --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/requests/TickHistoryRequest.java @@ -0,0 +1,157 @@ +package com.suneesh.trading.models.requests; + +import com.suneesh.trading.models.enums.TickStyles; +import com.suneesh.trading.models.responses.TickHistoryResponse; +import com.suneesh.trading.utils.Validator; +import com.google.gson.annotations.SerializedName; +import io.reactivex.annotations.Nullable; + +/** + *

TickHistoryRequest

+ * + *

Tick History Request

+ *

Get historic tick data for a given symbol name

+ * + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/3/2017 + */ +public class TickHistoryRequest extends RequestBase { + + /** + * Short symbol name + */ + @SerializedName("ticks_history") + private String symbol; + + /** + * Epoch value representing the end-datetime of the ticks. + * If non-numeric value (e.g. "latest", the end-datetime will be the latest available timestamp. + */ + @SerializedName("end") + private String end; + + /** + * Epoch value representing the start-datetime of the ticks (For styles: 'ticks', it will default to 1 day ago. + * For styles: 'candle', it will default to 1 day ago if count or granularity is undef ) + */ + @SerializedName("start") + @Nullable + private Integer start; + + /** + * An upper limit on ticks to receive (default: 5000) + */ + @SerializedName("count") + @Nullable + private Integer count; + + /** + * The tick-output style: must be one of 'ticks' or 'candles' (default: 'ticks') + */ + @SerializedName("style") + @Nullable + private String style; + + /** + * Provide for style: 'candles'. Candle time-dimension width setting. + * Allowed values 60, 120, 180, 300, 600, 900, 1800, 3600, 7200, 14400, 28800, 86400 (default: '60'). + */ + @SerializedName("granularity") + @Nullable + private Integer granularity; + + /** + * If market is closed at the end time, or license limit is before end time, then move interval backwards. + */ + @SerializedName("adjust_start_time") + @Nullable + private Integer adjustStartTime; + + /** + * If set to 1, will send updates whenever the price changes + */ + @SerializedName("subscribe") + @Nullable + private Integer subscribe; + + public TickHistoryRequest(String symbol, String end){ + this.responseType = TickHistoryResponse.class; + this.setSymbol(symbol); + this.setEnd(end); + } + + public String getSymbol() { + return symbol; + } + + public void setSymbol(String symbol) { + Validator.checkPattern("^\\w{2,30}$", symbol, + "Symbol does not match the regex pattern /^\\w{2,30}$/"); + this.symbol = symbol; + } + + public String getEnd() { + return end; + } + + public void setEnd(String end) { + Validator.checkPattern("^(latest|\\d{1,10})$", end, + "End does not match the regex pattern /^(latest|\\d{1,10})$/"); + this.end = end; + } + + public Integer getStart() { + return start; + } + + public void setStart(Integer start) { + Validator.checkPattern("^\\d{1,10}$", start.toString(), + "Start does not match the regex pattern /^\\d{1,10}$/"); + this.start = start; + } + + public Integer getCount() { + return count; + } + + public void setCount(Integer count) { + this.count = count; + } + + public String getStyle() { + return style; + } + + public void setStyle(TickStyles style) { + this.style = style.toString().toLowerCase(); + } + + public Integer getGranularity() { + return granularity; + } + + public void setGranularity(Integer granularity) { + this.granularity = granularity; + } + + public Integer getAdjustStartTime() { + return adjustStartTime; + } + + public void setAdjustStartTime(Integer adjustStartTime) { + Validator.checkPattern("^1?$", adjustStartTime.toString(), + "AdjustStartTime does not match the regex /^1?$/"); + this.adjustStartTime = adjustStartTime; + } + + public Integer getSubscribe() { + return subscribe; + } + + public void setSubscribe(Integer subscribe) { + Validator.checkPattern("^1?$", subscribe.toString(), + "Subscribe does not match the regex /^1?$/"); + this.subscribe = subscribe; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/requests/TickRequest.java b/Trading/src/main/java/com/suneesh/trading/models/requests/TickRequest.java new file mode 100644 index 0000000..6c625ad --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/requests/TickRequest.java @@ -0,0 +1,52 @@ +package com.suneesh.trading.models.requests; + +import com.suneesh.trading.models.responses.TickResponse; +import com.google.gson.annotations.SerializedName; +import io.reactivex.annotations.Nullable; + +/** + * Created by morteza on 7/19/2017. + */ + +public class TickRequest extends RequestBase{ + + public TickRequest(){ + this.responseType = TickResponse.class; + } + + public TickRequest(String symbol) { + this(); + this.symbol = symbol; + } + + public TickRequest(String symbol, Boolean subscribe){ + this(symbol); + this.subscribe = subscribe? 1: null; + } + + @SerializedName("ticks") + private String symbol; + + /** + * If set to 1, will send updates whenever the price changes + */ + @SerializedName("subscribe") + @Nullable + private Integer subscribe = null; + + public String getSymbol() { + return symbol; + } + + public void setSymbol(String symbol) { + this.symbol = symbol; + } + + public Integer getSubscribe() { + return subscribe; + } + + public void setSubscribe(Integer subscribe) { + this.subscribe = subscribe; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/requests/TimeRequest.java b/Trading/src/main/java/com/suneesh/trading/models/requests/TimeRequest.java new file mode 100644 index 0000000..38f7dcd --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/requests/TimeRequest.java @@ -0,0 +1,24 @@ +package com.suneesh.trading.models.requests; + +import com.suneesh.trading.models.responses.TimeResponse; +import com.google.gson.annotations.SerializedName; + +/** + *

TimeRequest

+ * + *

Time request

+ *

Request back-end server epoch time

+ * + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/3/2017 + */ +public class TimeRequest extends RequestBase { + + @SerializedName("time") + private final int time = 1; + + public TimeRequest() { + this.responseType = TimeResponse.class; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/requests/TopUpVirtualMoneyAccountRequest.java b/Trading/src/main/java/com/suneesh/trading/models/requests/TopUpVirtualMoneyAccountRequest.java new file mode 100644 index 0000000..d1a193b --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/requests/TopUpVirtualMoneyAccountRequest.java @@ -0,0 +1,26 @@ +package com.suneesh.trading.models.requests; + +import com.suneesh.trading.models.responses.TopUpVirtualMoneyAccountResponse; +import com.google.gson.annotations.SerializedName; + +/** + *

TopUpVirtualMoneyAccountRequest

+ * + *

Top Up Virtual Request

+ *

+ * When a virtual-money's account balance becomes low, it can be topped up using this call. + *

+ * + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/9/2017 + */ +public class TopUpVirtualMoneyAccountRequest extends RequestBase { + + @SerializedName("topup_virtual") + private final int topUpVirtual = 1; + + public TopUpVirtualMoneyAccountRequest() { + this.responseType = TopUpVirtualMoneyAccountResponse.class; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/requests/TradingTimesRequest.java b/Trading/src/main/java/com/suneesh/trading/models/requests/TradingTimesRequest.java new file mode 100644 index 0000000..c97aadf --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/requests/TradingTimesRequest.java @@ -0,0 +1,43 @@ +package com.suneesh.trading.models.requests; + +import com.suneesh.trading.models.responses.TradingTimesResponse; +import com.suneesh.trading.utils.Validator; +import com.google.gson.annotations.SerializedName; + +/** + *

TradingTimesRequest

+ * + *

Trading Times Send

+ *

Receive a list of marketing opening times for a given date

+ * + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/3/2017 + */ +public class TradingTimesRequest extends RequestBase { + + /** + * Trading date in yyyy-mm-dd format (or use 'today' for trading times for today's date). + */ + @SerializedName("trading_times") + private String tradingDate; + + public TradingTimesRequest() { + this.setResponseType(TradingTimesResponse.class); + } + + public TradingTimesRequest(String tradingDate) { + this(); + this.setTradingDate(tradingDate); + } + + public String getTradingDate() { + return tradingDate; + } + + public void setTradingDate(String tradingDate) { + Validator.checkPattern("^(\\d{4}-\\d{1,2}-\\d{1,2}|today)$", tradingDate, + "Trading Date does not match the regex pattern /^(\\d{4}-\\d{1,2}-\\d{1,2}|today)$/"); + this.tradingDate = tradingDate; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/requests/TransactionsStreamRequest.java b/Trading/src/main/java/com/suneesh/trading/models/requests/TransactionsStreamRequest.java new file mode 100644 index 0000000..ee60b4d --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/requests/TransactionsStreamRequest.java @@ -0,0 +1,29 @@ +package com.suneesh.trading.models.requests; + +import com.suneesh.trading.models.responses.TransactionsStreamResponse; +import com.google.gson.annotations.SerializedName; + +/** + *

TransactionsStreamRequest

+ * + *

Transaction Subscription

+ *

+ * Subscribe to transaction notifications + *

+ * + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/8/2017 + */ +public class TransactionsStreamRequest extends RequestBase { + + @SerializedName("transaction") + private final int transaction = 1; + + @SerializedName("subscribe") + private final int subscribe = 1; + + public TransactionsStreamRequest() { + this.responseType = TransactionsStreamResponse.class; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/requests/TransferBetweenAccountsRequest.java b/Trading/src/main/java/com/suneesh/trading/models/requests/TransferBetweenAccountsRequest.java new file mode 100644 index 0000000..a3ccc18 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/requests/TransferBetweenAccountsRequest.java @@ -0,0 +1,88 @@ +package com.suneesh.trading.models.requests; + +import com.suneesh.trading.models.responses.TransferBetweenAccountsResponse; +import com.google.gson.annotations.SerializedName; + +import java.math.BigDecimal; + +/** + *

TransferBetweenAccountsRequest

+ * + *

Transfer Between Accounts Request

+ *

+ * This call allows transfers between accounts held by a given user with the 'malta' and + * 'maltainvest' Landing Companies or between sub account and master account for omnibus accounts. + *

+ * + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 9/15/2017 + */ +public class TransferBetweenAccountsRequest extends RequestBase { + + /** + * if account_from and account_to are not provided, we'll just return available accounts + */ + @SerializedName("transfer_between_accounts") + private final int transferBetweenAccounts = 1; + + /** + * The account_from loginid + */ + @SerializedName("account_from") + private String accountFrom; + + /** + * The account_to loginid + */ + @SerializedName("account_to") + private String accountTo; + + /** + * Currency + */ + @SerializedName("currency") + private String currency; + + /** + * Amount + */ + @SerializedName("amount") + private BigDecimal amount; + + public TransferBetweenAccountsRequest() { + this.responseType = TransferBetweenAccountsResponse.class; + } + + public String getAccountFrom() { + return accountFrom; + } + + public void setAccountFrom(String accountFrom) { + this.accountFrom = accountFrom; + } + + public String getAccountTo() { + return accountTo; + } + + public void setAccountTo(String accountTo) { + this.accountTo = accountTo; + } + + public String getCurrency() { + return currency; + } + + public void setCurrency(String currency) { + this.currency = currency; + } + + public BigDecimal getAmount() { + return amount; + } + + public void setAmount(BigDecimal amount) { + this.amount = amount; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/requests/WebsiteStatusRequest.java b/Trading/src/main/java/com/suneesh/trading/models/requests/WebsiteStatusRequest.java new file mode 100644 index 0000000..b56183f --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/requests/WebsiteStatusRequest.java @@ -0,0 +1,45 @@ +package com.suneesh.trading.models.requests; + +import com.suneesh.trading.models.responses.WebsiteStatusResponse; +import com.suneesh.trading.utils.Validator; +import com.google.gson.annotations.SerializedName; +import io.reactivex.annotations.Nullable; +import okhttp3.WebSocket; + +/** + *

WebsiteStatusRequest

+ * + *

Server Status request

+ *

Request server status

+ * + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/3/2017 + */ +public class WebsiteStatusRequest extends RequestBase { + + @SerializedName("website_status") + private final int websiteStatus = 1; + + @SerializedName("subscribe") + @Nullable + private Integer subscribe; + + public WebsiteStatusRequest() { + this.responseType = WebsiteStatusResponse.class; + } + + public WebsiteStatusRequest(Integer subscribe){ + this(); + } + + public Integer getSubscribe() { + return subscribe; + } + + public void setSubscribe(Integer subscribe) { + Validator.checkPattern("^(1|0)$", subscribe.toString(), + "Subscribe does not match the regex pattern /^(1|0)$/"); + this.subscribe = subscribe; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/responses/AccountLimits.java b/Trading/src/main/java/com/suneesh/trading/models/responses/AccountLimits.java new file mode 100644 index 0000000..9c76708 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/responses/AccountLimits.java @@ -0,0 +1,136 @@ +package com.suneesh.trading.models.responses; + +import com.google.gson.annotations.SerializedName; + +import java.math.BigDecimal; +import java.util.List; +import java.util.Map; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/3/2017 + */ +public class AccountLimits { + + /** + * Maximum account cash balance + */ + @SerializedName("account_balance") + private BigDecimal accountBalance; + + /** + * Maximum daily turnover + */ + @SerializedName("daily_turnover") + private BigDecimal dailyTurnover; + + /** + * Maximum number of open positions + */ + @SerializedName("open_positions") + private int openPositions; + + /** + * Maximum aggregate payouts on open positions + */ + @SerializedName("payout") + private BigDecimal payout; + + /** + * Maximum aggregate payouts on open positions per symbol and contract type. + * This limit can be exceeded up to the overall payout limit if there is no prior open position. + */ + @SerializedName("payout_per_symbol_and_contract_type") + private BigDecimal payoutPerSymbolAndContractType; + + /** + * Lifetime withdrawal limit + */ + @SerializedName("lifetime_limit") + private BigDecimal lifetimeLimit; + + /** + * Number of days for num_of_days_limit withdrawal limit + */ + @SerializedName("num_of_days") + private int numOfDays; + + /** + * Withdrawal limit for num_of_days days + */ + @SerializedName("num_of_days_limit") + private int numOfDaysLimit; + + /** + * Amount left to reach withdrawal limit + */ + @SerializedName("remainder") + private BigDecimal remainder; + + /** + * Total withdrawal for num_of_days days + */ + @SerializedName("withdrawal_for_x_days_monetary") + private BigDecimal withdrawalForXDaysMonetary; + + /** + * Total withdrawal since inception + */ + @SerializedName("withdrawal_since_inception_monetary") + private BigDecimal withdrawalSinceInceptionMonetary; + + /** + * Markets Limits + */ + @SerializedName("market_specific") + private Map> marketSpecific; + + public BigDecimal getAccountBalance() { + return accountBalance; + } + + public BigDecimal getDailyTurnover() { + return dailyTurnover; + } + + public int getOpenPositions() { + return openPositions; + } + + public BigDecimal getPayout() { + return payout; + } + + public BigDecimal getPayoutPerSymbolAndContractType() { + return payoutPerSymbolAndContractType; + } + + public BigDecimal getLifetimeLimit() { + return lifetimeLimit; + } + + public int getNumOfDays() { + return numOfDays; + } + + public int getNumOfDaysLimit() { + return numOfDaysLimit; + } + + public BigDecimal getRemainder() { + return remainder; + } + + public BigDecimal getWithdrawalForXDaysMonetary() { + return withdrawalForXDaysMonetary; + } + + public BigDecimal getWithdrawalSinceInceptionMonetary() { + return withdrawalSinceInceptionMonetary; + } + + public Map> getMarketSpecific() { + return marketSpecific; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/responses/AccountLimitsResponse.java b/Trading/src/main/java/com/suneesh/trading/models/responses/AccountLimitsResponse.java new file mode 100644 index 0000000..a11cf2a --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/responses/AccountLimitsResponse.java @@ -0,0 +1,27 @@ +package com.suneesh.trading.models.responses; + +import com.suneesh.trading.models.requests.AccountLimitsRequest; +import com.google.gson.annotations.SerializedName; + +/** + *

AccountLimitResponse

+ * + *

Get Limits Receive

+ *

Trading and Withdrawal Limits

+ * + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/3/2017 + */ +public class AccountLimitsResponse extends ResponseBase { + + /** + * Trading limits of real account user + */ + @SerializedName("get_limits") + private AccountLimits limits; + + public AccountLimits getLimits() { + return limits; + } +} \ No newline at end of file diff --git a/Trading/src/main/java/com/suneesh/trading/models/responses/AccountSettings.java b/Trading/src/main/java/com/suneesh/trading/models/responses/AccountSettings.java new file mode 100644 index 0000000..2c12c32 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/responses/AccountSettings.java @@ -0,0 +1,357 @@ +package com.suneesh.trading.models.responses; + +import com.google.gson.annotations.SerializedName; +import io.reactivex.annotations.Nullable; + +/** + *

AccountSettings

+ * + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/4/2017 + */ +public class AccountSettings { + + /** + * User Email + */ + @SerializedName("email") + private String email; + + /** + * User Country + */ + @SerializedName("country") + @Nullable + private String country; + + /** + * 2-letter country code ISO standard + */ + @SerializedName("country_code") + @Nullable + private String countryCode; + + /** + * Salutation (note: not set for virtual-money accounts) + */ + @SerializedName("salutation") + @Nullable + private String salutation; + + /** + * First name (note: not set for virtual-money accounts) + */ + @SerializedName("first_name") + @Nullable + private String firstName; + + /** + * Last name (note: not set for virtual-money accounts) + */ + @SerializedName("last_name") + @Nullable + private String lastName; + + /** + * Epoch of user's birthday (note: not set for virtual-money accounts) + */ + @SerializedName("date_of_birth") + @Nullable + private Integer dateOfBirth; + + /** + * Address line 1 (note: not set for virtual-money accounts) + */ + @SerializedName("address_line_1") + @Nullable + private String firstAddressLine; + + /** + * Address line 2 (note: not set for virtual-money accounts) + */ + @SerializedName("address_line_2") + @Nullable + private String secondAddressLine; + + /** + * City (note: not set for virtual-money accounts) + */ + @SerializedName("address_city") + @Nullable + private String addressCity; + + /** + * State (note: not set for virtual-money accounts) + */ + @SerializedName("address_state") + @Nullable + private String addressState; + + /** + * Post Code (note: not set for virtual-money accounts) + */ + @SerializedName("address_postcode") + @Nullable + private String addressPostcode; + + /** + * Telephone (note: not set for virtual-money accounts) + */ + @SerializedName("phone") + @Nullable + private String phone; + + /** + * Boolean value 1 or 0, indicating whether is payment agent (note: not applicable for virtual money accounts) + */ + @SerializedName("is_authenticated_payment_agent") + private int isAuthenticatedPaymentAgent; + + /** + * Boolean value 1 or 0, indicating permission to use email address for any contact which may include marketing + */ + @SerializedName("email_consent") + private int emailConsent; + + /** + * Boolean value 1 or 0, indicating permission to allow others to follow your trades. + * Note: not applicable for Virtual account. Only allow for real money account. + */ + @SerializedName("allow_copier") + private int allowCopier; + + /** + * Latest terms and conditions version accepted by client + */ + @SerializedName("client_tnc_status") + @Nullable + private String clientTNCStatus; + + /** + * Place of birth, 2-letter country code. + */ + @SerializedName("place_of_birth") + @Nullable + private String placeOfBirth; + + /** + * Residence for tax purpose. Comma separated iso country code if multiple jurisdictions. + * Only applicable for real money account. + */ + @SerializedName("tax_residence") + @Nullable + private String taxResidence; + + /** + * Tax identification number. Only applicable for real money account. + */ + @SerializedName("tax_identification_number") + @Nullable + private String taxIdentificationNumber; + + /** + * Purpose and reason for requesting the account opening. Only applicable for real money account. + */ + @SerializedName("account_opening_reason") + @Nullable + private String accountOpeningReason; + + /** + * Japan real money account status, only applicable for Japan virtual money account client. + */ + @SerializedName("jp_account_status") + @Nullable + private JPAccountStatus jpAccountStatus; + + /** + * Japan real money client settings, only applicable for Japan real money account client. + */ + @SerializedName("jp_settings") + @Nullable + private JPSettings jpSettings; + + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } + + public String getCountry() { + return country; + } + + public void setCountry(String country) { + this.country = country; + } + + public String getCountryCode() { + return countryCode; + } + + public void setCountryCode(String countryCode) { + this.countryCode = countryCode; + } + + public String getSalutation() { + return salutation; + } + + public void setSalutation(String salutation) { + this.salutation = salutation; + } + + public String getFirstName() { + return firstName; + } + + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + public String getLastName() { + return lastName; + } + + public void setLastName(String lastName) { + this.lastName = lastName; + } + + public Integer getDateOfBirth() { + return dateOfBirth; + } + + public void setDateOfBirth(Integer dateOfBirth) { + this.dateOfBirth = dateOfBirth; + } + + public String getFirstAddressLine() { + return firstAddressLine; + } + + public void setFirstAddressLine(String firstAddressLine) { + this.firstAddressLine = firstAddressLine; + } + + public String getSecondAddressLine() { + return secondAddressLine; + } + + public void setSecondAddressLine(String secondAddressLine) { + this.secondAddressLine = secondAddressLine; + } + + public String getAddressCity() { + return addressCity; + } + + public void setAddressCity(String addressCity) { + this.addressCity = addressCity; + } + + public String getAddressState() { + return addressState; + } + + public void setAddressState(String addressState) { + this.addressState = addressState; + } + + public String getAddressPostcode() { + return addressPostcode; + } + + public void setAddressPostcode(String addressPostcode) { + this.addressPostcode = addressPostcode; + } + + public String getPhone() { + return phone; + } + + public void setPhone(String phone) { + this.phone = phone; + } + + public boolean isAuthenticatedPaymentAgent() { + return isAuthenticatedPaymentAgent == 1 ? true : false; + } + + public void setIsAuthenticatedPaymentAgent(boolean isAuthenticatedPaymentAgent) { + this.isAuthenticatedPaymentAgent = isAuthenticatedPaymentAgent ? 1 : 0; + } + + public boolean getEmailConsent() { + return emailConsent == 1 ? true : false; + } + + public void setEmailConsent(boolean emailConsent) { + this.emailConsent = emailConsent ? 1 : 0; + } + + public boolean getAllowCopier() { + return allowCopier == 1 ? true : false; + } + + public void setAllowCopier(boolean allowCopier) { + this.allowCopier = allowCopier ? 1 : 0; + } + + public String getClientTNCStatus() { + return clientTNCStatus; + } + + public void setClientTNCStatus(String clientTNCStatus) { + this.clientTNCStatus = clientTNCStatus; + } + + public String getPlaceOfBirth() { + return placeOfBirth; + } + + public void setPlaceOfBirth(String placeOfBirth) { + this.placeOfBirth = placeOfBirth; + } + + public String getTaxResidence() { + return taxResidence; + } + + public void setTaxResidence(String taxResidence) { + this.taxResidence = taxResidence; + } + + public String getTaxIdentificationNumber() { + return taxIdentificationNumber; + } + + public void setTaxIdentificationNumber(String taxIdentificationNumber) { + this.taxIdentificationNumber = taxIdentificationNumber; + } + + public String getAccountOpeningReason() { + return accountOpeningReason; + } + + public void setAccountOpeningReason(String accountOpeningReason) { + this.accountOpeningReason = accountOpeningReason; + } + + public JPAccountStatus getJpAccountStatus() { + return jpAccountStatus; + } + + public void setJpAccountStatus(JPAccountStatus jpAccountStatus) { + this.jpAccountStatus = jpAccountStatus; + } + + public JPSettings getJpSettings() { + return jpSettings; + } + + public void setJpSettings(JPSettings jpSettings) { + this.jpSettings = jpSettings; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/responses/AccountSettingsResponse.java b/Trading/src/main/java/com/suneesh/trading/models/responses/AccountSettingsResponse.java new file mode 100644 index 0000000..dfa0eac --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/responses/AccountSettingsResponse.java @@ -0,0 +1,27 @@ +package com.suneesh.trading.models.responses; + +import com.suneesh.trading.models.requests.AccountSettingsRequest; +import com.google.gson.annotations.SerializedName; + +/** + *

AccountSettingsResponse

+ *

+ *

Get User Settings Receive

+ *

A message with User Settings

+ * + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/4/2017 + */ +public class AccountSettingsResponse extends ResponseBase { + + /** + * Account settings + */ + @SerializedName("get_settings") + private AccountSettings settings; + + public AccountSettings getSettings() { + return settings; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/responses/AccountStatus.java b/Trading/src/main/java/com/suneesh/trading/models/responses/AccountStatus.java new file mode 100644 index 0000000..2372d16 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/responses/AccountStatus.java @@ -0,0 +1,53 @@ +package com.suneesh.trading.models.responses; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; + +import javax.persistence.*; +import java.util.List; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/4/2017 + */ +@Entity +@Data +public class AccountStatus { + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private Long identifier; + + /** + * Array of Status + */ + @SerializedName("status") +// private List status; + private String status; + + /** + * Indicates whether the client should be prompted to authenticate their account. + */ + @SerializedName("prompt_client_to_authenticate") + private int promptClientToAuthenticate; + + /** + * Client risk classification: low, standard, high + */ + @SerializedName("risk_classification") + private String riskClassification; + +// public List getStatus() { + public String getStatus() { + return String.join(",", status); +// status; + } + + public boolean getPromptClientToAuthenticate() { + return promptClientToAuthenticate == 1 ? true : false; + } + + public String getRiskClassification() { + return riskClassification; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/responses/AccountStatusResponse.java b/Trading/src/main/java/com/suneesh/trading/models/responses/AccountStatusResponse.java new file mode 100644 index 0000000..2a19598 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/responses/AccountStatusResponse.java @@ -0,0 +1,31 @@ +package com.suneesh.trading.models.responses; + +import com.suneesh.trading.models.requests.AccountStatusRequest; +import com.google.gson.annotations.SerializedName; + +/** + *

AccountStatusResponse

+ * + *

Get Account Status Receive

+ *

A message with Account Status

+ * + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/4/2017 + */ +public class AccountStatusResponse extends ResponseBase { + + public void setAccountStatus(AccountStatus accountStatus) { + this.accountStatus = accountStatus; + } + + /** + * Account status details + */ + @SerializedName("get_account_status") + private AccountStatus accountStatus; + + public AccountStatus getAccountStatus() { + return accountStatus; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/responses/ActiveSymbol.java b/Trading/src/main/java/com/suneesh/trading/models/responses/ActiveSymbol.java new file mode 100644 index 0000000..e2e5e64 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/responses/ActiveSymbol.java @@ -0,0 +1,357 @@ +package com.suneesh.trading.models.responses; + +import com.google.gson.annotations.SerializedName; +import io.reactivex.annotations.Nullable; + +import java.math.BigDecimal; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 7/31/2017 + */ +public class ActiveSymbol { + /** + * intraday_interval_minutes + */ + @SerializedName("symbol") + private String symbol; + + /** + * Intraday interval minutes + */ + @SerializedName("intraday_interval_minutes") + private int intradayIntervalMinutes; + + /** + * Symbol type (forex, commodities, etc) + */ + @SerializedName("symbol_type") + private String symbolType; + + /** + * 1 or 0 - whether the market is currently open or closed + */ + @SerializedName("exchange_is_open") + @Nullable + private Integer isExhcangeOpen; + + /** + * Exchange name (for underlyings listed on a Stock Exchange) + */ + @SerializedName("exchange_name") + private String exchangeName; + + /** + * Exchange name (for underlyings listed on a Stock Exchange) + */ + @SerializedName("delay_amount") + private int delayAmount; + + /** + * Display name + */ + @SerializedName("display_name") + private String displayName; + + /** + * Latest spot price of the underlying + */ + @SerializedName("spot") + @Nullable + private Integer spot; + + /** + * Latest spot epoch time + */ + @SerializedName("spot_time") + private String spotTime; + + /** + * 1 indicates that trading is currently suspended + */ + @SerializedName("is_trading_suspended") + @Nullable + private Integer isTradingSuspended; + + /** + * For stocks and stock indices, the underlying currency for that instrument + */ + @SerializedName("quoted_currency_symbole") + private String quotedCurrencySymbol; + + /** + * Number of seconds elapsed since the last spot price + */ + @SerializedName("spot_age") + private String spotAge; + + /** + * Market category (forex, indices etc) + */ + @SerializedName("market") + private String market; + + /** + * Translated market name + */ + @SerializedName("market_display_name") + private String marketDisplayName; + + /** + * Submarket name + */ + @SerializedName("submarket") + private String subMarket; + + /** + * Translated submarket name + */ + @SerializedName("submarket_display_name") + private String subMarketDisplayName; + + /** + * Pip size (i.e. minimum fluctuation amount) + */ + @SerializedName("pip") + private BigDecimal pip; + + /** + * {@link ActiveSymbol#symbol} + */ + public String getSymbol() { + + return symbol; + } + + /** + * {@link ActiveSymbol#symbol} + */ + public void setSymbol(String symbol) { + this.symbol = symbol; + } + + /** + * {@link ActiveSymbol#intradayIntervalMinutes} + */ + public int getIntradayIntervalMinutes() { + return intradayIntervalMinutes; + } + + /** + * {@link ActiveSymbol#intradayIntervalMinutes} + */ + public void setIntradayIntervalMinutes(int intradayIntervalMinutes) { + this.intradayIntervalMinutes = intradayIntervalMinutes; + } + + /** + * {@link ActiveSymbol#symbolType} + */ + public String getSymbolType() { + return symbolType; + } + + /** + * {@link ActiveSymbol#symbolType} + */ + public void setSymbolType(String symbolType) { + this.symbolType = symbolType; + } + + /** + * {@link ActiveSymbol#isExhcangeOpen} + */ + public Integer getIsExhcangeOpen() { + return isExhcangeOpen; + } + + /** + * {@link ActiveSymbol#isExhcangeOpen} + */ + public void setIsExhcangeOpen(Integer isExhcangeOpen) { + this.isExhcangeOpen = isExhcangeOpen; + } + + /** + * {@link ActiveSymbol#exchangeName} + */ + public String getExchangeName() { + return exchangeName; + } + + /** + * {@link ActiveSymbol#exchangeName} + */ + public void setExchangeName(String exchangeName) { + this.exchangeName = exchangeName; + } + + /** + * {@link ActiveSymbol#delayAmount} + */ + public int getDelayAmount() { + return delayAmount; + } + + /** + * {@link ActiveSymbol#delayAmount} + */ + public void setDelayAmount(int delayAmount) { + this.delayAmount = delayAmount; + } + + /** + * {@link ActiveSymbol#displayName} + */ + public String getDisplayName() { + return displayName; + } + + /** + * {@link ActiveSymbol#displayName} + */ + public void setDisplayName(String displayName) { + this.displayName = displayName; + } + + /** + * {@link ActiveSymbol#spot} + */ + public Integer getSpot() { + return spot; + } + + /** + * {@link ActiveSymbol#spot} + */ + public void setSpot(Integer spot) { + this.spot = spot; + } + + /** + * {@link ActiveSymbol#spotTime} + */ + public String getSpotTime() { + return spotTime; + } + + /** + * {@link ActiveSymbol#spotTime} + */ + public void setSpotTime(String spotTime) { + this.spotTime = spotTime; + } + + /** + * {@link ActiveSymbol#isTradingSuspended} + */ + public Integer getIsTradingSuspended() { + return isTradingSuspended; + } + + /** + * {@link ActiveSymbol#isTradingSuspended} + */ + public void setIsTradingSuspended(Integer isTradingSuspended) { + this.isTradingSuspended = isTradingSuspended; + } + + /** + * {@link ActiveSymbol#quotedCurrencySymbol} + */ + public String getQuotedCurrencySymbol() { + return quotedCurrencySymbol; + } + + /** + * {@link ActiveSymbol#quotedCurrencySymbol} + */ + public void setQuotedCurrencySymbol(String quotedCurrencySymbol) { + this.quotedCurrencySymbol = quotedCurrencySymbol; + } + + /** + * {@link ActiveSymbol#spotAge} + */ + public String getSpotAge() { + return spotAge; + } + + /** + * {@link ActiveSymbol#spotAge} + */ + public void setSpotAge(String spotAge) { + this.spotAge = spotAge; + } + + /** + * {@link ActiveSymbol#market} + */ + public String getMarket() { + return market; + } + + /** + * {@link ActiveSymbol#market} + */ + public void setMarket(String market) { + this.market = market; + } + + /** + * {@link ActiveSymbol#marketDisplayName} + */ + public String getMarketDisplayName() { + return marketDisplayName; + } + + /** + * {@link ActiveSymbol#marketDisplayName} + */ + public void setMarketDisplayName(String marketDisplayName) { + this.marketDisplayName = marketDisplayName; + } + + /** + * {@link ActiveSymbol#subMarket} + */ + public String getSubMarket() { + return subMarket; + } + + /** + * {@link ActiveSymbol#subMarket} + */ + public void setSubMarket(String subMarket) { + this.subMarket = subMarket; + } + + /** + * {@link ActiveSymbol#subMarketDisplayName} + */ + public String getSubMarketDisplayName() { + return subMarketDisplayName; + } + + /** + * {@link ActiveSymbol#subMarketDisplayName} + */ + public void setSubMarketDisplayName(String subMarketDisplayName) { + this.subMarketDisplayName = subMarketDisplayName; + } + + /** + * {@link ActiveSymbol#pip} + */ + public BigDecimal getPip() { + return pip; + } + + /** + * {@link ActiveSymbol#pip} + */ + public void setPip(BigDecimal pip) { + this.pip = pip; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/responses/ActiveSymbolResponse.java b/Trading/src/main/java/com/suneesh/trading/models/responses/ActiveSymbolResponse.java new file mode 100644 index 0000000..d96e36f --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/responses/ActiveSymbolResponse.java @@ -0,0 +1,38 @@ +package com.suneesh.trading.models.responses; + +import com.suneesh.trading.models.requests.ActiveSymbolRequest; +import com.google.gson.annotations.SerializedName; + +/** + *

ActiveSymbolResponse

+ * + *

Get list of active symbols Receive

+ *

A message list of active symbols

+ * @author Morteza Tavanarad + * @version 1.0.0 + * @since 7/31/2017 + */ +public class ActiveSymbolResponse extends ResponseBase { + + /** + * List of active symbols. Note: if the user is authenticated, + * then only symbols allowed under his account will be returned. + */ + @SerializedName("active_symbols") + private ActiveSymbol[] activeSymbols; + + /** + * {@link ActiveSymbolResponse#activeSymbols} + */ + public ActiveSymbol[] getActiveSymbols() { + return activeSymbols; + } + + /** + * {@link ActiveSymbolResponse#activeSymbols} + */ + public void setActiveSymbols(ActiveSymbol[] activeSymbols) { + this.activeSymbols = activeSymbols; + } +} + diff --git a/Trading/src/main/java/com/suneesh/trading/models/responses/ApiCallLimit.java b/Trading/src/main/java/com/suneesh/trading/models/responses/ApiCallLimit.java new file mode 100644 index 0000000..28645f1 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/responses/ApiCallLimit.java @@ -0,0 +1,42 @@ +package com.suneesh.trading.models.responses; + +import com.google.gson.annotations.SerializedName; +import io.reactivex.annotations.Nullable; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/3/2017 + */ +public class ApiCallLimit { + + @SerializedName("applies_to") + private String appliesTo; + + @SerializedName("max") + @Nullable + private Integer max; + + @SerializedName("hourly") + @Nullable + private Integer hourly; + + @SerializedName("minutely") + private String minutely; + + public String getAppliesTo() { + return appliesTo; + } + + public Integer getMax() { + return max; + } + + public Integer getHourly() { + return hourly; + } + + public String getMinutely() { + return minutely; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/responses/ApiToken.java b/Trading/src/main/java/com/suneesh/trading/models/responses/ApiToken.java new file mode 100644 index 0000000..0623c3a --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/responses/ApiToken.java @@ -0,0 +1,63 @@ +package com.suneesh.trading.models.responses; + +import com.google.gson.annotations.SerializedName; + +import java.util.List; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/9/2017 + */ +public class ApiToken { + + /** + * Display name + */ + @SerializedName("display_name") + private String displayName; + + /** + * Last used + */ + @SerializedName("last_used") + private String lastUsed; + + /** + * Scopes + */ + @SerializedName("scopes") + private List scopes; + + /** + * Token + */ + @SerializedName("token") + private String Token; + + /** + * Validated IP(s) list + */ + @SerializedName("valid_for_ip") + private String validForIp; + + public String getDisplayName() { + return displayName; + } + + public String getLastUsed() { + return lastUsed; + } + + public List getScopes() { + return scopes; + } + + public String getToken() { + return Token; + } + + public String getValidForIp() { + return validForIp; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/responses/ApiTokenManagementResponse.java b/Trading/src/main/java/com/suneesh/trading/models/responses/ApiTokenManagementResponse.java new file mode 100644 index 0000000..7e1e55e --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/responses/ApiTokenManagementResponse.java @@ -0,0 +1,68 @@ +package com.suneesh.trading.models.responses; + +import com.suneesh.trading.models.requests.ApiTokenManagementRequest; +import com.google.gson.annotations.SerializedName; + +import java.util.List; + +/** + *

ApiTokenManagementResponse

+ * + *

API Token Response

+ * + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/9/2017 + */ +public class ApiTokenManagementResponse extends ResponseBase { + + /** + * Api Token + */ + @SerializedName("api_token") + private ApiTokenResult apiTokenResult; + + public ApiTokenResult getApiTokenResult() { + return apiTokenResult; + } + + public class ApiTokenResult { + + /** + * API tokens + */ + @SerializedName("tokens") + private List tokens; + + /** + * Token created. + */ + @SerializedName("new_token") + private Integer isTokenCreated; + + /** + * Token Deleted + */ + @SerializedName("delete_token") + private Integer isTokenDeleted; + + @SerializedName("sub_account") + private String subAccount; + + public List getTokens() { + return tokens; + } + + public boolean isTokenCreated() { + return isTokenCreated == 1 ? true : false; + } + + public boolean isTokenDeleted() { + return isTokenDeleted == 1 ? true : false; + } + + public String getSubAccount() { + return subAccount; + } + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/responses/Application.java b/Trading/src/main/java/com/suneesh/trading/models/responses/Application.java new file mode 100644 index 0000000..e830d6c --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/responses/Application.java @@ -0,0 +1,109 @@ +package com.suneesh.trading.models.responses; + +import com.google.gson.annotations.SerializedName; + +import java.math.BigDecimal; +import java.util.List; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/9/2017 + */ +public class Application { + + /** + * Framework name + * + */ + @SerializedName("name") + private String name; + + @SerializedName("app_id") + private Long applicationId; + + /** + * Framework's homepage + * + */ + @SerializedName("homepage") + private String homepageUrl; + + /** + * Framework's GitHub page (for open-source projects) + * + */ + @SerializedName("github") + private String githubUrl; + + /** + * Framework's App Store URL (if applicable) + * + */ + @SerializedName("appstore") + private String appStoreUrl; + + /** + * Framework's Google Play URL (if applicable) + * + */ + @SerializedName("googleplay") + private String googlePlayUrl; + + /** + * Framework redirect_uri + * + */ + @SerializedName("redirect_uri") + private String redirectUri; + + /** + * Framework verification_uri + * + */ + @SerializedName("verification_uri") + private String verificationUri; + + /** + * Markup to be added to contract prices (as a percentage of contract payout). Min: 0, Max: 5 + * + */ + @SerializedName("app_markup_percentage") + private BigDecimal appMarkupPercentage; + + public String getName() { + return name; + } + + public Long getApplicationId() { + return applicationId; + } + + public String getHomepageUrl() { + return homepageUrl; + } + + public String getGithubUrl() { + return githubUrl; + } + + public String getAppStoreUrl() { + return appStoreUrl; + } + + public String getGooglePlayUrl() { + return googlePlayUrl; + } + + public String getRedirectUri() { + return redirectUri; + } + + public String getVerificationUri() { + return verificationUri; + } + + public BigDecimal getAppMarkupPercentage() { + return appMarkupPercentage; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/responses/ApplicationDeletionResponse.java b/Trading/src/main/java/com/suneesh/trading/models/responses/ApplicationDeletionResponse.java new file mode 100644 index 0000000..9f28b8b --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/responses/ApplicationDeletionResponse.java @@ -0,0 +1,21 @@ +package com.suneesh.trading.models.responses; + +import com.suneesh.trading.models.requests.ApplicationDeletionRequest; +import com.google.gson.annotations.SerializedName; +import io.reactivex.annotations.Nullable; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/20/2017 + */ +public class ApplicationDeletionResponse extends ResponseBase { + + @SerializedName("app_delete") + @Nullable + private Integer response; + + public boolean getResponse() { + return response == 1 ? true : false; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/responses/ApplicationDetailsResponse.java b/Trading/src/main/java/com/suneesh/trading/models/responses/ApplicationDetailsResponse.java new file mode 100644 index 0000000..17eeb35 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/responses/ApplicationDetailsResponse.java @@ -0,0 +1,26 @@ +package com.suneesh.trading.models.responses; + +import com.suneesh.trading.models.requests.ApplicationDetailsRequest; +import com.google.gson.annotations.SerializedName; +import io.reactivex.annotations.Nullable; + +/** + *

ApplicationDetailsResponse

+ * + *

App Get Receive

+ *

A message with requested application

+ * + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/27/2017 + */ +public class ApplicationDetailsResponse extends ResponseBase { + + @SerializedName("app_get") + @Nullable + private Application application; + + public Application getApplication() { + return application; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/responses/ApplicationListResponse.java b/Trading/src/main/java/com/suneesh/trading/models/responses/ApplicationListResponse.java new file mode 100644 index 0000000..ea9a0f2 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/responses/ApplicationListResponse.java @@ -0,0 +1,26 @@ +package com.suneesh.trading.models.responses; + +import com.suneesh.trading.models.requests.ApplicationListRequest; +import com.google.gson.annotations.SerializedName; + +import java.util.List; + +/** + *

ApplicationListResponse

+ * + *

App List Receive

+ *

A message with created applications

+ * + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/24/2017 + */ +public class ApplicationListResponse extends ResponseBase { + + @SerializedName("app_list") + private List applications; + + public List getApplications() { + return applications; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/responses/ApplicationRegistrationResponse.java b/Trading/src/main/java/com/suneesh/trading/models/responses/ApplicationRegistrationResponse.java new file mode 100644 index 0000000..e4bf2a9 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/responses/ApplicationRegistrationResponse.java @@ -0,0 +1,19 @@ +package com.suneesh.trading.models.responses; + +import com.suneesh.trading.models.requests.ApplicationRegistrationRequest; +import com.google.gson.annotations.SerializedName; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/9/2017 + */ +public class ApplicationRegistrationResponse extends ResponseBase { + + @SerializedName("app_register") + private Application registeredApplication; + + public Application getRegisteredApplication() { + return registeredApplication; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/responses/ApplicationUpdateResponse.java b/Trading/src/main/java/com/suneesh/trading/models/responses/ApplicationUpdateResponse.java new file mode 100644 index 0000000..ccf7fc0 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/responses/ApplicationUpdateResponse.java @@ -0,0 +1,21 @@ +package com.suneesh.trading.models.responses; + +import com.suneesh.trading.models.requests.ApplicationUpdateRequest; +import com.google.gson.annotations.SerializedName; +import io.reactivex.annotations.Nullable; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/27/2017 + */ +public class ApplicationUpdateResponse extends ResponseBase { + + @SerializedName("app_update") + @Nullable + private Application application; + + public Application getApplication() { + return application; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/responses/AssetIndex.java b/Trading/src/main/java/com/suneesh/trading/models/responses/AssetIndex.java new file mode 100644 index 0000000..6a1bc81 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/responses/AssetIndex.java @@ -0,0 +1,41 @@ +package com.suneesh.trading.models.responses; + +import com.google.gson.annotations.SerializedName; + +import java.util.ArrayList; +import java.util.List; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 7/31/2017 + */ +public class AssetIndex { + private String symbol; + private String symbolDisplayName; + List contracts = new ArrayList<>(); + + public String getSymbol() { + return symbol; + } + + public void setSymbol(String symbol) { + this.symbol = symbol; + } + + public String getSymbolDisplayName() { + return symbolDisplayName; + } + + public void setSymbolDisplayName(String symbolDisplayName) { + this.symbolDisplayName = symbolDisplayName; + } + + public void addContract(ContractInfo contract) { + this.contracts.add(contract); + } + + public List getContracts() { + return this.contracts; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/responses/AssetIndexResponse.java b/Trading/src/main/java/com/suneesh/trading/models/responses/AssetIndexResponse.java new file mode 100644 index 0000000..34fe761 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/responses/AssetIndexResponse.java @@ -0,0 +1,23 @@ +package com.suneesh.trading.models.responses; + +import com.suneesh.trading.models.requests.AssetIndexRequest; +import com.google.gson.annotations.SerializedName; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 7/31/2017 + */ +public class AssetIndexResponse extends ResponseBase { + + @SerializedName("asset_index") + private AssetIndex[] assetIndex; + + public AssetIndex[] getAssetIndex() { + return assetIndex; + } + + public void setAssetIndex(AssetIndex[] assetIndex) { + this.assetIndex = assetIndex; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/responses/Authorize.java b/Trading/src/main/java/com/suneesh/trading/models/responses/Authorize.java new file mode 100644 index 0000000..d7aaa72 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/responses/Authorize.java @@ -0,0 +1,147 @@ +package com.suneesh.trading.models.responses; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import java.math.BigDecimal; + +/** + * Created by morteza on 7/28/2017. + */ +public class Authorize { + @SerializedName("email") + private String email; + + @SerializedName("currency") + private String currency; + + @SerializedName("balance") + private BigDecimal balance; + + @SerializedName("loginid") + private String loginId; + + @SerializedName("is_virtual") + private int isVirtual; + + @SerializedName("landing_company_name") + private String landingCompanyName; + + @SerializedName("landing_company_fullname") + private String landingCompanyFullName; + + @SerializedName("country") + private String country; + + @SerializedName("fullname") + private String fullName; + + @SerializedName("scopes") + private String[] scopes; + + @SerializedName("allow_omnibus") + private int allowOmnibus; + + @SerializedName("sub_accounts") + private SubAccount[] subAccounts; + + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } + + public String getCurrency() { + return currency; + } + + public void setCurrency(String currency) { + this.currency = currency; + } + + public BigDecimal getBalance() { + return balance; + } + + public void setBalance(BigDecimal balance) { + this.balance = balance; + } + + public String getLoginId() { + return loginId; + } + + public void setLoginId(String loginId) { + this.loginId = loginId; + } + + public int getIsVirtual() { + return isVirtual; + } + + public void setIsVirtual(int isVirtual) { + this.isVirtual = isVirtual; + } + + public String getLandingCompanyName() { + return landingCompanyName; + } + + public void setLandingCompanyName(String landingCompanyName) { + this.landingCompanyName = landingCompanyName; + } + + public String getLandingCompanyFullName() { + return landingCompanyFullName; + } + + public void setLandingCompanyFullName(String landingCompanyFullName) { + this.landingCompanyFullName = landingCompanyFullName; + } + + public String getCountry() { + return country; + } + + public void setCountry(String country) { + this.country = country; + } + + public String getFullName() { + return fullName; + } + + public void setFullName(String fullName) { + this.fullName = fullName; + } + + public String[] getScopes() { + return scopes; + } + + public void setScopes(String[] scopes) { + this.scopes = scopes; + } + + public int getAllowOmnibus() { + return allowOmnibus; + } + + public void setAllowOmnibus(int allowOmnibus) { + this.allowOmnibus = allowOmnibus; + } + + public SubAccount[] getSubAccounts() { + return subAccounts; + } + + public void setSubAccounts(SubAccount[] subAccounts) { + this.subAccounts = subAccounts; + } +} \ No newline at end of file diff --git a/Trading/src/main/java/com/suneesh/trading/models/responses/AuthorizeResponse.java b/Trading/src/main/java/com/suneesh/trading/models/responses/AuthorizeResponse.java new file mode 100644 index 0000000..c544a64 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/responses/AuthorizeResponse.java @@ -0,0 +1,46 @@ +package com.suneesh.trading.models.responses; + +import com.suneesh.trading.models.requests.AuthorizeRequest; +import com.google.gson.annotations.SerializedName; +import com.suneesh.trading.utils.AutoTradingUtility; + +import java.util.Arrays; +import java.util.List; + +/** + * Created by morteza on 7/28/2017. + */ +public class AuthorizeResponse extends ResponseBase { + @SerializedName("authorize") + private Authorize authorize; + + public Authorize getAuthorize() { + return authorize; + } + + public void setAuthorize(Authorize authorize) { + this.authorize = authorize; + } + + @Override + public List databaseInsertStringList(){ + return Arrays.asList( + "INSERT INTO public.authorize " + + "(allow_omnibus ,balance ,country ,currency ,email ,full_name ,is_virtual ," + + " landing_company_full_name ,landing_company_name, login_id ) " + + " VALUES (" + + AutoTradingUtility.quotedString(authorize.getAllowOmnibus()) + ", " + + AutoTradingUtility.quotedString(authorize.getBalance()) + ", " + + AutoTradingUtility.quotedString(authorize.getCountry()) + ", " + + AutoTradingUtility.quotedString(authorize.getCurrency()) + ", " + + AutoTradingUtility.quotedString(authorize.getEmail()) + ", " + + AutoTradingUtility.quotedString(authorize.getFullName()) + ", " + + AutoTradingUtility.quotedString(authorize.getIsVirtual()) + ", " + + AutoTradingUtility.quotedString(authorize.getLandingCompanyFullName()) + ", " + + AutoTradingUtility.quotedString(authorize.getLandingCompanyName()) + ", " + + AutoTradingUtility.quotedString(authorize.getLoginId()) + ");" + ); + + } + +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/responses/Balance.java b/Trading/src/main/java/com/suneesh/trading/models/responses/Balance.java new file mode 100644 index 0000000..88bc863 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/responses/Balance.java @@ -0,0 +1,61 @@ +package com.suneesh.trading.models.responses; + +import com.google.gson.annotations.SerializedName; +import io.reactivex.annotations.Nullable; +import lombok.Data; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import java.math.BigDecimal; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/4/2017 + */ +@Data +public class Balance { + /** + * Balance amount + */ + @SerializedName("balance") + private BigDecimal balance; + + /** + * Currency Example: USD + */ + @SerializedName("currency") + private String currency; + + /** + * Client loginid Example: CR000000 + */ + @SerializedName("loginid") + private String loginId; + + /** + * A stream id that can be used to cancel this stream using the Forget request. + * Example: 1d6651e7d599bce6c54bd71a8283e579 + */ + @SerializedName("id") + @Nullable + private String id; + + public BigDecimal getBalance() { + return balance; + } + + public String getCurrency() { + return currency; + } + + public String getLoginId() { + return loginId; + } + + public String getId() { + return id; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/responses/BalanceResponse.java b/Trading/src/main/java/com/suneesh/trading/models/responses/BalanceResponse.java new file mode 100644 index 0000000..588d723 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/responses/BalanceResponse.java @@ -0,0 +1,51 @@ +package com.suneesh.trading.models.responses; + +import com.suneesh.trading.models.requests.BalanceRequest; +import com.google.gson.annotations.SerializedName; +import com.suneesh.trading.utils.AutoTradingUtility; + +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + +/** + *

BalanceResponse

+ * + *

Realtime Balance

+ *

Return details of user account balance

+ * + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/4/2017 + */ +public class BalanceResponse extends ResponseBase { + + /** + * Realtime stream of user balance changes. + */ + @SerializedName("balance") + private Balance balance; + + public Balance getBalance() { + return balance; + } + + public void setBalance(Balance balance) { + this.balance = balance; + } + + @Override + public List databaseInsertStringList(){ + return Arrays.asList( + "INSERT INTO public.balance " + + "(balance , currency , login_id , time, time_string) " + + " VALUES (" + + AutoTradingUtility.quotedString(balance.getBalance()) + ", " + + AutoTradingUtility.quotedString(balance.getCurrency()) + ", " + + AutoTradingUtility.quotedString(balance.getLoginId()) + ", " + + " extract(epoch from now()), " + + " now()::timestamp );" + ); + + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/responses/BuyContractForMultipleAccountsResponse.java b/Trading/src/main/java/com/suneesh/trading/models/responses/BuyContractForMultipleAccountsResponse.java new file mode 100644 index 0000000..c1ca1b8 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/responses/BuyContractForMultipleAccountsResponse.java @@ -0,0 +1,41 @@ +package com.suneesh.trading.models.responses; + +import com.suneesh.trading.models.requests.BuyContractForMultipleAccountsRequest; +import com.google.gson.annotations.SerializedName; + +import java.util.List; + +/** + *

BuyContractForMultipleAccountsResponse

+ * + *

Buy a Contract for multiple Accounts Receive

+ *

+ * A message with transaction results is received + *

+ * + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/8/2017 + */ +public class BuyContractForMultipleAccountsResponse extends ResponseBase { + + /** + * Receipt confirmation for the purchase + */ + @SerializedName("buy_contract_for_multiple_accounts") + private MassBuyContractResult buyContractResult; + + public MassBuyContractResult getMassBuyContractResult() { + return buyContractResult; + } + + public class MassBuyContractResult { + + @SerializedName("result") + private List result; + + public List getResult() { + return result; + } + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/responses/BuyContractResponse.java b/Trading/src/main/java/com/suneesh/trading/models/responses/BuyContractResponse.java new file mode 100644 index 0000000..25e609a --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/responses/BuyContractResponse.java @@ -0,0 +1,31 @@ +package com.suneesh.trading.models.responses; + +import com.suneesh.trading.models.requests.BuyContractRequest; +import com.google.gson.annotations.SerializedName; +import lombok.Data; + +/** + *

BuyContractResponse

+ * + *

Buy a Contract Receive

+ *

+ * A message with transaction results is received + *

+ * + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/8/2017 + */ +@Data +public class BuyContractResponse extends ResponseBase { + + /** + * + */ + @SerializedName("buy") + private BuyReceipt buyReceipt; + + public BuyReceipt getBuyReceipt() { + return buyReceipt; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/responses/BuyReceipt.java b/Trading/src/main/java/com/suneesh/trading/models/responses/BuyReceipt.java new file mode 100644 index 0000000..7a1c6cb --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/responses/BuyReceipt.java @@ -0,0 +1,132 @@ +package com.suneesh.trading.models.responses; + +import com.google.gson.annotations.SerializedName; + +import java.math.BigDecimal; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/8/2017 + */ +public class BuyReceipt { + + /** + * The new account balance after completion of the purchase + * (Required) + * + */ + @SerializedName("balance_after") + private BigDecimal balanceAfter; + + /** + * The description of contract purchased + * (Required) + * + */ + @SerializedName("longcode") + private String longCode; + + /** + * Compact description of the contract purchased + * (Required) + * + */ + @SerializedName("shortcode") + private String shortCode; + + /** + * Epoch value showing the expected start time of the contract + * (Required) + * + */ + @SerializedName("start_time") + private Long startTime; + + /** + * Internal contract identifier + * (Required) + * + */ + @SerializedName("contract_id") + private Long contractId; + + /** + * Actual effected purchase price + * (Required) + * + */ + @SerializedName("buy_price") + private BigDecimal buyPrice; + + /** + * Epoch value of the transaction purchase time + * (Required) + * + */ + @SerializedName("purchase_time") + private Long purchaseTime; + + /** + * Internal transaction identifier + * (Required) + * + */ + @SerializedName("transaction_id") + private Long transactionId; + + /** + * Proposed payout value + * (Required) + * + */ + @SerializedName("payout") + private BigDecimal payout; + + /** + * Account token that contract is bought for it. + * Note: it is just available when request is BuyContractForMultipleAccounts + */ + @SerializedName("token") + private String token; + + public BigDecimal getBalanceAfter() { + return balanceAfter; + } + + public String getLongCode() { + return longCode; + } + + public String getShortCode() { + return shortCode; + } + + public Long getStartTime() { + return startTime; + } + + public Long getContractId() { + return contractId; + } + + public BigDecimal getBuyPrice() { + return buyPrice; + } + + public Long getPurchaseTime() { + return purchaseTime; + } + + public Long getTransactionId() { + return transactionId; + } + + public BigDecimal getPayout() { + return payout; + } + + public String getToken() { + return token; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/responses/Candle.java b/Trading/src/main/java/com/suneesh/trading/models/responses/Candle.java new file mode 100644 index 0000000..64227c0 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/responses/Candle.java @@ -0,0 +1,104 @@ +package com.suneesh.trading.models.responses; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; + +import java.math.BigDecimal; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/3/2017 + */ + +@Data +public class Candle { + /** + * It is an epoch value + */ + @SerializedName("epoch") + private Integer epoch; + + @SerializedName("open_time") + private Integer open_time; + /** + * It is the open price value for the given time + */ + @SerializedName("open") + private BigDecimal open; + + /** + * It is the high price value for the given time + */ + @SerializedName("high") + private BigDecimal high; + + /** + * It is the low price value for the given time + */ + @SerializedName("low") + private BigDecimal low; + + /** + * It is the close price value for the given time + */ + @SerializedName("close") + private BigDecimal close; + + @SerializedName("granularity") + private Integer granularity; + + @SerializedName("symbol") + private String symbol; + + @SerializedName("direction") + private String direction; + + private BigDecimal openCloseDiff; + + public String getWriteTimeEpoch() { + return writeTimeEpoch; + } + + public void setWriteTimeEpoch() { + this.writeTimeEpoch = "extract(epoch from now() )"; + } + + private String writeTimeEpoch; + + public void setDirection() { + this.direction = (close.compareTo(open)>=0) ? "UP" : "DOWN";; + } + + public String getDirection() { + return direction; + } + + public BigDecimal getOpenCloseDiff() { + return openCloseDiff; + } + + public void setOpenCloseDiff() { + this.openCloseDiff = close.subtract(open); + } + + public Integer getEpoch() { + return epoch; + } + + public BigDecimal getOpen() { + return open; + } + + public BigDecimal getHigh() { + return high; + } + + public BigDecimal getLow() { + return low; + } + + public BigDecimal getClose() { + return close; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/responses/CashierPasswordResponse.java b/Trading/src/main/java/com/suneesh/trading/models/responses/CashierPasswordResponse.java new file mode 100644 index 0000000..b38f2be --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/responses/CashierPasswordResponse.java @@ -0,0 +1,19 @@ +package com.suneesh.trading.models.responses; + +import com.suneesh.trading.models.requests.CashierPasswordRequest; +import com.google.gson.annotations.SerializedName; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 9/14/2017 + */ +public class CashierPasswordResponse extends ResponseBase { + + @SerializedName("cashier_password") + private Integer lock; + + public boolean isLock() { + return lock == 1 ? true : false; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/responses/CashierURLResponse.java b/Trading/src/main/java/com/suneesh/trading/models/responses/CashierURLResponse.java new file mode 100644 index 0000000..5ec3667 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/responses/CashierURLResponse.java @@ -0,0 +1,25 @@ +package com.suneesh.trading.models.responses; + +import com.suneesh.trading.models.requests.CashierURLRequest; +import com.google.gson.annotations.SerializedName; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 9/14/2017 + */ +public class CashierURLResponse extends ResponseBase { + + /** + * cashier url, + * Note possible error codes: ASK_TNC_APPROVAL (API tnc_approval), ASK_AUTHENTICATE, + * ASK_UK_FUNDS_PROTECTION (API tnc_approval), ASK_CURRENCY (API set_account_currency), + * ASK_EMAIL_VERIFY (verify_email), ASK_FIX_DETAILS (API set_settings) + */ + @SerializedName("cashier") + private String cashierURL; + + public String getCashierURL() { + return cashierURL; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/responses/Company.java b/Trading/src/main/java/com/suneesh/trading/models/responses/Company.java new file mode 100644 index 0000000..dede280 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/responses/Company.java @@ -0,0 +1,125 @@ +package com.suneesh.trading.models.responses; + +import com.google.gson.annotations.SerializedName; + +import java.util.List; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/1/2017 + */ +public class Company { + + /** + * Landing Company short code + */ + @SerializedName("shortcode") + private String shortCode; + + /** + * Landing Company legal name + */ + @SerializedName("name") + private String name; + + /** + * Landing Company address + */ + @SerializedName("address") + private List address; + + /** + * Landing Company country of incorporation + */ + @SerializedName("country") + private String country; + + /** + * Default account currency + */ + @SerializedName("legal_default_currency") + private String legalDefaultCurrency; + + /** + * Allowable currencies + */ + @SerializedName("legal_allowed_currencies") + private List legalAllowedCurrencies; + + /** + * Allowable markets + */ + @SerializedName("legal_allowed_markets") + private List legalAllowedMarkets; + + /** + * Allowed contract types + */ + @SerializedName("legal_allowed_contract_categories") + private List legalAllowedContractCategories; + + public String getShortCode() { + return shortCode; + } + + public void setShortCode(String shortCode) { + this.shortCode = shortCode; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public List getAddress() { + return address; + } + + public void setAddress(List address) { + this.address = address; + } + + public String getCountry() { + return country; + } + + public void setCountry(String country) { + this.country = country; + } + + public String getLegalDefaultCurrency() { + return legalDefaultCurrency; + } + + public void setLegalDefaultCurrency(String legalDefaultCurrency) { + this.legalDefaultCurrency = legalDefaultCurrency; + } + + public List getLegalAllowedCurrencies() { + return legalAllowedCurrencies; + } + + public void setLegalAllowedCurrencies(List legalAllowedCurrencies) { + this.legalAllowedCurrencies = legalAllowedCurrencies; + } + + public List getLegalAllowedMarkets() { + return legalAllowedMarkets; + } + + public void setLegalAllowedMarkets(List legalAllowedMarkets) { + this.legalAllowedMarkets = legalAllowedMarkets; + } + + public List getLegalAllowedContractCategories() { + return legalAllowedContractCategories; + } + + public void setLegalAllowedContractCategories(List legalAllowedContractCategories) { + this.legalAllowedContractCategories = legalAllowedContractCategories; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/responses/Contract.java b/Trading/src/main/java/com/suneesh/trading/models/responses/Contract.java new file mode 100644 index 0000000..6993a9e --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/responses/Contract.java @@ -0,0 +1,317 @@ +package com.suneesh.trading.models.responses; + +import com.google.gson.annotations.SerializedName; +import io.reactivex.annotations.Nullable; + +import java.math.BigDecimal; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/1/2017 + */ +public class Contract { + + /** + * Type of market (forex, indices, ...) + */ + @SerializedName("market") + private String market; + + /** + * Type of contract (example: asian up) + */ + @SerializedName("contract_display") + private String contractsDisplay; + + /** + * Maximum contract duration (example: 10) + */ + @SerializedName("max_contract_duration") + private String maxContractDuration; + + @SerializedName("max_historical_pricer_duration") + @Nullable + private String maxHistoricalPricerDuration; + /** + * Category of barrier (example: asian) + */ + @SerializedName("barrier_category") + private String barrierCategory; + + /** + * Maximum payout (example: 10000) + */ + @SerializedName("payout_limit") + private BigDecimal payoutLimit; + + /** + * Type of submarket (example: major_pairs) + */ + @SerializedName("submarket") + private String subMarket; + + /** + * Name of exchange (example: EURONEXT) + */ + @SerializedName("exchange_name") + private String exchangeName; + + /** + * Category of the contract (example: Asians) + */ + @SerializedName("contract_category_display") + private String contractCategoryDisplay; + + /** + * Type of contract (example: ASIANU) + */ + @SerializedName("contract_type") + private String contractType; + + /** + * Minimum contract duration (example: 5) + */ + @SerializedName("min_contract_duration") + private String minContractDuration; + + @SerializedName("min_historical_pricer_duration") + @Nullable + private String minHistoricalPricerDuration; + + /** + * Type of sentiment (example: up) + */ + @SerializedName("sentiment") + private String sentiment; + + /** + * Barriers (example: 0) + */ + @SerializedName("barrier") + private BigDecimal barrier; + + /** + * Category of contract (example: asian) + */ + @SerializedName("contract_category") + private String contractCategory; + + /** + * Start Type (example: spot) + */ + @SerializedName("start_type") + private String startType; + + /** + * Expiry Type (example: tick) + */ + @SerializedName("expiry_type") + private String expiryType; + + /** + * Symbol code (example: R_50) + */ + @SerializedName("underlying_symbol") + private String underlyingSymbol; + + /** + * Array of returned forward starting options + */ + @SerializedName("forward_starting_options") + @Nullable + private ForwardStartingOption[] forwardStartingOptions; + + /** + * Array of available barriers for a predefined trading period (only return if region set to 'japan') + */ + @SerializedName("available_barriers") + @Nullable + private BigDecimal[][] availableBarriers; + + /** + * Array of barriers already expired (only return if region set to 'japan') + */ + @SerializedName("expired_barriers") + @Nullable + private BigDecimal[][] expiredBarriers; + + /** + * A hash of predefined trading period (only return if region set to 'japan') + */ + @SerializedName("trading_period") + @Nullable + private TradingPeriod tradingPeriod; + + @SerializedName("last_digit_range") + @Nullable + private int[] lastDigitRange; + + public String getMarket() { + return market; + } + + public void setMarket(String market) { + this.market = market; + } + + public String getContractsDisplay() { + return contractsDisplay; + } + + public void setContractsDisplay(String contractsDisplay) { + this.contractsDisplay = contractsDisplay; + } + + public String getMaxContractDuration() { + return maxContractDuration; + } + + public void setMaxContractDuration(String maxContractDuration) { + this.maxContractDuration = maxContractDuration; + } + + public String getBarrierCategory() { + return barrierCategory; + } + + public void setBarrierCategory(String barrierCategory) { + this.barrierCategory = barrierCategory; + } + + public BigDecimal getPayoutLimit() { + return payoutLimit; + } + + public void setPayoutLimit(BigDecimal payoutLimit) { + this.payoutLimit = payoutLimit; + } + + public String getSubMarket() { + return subMarket; + } + + public void setSubMarket(String subMarket) { + this.subMarket = subMarket; + } + + public String getExchangeName() { + return exchangeName; + } + + public void setExchangeName(String exchangeName) { + this.exchangeName = exchangeName; + } + + public String getContractCategoryDisplay() { + return contractCategoryDisplay; + } + + public void setContractCategoryDisplay(String contractCategoryDisplay) { + this.contractCategoryDisplay = contractCategoryDisplay; + } + + public String getContractType() { + return contractType; + } + + public void setContractType(String contractType) { + this.contractType = contractType; + } + + public String getMinContractDuration() { + return minContractDuration; + } + + public void setMinContractDuration(String minContractDuration) { + this.minContractDuration = minContractDuration; + } + + public String getSentiment() { + return sentiment; + } + + public void setSentiment(String sentiment) { + this.sentiment = sentiment; + } + + public BigDecimal getBarrier() { + return barrier; + } + + public void setBarrier(BigDecimal barrier) { + this.barrier = barrier; + } + + public String getContractCategory() { + return contractCategory; + } + + public void setContractCategory(String contractCategory) { + this.contractCategory = contractCategory; + } + + public String getStartType() { + return startType; + } + + public void setStartType(String startType) { + this.startType = startType; + } + + public String getExpiryType() { + return expiryType; + } + + public void setExpiryType(String expiryType) { + this.expiryType = expiryType; + } + + public String getUnderlyingSymbol() { + return underlyingSymbol; + } + + public void setUnderlyingSymbol(String underlyingSymbol) { + this.underlyingSymbol = underlyingSymbol; + } + + public ForwardStartingOption[] getForwardStartingOptions() { + return forwardStartingOptions; + } + + public void setForwardStartingOptions(ForwardStartingOption[] forwardStartingOptions) { + this.forwardStartingOptions = forwardStartingOptions; + } + + public BigDecimal[][] getAvailableBarriers() { + return availableBarriers; + } + + public void setAvailableBarriers(BigDecimal[][] availableBarriers) { + this.availableBarriers = availableBarriers; + } + + public BigDecimal[][] getExpiredBarriers() { + return expiredBarriers; + } + + public void setExpiredBarriers(BigDecimal[][] expiredBarriers) { + this.expiredBarriers = expiredBarriers; + } + + public TradingPeriod getTradingPeriod() { + return tradingPeriod; + } + + public void setTradingPeriod(TradingPeriod tradingPeriod) { + this.tradingPeriod = tradingPeriod; + } + + public int[] getLastDigitRange() { + return lastDigitRange; + } + + public void setLastDigitRange(int[] lastDigitRange) { + this.lastDigitRange = lastDigitRange; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/responses/ContractForSymbol.java b/Trading/src/main/java/com/suneesh/trading/models/responses/ContractForSymbol.java new file mode 100644 index 0000000..85c6719 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/responses/ContractForSymbol.java @@ -0,0 +1,100 @@ +package com.suneesh.trading.models.responses; + +import com.google.gson.annotations.SerializedName; +import io.reactivex.annotations.Nullable; + +import java.math.BigDecimal; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/1/2017 + */ +public class ContractForSymbol { + /** + * Array of available contracts details + */ + @SerializedName("available") + private Contract[] available; + + /** + * Symbol's next market-close time as an epoch value + */ + @SerializedName("close") + @Nullable + private Integer close; + + /** + * Symbol's next market-open time as an epoch value + */ + @SerializedName("open") + @Nullable + private Integer open; + + /** + * Count of contracts available + */ + @SerializedName("hit_count") + private int hitCount; + + /** + * Current spot price for this underlying + */ + @SerializedName("spot") + @Nullable + private BigDecimal spot; + + /** + * Indicates the feed license for symbol, for example whether its realtime or delayed + */ + @SerializedName("feed_license") + private String feedLicense; + + public Contract[] getAvailable() { + return available; + } + + public void setAvailable(Contract[] available) { + this.available = available; + } + + public Integer getClose() { + return close; + } + + public void setClose(Integer close) { + this.close = close; + } + + public Integer getOpen() { + return open; + } + + public void setOpen(Integer open) { + this.open = open; + } + + public int getHitCount() { + return hitCount; + } + + public void setHitCount(int hitCount) { + this.hitCount = hitCount; + } + + public BigDecimal getSpot() { + return spot; + } + + public void setSpot(BigDecimal spot) { + this.spot = spot; + } + + public String getFeedLicense() { + return feedLicense; + } + + public void setFeedLicense(String feedLicense) { + this.feedLicense = feedLicense; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/responses/ContractInfo.java b/Trading/src/main/java/com/suneesh/trading/models/responses/ContractInfo.java new file mode 100644 index 0000000..920e9be --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/responses/ContractInfo.java @@ -0,0 +1,45 @@ +package com.suneesh.trading.models.responses; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 7/31/2017 + */ +public class ContractInfo { + private String contractSymbol; + private String contractDisplayName; + private String minDuration; + private String maxDuration; + + public String getContractSymbol() { + return contractSymbol; + } + + public void setContractSymbol(String contractSymbol) { + this.contractSymbol = contractSymbol; + } + + public String getContractDisplayName() { + return contractDisplayName; + } + + public void setContractDisplayName(String contractDisplayName) { + this.contractDisplayName = contractDisplayName; + } + + public String getMinDuration() { + return minDuration; + } + + public void setMinDuration(String minDuration) { + this.minDuration = minDuration; + } + + public String getMaxDuration() { + return maxDuration; + } + + public void setMaxDuration(String maxDuration) { + this.maxDuration = maxDuration; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/responses/ContractsForSymbolResponse.java b/Trading/src/main/java/com/suneesh/trading/models/responses/ContractsForSymbolResponse.java new file mode 100644 index 0000000..d446bed --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/responses/ContractsForSymbolResponse.java @@ -0,0 +1,24 @@ +package com.suneesh.trading.models.responses; + +import com.suneesh.trading.models.requests.ContractsForSymbolRequest; +import com.google.gson.annotations.SerializedName; +import io.reactivex.annotations.Nullable; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/1/2017 + */ +public class ContractsForSymbolResponse extends ResponseBase { + + @SerializedName("contracts_for") + private ContractForSymbol contractsFor; + + public ContractForSymbol getContractsFor() { + return contractsFor; + } + + public void setContractsFor(ContractForSymbol contractsFor) { + this.contractsFor = contractsFor; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/responses/CreateMaltaAccountResponse.java b/Trading/src/main/java/com/suneesh/trading/models/responses/CreateMaltaAccountResponse.java new file mode 100644 index 0000000..e36891f --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/responses/CreateMaltaAccountResponse.java @@ -0,0 +1,21 @@ +package com.suneesh.trading.models.responses; + +import com.suneesh.trading.models.requests.CreateMaltaAccountRequest; +import com.google.gson.annotations.SerializedName; + +import java.util.Map; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 9/3/2017 + */ +public class CreateMaltaAccountResponse extends ResponseBase { + + @SerializedName("new_account_maltainvest") + private Map account; + + public Map getAccount() { + return account; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/responses/CreateRealAccountResponse.java b/Trading/src/main/java/com/suneesh/trading/models/responses/CreateRealAccountResponse.java new file mode 100644 index 0000000..8c6ff57 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/responses/CreateRealAccountResponse.java @@ -0,0 +1,25 @@ +package com.suneesh.trading.models.responses; + +import com.suneesh.trading.models.requests.CreateRealAccountRequest; +import com.google.gson.annotations.SerializedName; + +import java.util.Map; + +/** + *

CreateRealAccountResponse

+ * + *

Create real account Receive

+ * + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 9/3/2017 + */ +public class CreateRealAccountResponse extends ResponseBase { + + @SerializedName("new_account_real") + private Map account; + + public Map getAccount() { + return account; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/responses/CreateRealSubAccountResponse.java b/Trading/src/main/java/com/suneesh/trading/models/responses/CreateRealSubAccountResponse.java new file mode 100644 index 0000000..b649411 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/responses/CreateRealSubAccountResponse.java @@ -0,0 +1,28 @@ +package com.suneesh.trading.models.responses; + +import com.suneesh.trading.models.requests.CreateRealSubAccountRequest; +import com.google.gson.annotations.SerializedName; + +import java.util.Map; + +/** + *

CreateRealSubAccountResponse

+ * + *

Create sub account receive

+ *

+ * Response for new sub account call + *

+ * + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 9/4/2017 + */ +public class CreateRealSubAccountResponse extends ResponseBase { + + @SerializedName("new_sub_account") + private Map account; + + public Map getAccount() { + return account; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/responses/CurrencyConfig.java b/Trading/src/main/java/com/suneesh/trading/models/responses/CurrencyConfig.java new file mode 100644 index 0000000..10b10fc --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/responses/CurrencyConfig.java @@ -0,0 +1,25 @@ +package com.suneesh.trading.models.responses; + +import com.google.gson.annotations.SerializedName; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/3/2017 + */ +public class CurrencyConfig { + + @SerializedName("fractional_digits") + private int fractionalDigits; + + @SerializedName("type") + private String type; + + public int getFractionalDigits() { + return fractionalDigits; + } + + public String getType() { + return type; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/responses/DatabaseOperation.java b/Trading/src/main/java/com/suneesh/trading/models/responses/DatabaseOperation.java new file mode 100644 index 0000000..6b67c42 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/responses/DatabaseOperation.java @@ -0,0 +1,8 @@ +package com.suneesh.trading.models.responses; + +import java.util.List; + +public interface DatabaseOperation { + default List databaseInsertStringList(){ return null; }; + default List databaseUpdateStringList(){ return null; }; +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/responses/DateStructure.java b/Trading/src/main/java/com/suneesh/trading/models/responses/DateStructure.java new file mode 100644 index 0000000..fc901e4 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/responses/DateStructure.java @@ -0,0 +1,32 @@ +package com.suneesh.trading.models.responses; + +import com.google.gson.annotations.SerializedName; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/1/2017 + */ +public class DateStructure { + @SerializedName("date") + private String date; + + @SerializedName("epoch") + private String epoch; + + public String getDate() { + return date; + } + + public void setDate(String date) { + this.date = date; + } + + public String getEpoch() { + return epoch; + } + + public void setEpoch(String epoch) { + this.epoch = epoch; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/responses/EmailVerificationResponse.java b/Trading/src/main/java/com/suneesh/trading/models/responses/EmailVerificationResponse.java new file mode 100644 index 0000000..424f051 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/responses/EmailVerificationResponse.java @@ -0,0 +1,27 @@ +package com.suneesh.trading.models.responses; + +import com.suneesh.trading.models.requests.EmailVerificationRequest; +import com.google.gson.annotations.SerializedName; + +/** + *

EmailVerificationResponse

+ * + *

Verify Email Receive

+ *

Verify Email Receive

+ * + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/3/2017 + */ +public class EmailVerificationResponse extends ResponseBase { + + /** + * 1 for success (secure code has been sent to the email address) + */ + @SerializedName("verify_email") + private int VerifyEmail; + + public int getVerifyEmail() { + return VerifyEmail; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/responses/Error.java b/Trading/src/main/java/com/suneesh/trading/models/responses/Error.java new file mode 100644 index 0000000..0ce8950 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/responses/Error.java @@ -0,0 +1,33 @@ +package com.suneesh.trading.models.responses; + +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + +/** + * Created by morteza on 7/28/2017. + */ +public class Error { + @SerializedName("code") + @Expose + private String code; + + @SerializedName("message") + @Expose + private String message; + + public String getCode() { + return code; + } + + public void setCode(String code) { + this.code = code; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/responses/FinancialAssessment.java b/Trading/src/main/java/com/suneesh/trading/models/responses/FinancialAssessment.java new file mode 100644 index 0000000..93d4687 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/responses/FinancialAssessment.java @@ -0,0 +1,321 @@ +package com.suneesh.trading.models.responses; + +import com.google.gson.annotations.SerializedName; +import io.reactivex.annotations.Nullable; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/29/2017 + */ +public class FinancialAssessment { + + /** + * Total score based on client's answer for financial assessment + */ + @SerializedName("score") + @Nullable + private Integer score; + + /** + * The anticipated account turnover + */ + @SerializedName("account_turnover") + private String accountTurnover; + + /** + * Forex trading frequency + */ + @SerializedName("forex_trading_frequency") + private String forexTradingFrequency; + + /** + * Forex trading experience + */ + @SerializedName("forex_trading_experience") + private String forexTradingExperience; + + /** + * Indices trading frequency + */ + @SerializedName("indices_trading_frequency") + private String indicesTradingFrequency; + + /** + * Indices trading experience + */ + @SerializedName("indices_trading_experience") + private String indicesTradingExcperience; + + /** + * Commodities trading frequency + */ + @SerializedName("commodities_trading_frequency") + private String commoditiesTradingFrequency; + + /** + * Commodities trading experience + */ + @SerializedName("commodities_trading_experience") + private String commoditiesTradingExperience; + + /** + * Stocks trading experience + */ + @SerializedName("stocks_trading_experience") + private String stocksTradingExperience; + + /** + * Stocks trading frequency + */ + @SerializedName("stocks_trading_frequency") + private String stocksTradingFrequency; + + /** + * Binary options or other financial derivatives trading frequency + */ + @SerializedName("other_derivatives_trading_frequency") + private String otherDerivativesTradingFrequency; + + /** + * Binary options or other financial derivatives trading experience + */ + @SerializedName("other_derivatives_trading_experience") + private String otherDerivativesTradingExperience; + + /** + * Other financial instruments trading frequency + */ + @SerializedName("other_instruments_trading_frequency") + private String otherInstrumentsTradingFrequency; + + /** + * Other financial instruments trading experience + */ + @SerializedName("other_instruments_trading_experience") + private String otherInstrumentsTradingExperience; + + /** + * Industry of Employment + */ + @SerializedName("employment_industry") + private String employmentIndustry; + + /** + * Level of Education + */ + @SerializedName("education_level") + private String educationLevel; + + /** + * Income Source + */ + @SerializedName("income_source") + private String incomeSource; + + /** + * Net Annual Income + */ + @SerializedName("net_income") + private String netIncome; + + /** + * Estimated Net Worth + */ + @SerializedName("estimated_worth") + private String estimatedWorth; + + /** + * Occupation + */ + @SerializedName("occupation") + private String occupation; + + /** + * Employment Status + */ + @SerializedName("employment_status") + private String employmentStatus; + + /** + * Source of wealth + */ + @SerializedName("source_of_wealth") + private String sourceOfWealth; + + public Integer getScore() { + return score; + } + + public void setScore(Integer score) { + this.score = score; + } + + public String getAccountTurnover() { + return accountTurnover; + } + + public void setAccountTurnover(String accountTurnover) { + this.accountTurnover = accountTurnover; + } + + public String getForexTradingFrequency() { + return forexTradingFrequency; + } + + public void setForexTradingFrequency(String forexTradingFrequency) { + this.forexTradingFrequency = forexTradingFrequency; + } + + public String getForexTradingExperience() { + return forexTradingExperience; + } + + public void setForexTradingExperience(String forexTradingExperience) { + this.forexTradingExperience = forexTradingExperience; + } + + public String getIndicesTradingFrequency() { + return indicesTradingFrequency; + } + + public void setIndicesTradingFrequency(String indicesTradingFrequency) { + this.indicesTradingFrequency = indicesTradingFrequency; + } + + public String getIndicesTradingExcperience() { + return indicesTradingExcperience; + } + + public void setIndicesTradingExcperience(String indicesTradingExcperience) { + this.indicesTradingExcperience = indicesTradingExcperience; + } + + public String getCommoditiesTradingFrequency() { + return commoditiesTradingFrequency; + } + + public void setCommoditiesTradingFrequency(String commoditiesTradingFrequency) { + this.commoditiesTradingFrequency = commoditiesTradingFrequency; + } + + public String getCommoditiesTradingExperience() { + return commoditiesTradingExperience; + } + + public void setCommoditiesTradingExperience(String commoditiesTradingExperience) { + this.commoditiesTradingExperience = commoditiesTradingExperience; + } + + public String getStocksTradingExperience() { + return stocksTradingExperience; + } + + public void setStocksTradingExperience(String stocksTradingExperience) { + this.stocksTradingExperience = stocksTradingExperience; + } + + public String getStocksTradingFrequency() { + return stocksTradingFrequency; + } + + public void setStocksTradingFrequency(String stocksTradingFrequency) { + this.stocksTradingFrequency = stocksTradingFrequency; + } + + public String getOtherDerivativesTradingFrequency() { + return otherDerivativesTradingFrequency; + } + + public void setOtherDerivativesTradingFrequency(String otherDerivativesTradingFrequency) { + this.otherDerivativesTradingFrequency = otherDerivativesTradingFrequency; + } + + public String getOtherDerivativesTradingExperience() { + return otherDerivativesTradingExperience; + } + + public void setOtherDerivativesTradingExperience(String otherDerivativesTradingExperience) { + this.otherDerivativesTradingExperience = otherDerivativesTradingExperience; + } + + public String getOtherInstrumentsTradingFrequency() { + return otherInstrumentsTradingFrequency; + } + + public void setOtherInstrumentsTradingFrequency(String otherInstrumentsTradingFrequency) { + this.otherInstrumentsTradingFrequency = otherInstrumentsTradingFrequency; + } + + public String getOtherInstrumentsTradingExperience() { + return otherInstrumentsTradingExperience; + } + + public void setOtherInstrumentsTradingExperience(String otherInstrumentsTradingExperience) { + this.otherInstrumentsTradingExperience = otherInstrumentsTradingExperience; + } + + public String getEmploymentIndustry() { + return employmentIndustry; + } + + public void setEmploymentIndustry(String employmentIndustry) { + this.employmentIndustry = employmentIndustry; + } + + public String getEducationLevel() { + return educationLevel; + } + + public void setEducationLevel(String educationLevel) { + this.educationLevel = educationLevel; + } + + public String getIncomeSource() { + return incomeSource; + } + + public void setIncomeSource(String incomeSource) { + this.incomeSource = incomeSource; + } + + public String getNetIncome() { + return netIncome; + } + + public void setNetIncome(String netIncome) { + this.netIncome = netIncome; + } + + public String getEstimatedWorth() { + return estimatedWorth; + } + + public void setEstimatedWorth(String estimatedWorth) { + this.estimatedWorth = estimatedWorth; + } + + public String getOccupation() { + return occupation; + } + + public void setOccupation(String occupation) { + this.occupation = occupation; + } + + public String getEmploymentStatus() { + return employmentStatus; + } + + public void setEmploymentStatus(String employmentStatus) { + this.employmentStatus = employmentStatus; + } + + public String getSourceOfWealth() { + return sourceOfWealth; + } + + public void setSourceOfWealth(String sourceOfWealth) { + this.sourceOfWealth = sourceOfWealth; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/responses/ForgetResponse.java b/Trading/src/main/java/com/suneesh/trading/models/responses/ForgetResponse.java new file mode 100644 index 0000000..e47786c --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/responses/ForgetResponse.java @@ -0,0 +1,22 @@ +package com.suneesh.trading.models.responses; + +import com.suneesh.trading.models.requests.ForgetRequest; +import com.google.gson.annotations.SerializedName; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/1/2017 + */ +public class ForgetResponse extends ResponseBase { + @SerializedName("forget") + private int forget; + + public int getForget() { + return forget; + } + + public void setForget(int forget) { + this.forget = forget; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/responses/ForwardStartingOption.java b/Trading/src/main/java/com/suneesh/trading/models/responses/ForwardStartingOption.java new file mode 100644 index 0000000..ad660d0 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/responses/ForwardStartingOption.java @@ -0,0 +1,45 @@ +package com.suneesh.trading.models.responses; + +import com.google.gson.annotations.SerializedName; + +import java.math.BigDecimal; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/1/2017 + */ +public class ForwardStartingOption { + @SerializedName("close") + private int close; + + @SerializedName("date") + private int date; + + @SerializedName("open") + private int open; + + public int getClose() { + return close; + } + + public void setClose(int close) { + this.close = close; + } + + public int getDate() { + return date; + } + + public void setDate(int date) { + this.date = date; + } + + public int getOpen() { + return open; + } + + public void setOpen(int open) { + this.open = open; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/responses/GetFinancialAssessmentResponse.java b/Trading/src/main/java/com/suneesh/trading/models/responses/GetFinancialAssessmentResponse.java new file mode 100644 index 0000000..af7430b --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/responses/GetFinancialAssessmentResponse.java @@ -0,0 +1,31 @@ +package com.suneesh.trading.models.responses; + +import com.suneesh.trading.models.requests.GetFinancialAssessmentRequest; +import com.google.gson.annotations.SerializedName; +import io.reactivex.annotations.Nullable; + +/** + *

GetFinancialAssessmentResponse

+ * + *

Get financial assessment details

+ *

+ * This call gets the financial assessment details of client's account. + *

+ * + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/29/2017 + */ +public class GetFinancialAssessmentResponse extends ResponseBase { + + /** + * Client's financial asessment details + */ + @SerializedName("get_financial_assessment") + @Nullable + private FinancialAssessment financialAssessment; + + public FinancialAssessment getFinancialAssessment() { + return financialAssessment; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/responses/GetSelfExclusionResponse.java b/Trading/src/main/java/com/suneesh/trading/models/responses/GetSelfExclusionResponse.java new file mode 100644 index 0000000..59eef8e --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/responses/GetSelfExclusionResponse.java @@ -0,0 +1,29 @@ +package com.suneesh.trading.models.responses; + +import com.suneesh.trading.models.requests.GetSelfExclusionRequest; +import com.google.gson.annotations.SerializedName; + +/** + *

GetSelfExclusionResponse

+ * + *

Get User Self-Exclusion Receive

+ *

+ * A message with User Self-Exclusion + *

+ * + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/4/2017 + */ +public class GetSelfExclusionResponse extends ResponseBase { + + /** + * Echo of the request made + */ + @SerializedName("get_self_exclusion") + private SelfExclusion selfExclusion; + + public SelfExclusion getSelfExclusion() { + return selfExclusion; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/responses/History.java b/Trading/src/main/java/com/suneesh/trading/models/responses/History.java new file mode 100644 index 0000000..4b58edf --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/responses/History.java @@ -0,0 +1,28 @@ +package com.suneesh.trading.models.responses; + +import com.google.gson.annotations.SerializedName; + +import java.math.BigDecimal; +import java.util.List; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/3/2017 + */ +public class History { + + @SerializedName("times") + private List times; + + @SerializedName("prices") + private List prices; + + public List getTimes() { + return times; + } + + public List getPrices() { + return prices; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/responses/JPAccountStatus.java b/Trading/src/main/java/com/suneesh/trading/models/responses/JPAccountStatus.java new file mode 100644 index 0000000..eaec805 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/responses/JPAccountStatus.java @@ -0,0 +1,60 @@ +package com.suneesh.trading.models.responses; + +import com.suneesh.trading.models.enums.JPStatus; +import com.google.gson.annotations.SerializedName; +import io.reactivex.annotations.Nullable; + +/** + *

JPAccountStatus

+ * + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/4/2017 + */ +public class JPAccountStatus { + + /** + * Status of Japan real money account opening, any of the above. + */ + @SerializedName("status") + private String status; + + /** + * Optional field. When status equals 'jp_knowledge_test_fail', this shows last knowledge test taken time in epoch. + */ + @SerializedName("last_test_epoch") + @Nullable + private Integer lastTestEpoch; + + /** + * Optional field. When status equals 'jp_knowledge_test_pending' or 'jp_knowledge_test_fail', + * this shows next available knowledge test time in epoch. + */ + @SerializedName("next_test_epoch") + @Nullable + private Integer nextTextEpoch; + + public String getStatus() { + return status; + } + + public void setStatus(JPStatus status) { + this.status = status.toString(); + } + + public Integer getLastTestEpoch() { + return lastTestEpoch; + } + + public void setLastTestEpoch(Integer lastTestEpoch) { + this.lastTestEpoch = lastTestEpoch; + } + + public Integer getNextTextEpoch() { + return nextTextEpoch; + } + + public void setNextTextEpoch(Integer nextTextEpoch) { + this.nextTextEpoch = nextTextEpoch; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/responses/JPSettings.java b/Trading/src/main/java/com/suneesh/trading/models/responses/JPSettings.java new file mode 100644 index 0000000..21600b3 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/responses/JPSettings.java @@ -0,0 +1,232 @@ +package com.suneesh.trading.models.responses; + +import com.suneesh.trading.models.enums.*; +import com.google.gson.annotations.SerializedName; +import com.suneesh.trading.models.enums.*; +import io.reactivex.annotations.Nullable; + +import java.math.BigDecimal; + +/** + *

JPSettings

+ * + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/4/2017 + */ +public class JPSettings { + + /** + * Male (m) or female (f) (note: only set for Japan real-money accounts) + */ + @SerializedName("gender") + private String gender; + + /** + * Occupation (note: only set for Japan real-money accounts) + */ + @SerializedName("occupation") + private String occupation; + + /** + * Annual income (note: only set for Japan real-money accounts) + */ + @SerializedName("annual_income") + private String annualIncome; + + /** + * Financial asset (note: only set for Japan real-money accounts) + */ + @SerializedName("financial_asset") + private String financialAsset; + + /** + * Daily limit on losses in JPY (note: only set for Japan real-money accounts) + */ + @SerializedName("daily_loss_limit") + private BigDecimal daily_loss_limit; + + /** + * Equities trading experience (note: only set for Japan real-money accounts) + */ + @SerializedName("trading_experience_equities") + private String tradingExperienceEquities; + + /** + * Commodities trading experience (note: only set for Japan real-money accounts) + */ + @SerializedName("trading_experience_commodities") + private String tradingExperienceCommodities; + + /** + * Foreign currency deposit trading experience (note: only set for Japan real-money accounts) + */ + @SerializedName("trading_experience_foreign_currency_deposit") + private String tradingExperienceForeignCurrencyDeposit; + + /** + * Margin FX trading experience (note: only set for Japan real-money accounts) + */ + @SerializedName("trading_experience_margin_fx") + private String tradingExperienceMarginFX; + + /** + * Investment trust trading experience (note: only set for Japan real-money accounts) + */ + @SerializedName("trading_experience_investment_trust") + private String tradingExperienceInvestmentTrust; + + /** + * Public and corporation bond trading experience (note: only set for Japan real-money accounts) + */ + @SerializedName("trading_experience_public_bond") + private String tradingExperiencePublicBond; + + /** + * OTC Derivative (Option) trading experience (note: only set for Japan real-money accounts) + */ + @SerializedName("trading_experience_option_trading") + private String tradingExperienceOptionTrading; + + /** + * Trading purpose (note: only set for Japan real-money accounts) + */ + @SerializedName("trading_purpose") + private String tradingPurpose; + + /** + * Classification of assets requiring hedge + * (note: only set for Japan real-money accounts, if 'Hedging' is selected for 'Trading purpose') + */ + @SerializedName("hedge_asset") + @Nullable + private String hedgeAsset; + + /** + * Hedge asset amount in JPY + * (note: only set for Japan real-money accounts, if 'Hedging' is selected for 'Trading purpose') + */ + @SerializedName("hedge_asset_amount") + @Nullable + private BigDecimal hedgeAssetAmount; + + public String getGender() { + return gender; + } + + public void setGender(Gender gender) { + this.gender = gender.toString(); + } + + public String getOccupation() { + return occupation; + } + + public void setOccupation(JPOccupations occupation) { + this.occupation = occupation.toString(); + } + + public String getAnnualIncome() { + return annualIncome; + } + + public void setAnnualIncome(JPAnnualIncomes annualIncome) { + this.annualIncome = annualIncome.toString(); + } + + public String getFinancialAsset() { + return financialAsset; + } + + public void setFinancialAsset(JPAnnualIncomes financialAsset) { + this.financialAsset = financialAsset.toString(); + } + + public BigDecimal getDaily_loss_limit() { + return daily_loss_limit; + } + + public void setDaily_loss_limit(BigDecimal daily_loss_limit) { + this.daily_loss_limit = daily_loss_limit; + } + + public String getTradingExperienceEquities() { + return tradingExperienceEquities; + } + + public void setTradingExperienceEquities(JPTradingExperiences tradingExperienceEquities) { + this.tradingExperienceEquities = tradingExperienceEquities.toString(); + } + + public String getTradingExperienceCommodities() { + return tradingExperienceCommodities; + } + + public void setTradingExperienceCommodities(JPTradingExperiences tradingExperienceCommodities) { + this.tradingExperienceCommodities = tradingExperienceCommodities.toString(); + } + + public String getTradingExperienceForeignCurrencyDeposit() { + return tradingExperienceForeignCurrencyDeposit; + } + + public void setTradingExperienceForeignCurrencyDeposit(JPTradingExperiences tradingExperienceForeignCurrencyDeposit) { + this.tradingExperienceForeignCurrencyDeposit = tradingExperienceForeignCurrencyDeposit.toString(); + } + + public String getTradingExperienceMarginFX() { + return tradingExperienceMarginFX; + } + + public void setTradingExperienceMarginFX(JPTradingExperiences tradingExperienceMarginFX) { + this.tradingExperienceMarginFX = tradingExperienceMarginFX.toString(); + } + + public String getTradingExperienceInvestmentTrust() { + return tradingExperienceInvestmentTrust; + } + + public void setTradingExperienceInvestmentTrust(JPTradingExperiences tradingExperienceInvestmentTrust) { + this.tradingExperienceInvestmentTrust = tradingExperienceInvestmentTrust.toString(); + } + + public String getTradingExperiencePublicBond() { + return tradingExperiencePublicBond; + } + + public void setTradingExperiencePublicBond(JPTradingExperiences tradingExperiencePublicBond) { + this.tradingExperiencePublicBond = tradingExperiencePublicBond.toString(); + } + + public String getTradingExperienceOptionTrading() { + return tradingExperienceOptionTrading; + } + + public void setTradingExperienceOptionTrading(JPTradingExperiences tradingExperienceOptionTrading) { + this.tradingExperienceOptionTrading = tradingExperienceOptionTrading.toString(); + } + + public String getTradingPurpose() { + return tradingPurpose; + } + + public void setTradingPurpose(JPTradingPurposes tradingPurpose) { + this.tradingPurpose = tradingPurpose.toString(); + } + + public String getHedgeAsset() { + return hedgeAsset; + } + + public void setHedgeAsset(String hedgeAsset) { + this.hedgeAsset = hedgeAsset; + } + + public BigDecimal getHedgeAssetAmount() { + return hedgeAssetAmount; + } + + public void setHedgeAssetAmount(BigDecimal hedgeAssetAmount) { + this.hedgeAssetAmount = hedgeAssetAmount; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/responses/JapanKnowledgeTestResponse.java b/Trading/src/main/java/com/suneesh/trading/models/responses/JapanKnowledgeTestResponse.java new file mode 100644 index 0000000..c63fb87 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/responses/JapanKnowledgeTestResponse.java @@ -0,0 +1,21 @@ +package com.suneesh.trading.models.responses; + +import com.suneesh.trading.models.requests.JapanKnowledgeTestRequest; +import com.google.gson.annotations.SerializedName; + +import java.util.Map; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/30/2017 + */ +public class JapanKnowledgeTestResponse extends ResponseBase { + + @SerializedName("jp_knowledge_test") + private Map japanKnowledgeTest; + + public Map getJapanKnowledgeTest() { + return japanKnowledgeTest; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/responses/LandingCompany.java b/Trading/src/main/java/com/suneesh/trading/models/responses/LandingCompany.java new file mode 100644 index 0000000..6f34cd9 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/responses/LandingCompany.java @@ -0,0 +1,105 @@ +package com.suneesh.trading.models.responses; + +import com.google.gson.annotations.SerializedName; +import io.reactivex.annotations.Nullable; + +/** + *

Landing Company

+ * + *

Landing Company Receive

+ *

Returns the Landing Company for clients of a given country.

+ * + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/1/2017 + */ +public class LandingCompany { + + /** + * Country code + */ + @SerializedName("id") + private String id; + + /** + * Country name + */ + @SerializedName("name") + private String name; + + /** + * Landing Company for gaming contracts (Volatility Indices) + */ + @SerializedName("gaming_company") + @Nullable + private Company gamingCompany; + + /** + * Landing Company for financial contracts (all except Volatility Indices) + */ + @SerializedName("financial_company") + @Nullable + private Company financialCompany; + + /** + * Landing Company for MT5 gaming contracts (Volatility Indices) + */ + @SerializedName("mt_gaming_company") + @Nullable + private Company mtGamingCompany; + + /** + * Landing Company for MT5 financial contracts (all except Volatility Indices) + */ + @SerializedName("mt_financial_company") + @Nullable + private Company mtFinancialCompany; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Company getGamingCompany() { + return gamingCompany; + } + + public void setGamingCompany(Company gamingCompany) { + this.gamingCompany = gamingCompany; + } + + public Company getFinancialCompany() { + return financialCompany; + } + + public void setFinancialCompany(Company financialCompany) { + this.financialCompany = financialCompany; + } + + public Company getMtGamingCompany() { + return mtGamingCompany; + } + + public void setMtGamingCompany(Company mtGamingCompany) { + this.mtGamingCompany = mtGamingCompany; + } + + public Company getMtFinancialCompany() { + return mtFinancialCompany; + } + + public void setMtFinancialCompany(Company mtFinancialCompany) { + this.mtFinancialCompany = mtFinancialCompany; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/responses/LandingCompanyDetails.java b/Trading/src/main/java/com/suneesh/trading/models/responses/LandingCompanyDetails.java new file mode 100644 index 0000000..ecd8c7b --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/responses/LandingCompanyDetails.java @@ -0,0 +1,101 @@ +package com.suneesh.trading.models.responses; + +import com.google.gson.annotations.SerializedName; +import io.reactivex.annotations.Nullable; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/2/2017 + */ +public class LandingCompanyDetails { + + /** + * Landing Company shortcode + */ + @SerializedName("shortcode") + private String shortCode; + + /** + * Landing Company name + */ + @SerializedName("name") + private String name; + + /** + * Landing Company address + */ + @SerializedName("address") + @Nullable + private String[] address; + + /** + * Landing Company country + */ + @SerializedName("country") + private String county; + + /** + * Default currency of client accounts with this Landing Company + */ + @SerializedName("legal_default_currency") + private String legalDefaultCurrency; + + /** + * Allowable currencies for accounts with this Landing Company + */ + @SerializedName("legal_allowed_currencies") + private String[] legalAllowedCurrencies; + + @SerializedName("legal_allowed_markets") + private String[] legalAllowedMarkets; + + @SerializedName("legal_allowed_contract_categories") + private String[] legalAllowedContractCategories; + + /** + * Flag to indicate whether reality check is applicable for this Landing Company. + * 1: applicable, 0: not applicable. + * The Reality Check is a feature that gives a summary of the client's trades + * and account balances on a regular basis throughout his session, + * and is a regulatory requirement for certain Landing Companies. + */ + @SerializedName("has_reality_check") + private int hasRealityCheck; + + public String getShortCode() { + return shortCode; + } + + public String getName() { + return name; + } + + public String[] getAddress() { + return address; + } + + public String getCounty() { + return county; + } + + public String getLegalDefaultCurrency() { + return legalDefaultCurrency; + } + + public String[] getLegalAllowedCurrencies() { + return legalAllowedCurrencies; + } + + public String[] getLegalAllowedMarkets() { + return legalAllowedMarkets; + } + + public String[] getLegalAllowedContractCategories() { + return legalAllowedContractCategories; + } + + public int getHasRealityCheck() { + return hasRealityCheck; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/responses/LandingCompanyDetailsResponse.java b/Trading/src/main/java/com/suneesh/trading/models/responses/LandingCompanyDetailsResponse.java new file mode 100644 index 0000000..4398a26 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/responses/LandingCompanyDetailsResponse.java @@ -0,0 +1,26 @@ +package com.suneesh.trading.models.responses; + +import com.suneesh.trading.models.requests.LandingCompanyDetailsRequest; +import com.google.gson.annotations.SerializedName; + +/** + *

LandingCompanyDetailsResponse

+ * + *

Landing Company Receive

+ *

A message with Landing Company

+ * + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/2/2017 + */ +public class LandingCompanyDetailsResponse extends ResponseBase { + /** + * Landing Company Details + */ + @SerializedName("landing_company_details") + private LandingCompanyDetails landingCompanyDetails; + + public LandingCompanyDetails getLandingCompanyDetails() { + return landingCompanyDetails; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/responses/LandingCompanyResponse.java b/Trading/src/main/java/com/suneesh/trading/models/responses/LandingCompanyResponse.java new file mode 100644 index 0000000..6af22e5 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/responses/LandingCompanyResponse.java @@ -0,0 +1,23 @@ +package com.suneesh.trading.models.responses; + +import com.suneesh.trading.models.requests.LandingCompanyRequest; +import com.google.gson.annotations.SerializedName; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/1/2017 + */ +public class LandingCompanyResponse extends ResponseBase { + + @SerializedName("landing_company") + private LandingCompany landingCompany; + + public LandingCompany getLandingCompany() { + return landingCompany; + } + + public void setLandingCompany(LandingCompany landingCompany) { + this.landingCompany = landingCompany; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/responses/LoginHistory.java b/Trading/src/main/java/com/suneesh/trading/models/responses/LoginHistory.java new file mode 100644 index 0000000..eadec66 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/responses/LoginHistory.java @@ -0,0 +1,51 @@ +package com.suneesh.trading.models.responses; + +import com.google.gson.annotations.SerializedName; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/7/2017 + */ +public class LoginHistory { + + /** + * Epoch time of the activity + */ + @SerializedName("time") + private int time; + + /** + * Type of action. Example: login, logout + */ + @SerializedName("action") + private String action; + + /** + * Provides details about browser, device used during login or logout + */ + @SerializedName("environment") + private String evironment; + + /** + * Status of activity: 1 - success, 0 - failure + */ + @SerializedName("status") + private int status; + + public int getTime() { + return time; + } + + public String getAction() { + return action; + } + + public String getEvironment() { + return evironment; + } + + public boolean getStatus() { + return status == 1 ? true : false; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/responses/LoginHistoryResponse.java b/Trading/src/main/java/com/suneesh/trading/models/responses/LoginHistoryResponse.java new file mode 100644 index 0000000..4a16ab3 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/responses/LoginHistoryResponse.java @@ -0,0 +1,31 @@ +package com.suneesh.trading.models.responses; + +import com.suneesh.trading.models.requests.LoginHistoryRequest; +import com.google.gson.annotations.SerializedName; + +import java.util.List; + +/** + *

LoginHistoryResponse

+ * + *

Login History Response

+ *

+ * Recent login/logout history records + *

+ * + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/7/2017 + */ +public class LoginHistoryResponse extends ResponseBase { + + /** + * Array of records of client login/logout activities + */ + @SerializedName("login_history") + private List loginHistories; + + public List getLoginHistories() { + return loginHistories; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/responses/LogoutResponse.java b/Trading/src/main/java/com/suneesh/trading/models/responses/LogoutResponse.java new file mode 100644 index 0000000..5adb0ee --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/responses/LogoutResponse.java @@ -0,0 +1,23 @@ +package com.suneesh.trading.models.responses; + +import com.suneesh.trading.models.requests.LogoutRequest; +import com.google.gson.annotations.SerializedName; + +/** + *

LogouResponse

+ * + *

Logout Response

+ * + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/7/2017 + */ +public class LogoutResponse extends ResponseBase { + + @SerializedName("logout") + private int logout; + + public boolean getLogout() { + return logout == 1 ? true : false; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/responses/Market.java b/Trading/src/main/java/com/suneesh/trading/models/responses/Market.java new file mode 100644 index 0000000..557367a --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/responses/Market.java @@ -0,0 +1,27 @@ +package com.suneesh.trading.models.responses; + +import com.google.gson.annotations.SerializedName; + +import java.util.List; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/3/2017 + */ +public class Market { + + @SerializedName("name") + private String name; + + @SerializedName("submarkets") + private List subMarkets; + + public String getName() { + return name; + } + + public List getSubMarkets() { + return subMarkets; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/responses/MarketSpecific.java b/Trading/src/main/java/com/suneesh/trading/models/responses/MarketSpecific.java new file mode 100644 index 0000000..082eab8 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/responses/MarketSpecific.java @@ -0,0 +1,41 @@ +package com.suneesh.trading.models.responses; + +import com.google.gson.annotations.SerializedName; + +import java.math.BigDecimal; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/4/2017 + */ +public class MarketSpecific { + + @SerializedName("name") + private String name; + + @SerializedName("turnover_limit") + private BigDecimal turnoverLimit; + + @SerializedName("payout_limit") + private BigDecimal payoutLimit; + + @SerializedName("profile_name") + private String profileName; + + public String getName() { + return name; + } + + public BigDecimal getTurnoverLimit() { + return turnoverLimit; + } + + public BigDecimal getPayoutLimit() { + return payoutLimit; + } + + public String getProfileName() { + return profileName; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/responses/MassSellReceipt.java b/Trading/src/main/java/com/suneesh/trading/models/responses/MassSellReceipt.java new file mode 100644 index 0000000..7bd18e1 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/responses/MassSellReceipt.java @@ -0,0 +1,62 @@ +package com.suneesh.trading.models.responses; + +import com.google.gson.annotations.SerializedName; + +import java.math.BigDecimal; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/9/2017 + */ +public class MassSellReceipt { + + @SerializedName("balance_after") + private BigDecimal balanceAfter; + + @SerializedName("contract_id") + private Long contractId; + + @SerializedName("reference_id") + private Long referenceId; + + @SerializedName("sell_price") + private BigDecimal sellPrice; + + @SerializedName("sell_time") + private String sellTime; + + @SerializedName("transaction_id") + private Long transactionId; + + @SerializedName("token") + private String token; + + public BigDecimal getBalanceAfter() { + return balanceAfter; + } + + public Long getContractId() { + return contractId; + } + + public Long getReferenceId() { + return referenceId; + } + + public BigDecimal getSellPrice() { + return sellPrice; + } + + public String getSellTime() { + return sellTime; + } + + public Long getTransactionId() { + return transactionId; + } + + public String getToken() { + return token; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/responses/NewAccountVirtual.java b/Trading/src/main/java/com/suneesh/trading/models/responses/NewAccountVirtual.java new file mode 100644 index 0000000..7370382 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/responses/NewAccountVirtual.java @@ -0,0 +1,62 @@ +package com.suneesh.trading.models.responses; + +import com.google.gson.annotations.SerializedName; + +import java.math.BigDecimal; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/2/2017 + */ +public class NewAccountVirtual { + /** + * Client id of the new virtual-money account + */ + @SerializedName("client_id") + private String clientId; + + /** + * Email of the new virtual-money account + */ + @SerializedName("email") + private String email; + + /** + * Account currency + */ + @SerializedName("currency") + private String currency; + + /** + * Account balance + */ + @SerializedName("balance") + private BigDecimal balance; + + /** + * Oauth token for the client's login session (so that the user may be logged in immediately) + */ + @SerializedName("oauth_token") + private String oauthToken; + + public String getClientId() { + return clientId; + } + + public String getEmail() { + return email; + } + + public String getCurrency() { + return currency; + } + + public BigDecimal getBalance() { + return balance; + } + + public String getOauthToken() { + return oauthToken; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/responses/NewVirtualAccountResponse.java b/Trading/src/main/java/com/suneesh/trading/models/responses/NewVirtualAccountResponse.java new file mode 100644 index 0000000..e03844d --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/responses/NewVirtualAccountResponse.java @@ -0,0 +1,27 @@ +package com.suneesh.trading.models.responses; + +import com.suneesh.trading.models.requests.NewVirtualAccountRequest; +import com.google.gson.annotations.SerializedName; + +/** + *

NewVirtualAccountResponse

+ * + *

Create virtual account Receive

+ *

Create virtual-money account

+ * + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/2/2017 + */ +public class NewVirtualAccountResponse extends ResponseBase { + + /** + * New virtual-money account details + */ + @SerializedName("new_account_virtual") + private NewAccountVirtual accountDetails; + + public NewAccountVirtual getAccountDetails() { + return accountDetails; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/responses/OAuthApplication.java b/Trading/src/main/java/com/suneesh/trading/models/responses/OAuthApplication.java new file mode 100644 index 0000000..20dcad0 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/responses/OAuthApplication.java @@ -0,0 +1,66 @@ +package com.suneesh.trading.models.responses; + +import com.google.gson.annotations.SerializedName; +import io.reactivex.annotations.Nullable; + +import java.math.BigDecimal; +import java.util.List; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/7/2017 + */ +public class OAuthApplication { + + /** + * Framework name + */ + @SerializedName("name") + private String name; + + /** + * Framework id + */ + @SerializedName("app_id") + private Integer applicationId; + + /** + * Framework last used + */ + @SerializedName("last_used") + @Nullable + private String lastUsed; + + /** + * Scopes + */ + @SerializedName("scopes") + private List scopes; + + /** + * Markup added to contract prices (as a percentage of contract payout) + */ + @SerializedName("app_markup_percentage") + private BigDecimal markupPercentage; + + public String getName() { + return name; + } + + public Integer getApplicationId() { + return applicationId; + } + + public String getLastUsed() { + return lastUsed; + } + + public List getScopes() { + return scopes; + } + + public BigDecimal getMarkupPercentage() { + return markupPercentage; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/responses/OAuthApplicationResponse.java b/Trading/src/main/java/com/suneesh/trading/models/responses/OAuthApplicationResponse.java new file mode 100644 index 0000000..9828475 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/responses/OAuthApplicationResponse.java @@ -0,0 +1,28 @@ +package com.suneesh.trading.models.responses; + +import com.suneesh.trading.models.requests.OAuthApplicationsRequest; +import com.google.gson.annotations.SerializedName; + +import java.util.List; + +/** + *

OAuthApplicationResponse

+ * + *

OAuth Apps Receive

+ *

+ * A message with used applications + *

+ * + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/7/2017 + */ +public class OAuthApplicationResponse extends ResponseBase { + + @SerializedName("oauth_apps") + private List oauthApplications; + + public List getOauthApplications() { + return oauthApplications; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/responses/OpenContract.java b/Trading/src/main/java/com/suneesh/trading/models/responses/OpenContract.java new file mode 100644 index 0000000..7b744b6 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/responses/OpenContract.java @@ -0,0 +1,445 @@ +package com.suneesh.trading.models.responses; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; + +import java.math.BigDecimal; +import java.util.Map; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/8/2017 + */ +@Data +public class OpenContract { + + /** + * High barrier of the contract (if any). Example: 42.123 + */ + @SerializedName("high_barrier") + private BigDecimal highBarrier; + + /** + * Low barrier of the contract (if any). Example: 40.132 + */ + @SerializedName("low_barrier") + private BigDecimal lowBarrier; + + /** + * Barrier of the contract (if any). Example: 42.123 + */ + @SerializedName("barrier") + private BigDecimal barrier; + + /** + * The number of barriers a contract has. Example: 2 + */ + @SerializedName("barrier_count") + private Integer barrierCount; + + /** + * Price at which the contract could be sold back to Binary.com. Example: 5.14 + */ + @SerializedName("bid_price") + private BigDecimal bidPrice; + + /** + * Binary.com internal contract identifier + */ + @SerializedName("contract_id") + private Long contractId; + + /** + * Contract type, for example CALL, PUT + */ + @SerializedName("contract_type") + private String contractType; + + /** + * Example: USD + */ + @SerializedName("currency") + private String currency; + + /** + * Spot value if we have license to stream this symbol. Example: 9874.52 + */ + @SerializedName("current_spot") + private BigDecimal currentSpot; + + /** + * Example: 1439999052 + */ + @SerializedName("current_spot_time") + private Long currentSpotTime; + + /** + * Example: 9874.52 + */ + @SerializedName("entry_spot") + private BigDecimal entrySpot; + + /** + * Expiry date (epoch) of the Contract. Example: 1446629000. + * Please note that it is not applicable for tick trade contracts. + */ + @SerializedName("expiry_date") + private Long expiryDate; + + /** + * Settlement date (epoch) of the contract. Example: 1446629000 + */ + @SerializedName("date_setelment") + private Long dateSetelment; + + /** + * Start date (epoch) of the contract. Example: 1446629000 + */ + @SerializedName("date_start") + private Long dateStart; + + /** + * A stream id that can be used to cancel this stream using the Forget request. + * Example: 1d6651e7d599bce6c54bd71a8283e579 + */ + @SerializedName("id") + private String id; + + /** + * Whether the contract is expired or not. Boolean value 1 or 0 + */ + @SerializedName("is_expired") + private int isExpired; + + /** + * Whether the contract is settleable or not. Boolean value 1 or 0 + */ + @SerializedName("is_settleable") + private int isSettleable; + + /** + * Whether the contract is forward-starting or not. Boolean value 1 or 0 + */ + @SerializedName("is_forward_starting") + private int isFrowardStarting; + + /** + * Whether the contract is an intraday contract. Boolean value 1 or 0 + */ + @SerializedName("is_intraday") + private int isIntraday; + + /** + * Whether the contract expiry price will depend on the path of the market + * (e.g. One Touch contract). Boolean value 1 or 0 + */ + @SerializedName("is_path_dependent") + private int isPathDependent; + + /** + * Whether the contract can be sold back to Binary.com. Boolean value 1 or 0 + */ + @SerializedName("is_valid_to_sell") + private int isValidToSell; + + /** + * Text description of the contract purchased, + * Example: Win payout if Volatility 100 Index is strictly higher than entry spot at 10 minutes after contract start time. + */ + @SerializedName("longcode") + private String longCode; + + /** + * Payout value of the contract. Example: 10.50 + */ + @SerializedName("payout") + private BigDecimal payout; + + /** + * Coded description of the contract purchased, Example: CALL_R_100_90_1446704187_1446704787_S0P_0 + */ + @SerializedName("shortcode") + private String shortCode; + + /** + * Example: 5.14, same as ask_price + */ + @SerializedName("display_value") + private BigDecimal displayValue; + + /** + * Example: BSESENSEX30 + */ + @SerializedName("underlying") + private String underlying; + + /** + * display_name + */ + @SerializedName("display_name") + private String displayName; + + /** + * This is the entry spot of the contract. + * For contracts starting immediately it is the next tick after the start time. + * For forward-starting contracts it is the spot at the start time. Example: 86.630. + */ + @SerializedName("entry_tick") + private BigDecimal entryTick; + + /** + * This is the epoch time of the entry tick. Example: 1446629000 + */ + @SerializedName("entry_tick_time") + private Long entryTickTime; + + /** + * This is the latest spot value at the end time of the contract. Example: 86.810 + */ + @SerializedName("exit_tick") + private BigDecimal exitTick; + + /** + * This is the epoch time of the exit tick. + * Note that since certain instruments don't tick every second, the exit tick time may be a few seconds before the end time. Example: 1446629000 + */ + @SerializedName("exit_tick_time") + private Long exitTickTime; + + /** + * Only for tick trades, number of ticks + */ + @SerializedName("tick_count") + private Integer tickCount; + + /** + * Error message if validation fails + */ + @SerializedName("validation_error") + private String validationError; + + /** + * Error message if validation fails + */ + @SerializedName("status") + private String status; + + /** + * Price at which contract was sold, only available when contract has been sold. + */ + @SerializedName("sell_price") + private BigDecimal sellPrice; + + /** + * Price at which contract was purchased + */ + @SerializedName("buy_price") + private BigDecimal buyPrice; + + /** + * Epoch of purchase time, will be same as date_start for all contracts except forward starting contracts. + */ + @SerializedName("purchase_time") + private Long purchaseTime; + + /** + * Epoch time of when the contract was sold (only present for contracts already sold) + */ + @SerializedName("sell_time") + private Long sellTime; + + /** + * Latest spot value at the sell time. Example: 86.630 (only present for contracts already sold) + */ + @SerializedName("sell_spot") + private BigDecimal sellSpot; + + /** + * Epoch time of the sell spot. + * Note that since certain underlyings don't tick every second, the sell spot time may be a few seconds before the sell time. + * Example: 1446629000 (only present for contracts already sold) + */ + @SerializedName("sell_spot_time") + private Long sellSpotTime; + + /** + * Every contract has buy and sell transaction ids, + * i.e. when you purchase a contract we associate it with buy transaction id, + * and if contract is already sold we associate that with sell transaction id. + */ + @SerializedName("transaction_ids") + private Map transactionIds; + + /** + * Latest spot value at the sell time. Example: 86.630 (only present for contracts already sold) + */ + @SerializedName("profit") + private BigDecimal profit; + + /** + * Latest spot value at the sell time. Example: 86.630 (only present for contracts already sold) + */ + @SerializedName("profit_percentage") + private BigDecimal profit_percentage; + + public BigDecimal getHighBarrier() { + return highBarrier; + } + + public BigDecimal getLowBarrier() { + return lowBarrier; + } + + public BigDecimal getBarrier() { + return barrier; + } + + public Integer getBarrierCount() { + return barrierCount; + } + + public BigDecimal getBidPrice() { + return bidPrice; + } + + public Long getContractId() { + return contractId; + } + + public String getContractType() { + return contractType; + } + + public String getCurrency() { + return currency; + } + + public BigDecimal getCurrentSpot() { + return currentSpot; + } + + public Long getCurrentSpotTime() { + return currentSpotTime; + } + + public BigDecimal getEntrySpot() { + return entrySpot; + } + + public Long getExpiryDate() { + return expiryDate; + } + + public Long getDateSetelment() { + return dateSetelment; + } + + public Long getDateStart() { + return dateStart; + } + + public String getId() { + return id; + } + + public boolean isExpired() { + return isExpired == 1 ? true : false; + } + + public boolean isSettleable() { + return isSettleable == 1 ? true : false; + } + + public boolean isFrowardStarting() { + return isFrowardStarting == 1 ? true : false; + } + + public boolean isIntraday() { + return isIntraday == 1 ? true : false; + } + + public boolean isPathDependent() { + return isPathDependent == 1 ? true : false; + } + + public boolean isValidToSell() { + return isValidToSell == 1 ? true : false; + } + + public String getLongCode() { + return longCode; + } + + public BigDecimal getPayout() { + return payout; + } + + public String getShortCode() { + return shortCode; + } + + public BigDecimal getDisplayValue() { + return displayValue; + } + + public String getUnderlying() { + return underlying; + } + + public String getDisplayName() { + return displayName; + } + + public BigDecimal getEntryTick() { + return entryTick; + } + + public Long getEntryTickTime() { + return entryTickTime; + } + + public BigDecimal getExitTick() { + return exitTick; + } + + public Long getExitTickTime() { + return exitTickTime; + } + + public Integer getTickCount() { + return tickCount; + } + + public String getValidationError() { + return validationError; + } + + public BigDecimal getSellPrice() { + return sellPrice; + } + + public BigDecimal getBuyPrice() { + return buyPrice; + } + + public Long getPurchaseTime() { + return purchaseTime; + } + + public Long getSellTime() { + return sellTime; + } + + public BigDecimal getSellSpot() { + return sellSpot; + } + + public Long getSellSpotTime() { + return sellSpotTime; + } + + public Map getTransactionIds() { + return transactionIds; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/responses/PaymentAgent.java b/Trading/src/main/java/com/suneesh/trading/models/responses/PaymentAgent.java new file mode 100644 index 0000000..ec67aa5 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/responses/PaymentAgent.java @@ -0,0 +1,104 @@ +package com.suneesh.trading.models.responses; + +import com.google.gson.annotations.SerializedName; + +import java.math.BigDecimal; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/2/2017 + */ +public class PaymentAgent { + + @SerializedName("currencies") + private String currencies; + + @SerializedName("deposit_commission") + private String depositCommission; + + @SerializedName("email") + private String email; + + @SerializedName("further_information") + private String furtherInformation; + + @SerializedName("max_withdrawal") + private BigDecimal maxWithdrawal; + + @SerializedName("min_withdrawal") + private BigDecimal minWithdrawal; + + @SerializedName("name") + private String name; + + @SerializedName("paymentagent_loginid") + private String paymentAgentLoginId; + + @SerializedName("summary") + private String summary; + + @SerializedName("supported_banks") + private String supportedBanks; + + @SerializedName("telephone") + private String telephone; + + @SerializedName("url") + private String url; + + @SerializedName("withdrawal_commission") + private String withdrawalCommission; + + public String getCurrencies() { + return currencies; + } + + public String getDepositCommission() { + return depositCommission; + } + + public String getEmail() { + return email; + } + + public String getFurtherInformation() { + return furtherInformation; + } + + public BigDecimal getMaxWithdrawal() { + return maxWithdrawal; + } + + public BigDecimal getMinWithdrawal() { + return minWithdrawal; + } + + public String getName() { + return name; + } + + public String getPaymentAgentLoginId() { + return paymentAgentLoginId; + } + + public String getSummary() { + return summary; + } + + public String getSupportedBanks() { + return supportedBanks; + } + + public String getTelephone() { + return telephone; + } + + public String getUrl() { + return url; + } + + public String getWithdrawalCommission() { + return withdrawalCommission; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/responses/PaymentAgentListResponse.java b/Trading/src/main/java/com/suneesh/trading/models/responses/PaymentAgentListResponse.java new file mode 100644 index 0000000..8307478 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/responses/PaymentAgentListResponse.java @@ -0,0 +1,40 @@ +package com.suneesh.trading.models.responses; + +import com.suneesh.trading.models.requests.PaymentAgentListRequest; +import com.google.gson.annotations.SerializedName; + +import java.util.List; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/2/2017 + */ +public class PaymentAgentListResponse extends ResponseBase { + + /** + * Payment Agent List + */ + @SerializedName("paymentagent_list") + private PaymentAgentList paymentAgentList; + + public PaymentAgentList getPaymentAgentList() { + return paymentAgentList; + } + + public class PaymentAgentList { + @SerializedName("available_countries") + private List> availableCountries; + + @SerializedName("list") + private List paymentAgents; + + public List> getAvailableCountries() { + return availableCountries; + } + + public List getPaymentAgents() { + return paymentAgents; + } + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/responses/PaymentAgentTransferResponse.java b/Trading/src/main/java/com/suneesh/trading/models/responses/PaymentAgentTransferResponse.java new file mode 100644 index 0000000..930ef28 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/responses/PaymentAgentTransferResponse.java @@ -0,0 +1,54 @@ +package com.suneesh.trading.models.responses; + +import com.suneesh.trading.models.requests.PaymentAgentTransferRequest; +import com.google.gson.annotations.SerializedName; + +/** + *

PaymentAgentTransferResponse

+ * + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 9/15/2017 + */ +public class PaymentAgentTransferResponse extends ResponseBase { + + /** + * If 1, transfer success. If 2, dry-run success. + */ + @SerializedName("paymentagent_transfer") + private Integer result; + + /** + * The transfer_to client full name + */ + @SerializedName("client_to_full_name") + private String clientToFullName; + + /** + * The transfer_to client loginid + */ + @SerializedName("client_to_loginid") + private String clientToLoginId; + + /** + * Reference id of transfer performed + */ + @SerializedName("transaction_id") + private Long transactionId; + + public Integer getResult() { + return result; + } + + public String getClientToFullName() { + return clientToFullName; + } + + public String getClientToLoginId() { + return clientToLoginId; + } + + public Long getTransactionId() { + return transactionId; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/responses/PaymentAgentWithdrawalResponse.java b/Trading/src/main/java/com/suneesh/trading/models/responses/PaymentAgentWithdrawalResponse.java new file mode 100644 index 0000000..e46683e --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/responses/PaymentAgentWithdrawalResponse.java @@ -0,0 +1,46 @@ +package com.suneesh.trading.models.responses; + +import com.suneesh.trading.models.requests.PaymentAgentWithdrawalRequest; +import com.google.gson.annotations.SerializedName; + +/** + *

PaymentAgentWithdrawalResponse

+ * + *

Payment Agent Withdrawal Response

+ * + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 9/15/2017 + */ +public class PaymentAgentWithdrawalResponse extends ResponseBase { + + /** + * If 1, withdrawal success. If 2, dry-run success. + */ + @SerializedName("paymentagent_withdraw") + private Integer result; + + /** + * Payment agent name + */ + @SerializedName("paymentagent_name") + private String paymentAgentName; + + /** + * Reference id of withdrawal performed + */ + @SerializedName("transaction_id") + private Long transactionId; + + public Integer getResult() { + return result; + } + + public String getPaymentAgentName() { + return paymentAgentName; + } + + public Long getTransactionId() { + return transactionId; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/responses/PayoutCurrenciesResponse.java b/Trading/src/main/java/com/suneesh/trading/models/responses/PayoutCurrenciesResponse.java new file mode 100644 index 0000000..052a908 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/responses/PayoutCurrenciesResponse.java @@ -0,0 +1,25 @@ +package com.suneesh.trading.models.responses; + +import com.suneesh.trading.models.requests.PayoutCurrenciesRequest; +import com.google.gson.annotations.SerializedName; + +import java.util.List; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/2/2017 + */ +public class PayoutCurrenciesResponse extends ResponseBase { + + /** + * Available payout currencies. + * Note: if a user is logged in, only the currency available for his account will be returned. + */ + @SerializedName("payout_currencies") + private List payoutCurrencies; + + public List getPayoutCurrencies() { + return payoutCurrencies; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/responses/PingResponse.java b/Trading/src/main/java/com/suneesh/trading/models/responses/PingResponse.java new file mode 100644 index 0000000..c0ddcca --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/responses/PingResponse.java @@ -0,0 +1,22 @@ +package com.suneesh.trading.models.responses; + +import com.suneesh.trading.models.requests.PingRequest; +import com.google.gson.annotations.SerializedName; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/2/2017 + */ +public class PingResponse extends ResponseBase { + + /** + * Will return 'pong' + */ + @SerializedName("ping") + private String ping; + + public String getPing() { + return ping; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/responses/Portfolio.java b/Trading/src/main/java/com/suneesh/trading/models/responses/Portfolio.java new file mode 100644 index 0000000..2bb6f28 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/responses/Portfolio.java @@ -0,0 +1,27 @@ +package com.suneesh.trading.models.responses; + +import com.google.gson.annotations.SerializedName; + +import java.util.List; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/7/2017 + */ +public class Portfolio { + + public void setContracts(List contracts) { + this.contracts = contracts; + } + + /** + * Client open positions + */ + @SerializedName("contracts") + private List contracts; + + public List getContracts() { + return contracts; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/responses/PortfolioResponse.java b/Trading/src/main/java/com/suneesh/trading/models/responses/PortfolioResponse.java new file mode 100644 index 0000000..c53fcfd --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/responses/PortfolioResponse.java @@ -0,0 +1,65 @@ +package com.suneesh.trading.models.responses; + +import com.suneesh.trading.models.requests.PortfolioRequest; +import com.google.gson.annotations.SerializedName; +import com.suneesh.trading.utils.AutoTradingUtility; + +import java.util.List; +import java.util.stream.Collectors; + +/** + *

PortfolioResponse

+ * + *

Portfolio Receive

+ *

+ * Receive a list of outstanding options in the user's portfolio + *

+ * + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/7/2017 + */ +public class PortfolioResponse extends ResponseBase { + + public void setPortfolio(Portfolio portfolio) { + this.portfolio = portfolio; + } + + /** + * Client open positions + */ + @SerializedName("portfolio") + private Portfolio portfolio; + + public Portfolio getPortfolio() { + return portfolio; + } + + + @Override + public List databaseInsertStringList() { + return portfolio.getContracts().stream().map(portfolioTransaction -> { + return "INSERT INTO public.portfolio_transaction " + + "( app_id ,buy_price ,contract_id ,contract_type ,currency ,date_start ," + + " expiry_time ,long_code ,short_code , payout ,symbol ,purchase_time ,transaction_id, " + + " date_start_string , expiry_time_string, purchase_time_string )" + + " VALUES (" + + AutoTradingUtility.quotedString(portfolioTransaction.getAppId()) + ", " + + AutoTradingUtility.quotedString(portfolioTransaction.getBuyPrice()) + ", " + + AutoTradingUtility.quotedString(portfolioTransaction.getContractId()) + ", " + + AutoTradingUtility.quotedString(portfolioTransaction.getContractType()) + ", " + + AutoTradingUtility.quotedString(portfolioTransaction.getCurrency()) + ", " + + AutoTradingUtility.quotedString(portfolioTransaction.getDateStart()) + ", " + + AutoTradingUtility.quotedString(portfolioTransaction.getExpiryTime()) + ", " + + AutoTradingUtility.quotedString(portfolioTransaction.getLongCode()) + ", " + + AutoTradingUtility.quotedString(portfolioTransaction.getShortCode()) + ", " + + AutoTradingUtility.quotedString(portfolioTransaction.getPayout()) + ", " + + AutoTradingUtility.quotedString(portfolioTransaction.getSymbol()) + ", " + + AutoTradingUtility.quotedString(portfolioTransaction.getPurchaseTime()) + ", " + + AutoTradingUtility.quotedString(portfolioTransaction.getTransactionId()) + ", " + + AutoTradingUtility.getTimeStampString(portfolioTransaction.getDateStart()) + ", " + + AutoTradingUtility.getTimeStampString(portfolioTransaction.getExpiryTime()) + ", " + + AutoTradingUtility.getTimeStampString(portfolioTransaction.getPurchaseTime()) + "); "; + }).collect(Collectors.toList()); + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/responses/PortfolioTransaction.java b/Trading/src/main/java/com/suneesh/trading/models/responses/PortfolioTransaction.java new file mode 100644 index 0000000..52932eb --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/responses/PortfolioTransaction.java @@ -0,0 +1,146 @@ +package com.suneesh.trading.models.responses; + +import com.google.gson.annotations.SerializedName; +import io.reactivex.annotations.Nullable; +import lombok.Data; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import java.math.BigDecimal; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/7/2017 + */ +@Data +public class PortfolioTransaction { + /** + * Binary.com internal contract identifier number (to be used in a Price Proposal - Open Contract API call) + */ + @SerializedName("contract_id") + private Long contractId; + + /** + * It is the transaction id. Every contract (buy or sell) and every payment has a unique id. Example: 10867502908 + */ + @SerializedName("transaction_id") + private Long transactionId; + + /** + * Epoch of purchase time + */ + @SerializedName("purchase_time") + private long purchaseTime; + + /** + * Symbol code + */ + @SerializedName("symbol") + private String symbol; + + /** + * Payout price + */ + @SerializedName("payout") + private BigDecimal payout; + + /** + * Buy price + */ + @SerializedName("buy_price") + private BigDecimal buyPrice; + + /** + * Epoch of start date + */ + @SerializedName("date_start") + private long dateStart; + + /** + * Epoch of expiry time + */ + @SerializedName("expiry_time") + private long expiryTime; + + /** + * Contract type + */ + @SerializedName("contract_type") + private String contractType; + + /** + * Contract currency + */ + @SerializedName("currency") + private String currency; + + /** + * Contract description + */ + @SerializedName("longcode") + private String longCode; + + /** + * Contract description + */ + @SerializedName("shortcode") + private String shortCode; + + /** + * Id of an app from where this contract was purchased. For example, it's 1 for binary.com. + */ + @SerializedName("app_id") + @Nullable + private Integer appId; + + public Long getContractId() { + return contractId; + } + + public Long getTransactionId() { + return transactionId; + } + + public long getPurchaseTime() { + return purchaseTime; + } + + public String getSymbol() { + return symbol; + } + + public BigDecimal getPayout() { + return payout; + } + + public BigDecimal getBuyPrice() { + return buyPrice; + } + + public long getDateStart() { + return dateStart; + } + + public long getExpiryTime() { + return expiryTime; + } + + public String getContractType() { + return contractType; + } + + public String getCurrency() { + return currency; + } + + public String getLongCode() { + return longCode; + } + + public Integer getAppId() { + return appId; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/responses/PriceProposalResponse.java b/Trading/src/main/java/com/suneesh/trading/models/responses/PriceProposalResponse.java new file mode 100644 index 0000000..5e3601a --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/responses/PriceProposalResponse.java @@ -0,0 +1,26 @@ +package com.suneesh.trading.models.responses; + +import com.suneesh.trading.models.requests.PriceProposalRequest; +import com.google.gson.annotations.SerializedName; + +/** + *

PriceProposalRequest

+ * + *

Price Proposal Response

+ *

Latest price and other details for a given contract

+ * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/2/2017 + */ +public class PriceProposalResponse extends ResponseBase { + + /** + * Latest price and other details for a given contract + */ + @SerializedName("proposal") + private Proposal proposal; + + public Proposal getProposal() { + return proposal; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/responses/ProfitTable.java b/Trading/src/main/java/com/suneesh/trading/models/responses/ProfitTable.java new file mode 100644 index 0000000..d7d1b03 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/responses/ProfitTable.java @@ -0,0 +1,33 @@ +package com.suneesh.trading.models.responses; + +import com.google.gson.annotations.SerializedName; + +import java.util.List; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/8/2017 + */ +public class ProfitTable { + + /** + * Number of transactions returned in this call + */ + @SerializedName("count") + private Integer count; + + /** + * Array of returned transactions + */ + @SerializedName("transactions") + private List transactions; + + public Integer getCount() { + return count; + } + + public List getTransactions() { + return transactions; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/responses/ProfitTableResponse.java b/Trading/src/main/java/com/suneesh/trading/models/responses/ProfitTableResponse.java new file mode 100644 index 0000000..4a95e64 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/responses/ProfitTableResponse.java @@ -0,0 +1,31 @@ +package com.suneesh.trading.models.responses; + +import com.suneesh.trading.models.requests.ProfitTableRequest; +import com.google.gson.annotations.SerializedName; +import io.reactivex.annotations.Nullable; + +/** + *

ProfitTableResponse

+ * + *

Profit Table Receive

+ *

+ * A summary of account profit table is received + *

+ * + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/8/2017 + */ +public class ProfitTableResponse extends ResponseBase { + + /** + * Account Profit Table. + */ + @SerializedName("profit_table") + @Nullable + private ProfitTable profitTable; + + public ProfitTable getProfitTable() { + return profitTable; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/responses/ProfitTableTransaction.java b/Trading/src/main/java/com/suneesh/trading/models/responses/ProfitTableTransaction.java new file mode 100644 index 0000000..0cb416d --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/responses/ProfitTableTransaction.java @@ -0,0 +1,77 @@ +package com.suneesh.trading.models.responses; + +import com.google.gson.annotations.SerializedName; +import io.reactivex.annotations.Nullable; + +import java.math.BigDecimal; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/8/2017 + */ +public class ProfitTableTransaction { + + /** + * It is the transaction id. every contract (buy or sell) and every payment has a unique id. Example: 10867502908 + */ + @SerializedName("transaction_id") + private String transactionId; + + /** + * It is the contract id Example: 4867502908 + */ + @SerializedName("contract_id") + private String contractId; + + /** + * It is the purchase time of transaction + */ + @SerializedName("purchase_time") + private Long purchaseTime; + + /** + * It is the sell time of transaction + */ + @SerializedName("sell_time") + @Nullable + private Long sellTime; + + /** + * Buy price + */ + @SerializedName("buy_price") + private BigDecimal buyPrice; + + /** + * Sold price + */ + @SerializedName("sell_price") + private BigDecimal sellPrice; + + /** + * The description of contract purchased if description is set to 1 + */ + @SerializedName("longcode") + private String longCode; + + /** + * Compact description of the contract purchased if description is set to 1 + */ + @SerializedName("shortcode") + private String shortCode; + + /** + * Payout price + */ + @SerializedName("payout") + private BigDecimal payout; + + /** + * App id of app where this transaction was performed. For example, it's 1 for binary.com. + */ + @SerializedName("app_id") + @Nullable + private Integer applicationId; + +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/responses/Proposal.java b/Trading/src/main/java/com/suneesh/trading/models/responses/Proposal.java new file mode 100644 index 0000000..049520a --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/responses/Proposal.java @@ -0,0 +1,94 @@ +package com.suneesh.trading.models.responses; + +import com.google.gson.annotations.SerializedName; + +import java.math.BigDecimal; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/2/2017 + */ +public class Proposal { + + /** + * Example: Win payout if Random 100 Index is strictly higher than entry spot at 15 minutes after contract start time. + */ + @SerializedName("longcode") + private String longCode; + + /** + * Spot value (if there are no Exchange data-feed licensing restrictions for the underlying symbol). + * Example: 9874.52 + */ + @SerializedName("spot") + private BigDecimal spot; + + /** + * Example: 1439999052 + */ + @SerializedName("spot_time") + private int spotTime; + + /** + * Example: 5.14 + */ + @SerializedName("ask_price") + private BigDecimal askPrice; + + /** + * Example: 5.14, same as ask_price + */ + @SerializedName("display_value") + private BigDecimal displayValue; + + /** + * Example: 1439999053 + */ + @SerializedName("date_start") + private int dateStart; + + /** + * A stream id that can be used to cancel this stream using the Forget request. Example: 1d6651e7d599bce6c54bd71a8283e579 + */ + @SerializedName("id") + private String id; + + /** + * Example: 10 + */ + @SerializedName("payout") + private BigDecimal payout; + + public String getLongCode() { + return longCode; + } + + public BigDecimal getSpot() { + return spot; + } + + public int getSpotTime() { + return spotTime; + } + + public BigDecimal getAskPrice() { + return askPrice; + } + + public BigDecimal getDisplayValue() { + return displayValue; + } + + public int getDateStart() { + return dateStart; + } + + public String getId() { + return id; + } + + public BigDecimal getPayout() { + return payout; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/responses/ProposalOpenContractResponse.java b/Trading/src/main/java/com/suneesh/trading/models/responses/ProposalOpenContractResponse.java new file mode 100644 index 0000000..894009a --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/responses/ProposalOpenContractResponse.java @@ -0,0 +1,109 @@ +package com.suneesh.trading.models.responses; + +import com.suneesh.trading.models.requests.ProposalOpenContractRequest; +import com.google.gson.annotations.SerializedName; +import com.suneesh.trading.utils.AutoTradingUtility; + +import java.util.Arrays; +import java.util.List; + +/** + *

ProposalOpenContractResponse

+ * + *

Open contract proposal response

+ *

+ * Latest price and other details for an open contract in the user's portfolio + *

+ * + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/8/2017 + */ +public class ProposalOpenContractResponse extends ResponseBase { + + /** + * Latest price and other details for an open contract + */ + @SerializedName("proposal_open_contract") + private OpenContract openContract; + + public OpenContract getOpenContract() { + return openContract; + } + + public void setOpenContract(OpenContract openContract) { + this.openContract = openContract; + } + + @Override + public List databaseUpdateStringList() { + return Arrays.asList("UPDATE public.open_contract SET " + + "bidPrice = " + AutoTradingUtility.quotedString(openContract.getBidPrice()) + " , " + + "currentSpot = " + AutoTradingUtility.quotedString(openContract.getCurrentSpot()) + " , " + + "currentSpotTime = " + AutoTradingUtility.quotedString(openContract.getCurrentSpotTime()) + " , " + + "expiryDate = " + AutoTradingUtility.quotedString(openContract.getExpiryDate()) + " , " + + "dateSetelment = " + AutoTradingUtility.quotedString(openContract.getDateSetelment()) + " , " + + "displayName = " + AutoTradingUtility.quotedString(openContract.getDisplayName()) + " , " + + "exitTick = " + AutoTradingUtility.quotedString(openContract.getExitTick()) + " , " + + "exitTickTime = " + AutoTradingUtility.quotedString(openContract.getExitTickTime()) + " , " + + "isExpired = " + AutoTradingUtility.quotedString(openContract.getIsExpired()) + " , " + + "isSettleable = " + AutoTradingUtility.quotedString(openContract.getIsSettleable()) + " , " + + "isValidToSell = " + AutoTradingUtility.quotedString(openContract.getIsValidToSell()) + " , " + + "profit = " + AutoTradingUtility.quotedString(openContract.getProfit()) + " , " + + "profit_percentage = " + AutoTradingUtility.quotedString(openContract.getProfit_percentage()) + " , " + + "sellPrice = " + AutoTradingUtility.quotedString(openContract.getSellPrice()) + " , " + + "sellSpot = " + AutoTradingUtility.quotedString(openContract.getSellSpot()) + " , " + + "sellSpotTime = " + AutoTradingUtility.quotedString(openContract.getSellSpotTime()) + " , " + + "sellTime = " + AutoTradingUtility.quotedString(openContract.getSellTime()) + " , " + + "status = " + AutoTradingUtility.quotedString(openContract.getStatus()) + " , " + + "validation_error = " + AutoTradingUtility.quotedString(openContract.getValidationError()) + + " WHERE contractId = " + AutoTradingUtility.quotedString(openContract.getContractId()) + ); + } + + + @Override + public List databaseInsertStringList(){ + return Arrays.asList("INSERT INTO public.open_contract " + + "(barrier, barrierCount, bidPrice, buyPrice, contractId, contractType, currency, currentSpot, " + + "currentSpotTime, expiryDate, dateSetelment, dateStart, displayName, entryTick, entryTickTime, " + + "exitTick, exitTickTime, isExpired, isIntraday, isSettleable, isValidToSell, longCode, payout, " + + "profit, profit_percentage, purchaseTime, sellPrice, sellSpot, sellSpotTime, sellTime, shortCode, " + + "status, validation_error) " + + " VALUES (" + + AutoTradingUtility.quotedString(openContract.getBarrier()) + ", " + + AutoTradingUtility.quotedString(openContract.getBarrierCount()) + ", " + + AutoTradingUtility.quotedString(openContract.getBidPrice()) + ", " + + AutoTradingUtility.quotedString(openContract.getBuyPrice()) + ", " + + AutoTradingUtility.quotedString(openContract.getContractId()) + ", " + + AutoTradingUtility.quotedString(openContract.getContractType()) + ", " + + AutoTradingUtility.quotedString(openContract.getCurrency()) + ", " + + AutoTradingUtility.quotedString(openContract.getCurrentSpot()) + ", " + + AutoTradingUtility.quotedString(openContract.getCurrentSpotTime()) + ", " + + AutoTradingUtility.quotedString(openContract.getExpiryDate()) + ", " + + AutoTradingUtility.quotedString(openContract.getDateSetelment()) + ", " + + AutoTradingUtility.quotedString(openContract.getDateStart()) + ", " + + AutoTradingUtility.quotedString(openContract.getDisplayName()) + ", " + + AutoTradingUtility.quotedString(openContract.getEntryTick()) + ", " + + AutoTradingUtility.quotedString(openContract.getEntryTickTime()) + ", " + + AutoTradingUtility.quotedString(openContract.getExitTick()) + ", " + + AutoTradingUtility.quotedString(openContract.getExitTickTime()) + ", " + + AutoTradingUtility.quotedString(openContract.getIsExpired()) + ", " + + AutoTradingUtility.quotedString(openContract.getIsIntraday()) + ", " + + AutoTradingUtility.quotedString(openContract.getIsSettleable()) + ", " + + AutoTradingUtility.quotedString(openContract.getIsValidToSell()) + ", " + + AutoTradingUtility.quotedString(openContract.getLongCode()) + ", " + + AutoTradingUtility.quotedString(openContract.getPayout()) + ", " + + AutoTradingUtility.quotedString(openContract.getProfit()) + ", " + + AutoTradingUtility.quotedString(openContract.getProfit_percentage()) + ", " + + AutoTradingUtility.quotedString(openContract.getPurchaseTime()) + ", " + + AutoTradingUtility.quotedString(openContract.getSellPrice()) + ", " + + AutoTradingUtility.quotedString(openContract.getSellSpot()) + ", " + + AutoTradingUtility.quotedString(openContract.getSellSpotTime()) + ", " + + AutoTradingUtility.quotedString(openContract.getSellTime()) + ", " + + AutoTradingUtility.quotedString(openContract.getShortCode()) + ", " + + AutoTradingUtility.quotedString(openContract.getStatus()) + ", " + + AutoTradingUtility.quotedString(openContract.getValidationError()) + ");" ); + } + +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/responses/RealityCheck.java b/Trading/src/main/java/com/suneesh/trading/models/responses/RealityCheck.java new file mode 100644 index 0000000..d01de34 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/responses/RealityCheck.java @@ -0,0 +1,103 @@ +package com.suneesh.trading.models.responses; + +import com.google.gson.annotations.SerializedName; + +import java.math.BigDecimal; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/8/2017 + */ +public class RealityCheck { + + /** + * Reality check summary start time epoch + */ + @SerializedName("start_time") + private Long startTime; + + /** + * Client loginid Example: CR000000 + */ + @SerializedName("loginid") + private String loginId; + + /** + * Currency of client account i.e currency for trading + */ + @SerializedName("currency") + private String currency; + + /** + * Total count of contract purchased. + */ + @SerializedName("buy_count") + private Integer buyCount; + + /** + * Total amount of contract purchased. + */ + @SerializedName("buy_amount") + private BigDecimal buyAmount; + + /** + * Total count of contract sold. + */ + @SerializedName("sell_count") + private Integer sellCount; + + /** + * Total amount of contracts sold. + */ + @SerializedName("sell_amount") + private BigDecimal sellAmount; + + /** + * Indicative profit of contract as per current market price. + */ + @SerializedName("potential_profit") + private BigDecimal potentialProfit; + + /** + * Total count of contracts that are not yet expired. + */ + @SerializedName("open_contract_count") + private Integer openContractCount; + + public Long getStartTime() { + return startTime; + } + + public String getLoginId() { + return loginId; + } + + public String getCurrency() { + return currency; + } + + public Integer getBuyCount() { + return buyCount; + } + + public BigDecimal getBuyAmount() { + return buyAmount; + } + + public Integer getSellCount() { + return sellCount; + } + + public BigDecimal getSellAmount() { + return sellAmount; + } + + public BigDecimal getPotentialProfit() { + return potentialProfit; + } + + public Integer getOpenContractCount() { + return openContractCount; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/responses/RealityCheckResponse.java b/Trading/src/main/java/com/suneesh/trading/models/responses/RealityCheckResponse.java new file mode 100644 index 0000000..955740c --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/responses/RealityCheckResponse.java @@ -0,0 +1,29 @@ +package com.suneesh.trading.models.responses; + +import com.suneesh.trading.models.requests.RealityCheckRequest; +import com.google.gson.annotations.SerializedName; + +/** + *

RealityCheckResponse

+ * + *

Reality check receive

+ *

+ * This gives summary of client's trades and account for reality check + *

+ * + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/8/2017 + */ +public class RealityCheckResponse extends ResponseBase { + + /** + * Reality check summary of trades. + */ + @SerializedName("reality_check") + private RealityCheck realityCheck; + + public RealityCheck getRealityCheck() { + return realityCheck; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/responses/Residence.java b/Trading/src/main/java/com/suneesh/trading/models/responses/Residence.java new file mode 100644 index 0000000..8438ea0 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/responses/Residence.java @@ -0,0 +1,43 @@ +package com.suneesh.trading.models.responses; + +import com.google.gson.annotations.SerializedName; +import io.reactivex.annotations.Nullable; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/2/2017 + */ +public class Residence { + + /** + * 2-letter country code + */ + @SerializedName("value") + private String value; + + /** + * Country full name + */ + @SerializedName("text") + private String text; + + /** + * IDD code of country + */ + @SerializedName("phone_idd") + @Nullable + private String phoneIDD; + + public String getValue() { + return value; + } + + public String getText() { + return text; + } + + public String getPhoneIDD() { + return phoneIDD; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/responses/ResidenceListResponce.java b/Trading/src/main/java/com/suneesh/trading/models/responses/ResidenceListResponce.java new file mode 100644 index 0000000..759e5bd --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/responses/ResidenceListResponce.java @@ -0,0 +1,29 @@ +package com.suneesh.trading.models.responses; + +import com.suneesh.trading.models.requests.ResidenceListRequest; +import com.google.gson.annotations.SerializedName; + +import java.util.List; + +/** + *

ResidenceListResponse

+ * + *

Residence List Receive

+ *

A message with Residence List

+ * + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/2/2017 + */ +public class ResidenceListResponce extends ResponseBase { + + /** + * List of countries for account opening + */ + @SerializedName("residence_list") + private List residenceList; + + public List getResidenceList() { + return residenceList; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/responses/ResponseBase.java b/Trading/src/main/java/com/suneesh/trading/models/responses/ResponseBase.java new file mode 100644 index 0000000..1660047 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/responses/ResponseBase.java @@ -0,0 +1,36 @@ +package com.suneesh.trading.models.responses; + +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + +import java.util.List; + +/** + * Created by morteza on 7/19/2017. + */ + +public abstract class ResponseBase implements DatabaseOperation { + @SerializedName("echo_req") + @Expose + T request; + + @SerializedName("msg_type") + @Expose + String type; + + @SerializedName("error") + @Expose + Error error; + + public String getType(){ + return this.type; + } + + public T getRequest(){ + return this.request; + } + + public Error getError() { + return error; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/responses/RevokeOauthApplicationResponse.java b/Trading/src/main/java/com/suneesh/trading/models/responses/RevokeOauthApplicationResponse.java new file mode 100644 index 0000000..cd37f59 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/responses/RevokeOauthApplicationResponse.java @@ -0,0 +1,28 @@ +package com.suneesh.trading.models.responses; + +import com.suneesh.trading.models.requests.RevokeOauthApplicationRequest; +import com.google.gson.annotations.SerializedName; +import io.reactivex.annotations.Nullable; + +/** + *

RevokeOauthApplicationResponse

+ * + *

Revoke an OAuth App

+ *

+ * A message with revoking a used application + *

+ * + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 9/4/2017 + */ +public class RevokeOauthApplicationResponse extends ResponseBase { + + @SerializedName("revoke_oauth_app") + @Nullable + private Integer result; + + public Integer getResult() { + return result; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/responses/SelfExclusion.java b/Trading/src/main/java/com/suneesh/trading/models/responses/SelfExclusion.java new file mode 100644 index 0000000..f48f24b --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/responses/SelfExclusion.java @@ -0,0 +1,183 @@ +package com.suneesh.trading.models.responses; + +import com.suneesh.trading.utils.Validator; +import com.google.gson.annotations.SerializedName; +import io.reactivex.annotations.Nullable; + +import java.math.BigDecimal; + +/** + *

SelfExclusion

+ * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/4/2017 + */ +public class SelfExclusion { + + /** + * Maximum account cash balance + */ + @SerializedName("max_balance") + @Nullable + private BigDecimal maxBalance; + + /** + * Daily turnover limit + */ + @SerializedName("max_turnover") + @Nullable + private BigDecimal maxTurnover; + + /** + * Daily limit on losses + */ + @SerializedName("max_losses") + @Nullable + private BigDecimal maxLosses; + + /** + * 7-day turnover limit + */ + @SerializedName("max_7day_turnover") + @Nullable + private BigDecimal maxSevenDayTurnover; + + /** + * 7-day limit on losses + */ + @SerializedName("max_7day_losses") + @Nullable + private BigDecimal maxSevenDayLosses; + + /** + * 30-day turnover limit + */ + @SerializedName("max_30day_turnover") + @Nullable + private BigDecimal maxThirtyDayTurnover; + + /** + * 30-day limit on losses + */ + @SerializedName("max_30day_losses") + @Nullable + private BigDecimal maxThirtydayLosses; + + /** + * Maximum number of open positions + */ + @SerializedName("max_open_bets") + @Nullable + private Integer maxOpenBets; + + /** + * Session duration limit, in minutes + */ + @SerializedName("session_duration_limit") + @Nullable + private Integer sessionDurationLimit; + + /** + * Exclude me from the website until (date YYYY-MM-DD) + */ + @SerializedName("exclude_until") + @Nullable + private String excludeUntil; + + /** + * Exclude me from the website until (epoch time) + */ + @SerializedName("timeout_until") + @Nullable + private Integer timeoutUntil; + + public BigDecimal getMaxBalance() { + return maxBalance; + } + + public void setMaxBalance(BigDecimal maxBalance) { + this.maxBalance = maxBalance; + } + + public BigDecimal getMaxTurnover() { + return maxTurnover; + } + + public void setMaxTurnover(BigDecimal maxTurnover) { + this.maxTurnover = maxTurnover; + } + + public BigDecimal getMaxLosses() { + return maxLosses; + } + + public void setMaxLosses(BigDecimal maxLosses) { + this.maxLosses = maxLosses; + } + + public BigDecimal getMaxSevenDayTurnover() { + return maxSevenDayTurnover; + } + + public void setMaxSevenDayTurnover(BigDecimal maxSevenDayTurnover) { + this.maxSevenDayTurnover = maxSevenDayTurnover; + } + + public BigDecimal getMaxSevenDayLosses() { + return maxSevenDayLosses; + } + + public void setMaxSevenDayLosses(BigDecimal maxSevenDayLosses) { + this.maxSevenDayLosses = maxSevenDayLosses; + } + + public BigDecimal getMaxThirtyDayTurnover() { + return maxThirtyDayTurnover; + } + + public void setMaxThirtyDayTurnover(BigDecimal maxThirtyDayTurnover) { + this.maxThirtyDayTurnover = maxThirtyDayTurnover; + } + + public BigDecimal getMaxThirtydayLosses() { + return maxThirtydayLosses; + } + + public void setMaxThirtydayLosses(BigDecimal maxThirtydayLosses) { + this.maxThirtydayLosses = maxThirtydayLosses; + } + + public Integer getMaxOpenBets() { + return maxOpenBets; + } + + public void setMaxOpenBets(Integer maxOpenBets) { + this.maxOpenBets = maxOpenBets; + } + + public Integer getSessionDurationLimit() { + return sessionDurationLimit; + } + + public void setSessionDurationLimit(Integer sessionDurationLimit) { + this.sessionDurationLimit = sessionDurationLimit; + } + + public String getExcludeUntil() { + return excludeUntil; + } + + public void setExcludeUntil(String excludeUntil) { + Validator.checkPattern("^\\d{4}-\\d{2}-\\d{2}$", excludeUntil, + "ExcludeUntil does not match the regex pattern /^\\d{4}-\\d{2}-\\d{2}$/"); + this.excludeUntil = excludeUntil; + } + + public Integer getTimeoutUntil() { + return timeoutUntil; + } + + public void setTimeoutUntil(Integer timeoutUntil) { + this.timeoutUntil = timeoutUntil; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/responses/SellContractForMultipleAccountsResponse.java b/Trading/src/main/java/com/suneesh/trading/models/responses/SellContractForMultipleAccountsResponse.java new file mode 100644 index 0000000..1cc00a5 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/responses/SellContractForMultipleAccountsResponse.java @@ -0,0 +1,41 @@ +package com.suneesh.trading.models.responses; + +import com.suneesh.trading.models.requests.SellContractForMultipleAccountsRequest; +import com.google.gson.annotations.SerializedName; + +import java.util.List; + +/** + *

SellContractForMultipleAccountsResponse

+ * + *

Sell for multiple contracts response

+ *

+ * Confirmation of the sale status for the selected contracts and accounts. + *

+ * + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/9/2017 + */ +public class SellContractForMultipleAccountsResponse extends ResponseBase { + + /** + * Status information for each affected acccount + */ + @SerializedName("sell_contract_for_multiple_accounts") + private MassSellContractResult massSellContractResult; + + public MassSellContractResult getMassSellContractResult() { + return massSellContractResult; + } + + public class MassSellContractResult { + + @SerializedName("result") + private List massSellReceipts; + + public List getSellReceipts() { + return massSellReceipts; + } + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/responses/SellContractResponse.java b/Trading/src/main/java/com/suneesh/trading/models/responses/SellContractResponse.java new file mode 100644 index 0000000..dbc0714 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/responses/SellContractResponse.java @@ -0,0 +1,35 @@ +package com.suneesh.trading.models.responses; + +import com.suneesh.trading.models.requests.SellContractRequest; +import com.google.gson.annotations.SerializedName; +import com.suneesh.trading.utils.AutoTradingUtility; +import lombok.Data; + +import java.util.Arrays; +import java.util.List; + +/** + *

SellContractResponse

+ * + *

Sell a Contract Receive

+ *

+ * A message with transaction results is received + *

+ * + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/9/2017 + */ +@Data +public class SellContractResponse extends ResponseBase { + + /** + * Receipt for the transaction + */ + @SerializedName("sell") + private SellReceipt sellReceipt; + + public SellReceipt getSellReceipt() { + return sellReceipt; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/responses/SellExpiredContractsResponse.java b/Trading/src/main/java/com/suneesh/trading/models/responses/SellExpiredContractsResponse.java new file mode 100644 index 0000000..d412781 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/responses/SellExpiredContractsResponse.java @@ -0,0 +1,31 @@ +package com.suneesh.trading.models.responses; + +import com.suneesh.trading.models.requests.SellExpiredContractsRequest; +import com.google.gson.annotations.SerializedName; + +import java.util.Map; + +/** + *

SellExpiredContractsResponse

+ * + *

Sell expired contracts

+ *

+ * Sell expired contract response + *

+ * + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/9/2017 + */ +public class SellExpiredContractsResponse extends ResponseBase { + + /** + * Sell expired contract object containing count of contracts sold + */ + @SerializedName("sell_expired") + private Map result; + + public Integer getResult() { + return result.size() > 0 ? result.get("count") : new Integer(0); + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/responses/SellReceipt.java b/Trading/src/main/java/com/suneesh/trading/models/responses/SellReceipt.java new file mode 100644 index 0000000..d69f16b --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/responses/SellReceipt.java @@ -0,0 +1,63 @@ +package com.suneesh.trading.models.responses; + +import com.google.gson.annotations.SerializedName; + +import java.math.BigDecimal; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/9/2017 + */ +public class SellReceipt { + + /** + * New account balance after completion of the sale + */ + @SerializedName("balance_after") + private BigDecimal balanceAfter; + + /** + * Internal contract identifier for the sold contract + */ + @SerializedName("contract_id") + private Long contractId; + + /** + * Actual effected sale price + */ + @SerializedName("sold_for") + private BigDecimal soldFor; + + /** + * Internal transaction identifier for the sale transaction + */ + @SerializedName("transaction_id") + private Long transactionId; + + /** + * Internal transaction identifier for the corresponding buy transaction + */ + @SerializedName("reference_id") + private Long referenceId; + + public BigDecimal getBalanceAfter() { + return balanceAfter; + } + + public Long getContractId() { + return contractId; + } + + public BigDecimal getSoldFor() { + return soldFor; + } + + public Long getTransactionId() { + return transactionId; + } + + public Long getReferenceId() { + return referenceId; + } +} \ No newline at end of file diff --git a/Trading/src/main/java/com/suneesh/trading/models/responses/SetAccountCurrencyResponse.java b/Trading/src/main/java/com/suneesh/trading/models/responses/SetAccountCurrencyResponse.java new file mode 100644 index 0000000..41cc772 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/responses/SetAccountCurrencyResponse.java @@ -0,0 +1,29 @@ +package com.suneesh.trading.models.responses; + +import com.suneesh.trading.models.requests.SetAccountCurrencyRequest; +import com.google.gson.annotations.SerializedName; + +/** + *

SetAccountCurrencyResponse

+ * + *

Set Account Currency Response

+ *

+ * Status of set account currency call + *

+ * + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 9/4/2017 + */ +public class SetAccountCurrencyResponse extends ResponseBase { + + /** + * 1: success, 0: no change + */ + @SerializedName("set_account_currency") + private Integer result; + + public Integer getResult() { + return result; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/responses/SetAccountSettingsResponse.java b/Trading/src/main/java/com/suneesh/trading/models/responses/SetAccountSettingsResponse.java new file mode 100644 index 0000000..ea93bd9 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/responses/SetAccountSettingsResponse.java @@ -0,0 +1,19 @@ +package com.suneesh.trading.models.responses; + +import com.suneesh.trading.models.requests.SetAccountSettingsRequest; +import com.google.gson.annotations.SerializedName; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 9/14/2017 + */ +public class SetAccountSettingsResponse extends ResponseBase { + + @SerializedName("set_settings") + private Integer result; + + public Integer getResult() { + return result; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/responses/SetFinancialAssessmentResponse.java b/Trading/src/main/java/com/suneesh/trading/models/responses/SetFinancialAssessmentResponse.java new file mode 100644 index 0000000..c784580 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/responses/SetFinancialAssessmentResponse.java @@ -0,0 +1,21 @@ +package com.suneesh.trading.models.responses; + +import com.suneesh.trading.models.requests.SetFinancialAssessmentRequest; +import com.google.gson.annotations.SerializedName; + +import java.util.Map; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 9/10/2017 + */ +public class SetFinancialAssessmentResponse extends ResponseBase { + + @SerializedName("set_financial_assessment") + private Map result; + + public Map getResult() { + return result; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/responses/SetSelfExclusionSettingsResponse.java b/Trading/src/main/java/com/suneesh/trading/models/responses/SetSelfExclusionSettingsResponse.java new file mode 100644 index 0000000..3c1dad2 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/responses/SetSelfExclusionSettingsResponse.java @@ -0,0 +1,19 @@ +package com.suneesh.trading.models.responses; + +import com.suneesh.trading.models.requests.SetSelfExclusionSettingsRequest; +import com.google.gson.annotations.SerializedName; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 9/12/2017 + */ +public class SetSelfExclusionSettingsResponse extends ResponseBase { + + @SerializedName("set_self_exclusion") + private Integer result; + + public Integer getResult() { + return result; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/responses/StartCopyTradeResponse.java b/Trading/src/main/java/com/suneesh/trading/models/responses/StartCopyTradeResponse.java new file mode 100644 index 0000000..a16a595 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/responses/StartCopyTradeResponse.java @@ -0,0 +1,29 @@ +package com.suneesh.trading.models.responses; + +import com.suneesh.trading.models.requests.StartCopyTradeRequest; +import com.google.gson.annotations.SerializedName; + +/** + *

StartCopyTradeResponse

+ * + *

Copy Start Receive

+ *

+ * A message with results is received + *

+ * + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/9/2017 + */ +public class StartCopyTradeResponse extends ResponseBase { + + /** + * Copy start confirmation. Returns 1 is success. + */ + @SerializedName("copy_start") + private Integer result; + + public Integer getResult() { + return result; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/responses/State.java b/Trading/src/main/java/com/suneesh/trading/models/responses/State.java new file mode 100644 index 0000000..188e2fa --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/responses/State.java @@ -0,0 +1,26 @@ +package com.suneesh.trading.models.responses; + +import com.google.gson.annotations.SerializedName; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/2/2017 + */ +public class State { + + @SerializedName("value") + private String value; + + @SerializedName("text") + private String text; + + public String getText() { + return text; + } + + public String getValue() { + + return value; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/responses/Statement.java b/Trading/src/main/java/com/suneesh/trading/models/responses/Statement.java new file mode 100644 index 0000000..5571022 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/responses/Statement.java @@ -0,0 +1,33 @@ +package com.suneesh.trading.models.responses; + +import com.google.gson.annotations.SerializedName; + +import java.util.List; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/7/2017 + */ +public class Statement { + + /** + * Number of transactions returned in this call + */ + @SerializedName("count") + private int count; + + /** + * Array of returned transactions + */ + @SerializedName("transactions") + private List transactions; + + public int getCount() { + return count; + } + + public List getTransactions() { + return transactions; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/responses/StatementResponse.java b/Trading/src/main/java/com/suneesh/trading/models/responses/StatementResponse.java new file mode 100644 index 0000000..cfaf113 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/responses/StatementResponse.java @@ -0,0 +1,29 @@ +package com.suneesh.trading.models.responses; + +import com.suneesh.trading.models.requests.StatementRequest; +import com.google.gson.annotations.SerializedName; + +/** + *

StatementResponse

+ * + *

Statement Receive

+ *

+ * A summary of account statement is received + *

+ * + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/7/2017 + */ +public class StatementResponse extends ResponseBase { + + /** + * Account statement. + */ + @SerializedName("statement") + private Statement statement; + + public Statement getStatement() { + return statement; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/responses/StatementTransaction.java b/Trading/src/main/java/com/suneesh/trading/models/responses/StatementTransaction.java new file mode 100644 index 0000000..17e96af --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/responses/StatementTransaction.java @@ -0,0 +1,140 @@ +package com.suneesh.trading.models.responses; + +import com.google.gson.annotations.SerializedName; +import io.reactivex.annotations.Nullable; + +import java.math.BigDecimal; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/7/2017 + */ +public class StatementTransaction { + + /** + * It is the remaining balance Example: 10150.1300 + */ + @SerializedName("balance_after") + private BigDecimal balanceAfter; + + /** + * It is the transaction id. In statement every contract (buy or sell) and every payment has a unique id. + * Example: 10867502908 + */ + @SerializedName("transaction_id") + private Long transactionId; + + /** + * Internal transaction identifier for the corresponding buy transaction ( set only for contract selling ) + */ + @SerializedName("reference_id") + @Nullable + private Long referenceId; + + /** + * It is the contract id Example: 4867502908 + */ + @SerializedName("contract_id") + @Nullable + private Long contractId; + + /** + * It is the time of transaction Example: 1441175849 + */ + @SerializedName("transaction_time") + private int transactionTime; + + /** + * Time at which contract was purchased, present only for sell transaction + */ + @SerializedName("purchase_time") + private int purchaseTime; + + /** + * It is the type of action Example: buy + */ + @SerializedName("action_type") + private String actionType; + + /** + * It is the amount of transaction Example: -83.2300 + */ + @SerializedName("amount") + private BigDecimal amount; + + /** + * The description of contract purchased if description is set to 1 + */ + @SerializedName("longcode") + private String longCode; + + /** + * Compact description of the contract purchased if description is set to 1 + */ + @SerializedName("shortcode") + @Nullable + private String shortCode; + + /** + * Payout price + */ + @SerializedName("payout") + @Nullable + private BigDecimal payout; + + /** + * Id of an app where this transaction was performed. For example, it's 1 for binary.com. + */ + @SerializedName("app_id") + @Nullable + private Integer applicationId; + + public BigDecimal getBalanceAfter() { + return balanceAfter; + } + + public Long getTransactionId() { + return transactionId; + } + + public Long getReferenceId() { + return referenceId; + } + + public Long getContractId() { + return contractId; + } + + public int getTransactionTime() { + return transactionTime; + } + + public int getPurchaseTime() { + return purchaseTime; + } + + public String getActionType() { + return actionType; + } + + public BigDecimal getAmount() { + return amount; + } + + public String getLongCode() { + return longCode; + } + + public String getShortCode() { + return shortCode; + } + + public BigDecimal getPayout() { + return payout; + } + + public Integer getApplicationId() { + return applicationId; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/responses/StatesListResponse.java b/Trading/src/main/java/com/suneesh/trading/models/responses/StatesListResponse.java new file mode 100644 index 0000000..7e89337 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/responses/StatesListResponse.java @@ -0,0 +1,29 @@ +package com.suneesh.trading.models.responses; + +import com.suneesh.trading.models.requests.StatesListRequest; +import com.google.gson.annotations.SerializedName; + +import java.util.List; + +/** + *

StatesListResponse

+ * + *

States List Receive

+ *

A message with States List

+ * + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/2/2017 + */ +public class StatesListResponse extends ResponseBase { + + /** + * List of states. + */ + @SerializedName("states_list") + private List statesList; + + public List getStatesList() { + return statesList; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/responses/StopCopyTradeResponse.java b/Trading/src/main/java/com/suneesh/trading/models/responses/StopCopyTradeResponse.java new file mode 100644 index 0000000..dc15c44 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/responses/StopCopyTradeResponse.java @@ -0,0 +1,29 @@ +package com.suneesh.trading.models.responses; + +import com.suneesh.trading.models.requests.StopCopyTradeRequest; +import com.google.gson.annotations.SerializedName; + +/** + *

StopCopyTradeResponse

+ * + *

Copy Stop Receive

+ *

+ * A message with results is received + *

+ * + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/9/2017 + */ +public class StopCopyTradeResponse extends ResponseBase { + + /** + * Copy stopping confirmation. Returns 1 is success. + */ + @SerializedName("copy_stop") + private Integer result; + + public Integer getResult() { + return result; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/responses/SubAccount.java b/Trading/src/main/java/com/suneesh/trading/models/responses/SubAccount.java new file mode 100644 index 0000000..9341cc2 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/responses/SubAccount.java @@ -0,0 +1,30 @@ +package com.suneesh.trading.models.responses; + +import com.google.gson.annotations.SerializedName; + +/** + * Created by morteza on 7/28/2017. + */ +public class SubAccount { + @SerializedName("loginid") + private String loginId; + + @SerializedName("currency") + private String currency; + + public String getLoginId() { + return loginId; + } + + public void setLoginId(String loginId) { + this.loginId = loginId; + } + + public String getCurrency() { + return currency; + } + + public void setCurrency(String currency) { + this.currency = currency; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/responses/SubMarket.java b/Trading/src/main/java/com/suneesh/trading/models/responses/SubMarket.java new file mode 100644 index 0000000..0d6440d --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/responses/SubMarket.java @@ -0,0 +1,27 @@ +package com.suneesh.trading.models.responses; + +import com.google.gson.annotations.SerializedName; + +import java.util.List; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/3/2017 + */ +public class SubMarket { + + @SerializedName("name") + private String name; + + @SerializedName("symbols") + private List symbols; + + public String getName() { + return name; + } + + public List getUnderlyings() { + return symbols; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/responses/TNCApprovalResponse.java b/Trading/src/main/java/com/suneesh/trading/models/responses/TNCApprovalResponse.java new file mode 100644 index 0000000..ba58f07 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/responses/TNCApprovalResponse.java @@ -0,0 +1,23 @@ +package com.suneesh.trading.models.responses; + +import com.suneesh.trading.models.requests.TNCApprovalRequest; +import com.google.gson.annotations.SerializedName; + +/** + *

TNCApprovalResponse

+ * + *

T&C Approval Receive

+ * + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 9/4/2017 + */ +public class TNCApprovalResponse extends ResponseBase { + + @SerializedName("tnc_approval") + private Integer result; + + public Integer getResult() { + return result; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/responses/Tick.java b/Trading/src/main/java/com/suneesh/trading/models/responses/Tick.java new file mode 100644 index 0000000..86a2b10 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/responses/Tick.java @@ -0,0 +1,98 @@ +package com.suneesh.trading.models.responses; + +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import org.springframework.context.annotation.Configuration; +import org.springframework.data.jpa.repository.config.EnableJpaRepositories; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; + +/** + * Created by morteza on 7/19/2017. + */ + +@Data +public class Tick { + @SerializedName("ask") + @Expose + private + String ask; + + @SerializedName("bid") + @Expose + private + String bid; + + @SerializedName("id") + @Expose + private + String id; + + @SerializedName("epoch") + @Expose + private + String epoch; + + @SerializedName("quote") + @Expose + private + String quote; + + @SerializedName("symbol") + @Expose + private + String symbol; + + public String getAsk(){ + return this.ask; + } + + public String getBid(){ + return this.bid; + } + + public String getEpoch (){ + return this.epoch; + } + + public String getId(){ + return this.id; + } + + public String getQuote(){ + return this.quote; + } + + public void setAsk(String ask) { + this.ask = ask; + } + + public void setBid(String bid) { + this.bid = bid; + } + + public void setEpoch(String epoch) { + this.epoch = epoch; + } + + public void setId(String id) { + this.id = id; + } + + public void setQuote(String quote) { + this.quote = quote; + } + + public String getSymbol() { + return symbol; + } + + public void setSymbol(String symbol) { + this.symbol = symbol; + } + +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/responses/TickHistoryResponse.java b/Trading/src/main/java/com/suneesh/trading/models/responses/TickHistoryResponse.java new file mode 100644 index 0000000..9f831ec --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/responses/TickHistoryResponse.java @@ -0,0 +1,77 @@ +package com.suneesh.trading.models.responses; + +import com.suneesh.trading.models.requests.TickHistoryRequest; +import com.google.gson.annotations.SerializedName; +import com.suneesh.trading.utils.AutoTradingUtility; +import io.reactivex.annotations.Nullable; + +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + +/** + *

TickHistoryResponse

+ * + *

Tick History Response

+ *

Historic tick data for a single symbol

+ * + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/3/2017 + */ +public class TickHistoryResponse extends ResponseBase { + + /** + * Historic tick data for a given symbol + */ + @SerializedName("history") + @Nullable + private History history; + + public void setCandles(List candles) { + this.candles = candles; + } + + /** + * Array of OHLC (open/high/low/close) price values for the given time (only for style='candles') + */ + @SerializedName("candles") + @Nullable + private List candles; + + public History getHistory() { + return history; + } + + public List getCandles() { + return candles; + } + + @Override + public List databaseInsertStringList(){ + return candles.stream().map(candle->{ + candle.setDirection(); + candle.setOpenCloseDiff(); + candle.setWriteTimeEpoch(); + String candleStartEpochTime = candle.getOpen_time() == null ? String.valueOf(candle.getEpoch()) : String.valueOf(candle.getOpen_time()); + + String result = "INSERT INTO public.candle " + + "(close, epoch, high, low, open, granularity, symbol, direction, open_close_diff, epoch_string) " + + " VALUES (" + + AutoTradingUtility.quotedString(candle.getClose()) + ", " + + AutoTradingUtility.quotedString(candleStartEpochTime) + ", " + + AutoTradingUtility.quotedString(candle.getHigh()) + ", " + + AutoTradingUtility.quotedString(candle.getLow()) + ", " + + AutoTradingUtility.quotedString(candle.getOpen()) + ", " + + AutoTradingUtility.quotedString(candle.getGranularity()) + ", " + + AutoTradingUtility.quotedString(candle.getSymbol()) + ", " + + AutoTradingUtility.quotedString(candle.getDirection()) + "," + + AutoTradingUtility.quotedString(candle.getOpenCloseDiff()) + "," + + AutoTradingUtility.getTimeStampString(Long.valueOf(candleStartEpochTime)) + ");"; + return result; + } + ).collect(Collectors.toList()); + + } + +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/responses/TickResponse.java b/Trading/src/main/java/com/suneesh/trading/models/responses/TickResponse.java new file mode 100644 index 0000000..fd7dfcd --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/responses/TickResponse.java @@ -0,0 +1,42 @@ +package com.suneesh.trading.models.responses; + +import com.suneesh.trading.models.requests.TickRequest; +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; +import com.suneesh.trading.utils.AutoTradingUtility; + +import java.util.Arrays; +import java.util.List; + +/** + * Created by morteza on 7/19/2017. + */ + +public class TickResponse extends ResponseBase { + @SerializedName("tick") + @Expose + private + Tick tick; + + public Tick getTick() { + return tick; + } + + public void setTick(Tick tick) { + this.tick = tick; + } + + @Override + public List databaseInsertStringList(){ + return Arrays.asList("INSERT INTO public.tick " + + "(ask, bid, epoch, quote, symbol,epoch_string) " + + " VALUES (" + AutoTradingUtility.quotedString(tick.getAsk())+", " + + AutoTradingUtility.quotedString(tick.getBid())+", " + + AutoTradingUtility.quotedString(tick.getEpoch())+", " + + AutoTradingUtility.quotedString(tick.getQuote())+", " + + AutoTradingUtility.quotedString(tick.getSymbol()) +"," + + AutoTradingUtility.getTimeStampString(Long.valueOf(tick.getEpoch())) +");"); + + } + +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/responses/TimeResponse.java b/Trading/src/main/java/com/suneesh/trading/models/responses/TimeResponse.java new file mode 100644 index 0000000..8289d44 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/responses/TimeResponse.java @@ -0,0 +1,24 @@ +package com.suneesh.trading.models.responses; + +import com.suneesh.trading.models.requests.TimeRequest; +import com.google.gson.annotations.SerializedName; + +/** + *

TimeResponse

+ * + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/3/2017 + */ +public class TimeResponse extends ResponseBase { + + /** + * Epoch of server time. + */ + @SerializedName("time") + private int time; + + public int getTime() { + return time; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/responses/TopUpVirtualMoneyAccountResponse.java b/Trading/src/main/java/com/suneesh/trading/models/responses/TopUpVirtualMoneyAccountResponse.java new file mode 100644 index 0000000..a2e248d --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/responses/TopUpVirtualMoneyAccountResponse.java @@ -0,0 +1,33 @@ +package com.suneesh.trading.models.responses; + +import com.suneesh.trading.models.requests.TopUpVirtualMoneyAccountRequest; +import com.google.gson.annotations.SerializedName; + +import java.math.BigDecimal; +import java.util.Map; + +/** + *

TopUpVirtualMoneyAccountResponse

+ * + *

Top Up Virtual Response

+ * + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/9/2017 + */ +public class TopUpVirtualMoneyAccountResponse extends ResponseBase { + + /** + * Top Up Virtual Response + */ + @SerializedName("topup_virtual") + private Map result; + + public String getCurrency() { + return result.size() > 0 ? result.get("currency") : null; + } + + public BigDecimal getAmount() { + return result.size() > 0 ? new BigDecimal(result.get("amount")) : null; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/responses/TradingPeriod.java b/Trading/src/main/java/com/suneesh/trading/models/responses/TradingPeriod.java new file mode 100644 index 0000000..7a47330 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/responses/TradingPeriod.java @@ -0,0 +1,43 @@ +package com.suneesh.trading.models.responses; + +import com.google.gson.annotations.SerializedName; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/1/2017 + */ +public class TradingPeriod { + @SerializedName("date_start") + private DateStructure dateStart; + + @SerializedName("date_expiry") + private DateStructure dateExpiry; + + @SerializedName("duration") + private String duration; + + public DateStructure getDateStart() { + return dateStart; + } + + public void setDateStart(DateStructure dateStart) { + this.dateStart = dateStart; + } + + public DateStructure getDateExpiry() { + return dateExpiry; + } + + public void setDateExpiry(DateStructure dateExpiry) { + this.dateExpiry = dateExpiry; + } + + public String getDuration() { + return duration; + } + + public void setDuration(String duration) { + this.duration = duration; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/responses/TradingTimesResponse.java b/Trading/src/main/java/com/suneesh/trading/models/responses/TradingTimesResponse.java new file mode 100644 index 0000000..3a4e1ef --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/responses/TradingTimesResponse.java @@ -0,0 +1,40 @@ +package com.suneesh.trading.models.responses; + +import com.suneesh.trading.models.requests.TradingTimesRequest; +import com.google.gson.annotations.SerializedName; + +import java.util.List; + +/** + *

TradingTimesResponse

+ * + *

Trading Times Receive

+ *

A message with Trading Times

+ * + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/3/2017 + */ +public class TradingTimesResponse extends ResponseBase { + + /** + * The trading times structure is a hierarchy as follows: Market -> SubMarket -> Underlyings + */ + @SerializedName("trading_times") + private TradingTimes tradingTimes; + + public TradingTimes getTradingTimes() { + return tradingTimes; + } + + + public class TradingTimes { + + @SerializedName("markets") + private List markets; + + public List getMarkets() { + return markets; + } + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/responses/Transaction.java b/Trading/src/main/java/com/suneesh/trading/models/responses/Transaction.java new file mode 100644 index 0000000..f7445f8 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/responses/Transaction.java @@ -0,0 +1,189 @@ +package com.suneesh.trading.models.responses; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import java.math.BigDecimal; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/8/2017 + */ +public class Transaction { + /** + * Balance amount + * + */ + @SerializedName("balance") + private BigDecimal balance; + + @SerializedName("action") + private String action; + + /** + * It is the contract id Example: 4867502908 + * + */ + @SerializedName("contract_id") + private Long contractId; + + /** + * It is the transaction id. Every contract (buy or sell) or payment has a unique id. Example: 10867502908 + * + */ + @SerializedName("transaction_id") + private Long transactionId; + + /** + * It is the amount of transaction performed Example: -83.2300 + * + */ + @SerializedName("amount") + private BigDecimal amount; + + /** + * A stream id that can be used to cancel this stream using the Forget request. Example: 1d6651e7d599bce6c54bd71a8283e579 + * + */ + @SerializedName("id") + private String id; + + /** + * Time at which transaction was performed, for buy its purchase time, for sell its sell time + * + */ + @SerializedName("transaction_time") + private Long transactionTime; + + /** + * Time at which contract was purchased, present only for sell transaction + * + */ + @SerializedName("purchase_time") + private Long purchaseTime; + + /** + * Transaction currency + * + */ + @SerializedName("currency") + private String currency; + + /** + * Description of contract purchased + * + */ + @SerializedName("longcode") + private String longCode; + + /** + * Symbol code + * + */ + @SerializedName("symbol") + private String symbol; + + /** + * Display name of symbol + * + */ + @SerializedName("display_name") + private String displayName; + + /** + * Epoch value of the expiry time of the contract. Please note that in case of buy transaction this is approximate value not exact one. + * + */ + @SerializedName("date_expiry") + private Long dateExpiry; + + /** + * Barrier of the contract. Only applicable to single barrier contracts. Could be undefined if a contract does not have a barrier. + * + */ + @SerializedName("barrier") + private String barrier; + + /** + * The high barrier of a contract. Only applicable to double barrier contracts. + * + */ + @SerializedName("high_barrier") + private String highBarrier; + + /** + * The low barrier of a contract. Only applicable to double barrier contracts. + * + */ + @SerializedName("low_barrier") + private String lowBarrier; + + public BigDecimal getBalance() { + return balance; + } + + public String getAction() { + return action; + } + + public Long getContractId() { + return contractId; + } + + public Long getTransactionId() { + return transactionId; + } + + public BigDecimal getAmount() { + return amount; + } + + public String getId() { + return id; + } + + public Long getTransactionTime() { + return transactionTime; + } + + public Long getPurchaseTime() { + return purchaseTime; + } + + public String getCurrency() { + return currency; + } + + public String getLongCode() { + return longCode; + } + + public String getSymbol() { + return symbol; + } + + public String getDisplayName() { + return displayName; + } + + public Long getDateExpiry() { + return dateExpiry; + } + + public String getBarrier() { + return barrier; + } + + public String getHighBarrier() { + return highBarrier; + } + + public String getLowBarrier() { + return lowBarrier; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/responses/TransactionsStreamResponse.java b/Trading/src/main/java/com/suneesh/trading/models/responses/TransactionsStreamResponse.java new file mode 100644 index 0000000..9ff5ad3 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/responses/TransactionsStreamResponse.java @@ -0,0 +1,68 @@ +package com.suneesh.trading.models.responses; + +import com.suneesh.trading.models.requests.TransactionsStreamRequest; +import com.google.gson.annotations.SerializedName; +import com.suneesh.trading.utils.AutoTradingUtility; + +import java.util.Arrays; +import java.util.List; + +/** + *

TransactionStreamResponse

+ * + *

Transaction Updates

+ *

+ * Return transaction updates + *

+ * + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/8/2017 + */ +public class TransactionsStreamResponse extends ResponseBase { + + /** + * Realtime stream of user transaction updates. + */ + @SerializedName("transaction") + private Transaction transaction; + + public Transaction getTransaction() { + return transaction; + } + + public void setTransaction(Transaction transaction) { + this.transaction = transaction; + } + + @Override + public List databaseInsertStringList() { + + Long purchaseTime =transaction.getPurchaseTime()==null?transaction.getTransactionTime():transaction.getPurchaseTime(); + return + Arrays.asList( + "INSERT INTO public.transaction " + + "( action ,amount ,balance ,barrier ,contract_id ,currency ,date_expiry ,display_name ," + + " long_code ,purchase_time ,symbol ,transaction_id ,transaction_time, date_expiry_string ," + + " purchase_time_string , transaction_time_string )" + + " VALUES (" + + AutoTradingUtility.quotedString(transaction.getAction()) + ", " + + AutoTradingUtility.quotedString(transaction.getAmount()) + ", " + + AutoTradingUtility.quotedString(transaction.getBalance()) + ", " + + AutoTradingUtility.quotedString(transaction.getBarrier()) + ", " + + AutoTradingUtility.quotedString(transaction.getContractId()) + ", " + + AutoTradingUtility.quotedString(transaction.getCurrency()) + ", " + + AutoTradingUtility.quotedString(transaction.getDateExpiry()) + ", " + + AutoTradingUtility.quotedString(transaction.getDisplayName()) + ", " + + AutoTradingUtility.quotedString(transaction.getLongCode()) + ", " + + AutoTradingUtility.quotedString(purchaseTime ) + ", " + + AutoTradingUtility.quotedString(transaction.getSymbol()) + ", " + + AutoTradingUtility.quotedString(transaction.getTransactionId()) + ", " + + AutoTradingUtility.quotedString(transaction.getTransactionTime()) + "," + + AutoTradingUtility.getTimeStampString(transaction.getDateExpiry()) + "," + + AutoTradingUtility.getTimeStampString(purchaseTime) + "," + + AutoTradingUtility.getTimeStampString(transaction.getTransactionTime()) + ");" + ); + + } + } diff --git a/Trading/src/main/java/com/suneesh/trading/models/responses/TransferBetweenAccountsResponse.java b/Trading/src/main/java/com/suneesh/trading/models/responses/TransferBetweenAccountsResponse.java new file mode 100644 index 0000000..21b7f30 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/responses/TransferBetweenAccountsResponse.java @@ -0,0 +1,69 @@ +package com.suneesh.trading.models.responses; + +import com.suneesh.trading.models.requests.TransferBetweenAccountsRequest; +import com.google.gson.annotations.SerializedName; + +import java.util.List; +import java.util.Map; + +/** + *

TransferBetweenAccountsResponse

+ * + *

Transfer Between Accounts Response

+ * + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 9/15/2017 + */ +public class TransferBetweenAccountsResponse extends ResponseBase { + + /** + * If 1, transfer success. + */ + @SerializedName("transfer_between_accounts") + private Integer result; + + /** + * the avaiable accounts to transfer + */ + @SerializedName("accounts") + private List> accounts; + + /** + * the avaiable accounts to transfer + */ + @SerializedName("client_to_full_name") + private String clientToFullName; + + /** + * The account to client loginid + */ + @SerializedName("client_to_loginid") + private String clientToLoginId; + + /** + * Reference id of transfer performed + */ + @SerializedName("transaction_id") + private Long transactionId; + + public boolean getResult() { + return result == 1 ? true : false; + } + + public List> getAccounts() { + return accounts; + } + + public String getClientToFullName() { + return clientToFullName; + } + + public String getClientToLoginId() { + return clientToLoginId; + } + + public Long getTransactionId() { + return transactionId; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/responses/Underlying.java b/Trading/src/main/java/com/suneesh/trading/models/responses/Underlying.java new file mode 100644 index 0000000..152b9d5 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/responses/Underlying.java @@ -0,0 +1,59 @@ +package com.suneesh.trading.models.responses; + +import com.google.gson.annotations.SerializedName; +import io.reactivex.annotations.Nullable; + +import java.util.List; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/3/2017 + */ +public class Underlying { + + @SerializedName("name") + private String name; + + @SerializedName("settlement") + private String settlement; + + @SerializedName("symbol") + private String symbol; + + @SerializedName("events") + @Nullable + private List events; + + @SerializedName("times") + private UnderlyingTimes times; + + public class UnderlyingEvent { + + @SerializedName("dates") + private String dates; + + @SerializedName("descrip") + private String description; + + public String getDates() { + return dates; + } + + public String getDescription() { + return description; + } + } + + public class UnderlyingTimes { + + @SerializedName("close") + private List close; + + @SerializedName("open") + private List open; + + @SerializedName("settlement") + private String settlement; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/responses/WebsiteStatus.java b/Trading/src/main/java/com/suneesh/trading/models/responses/WebsiteStatus.java new file mode 100644 index 0000000..f0aa244 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/responses/WebsiteStatus.java @@ -0,0 +1,97 @@ +package com.suneesh.trading.models.responses; + +import com.google.gson.annotations.SerializedName; +import io.reactivex.annotations.Nullable; + +import java.util.List; +import java.util.Map; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/3/2017 + */ +public class WebsiteStatus { + + /** + * Latest terms and conditions version + */ + @SerializedName("terms_conditions_version") + private String termsConditionsVersion; + + /** + * Limits for api call for each websocket connection + */ + @SerializedName("api_call_limits") + private Map apiCallLimits; + + /** + * Country code of connected IP + */ + @SerializedName("clients_country") + private String clientsCountry; + + /** + * Provides codes for languages supported + */ + @SerializedName("supported_languages") + private List supportedLanguages; + + /** + * Show fractional digits for supported currencies, for example USD have display of 2 fractional digits. + * { USD => { fractional_digits => 2 } } + */ + @SerializedName("currencies_config") + private Map currenciesConfig; + + /** + * Current status of the ico auction. closed or open + */ + @SerializedName("ico_status") + private String icoStatus; + + /** + * Current status of the site. up or down + */ + @SerializedName("site_status") + private String siteStatus; + + /** + * Text for site status banner. Contains problem description. Showed only if site_status is down + */ + @SerializedName("message") + @Nullable + private String message; + + public String getTermsConditionsVersion() { + return termsConditionsVersion; + } + + public Map getApiCallLimits() { + return apiCallLimits; + } + + public String getClientsCountry() { + return clientsCountry; + } + + public List getSupportedLanguages() { + return supportedLanguages; + } + + public Map getCurrenciesConfig() { + return currenciesConfig; + } + + public String getIcoStatus() { + return icoStatus; + } + + public String getSiteStatus() { + return siteStatus; + } + + public String getMessage() { + return message; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/models/responses/WebsiteStatusResponse.java b/Trading/src/main/java/com/suneesh/trading/models/responses/WebsiteStatusResponse.java new file mode 100644 index 0000000..43cd023 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/models/responses/WebsiteStatusResponse.java @@ -0,0 +1,23 @@ +package com.suneesh.trading.models.responses; + +import com.suneesh.trading.models.requests.WebsiteStatusRequest; +import com.google.gson.annotations.SerializedName; + +/** + *

WebsiteStatusResponse

+ * + *

Server status

+ * + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/3/2017 + */ +public class WebsiteStatusResponse extends ResponseBase { + + @SerializedName("website_status") + private WebsiteStatus websiteStatus; + + public WebsiteStatus getWebsiteStatus() { + return websiteStatus; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/spring_stuff/StartApplication.java b/Trading/src/main/java/com/suneesh/trading/spring_stuff/StartApplication.java new file mode 100644 index 0000000..b05a98c --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/spring_stuff/StartApplication.java @@ -0,0 +1,54 @@ +package com.suneesh.trading.spring_stuff; + +import com.suneesh.trading.models.requests.RequestBase; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.CommandLineRunner; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Configuration; +import org.springframework.data.jpa.repository.config.EnableJpaRepositories; + +import java.util.concurrent.BlockingQueue; +import java.util.concurrent.LinkedBlockingQueue; + + +@SpringBootApplication(scanBasePackages = {"com.suneesh.trading"}) +@EnableJpaRepositories("com.suneesh.trading.spring_stuff.repository") +@Configuration +public class StartApplication implements CommandLineRunner { + + private static final Logger logger = LogManager.getLogger(); + private static BlockingQueue inputMessageQueue = new LinkedBlockingQueue<>(); + + @Value("${Application.id}") + private String applicationID; + + @Value("${Application.authorizeCode}") + private String applicationAuthorizeCode; + +// @Autowired +// protected TickRepository tickRepository; + + + public static void main(String[] args) { + SpringApplication.run(StartApplication.class, args); + } + + @Override + public void run(String... args) { + + logger.info("Starting Automated Trading Application..."); + logger.info("{} - {} ",applicationID, applicationAuthorizeCode); + +// BinaryWebServiceConnector binaryWebServiceConnector = new BinaryWebServiceConnector(inputMessageQueue,applicationID, applicationAuthorizeCode); +// BinaryWebServiceConnector.init(); +// BinaryWebServiceConnector.getTickDetail("R_10"); + + +// bookRepository.save(new Book("Python 2")); + + } + +} diff --git a/Trading/src/main/java/com/suneesh/trading/spring_stuff/repository/AccountStatusResponseRepository.java b/Trading/src/main/java/com/suneesh/trading/spring_stuff/repository/AccountStatusResponseRepository.java new file mode 100644 index 0000000..79b0031 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/spring_stuff/repository/AccountStatusResponseRepository.java @@ -0,0 +1,12 @@ +package com.suneesh.trading.spring_stuff.repository; + +import com.suneesh.trading.models.responses.AccountStatus; +import org.springframework.data.repository.CrudRepository; + +import java.util.List; + +public interface AccountStatusResponseRepository extends CrudRepository { + + List findByName(String name); + +} diff --git a/Trading/src/main/java/com/suneesh/trading/spring_stuff/repository/AccountStatusResponseRepositoryImpl.java b/Trading/src/main/java/com/suneesh/trading/spring_stuff/repository/AccountStatusResponseRepositoryImpl.java new file mode 100644 index 0000000..e0f2c85 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/spring_stuff/repository/AccountStatusResponseRepositoryImpl.java @@ -0,0 +1,68 @@ +package com.suneesh.trading.spring_stuff.repository; + +import com.suneesh.trading.models.responses.AccountStatus; + +import java.util.List; +import java.util.Optional; + +public class AccountStatusResponseRepositoryImpl implements AccountStatusResponseRepository { + @Override + public List findByName(String name) { + return null; + } + + @Override + public S save(S entity) { + return null; + } + + @Override + public Iterable saveAll(Iterable entities) { + return null; + } + + @Override + public Optional findById(Long aLong) { + return Optional.empty(); + } + + @Override + public boolean existsById(Long aLong) { + return false; + } + + @Override + public Iterable findAll() { + return null; + } + + @Override + public Iterable findAllById(Iterable longs) { + return null; + } + + @Override + public long count() { + return 0; + } + + @Override + public void deleteById(Long aLong) { + + } + + @Override + public void delete(AccountStatus entity) { + + } + + @Override + public void deleteAll(Iterable entities) { + + } + + @Override + public void deleteAll() { + + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/spring_stuff/repository/AuthorizeResponseRepository.java b/Trading/src/main/java/com/suneesh/trading/spring_stuff/repository/AuthorizeResponseRepository.java new file mode 100644 index 0000000..1b9af9f --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/spring_stuff/repository/AuthorizeResponseRepository.java @@ -0,0 +1,12 @@ +package com.suneesh.trading.spring_stuff.repository; + +import com.suneesh.trading.models.responses.Authorize; +import org.springframework.data.repository.CrudRepository; + +import java.util.List; + +public interface AuthorizeResponseRepository extends CrudRepository { + + List findByName(String name); + +} diff --git a/Trading/src/main/java/com/suneesh/trading/spring_stuff/repository/AuthorizeResponseRepositoryImpl.java b/Trading/src/main/java/com/suneesh/trading/spring_stuff/repository/AuthorizeResponseRepositoryImpl.java new file mode 100644 index 0000000..080218a --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/spring_stuff/repository/AuthorizeResponseRepositoryImpl.java @@ -0,0 +1,68 @@ +package com.suneesh.trading.spring_stuff.repository; + +import com.suneesh.trading.models.responses.Authorize; + +import java.util.List; +import java.util.Optional; + +public class AuthorizeResponseRepositoryImpl implements AuthorizeResponseRepository { + @Override + public List findByName(String name) { + return null; + } + + @Override + public S save(S entity) { + return null; + } + + @Override + public Iterable saveAll(Iterable entities) { + return null; + } + + @Override + public Optional findById(Long aLong) { + return Optional.empty(); + } + + @Override + public boolean existsById(Long aLong) { + return false; + } + + @Override + public Iterable findAll() { + return null; + } + + @Override + public Iterable findAllById(Iterable longs) { + return null; + } + + @Override + public long count() { + return 0; + } + + @Override + public void deleteById(Long aLong) { + + } + + @Override + public void delete(Authorize entity) { + + } + + @Override + public void deleteAll(Iterable entities) { + + } + + @Override + public void deleteAll() { + + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/spring_stuff/repository/BalanceResponseRepository.java b/Trading/src/main/java/com/suneesh/trading/spring_stuff/repository/BalanceResponseRepository.java new file mode 100644 index 0000000..390568a --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/spring_stuff/repository/BalanceResponseRepository.java @@ -0,0 +1,12 @@ +package com.suneesh.trading.spring_stuff.repository; + +import com.suneesh.trading.models.responses.Balance; +import org.springframework.data.repository.CrudRepository; + +import java.util.List; + +public interface BalanceResponseRepository extends CrudRepository { + + List findByName(String name); + +} diff --git a/Trading/src/main/java/com/suneesh/trading/spring_stuff/repository/BalanceResponseRepositoryImpl.java b/Trading/src/main/java/com/suneesh/trading/spring_stuff/repository/BalanceResponseRepositoryImpl.java new file mode 100644 index 0000000..3d5315a --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/spring_stuff/repository/BalanceResponseRepositoryImpl.java @@ -0,0 +1,68 @@ +package com.suneesh.trading.spring_stuff.repository; + +import com.suneesh.trading.models.responses.Balance; + +import java.util.List; +import java.util.Optional; + +public class BalanceResponseRepositoryImpl implements BalanceResponseRepository { + @Override + public List findByName(String name) { + return null; + } + + @Override + public S save(S entity) { + return null; + } + + @Override + public Iterable saveAll(Iterable entities) { + return null; + } + + @Override + public Optional findById(Long aLong) { + return Optional.empty(); + } + + @Override + public boolean existsById(Long aLong) { + return false; + } + + @Override + public Iterable findAll() { + return null; + } + + @Override + public Iterable findAllById(Iterable longs) { + return null; + } + + @Override + public long count() { + return 0; + } + + @Override + public void deleteById(Long aLong) { + + } + + @Override + public void delete(Balance entity) { + + } + + @Override + public void deleteAll(Iterable entities) { + + } + + @Override + public void deleteAll() { + + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/spring_stuff/repository/PortfolioResponseRepository.java b/Trading/src/main/java/com/suneesh/trading/spring_stuff/repository/PortfolioResponseRepository.java new file mode 100644 index 0000000..18eee65 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/spring_stuff/repository/PortfolioResponseRepository.java @@ -0,0 +1,12 @@ +package com.suneesh.trading.spring_stuff.repository; + +import com.suneesh.trading.models.responses.PortfolioTransaction; +import org.springframework.data.repository.CrudRepository; + +import java.util.List; + +public interface PortfolioResponseRepository extends CrudRepository { + + List findByName(String name); + +} diff --git a/Trading/src/main/java/com/suneesh/trading/spring_stuff/repository/PortfolioResponseRepositoryImpl.java b/Trading/src/main/java/com/suneesh/trading/spring_stuff/repository/PortfolioResponseRepositoryImpl.java new file mode 100644 index 0000000..3643394 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/spring_stuff/repository/PortfolioResponseRepositoryImpl.java @@ -0,0 +1,68 @@ +package com.suneesh.trading.spring_stuff.repository; + +import com.suneesh.trading.models.responses.PortfolioTransaction; + +import java.util.List; +import java.util.Optional; + +public class PortfolioResponseRepositoryImpl implements PortfolioResponseRepository { + @Override + public List findByName(String name) { + return null; + } + + @Override + public S save(S entity) { + return null; + } + + @Override + public Iterable saveAll(Iterable entities) { + return null; + } + + @Override + public Optional findById(Long aLong) { + return Optional.empty(); + } + + @Override + public boolean existsById(Long aLong) { + return false; + } + + @Override + public Iterable findAll() { + return null; + } + + @Override + public Iterable findAllById(Iterable longs) { + return null; + } + + @Override + public long count() { + return 0; + } + + @Override + public void deleteById(Long aLong) { + + } + + @Override + public void delete(PortfolioTransaction entity) { + + } + + @Override + public void deleteAll(Iterable entities) { + + } + + @Override + public void deleteAll() { + + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/spring_stuff/repository/TickHistoryResponseRepository.java b/Trading/src/main/java/com/suneesh/trading/spring_stuff/repository/TickHistoryResponseRepository.java new file mode 100644 index 0000000..1a59d24 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/spring_stuff/repository/TickHistoryResponseRepository.java @@ -0,0 +1,12 @@ +package com.suneesh.trading.spring_stuff.repository; + +import com.suneesh.trading.models.responses.Candle; +import org.springframework.data.repository.CrudRepository; + +import java.util.List; + +public interface TickHistoryResponseRepository extends CrudRepository { + + List findByName(String name); + +} diff --git a/Trading/src/main/java/com/suneesh/trading/spring_stuff/repository/TickHistoryResponseRepositoryImpl.java b/Trading/src/main/java/com/suneesh/trading/spring_stuff/repository/TickHistoryResponseRepositoryImpl.java new file mode 100644 index 0000000..4b9868d --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/spring_stuff/repository/TickHistoryResponseRepositoryImpl.java @@ -0,0 +1,68 @@ +package com.suneesh.trading.spring_stuff.repository; + +import com.suneesh.trading.models.responses.Candle; + +import java.util.List; +import java.util.Optional; + +public class TickHistoryResponseRepositoryImpl implements TickHistoryResponseRepository{ + @Override + public List findByName(String name) { + return null; + } + + @Override + public S save(S entity) { + return null; + } + + @Override + public Iterable saveAll(Iterable entities) { + return null; + } + + @Override + public Optional findById(Long aLong) { + return Optional.empty(); + } + + @Override + public boolean existsById(Long aLong) { + return false; + } + + @Override + public Iterable findAll() { + return null; + } + + @Override + public Iterable findAllById(Iterable longs) { + return null; + } + + @Override + public long count() { + return 0; + } + + @Override + public void deleteById(Long aLong) { + + } + + @Override + public void delete(Candle entity) { + + } + + @Override + public void deleteAll(Iterable entities) { + + } + + @Override + public void deleteAll() { + + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/spring_stuff/repository/TickRepository.java b/Trading/src/main/java/com/suneesh/trading/spring_stuff/repository/TickRepository.java new file mode 100644 index 0000000..79d34d0 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/spring_stuff/repository/TickRepository.java @@ -0,0 +1,14 @@ +package com.suneesh.trading.spring_stuff.repository; + +import com.suneesh.trading.models.responses.Tick; +import org.springframework.data.repository.CrudRepository; +import org.springframework.stereotype.Repository; + +import java.util.List; + +@Repository +public interface TickRepository extends CrudRepository { + + List findByName(String name); + +} diff --git a/Trading/src/main/java/com/suneesh/trading/spring_stuff/repository/TickRepositoryImpl.java b/Trading/src/main/java/com/suneesh/trading/spring_stuff/repository/TickRepositoryImpl.java new file mode 100644 index 0000000..eab6f8b --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/spring_stuff/repository/TickRepositoryImpl.java @@ -0,0 +1,68 @@ +package com.suneesh.trading.spring_stuff.repository; + +import com.suneesh.trading.models.responses.Tick; + +import java.util.List; +import java.util.Optional; + +public class TickRepositoryImpl implements TickRepository{ + @Override + public List findByName(String name) { + return null; + } + + @Override + public S save(S entity) { + return null; + } + + @Override + public Iterable saveAll(Iterable entities) { + return null; + } + + @Override + public Optional findById(Long aLong) { + return Optional.empty(); + } + + @Override + public boolean existsById(Long aLong) { + return false; + } + + @Override + public Iterable findAll() { + return null; + } + + @Override + public Iterable findAllById(Iterable longs) { + return null; + } + + @Override + public long count() { + return 0; + } + + @Override + public void deleteById(Long aLong) { + + } + + @Override + public void delete(Tick entity) { + + } + + @Override + public void deleteAll(Iterable entities) { + + } + + @Override + public void deleteAll() { + + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/spring_stuff/repository/TransactionStreamResponseRepository.java b/Trading/src/main/java/com/suneesh/trading/spring_stuff/repository/TransactionStreamResponseRepository.java new file mode 100644 index 0000000..3ca2714 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/spring_stuff/repository/TransactionStreamResponseRepository.java @@ -0,0 +1,12 @@ +package com.suneesh.trading.spring_stuff.repository; + +import com.suneesh.trading.models.responses.Transaction; +import org.springframework.data.repository.CrudRepository; + +import java.util.List; + +public interface TransactionStreamResponseRepository extends CrudRepository { + + List findByName(String name); + +} diff --git a/Trading/src/main/java/com/suneesh/trading/spring_stuff/repository/TransactionStreamResponseRepositoryImpl.java b/Trading/src/main/java/com/suneesh/trading/spring_stuff/repository/TransactionStreamResponseRepositoryImpl.java new file mode 100644 index 0000000..aba947c --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/spring_stuff/repository/TransactionStreamResponseRepositoryImpl.java @@ -0,0 +1,68 @@ +package com.suneesh.trading.spring_stuff.repository; + +import com.suneesh.trading.models.responses.Transaction; + +import java.util.List; +import java.util.Optional; + +public class TransactionStreamResponseRepositoryImpl implements TransactionStreamResponseRepository{ + @Override + public List findByName(String name) { + return null; + } + + @Override + public S save(S entity) { + return null; + } + + @Override + public Iterable saveAll(Iterable entities) { + return null; + } + + @Override + public Optional findById(Long aLong) { + return Optional.empty(); + } + + @Override + public boolean existsById(Long aLong) { + return false; + } + + @Override + public Iterable findAll() { + return null; + } + + @Override + public Iterable findAllById(Iterable longs) { + return null; + } + + @Override + public long count() { + return 0; + } + + @Override + public void deleteById(Long aLong) { + + } + + @Override + public void delete(Transaction entity) { + + } + + @Override + public void deleteAll(Iterable entities) { + + } + + @Override + public void deleteAll() { + + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/utils/AssetIndexDeserializer.java b/Trading/src/main/java/com/suneesh/trading/utils/AssetIndexDeserializer.java new file mode 100644 index 0000000..ff18f0e --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/utils/AssetIndexDeserializer.java @@ -0,0 +1,39 @@ +package com.suneesh.trading.utils; + +import com.suneesh.trading.models.responses.AssetIndex; +import com.suneesh.trading.models.responses.ContractInfo; +import com.google.gson.*; +import com.google.gson.annotations.JsonAdapter; + +import java.lang.reflect.Type; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 7/31/2017 + */ +public class AssetIndexDeserializer implements JsonDeserializer { + @Override + public AssetIndex deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { + + JsonArray jArray = (JsonArray) json; + AssetIndex assetIndex = new AssetIndex(); + + assetIndex.setSymbol(jArray.get(0).toString()); + assetIndex.setSymbolDisplayName(jArray.get(1).toString()); + JsonArray contracts = (JsonArray) jArray.get(2); + + for(int i=0; i < contracts.size(); i++){ + JsonArray contractInfo = (JsonArray) contracts.get(i); + ContractInfo contract = new ContractInfo(); + + contract.setContractSymbol(contractInfo.get(0).toString()); + contract.setContractDisplayName(contractInfo.get(1).toString()); + contract.setMinDuration(contractInfo.get(2).toString()); + contract.setMaxDuration(contractInfo.get(3).toString()); + + assetIndex.addContract(contract); + } + return assetIndex; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/utils/AutoTradingUtility.java b/Trading/src/main/java/com/suneesh/trading/utils/AutoTradingUtility.java new file mode 100644 index 0000000..88f410f --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/utils/AutoTradingUtility.java @@ -0,0 +1,92 @@ +package com.suneesh.trading.utils; + + +import java.io.*; +import java.net.URL; +import java.util.Arrays; +import java.util.List; +import java.util.Properties; +import java.util.stream.Collectors; + +public class AutoTradingUtility { + + protected static Properties applicationProperties; + + // get file from classpath, resources folder + public static File getFileFromResources(String fileName) { + + ClassLoader classLoader = AutoTradingUtility.class.getClassLoader(); + + URL resource = classLoader.getResource(fileName); + if (resource == null) { + throw new IllegalArgumentException("file is not found!"); + } else { + return new File(resource.getFile()); + } + + } + + public static String readFile(File file) throws IOException { + StringBuilder result = new StringBuilder(); + if (file == null) return null; + + try (FileReader reader = new FileReader(file); + BufferedReader br = new BufferedReader(reader)) { + + String line; + while ((line = br.readLine()) != null) { + result.append(line); + } + } + return String.valueOf(result); + } + + public static String quotedString(Object str){ + String result = null; + if(str!=null){ + result ="'"+String.valueOf(str)+"'"; + } + return result; + } + + public static String getTimeStampString(long epochTime){ + return "TIMESTAMP 'epoch' + "+epochTime+" * INTERVAL '1 second' " ; + } + + public static Properties readProperties(){ + File applicationPropertiesFile = getFileFromResources("application.properties"); + Properties appProps = new Properties(); + try(FileInputStream fileInputStream = new FileInputStream(applicationPropertiesFile)){ + appProps.load(fileInputStream); + } catch (FileNotFoundException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } + + return appProps; + } + + public static String getPropertyFromPropertyFile(String property){ + if(applicationProperties==null){ + applicationProperties = readProperties(); + } + return applicationProperties.getProperty(property).trim(); + } + + + public static void sleep(int milliSeconds){ + try { + Thread.sleep(milliSeconds); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + + + public static List readListFromPropertyFile(String property){ + String listAsString = AutoTradingUtility.getPropertyFromPropertyFile(property); + List list= Arrays.asList(listAsString.split(",")); + return(list.stream().map(m -> m.trim()).collect(Collectors.toList())); + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/utils/ClassUtils.java b/Trading/src/main/java/com/suneesh/trading/utils/ClassUtils.java new file mode 100644 index 0000000..4b22543 --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/utils/ClassUtils.java @@ -0,0 +1,154 @@ +package com.suneesh.trading.utils; + +import com.suneesh.trading.models.requests.ForgetAllResponse; +import com.suneesh.trading.models.requests.SellContractForMultipleAccountsRequest; +import com.suneesh.trading.models.responses.*; +import com.suneesh.trading.models.responses.*; + +import java.lang.reflect.Type; + +/** + * Created by morteza on 7/19/2017. + */ + +public class ClassUtils { + public static Type getClassType(String type){ + switch (type){ + case "tick": + return TickResponse.class; + case "authorize": + return AuthorizeResponse.class; + case "active_symbols": + return ActiveSymbolResponse.class; + case "asset_index": + return AssetIndexResponse.class; + case "contracts_for": + return ContractsForSymbolResponse.class; + case "forget": + return ForgetResponse.class; + case "forget_all": + return ForgetAllResponse.class; + case "landing_company": + return LandingCompanyResponse.class; + case "new_account_virtual": + return NewVirtualAccountResponse.class; + case "landing_company_details": + return LandingCompanyDetailsResponse.class; + case "ping": + return PingResponse.class; + case "paymentagent_list": + return PaymentAgentListResponse.class; + case "payout_currencies": + return PayoutCurrenciesResponse.class; + case "proposal": + return PriceProposalResponse.class; + case "residence_list": + return ResidenceListResponce.class; + case "states_list": + return StatesListResponse.class; + case "candles": + return TickHistoryResponse.class; + case "history": + return TickHistoryResponse.class; + case "time": + return TimeResponse.class; + case "trading_times": + return TradingTimesResponse.class; + case "verify_email": + return EmailVerificationResponse.class; + case "website_status": + return WebsiteStatusResponse.class; + // Read Scope + case "get_limits": + return AccountLimitsResponse.class; + case "get_settings": + return AccountSettingsResponse.class; + case "get_account_status": + return AccountStatusResponse.class; + case "balance": + return BalanceResponse.class; + case "get_self_exclusion": + return GetSelfExclusionResponse.class; + case "login_history": + return LoginHistoryResponse.class; + case "logout": + return LogoutResponse.class; + case "oauth_apps": + return OAuthApplicationResponse.class; + case "statement": + return StatementResponse.class; + case "portfolio": + return PortfolioResponse.class; + case "profit_table": + return ProfitTableResponse.class; + case "proposal_open_contract": + return ProposalOpenContractResponse.class; + case "reality_check": + return RealityCheckResponse.class; + case "transaction": + return TransactionsStreamResponse.class; + // Trade Scope + case "buy": + return BuyContractResponse.class; + case "buy_contract_for_multiple_accounts": + return BuyContractForMultipleAccountsResponse.class; + case "sell_contract_for_multiple_accounts": + return SellContractForMultipleAccountsRequest.class; + case "copy_start": + return StartCopyTradeResponse.class; + case "copy_stop": + return StopCopyTradeResponse.class; + case "sell": + return SellContractResponse.class; + case "sell_expired": + return SellExpiredContractsResponse.class; + case "topup_virtual": + return TopUpVirtualMoneyAccountResponse.class; + case "api_token": + return ApiTokenManagementResponse.class; + case "app_register": + return ApplicationRegistrationResponse.class; + case "app_delete": + return ApplicationDeletionResponse.class; + case "app_list": + return ApplicationListResponse.class; + case "app_get": + return ApplicationDetailsResponse.class; + case "app_update": + return ApplicationUpdateResponse.class; + case "get_financial_assessment": + return GetFinancialAssessmentResponse.class; + case "jp_knowledge_test": + return JapanKnowledgeTestResponse.class; + case "new_account_maltainvest": + return CreateMaltaAccountResponse.class; + case "new_account_real": + return CreateRealAccountResponse.class; + case "new_sub_account": + return CreateRealSubAccountResponse.class; + case "revoke_oauth_app": + return RevokeOauthApplicationResponse.class; + case "tnc_approval": + return TNCApprovalResponse.class; + case "set_account_currency": + return SetAccountCurrencyResponse.class; + case "set_financial_assessment": + return SetFinancialAssessmentResponse.class; + case "set_self_exclusion": + return SetSelfExclusionSettingsResponse.class; + case "set_settings": + return SetAccountSettingsResponse.class; + case "cashier": + return CashierURLResponse.class; + case "cashier_password": + return CashierPasswordResponse.class; + case "paymentagent_withdraw": + return PaymentAgentWithdrawalResponse.class; + case "paymentagent_transfer": + return PaymentAgentTransferResponse.class; + case "transfer_between_accounts": + return TransferBetweenAccountsResponse.class; + } + return null; + } +} diff --git a/Trading/src/main/java/com/suneesh/trading/utils/Validator.java b/Trading/src/main/java/com/suneesh/trading/utils/Validator.java new file mode 100644 index 0000000..e2b874a --- /dev/null +++ b/Trading/src/main/java/com/suneesh/trading/utils/Validator.java @@ -0,0 +1,14 @@ +package com.suneesh.trading.utils; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/1/2017 + */ +public class Validator { + public static void checkPattern(String pattern, String value, String message) { + if (!value.matches(pattern)) { + throw new IllegalArgumentException(message); + } + } +} diff --git a/Trading/src/main/resources/amount_result.sql b/Trading/src/main/resources/amount_result.sql new file mode 100644 index 0000000..46b371d --- /dev/null +++ b/Trading/src/main/resources/amount_result.sql @@ -0,0 +1,14 @@ +create table IF NOT EXISTS amount_result( +identifier bigserial, +test_run_id bigint, +strategy_id integer, +total_bid_amount bigint, +total_amount_won bigint, +net_amount_diff bigint, +total_trades integer, +total_successful_trades integer, +total_failed_trades integer, +max_steps integer, +max_failed_steps integer, +PRIMARY KEY(test_run_id, strategy_id) +); diff --git a/Trading/src/main/resources/application.properties b/Trading/src/main/resources/application.properties new file mode 100644 index 0000000..5009fc3 --- /dev/null +++ b/Trading/src/main/resources/application.properties @@ -0,0 +1,45 @@ +#----------------------------------------------------------------------------- +# Application Settings +#----------------------------------------------------------------------------- +ApplicationId=21829 +ApplicationAuthorizeToken=9s5aGYbnsUQr3Fv +ApplicationMode=Demo + +# Note I will Append ApplicationMode to "AccountCurrency" to get currency details. +LiveAccountCurrency=GBP +DemoAccountCurrency=USD + +#----------------------------------------------------------------------------- +# Database Settings +#----------------------------------------------------------------------------- +DatabaseServerEngine=Postgres +DatabaseName=automated_trading +# Docker Database URL +DatabaseURL=jdbc:postgresql://192.168.99.100:5432 +# Localhost Database URL +#DatabaseURL=jdbc:postgresql://localhost:5432 + +DatabaseUsername=suneesh +DatabasePassword=suneesh + +ListOfDatabaseTablesToCreate=amount_result, authorize, balance, bollinger_band, candle, error_table, open_contract, portfolio_transaction, strategy, strategy_algorithm, strategy_steps, tick, transaction, trade +ListOfDatabaseTablesToPopulate=strategy, strategy_steps, strategy_algorithm +DropDatabaseTables=true + +ListOfDatabaseTablesToDrop=ListOfMainApplicationTablesToDrop +#ListOfDatabaseTablesToDrop=ListOfBackTestingTablesToDrop + +ListOfMainApplicationTablesToDrop=amount_result, authorize, balance, bollinger_band, candle, error_table, open_contract, portfolio_transaction, strategy, strategy_algorithm, strategy_steps, tick, transaction, trade +ListOfBackTestingTablesToDrop=amount_result, candle, bollinger_band, trade + +#----------------------------------------------------------------------------- +# Backtesting Settings +#----------------------------------------------------------------------------- +BackTesting=false +BackTestingDatabaseName=backtesting_automated_trading + +#----------------------------------------------------------------------------- +# Websocket Settings +#----------------------------------------------------------------------------- +PingIntervalInSeconds=60 + diff --git a/Trading/src/main/resources/authorize.sql b/Trading/src/main/resources/authorize.sql new file mode 100644 index 0000000..5a42723 --- /dev/null +++ b/Trading/src/main/resources/authorize.sql @@ -0,0 +1,15 @@ +CREATE TABLE IF NOT EXISTS public.authorize +( + identifier BIGSERIAL, + allow_omnibus integer NOT NULL, + balance numeric(19,4), + country character varying(255) , + currency character varying(255) , + email character varying(255) , + full_name character varying(255) , + is_virtual integer NOT NULL, + landing_company_full_name character varying(255) , + landing_company_name character varying(255) , + login_id character varying(255) , + CONSTRAINT authorize_pkey PRIMARY KEY (identifier) +) diff --git a/Trading/src/main/resources/balance.sql b/Trading/src/main/resources/balance.sql new file mode 100644 index 0000000..28b3b25 --- /dev/null +++ b/Trading/src/main/resources/balance.sql @@ -0,0 +1,10 @@ +CREATE TABLE IF NOT EXISTS public.balance +( + identifier BIGSERIAL, + balance numeric(19,4), + currency character varying(255) , + login_id character varying(255) , + time bigint, + time_string timestamp, + CONSTRAINT balance_pkey PRIMARY KEY (identifier) +) diff --git a/Trading/src/main/resources/bollinger_band.sql b/Trading/src/main/resources/bollinger_band.sql new file mode 100644 index 0000000..8978831 --- /dev/null +++ b/Trading/src/main/resources/bollinger_band.sql @@ -0,0 +1,11 @@ +create table IF NOT EXISTS bollinger_band( + identifier bigserial, + average NUMERIC(19,4), + standard_deviation NUMERIC(19,4), + upper_band NUMERIC(19,4), + lower_band NUMERIC(19,4), + bandwidth NUMERIC(19,4), + candle_id bigint, + candle_epoch_string timestamp, + PRIMARY KEY(identifier) +); diff --git a/Trading/src/main/resources/candle.sql b/Trading/src/main/resources/candle.sql new file mode 100644 index 0000000..c925fe6 --- /dev/null +++ b/Trading/src/main/resources/candle.sql @@ -0,0 +1,15 @@ +CREATE TABLE IF NOT EXISTS public.candle +( + identifier BIGSERIAL, + close numeric(19,4), + epoch bigint, + high numeric(19,4), + low numeric(19,4), + open numeric(19,4), + granularity int, + symbol character varying(255) , + direction character varying(10) , + open_close_diff numeric(19,4), + epoch_string timestamp, + CONSTRAINT candle_pkey PRIMARY KEY (identifier) +) diff --git a/Trading/src/main/resources/commands.sql b/Trading/src/main/resources/commands.sql new file mode 100644 index 0000000..01d262d --- /dev/null +++ b/Trading/src/main/resources/commands.sql @@ -0,0 +1,12 @@ +select result, count(*) from trade group by result; + +create table amount_result( +strategy_id integer PRIMARY KEY, +total_bid_amount bigint, +total_amount_won bigint, +total_number_of_trades integer, +total_number_of_successful_trades integer, +total_number_of_failed_trades integer +); + +select * from amount_result; diff --git a/Trading/src/main/resources/error_table.sql b/Trading/src/main/resources/error_table.sql new file mode 100644 index 0000000..642ba04 --- /dev/null +++ b/Trading/src/main/resources/error_table.sql @@ -0,0 +1,9 @@ +CREATE TABLE IF NOT EXISTS error_table +( +identifier BIGSERIAL PRIMARY KEY, +error_message character varying(255) NOT NULL, +status character varying(255) NOT NULL, +creation_time timestamp NOT NULL, +fix_time timestamp +); + diff --git a/Trading/src/main/resources/log4j2.properties b/Trading/src/main/resources/log4j2.properties new file mode 100644 index 0000000..d4142ba --- /dev/null +++ b/Trading/src/main/resources/log4j2.properties @@ -0,0 +1,20 @@ +status = error +name = PropertiesConfig + +filters = threshold + +filter.threshold.type = ThresholdFilter +filter.threshold.level = info + +appenders = console + +appender.console.type = Console +appender.console.name = STDOUT +appender.console.layout.type = PatternLayout +#appender.console.layout.pattern = %d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n +#appender.file.layout.pattern=[%-5level] %d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %c{1} - %msg%n +appender.file.layout.pattern=%sn %d{yyyy/MM/dd HH:mm:ss,SSS} %r [%-6p] [%t] %c{3} %C{3}.%M(%F:%L) – %m%n + +rootLogger.level = info +rootLogger.appenderRefs = stdout +rootLogger.appenderRef.stdout.ref = STDOUT diff --git a/Trading/src/main/resources/open_contract.sql b/Trading/src/main/resources/open_contract.sql new file mode 100644 index 0000000..cdcaac8 --- /dev/null +++ b/Trading/src/main/resources/open_contract.sql @@ -0,0 +1,37 @@ + +create table IF NOT EXISTS open_contract( +identifier BIGSERIAL PRIMARY KEY, +barrier NUMERIC(19,4), +barrierCount INTEGER, +bidPrice NUMERIC(19,4), +buyPrice NUMERIC(19,4), +contractId BIGINT, +contractType character varying(255), +currency character varying(255), +currentSpot NUMERIC(19,4), +currentSpotTime BIGINT, +expiryDate BIGINT, +dateSetelment BIGINT, +dateStart BIGINT, +displayName character varying(255), +entryTick NUMERIC(19,4), +entryTickTime BIGINT, +exitTick NUMERIC(19,4), +exitTickTime BIGINT, +isExpired BOOLEAN, +isIntraday BOOLEAN, +isSettleable BOOLEAN, +isValidToSell BOOLEAN, +longCode character varying(255), +payout NUMERIC(19,4), +profit NUMERIC(19,4), +profit_percentage NUMERIC(19,4), +purchaseTime BIGINT, +sellPrice NUMERIC(19,4), +sellSpot NUMERIC(19,4), +sellSpotTime BIGINT, +sellTime BIGINT, +shortCode character varying(255), +status character varying(30), +validation_error character varying(255) +); diff --git a/Trading/src/main/resources/populate_strategy.sql b/Trading/src/main/resources/populate_strategy.sql new file mode 100644 index 0000000..e2d516f --- /dev/null +++ b/Trading/src/main/resources/populate_strategy.sql @@ -0,0 +1,17 @@ +DELETE FROM public.strategy WHERE identifier in ( 1,2,3 ,4 ); + +INSERT INTO public.strategy( identifier, strategy_name, strategy_algorithm_id, creation_date, max_steps, next_strategy_id_link, is_backtesting_strategy, is_default_strategy, reset_step_count_on_success, active_strategy) VALUES + (1, 'Multiple of 2.5 of last bid amount', 1, now(), 5, 2, FALSE, TRUE, TRUE, FALSE); +INSERT INTO public.strategy( identifier, strategy_name, strategy_algorithm_id, creation_date, max_steps, next_strategy_id_link, is_backtesting_strategy, is_default_strategy, reset_step_count_on_success, active_strategy) VALUES +(2, '2.5 Multiple Strategys 6th step amount divided in £10 Bid, and also recovering all the 10 - £1 bids', 2,now(), 11, 1, FALSE, FALSE, FALSE , FALSE); +INSERT INTO public.strategy( identifier, strategy_name, strategy_algorithm_id, creation_date, max_steps, next_strategy_id_link, is_backtesting_strategy, is_default_strategy, reset_step_count_on_success, active_strategy) VALUES +(3, 'Backtesting strategy 1', 4,now(), 10, 3, TRUE, FALSE, TRUE, TRUE); +INSERT INTO public.strategy( identifier, strategy_name, strategy_algorithm_id, creation_date, max_steps, next_strategy_id_link, is_backtesting_strategy, is_default_strategy, reset_step_count_on_success, active_strategy) VALUES +(4, 'Bollinger Band Strategy', 4, now(), 10, 4, FALSE, FALSE, TRUE, FALSE); +INSERT INTO public.strategy( identifier, strategy_name, strategy_algorithm_id, creation_date, max_steps, next_strategy_id_link, is_backtesting_strategy, is_default_strategy, reset_step_count_on_success, active_strategy) VALUES +(5, 'Close Price hitting High or Low Strategy', 3, now(), 10, 5, FALSE, FALSE, TRUE, FALSE); + + + + + diff --git a/Trading/src/main/resources/populate_strategy_algorithm.sql b/Trading/src/main/resources/populate_strategy_algorithm.sql new file mode 100644 index 0000000..9206914 --- /dev/null +++ b/Trading/src/main/resources/populate_strategy_algorithm.sql @@ -0,0 +1,6 @@ +insert into strategy_algorithm (identifier,algorithm_name) values ( 1, 'CandleFollowWithIncreaseStrategyImplementation' ); +insert into strategy_algorithm (identifier,algorithm_name) values ( 2, 'FixedAmountFixedCountNoResetStrategyImplementation'); +insert into strategy_algorithm (identifier,algorithm_name) values (3, 'ClosePriceHighLowStrategyImplementation'); +insert into strategy_algorithm (identifier,algorithm_name) values (4, 'BollingerStrategyImplementation'); + + diff --git a/Trading/src/main/resources/populate_strategy_steps.sql b/Trading/src/main/resources/populate_strategy_steps.sql new file mode 100644 index 0000000..982cfe2 --- /dev/null +++ b/Trading/src/main/resources/populate_strategy_steps.sql @@ -0,0 +1,53 @@ +DELETE FROM public.strategy_steps WHERE strategy_id in ( 1,2,3); + +INSERT INTO public.strategy_steps(strategy_id, step_count, value) VALUES (1, 1, 1.00); +INSERT INTO public.strategy_steps(strategy_id, step_count, value) VALUES (1, 2, 2.50); +INSERT INTO public.strategy_steps(strategy_id, step_count, value) VALUES (1, 3, 6.25); +INSERT INTO public.strategy_steps(strategy_id, step_count, value) VALUES (1, 4, 15.63); +INSERT INTO public.strategy_steps(strategy_id, step_count, value) VALUES (1, 5, 39.07); + +INSERT INTO public.strategy_steps(strategy_id, step_count, value) VALUES (2, 1, 10.00); +INSERT INTO public.strategy_steps(strategy_id, step_count, value) VALUES (2, 2, 10.00); +INSERT INTO public.strategy_steps(strategy_id, step_count, value) VALUES (2, 3, 10.00); +INSERT INTO public.strategy_steps(strategy_id, step_count, value) VALUES (2, 4, 10.00); +INSERT INTO public.strategy_steps(strategy_id, step_count, value) VALUES (2, 5, 10.00); +INSERT INTO public.strategy_steps(strategy_id, step_count, value) VALUES (2, 6, 10.00); +INSERT INTO public.strategy_steps(strategy_id, step_count, value) VALUES (2, 7, 10.00); +INSERT INTO public.strategy_steps(strategy_id, step_count, value) VALUES (2, 8, 10.00); +INSERT INTO public.strategy_steps(strategy_id, step_count, value) VALUES (2, 9, 10.00); +INSERT INTO public.strategy_steps(strategy_id, step_count, value) VALUES (2, 10, 10.00); +INSERT INTO public.strategy_steps(strategy_id, step_count, value) VALUES (2, 11, 10.00); + +INSERT INTO public.strategy_steps(strategy_id, step_count, value) VALUES (3, 1, 1.00); +INSERT INTO public.strategy_steps(strategy_id, step_count, value, profit_percentage_threshold) VALUES (3, 2, 2.50, 80); +INSERT INTO public.strategy_steps(strategy_id, step_count, value, profit_percentage_threshold) VALUES (3, 3, 6.25, 70); +INSERT INTO public.strategy_steps(strategy_id, step_count, value, profit_percentage_threshold) VALUES (3, 4, 15.63, 70); +INSERT INTO public.strategy_steps(strategy_id, step_count, value, profit_percentage_threshold) VALUES (3, 5, 39.07, 70); +INSERT INTO public.strategy_steps(strategy_id, step_count, value, profit_percentage_threshold) VALUES (3, 6, 97.66, 60); +INSERT INTO public.strategy_steps(strategy_id, step_count, value, profit_percentage_threshold) VALUES (3, 7, 244.14, 60); +INSERT INTO public.strategy_steps(strategy_id, step_count, value, profit_percentage_threshold) VALUES (3, 8, 610.35, 60); +INSERT INTO public.strategy_steps(strategy_id, step_count, value, profit_percentage_threshold) VALUES (3, 9, 1525.88, 60); +INSERT INTO public.strategy_steps(strategy_id, step_count, value, profit_percentage_threshold) VALUES (3, 10, 3814.70, 60); + +INSERT INTO public.strategy_steps(strategy_id, step_count, value) VALUES (4, 1, 1.00); +INSERT INTO public.strategy_steps(strategy_id, step_count, value) VALUES (4, 2, 2.50); +INSERT INTO public.strategy_steps(strategy_id, step_count, value) VALUES (4, 3, 6.25); +INSERT INTO public.strategy_steps(strategy_id, step_count, value) VALUES (4, 4, 15.63); +INSERT INTO public.strategy_steps(strategy_id, step_count, value) VALUES (4, 5, 39.07); +INSERT INTO public.strategy_steps(strategy_id, step_count, value) VALUES (4, 6, 97.66); +INSERT INTO public.strategy_steps(strategy_id, step_count, value) VALUES (4, 7, 244.14); +INSERT INTO public.strategy_steps(strategy_id, step_count, value) VALUES (4, 8, 610.35); +INSERT INTO public.strategy_steps(strategy_id, step_count, value) VALUES (4, 9, 1525.88); +INSERT INTO public.strategy_steps(strategy_id, step_count, value) VALUES (4, 10, 3814.70); + +INSERT INTO public.strategy_steps(strategy_id, step_count, value) VALUES (5, 1, 1.00); +INSERT INTO public.strategy_steps(strategy_id, step_count, value) VALUES (5, 2, 2.50); +INSERT INTO public.strategy_steps(strategy_id, step_count, value) VALUES (5, 3, 6.25); +INSERT INTO public.strategy_steps(strategy_id, step_count, value) VALUES (5, 4, 15.63); +INSERT INTO public.strategy_steps(strategy_id, step_count, value) VALUES (5, 5, 39.07); +INSERT INTO public.strategy_steps(strategy_id, step_count, value) VALUES (5, 6, 97.66); +INSERT INTO public.strategy_steps(strategy_id, step_count, value) VALUES (5, 7, 244.14); +INSERT INTO public.strategy_steps(strategy_id, step_count, value) VALUES (5, 8, 610.35); +INSERT INTO public.strategy_steps(strategy_id, step_count, value) VALUES (5, 9, 1525.88); +INSERT INTO public.strategy_steps(strategy_id, step_count, value) VALUES (5, 10, 3814.70); + diff --git a/Trading/src/main/resources/portfolio_transaction.sql b/Trading/src/main/resources/portfolio_transaction.sql new file mode 100644 index 0000000..84a72a9 --- /dev/null +++ b/Trading/src/main/resources/portfolio_transaction.sql @@ -0,0 +1,22 @@ +CREATE TABLE IF NOT EXISTS public.portfolio_transaction +( + identifier BIGSERIAL, + app_id integer, + buy_price numeric(19,4), + contract_id bigint, + contract_type character varying(255) , + currency character varying(255) , + date_start bigint NOT NULL, + expiry_time bigint NOT NULL, + purchase_time bigint NOT NULL, + long_code character varying(255) , + short_code character varying(255) , + payout numeric(19,4), + symbol character varying(255) , + transaction_id bigint, + date_start_string timestamp, + expiry_time_string timestamp, + purchase_time_string timestamp, + CONSTRAINT portfolio_transaction_pkey PRIMARY KEY (identifier) +) + diff --git a/Trading/src/main/resources/strategy.sql b/Trading/src/main/resources/strategy.sql new file mode 100644 index 0000000..bc38a65 --- /dev/null +++ b/Trading/src/main/resources/strategy.sql @@ -0,0 +1,18 @@ +CREATE TABLE IF NOT EXISTS public.strategy +( + identifier SERIAL, + strategy_name character varying(255) , + max_steps INTEGER NOT NULL, + next_strategy_id_link INTEGER, + active_strategy boolean, + is_default_strategy boolean, + is_backtesting_strategy boolean, + reset_step_count_on_success boolean, + strategy_algorithm_id bigint , + creation_date timestamp NOT NULL, + CONSTRAINT strategy_pkey PRIMARY KEY (identifier) +) + +--Helpful Query +--select * From strategy_steps ss join strategy s on ( ss.strategy_id = s.identifier) + diff --git a/Trading/src/main/resources/strategy_algorithm.sql b/Trading/src/main/resources/strategy_algorithm.sql new file mode 100644 index 0000000..e38d266 --- /dev/null +++ b/Trading/src/main/resources/strategy_algorithm.sql @@ -0,0 +1,6 @@ +create table IF NOT EXISTS strategy_algorithm( +identifier bigserial PRIMARY KEY, +algorithm_name character varying(255) +); + + diff --git a/Trading/src/main/resources/strategy_steps.sql b/Trading/src/main/resources/strategy_steps.sql new file mode 100644 index 0000000..8ec51f2 --- /dev/null +++ b/Trading/src/main/resources/strategy_steps.sql @@ -0,0 +1,10 @@ +CREATE TABLE IF NOT EXISTS public.strategy_steps +( + identifier SERIAL, + strategy_id INTEGER NOT NULL, + step_count integer NOT NULL, + value numeric(19,4) NOT NULL, + profit_percentage_threshold NUMERIC(10,2) NOT NULL DEFAULT 95.00, + CONSTRAINT strategy_steps_pkey PRIMARY KEY (identifier) +); + diff --git a/Trading/src/main/resources/tick.sql b/Trading/src/main/resources/tick.sql new file mode 100644 index 0000000..684965f --- /dev/null +++ b/Trading/src/main/resources/tick.sql @@ -0,0 +1,13 @@ +CREATE TABLE IF NOT EXISTS public.tick +( + identifier BIGSERIAL , + ask numeric(19,4) , + bid numeric(19,4) , + epoch bigint , + quote numeric(19,4) , + symbol character varying(255) , + epoch_string timestamp, + CONSTRAINT tick_pkey PRIMARY KEY (identifier) +) + + diff --git a/Trading/src/main/resources/trade.sql b/Trading/src/main/resources/trade.sql new file mode 100644 index 0000000..236e979 --- /dev/null +++ b/Trading/src/main/resources/trade.sql @@ -0,0 +1,18 @@ +CREATE TABLE IF NOT EXISTS public.trade +( + identifier BIGSERIAL, + trade_time_string timestamp, + strike_price numeric(19,4), + result character varying(30) , + bid_amount numeric(19,4) NOT NULL, + amount_won numeric(19,4) NOT NULL, + call_or_put character varying(30) , + symbol character varying(255) , + step_count integer NOT NULL, + strategy_id int NOT NULL, + contract_id bigint, + trade_time bigint, + close_type character varying(255) , + CONSTRAINT trade_pkey PRIMARY KEY (identifier) +); + diff --git a/Trading/src/main/resources/transaction.sql b/Trading/src/main/resources/transaction.sql new file mode 100644 index 0000000..38b0293 --- /dev/null +++ b/Trading/src/main/resources/transaction.sql @@ -0,0 +1,22 @@ +CREATE TABLE IF NOT EXISTS public.transaction +( + identifier BIGSERIAL, + action character varying(255) , + amount numeric(19,4), + balance numeric(19,4), + barrier character varying(255) , + contract_id bigint, + currency character varying(255) , + date_expiry bigint, + purchase_time bigint, + transaction_time bigint, + display_name character varying(255) , + long_code character varying(255) , + symbol character varying(255) , + transaction_id bigint, + date_expiry_string timestamp, + purchase_time_string timestamp, + transaction_time_string timestamp, + CONSTRAINT transaction_pkey PRIMARY KEY (identifier) +) + diff --git a/Trading/src/test/java/com/suneesh/trading/AccountLimitsTest.java b/Trading/src/test/java/com/suneesh/trading/AccountLimitsTest.java new file mode 100644 index 0000000..b311498 --- /dev/null +++ b/Trading/src/test/java/com/suneesh/trading/AccountLimitsTest.java @@ -0,0 +1,55 @@ +package com.suneesh.trading; + +import com.suneesh.trading.core.ApiWrapper; +import com.suneesh.trading.models.requests.AccountLimitsRequest; +import com.suneesh.trading.models.requests.AuthorizeRequest; +import com.suneesh.trading.models.responses.AccountLimitsResponse; +import com.suneesh.trading.models.responses.ResponseBase; +import io.reactivex.observers.TestObserver; +import org.junit.Before; +import org.junit.Test; + +import java.util.Properties; +import java.util.concurrent.TimeUnit; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/4/2017 + */ +public class AccountLimitsTest { + private ApiWrapper api; + private Properties properties; + @Before + public void setup() throws Exception{ + TestUtility testUtility = new TestUtility(); + this.properties = testUtility.getProperties(); + this.api = testUtility.getApi(); + } + + @Test + public void getAccountLimitsTest() throws Exception { + AccountLimitsRequest request = new AccountLimitsRequest(); + AuthorizeRequest authorizeRequest = new AuthorizeRequest(properties.getProperty("CR_READ"), false); + TestObserver testObserver = new TestObserver<>(); + + this.api.sendRequest(authorizeRequest) + .subscribe(); + testObserver.await(5, TimeUnit.SECONDS); + + this.api.sendRequest(request) + .subscribe(testObserver); + + testObserver.await(10, TimeUnit.SECONDS); + + AccountLimitsResponse response = (AccountLimitsResponse) testObserver.values().get(0); + + assertEquals(response.getType(), "get_limits"); + assertEquals(response.getError(), null); + assertNotEquals(response.getLimits(), null); + + } +} diff --git a/Trading/src/test/java/com/suneesh/trading/AccountSettingsTest.java b/Trading/src/test/java/com/suneesh/trading/AccountSettingsTest.java new file mode 100644 index 0000000..49f86b0 --- /dev/null +++ b/Trading/src/test/java/com/suneesh/trading/AccountSettingsTest.java @@ -0,0 +1,57 @@ +package com.suneesh.trading; + +import com.suneesh.trading.core.ApiWrapper; +import com.suneesh.trading.models.requests.AccountSettingsRequest; +import com.suneesh.trading.models.requests.AuthorizeRequest; +import com.suneesh.trading.models.responses.AccountSettingsResponse; +import com.suneesh.trading.models.responses.AuthorizeResponse; +import com.suneesh.trading.models.responses.ResponseBase; +import io.reactivex.observers.TestObserver; +import org.junit.Before; +import org.junit.Test; + +import java.util.Properties; +import java.util.concurrent.TimeUnit; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/4/2017 + */ +public class AccountSettingsTest { + private ApiWrapper api; + private Properties properties; + + @Before + public void setUp() throws Exception { + TestUtility testUtility = new TestUtility(); + this.api = testUtility.getApi(); + this.properties = testUtility.getProperties(); + } + + @Test + public void getAccountSettingsTest() throws Exception { + AccountSettingsRequest request = new AccountSettingsRequest(); + AuthorizeRequest authorizeRequest = new AuthorizeRequest(properties.getProperty("CR_READ"), false); + TestObserver testObserver = new TestObserver<>(); + + this.api.sendRequest(authorizeRequest) + .subscribe(o -> { + AuthorizeResponse auth = (AuthorizeResponse) o; + assertNotEquals(auth.getAuthorize(), null); + + this.api.sendRequest(request) + .subscribe(testObserver); + }); + + testObserver.await(10, TimeUnit.SECONDS); + + AccountSettingsResponse response = (AccountSettingsResponse) testObserver.values().get(0); + assertEquals(response.getType(), "get_settings"); + assertEquals(response.getError(), null); + assertNotEquals(response.getSettings(), null); + } +} diff --git a/Trading/src/test/java/com/suneesh/trading/AccountStatusTest.java b/Trading/src/test/java/com/suneesh/trading/AccountStatusTest.java new file mode 100644 index 0000000..34d3228 --- /dev/null +++ b/Trading/src/test/java/com/suneesh/trading/AccountStatusTest.java @@ -0,0 +1,60 @@ +package com.suneesh.trading; + +import com.suneesh.trading.core.ApiWrapper; +import com.suneesh.trading.models.requests.AccountStatusRequest; +import com.suneesh.trading.models.requests.AuthorizeRequest; +import com.suneesh.trading.models.responses.AccountStatusResponse; +import com.suneesh.trading.models.responses.AuthorizeResponse; +import com.suneesh.trading.models.responses.ResponseBase; +import io.reactivex.observers.TestObserver; +import org.junit.Before; +import org.junit.Test; + +import java.util.Properties; +import java.util.concurrent.TimeUnit; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/4/2017 + */ +public class AccountStatusTest { + private ApiWrapper api; + private Properties properties; + + @Before + public void setUp() throws Exception { + TestUtility testUtility = new TestUtility(); + this.api = testUtility.getApi(); + this.properties = testUtility.getProperties(); + } + + @Test + public void getAccountStatusTest() throws Exception { + AuthorizeRequest authorizeRequest = new AuthorizeRequest(properties.getProperty("CR_READ"), false); + AccountStatusRequest request = new AccountStatusRequest(); + TestObserver testObserver = new TestObserver<>(); + + this.api.sendRequest(authorizeRequest) + .subscribe(o -> { + AuthorizeResponse auth = (AuthorizeResponse) o; + assertNotEquals(auth.getAuthorize(), null); + + this.api.sendRequest(request) + .subscribe(testObserver); + }); + + testObserver.await(5, TimeUnit.SECONDS); + + AccountStatusResponse response = (AccountStatusResponse) testObserver.values().get(0); + + assertEquals(response.getType(), "get_account_status"); + assertEquals(response.getError(), null); + assertNotEquals(response.getAccountStatus(), null); + } + + +} diff --git a/Trading/src/test/java/com/suneesh/trading/ActiveSymbolTest.java b/Trading/src/test/java/com/suneesh/trading/ActiveSymbolTest.java new file mode 100644 index 0000000..82fa5a3 --- /dev/null +++ b/Trading/src/test/java/com/suneesh/trading/ActiveSymbolTest.java @@ -0,0 +1,45 @@ +package com.suneesh.trading; + +import com.suneesh.trading.core.ApiWrapper; +import com.suneesh.trading.models.requests.ActiveSymbolRequest; +import com.suneesh.trading.models.responses.ActiveSymbolResponse; +import com.suneesh.trading.models.responses.ResponseBase; +import io.reactivex.observers.TestObserver; +import org.junit.Before; +import org.junit.Test; + +import java.util.concurrent.TimeUnit; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 7/31/2017 + */ +public class ActiveSymbolTest { + private ApiWrapper api; + @Before + public void setup() throws Exception{ + this.api = ApiWrapper.build("10"); + } + + @Test + public void getActiveSymbolTest() throws Exception { + ActiveSymbolRequest request = new ActiveSymbolRequest(); + TestObserver testObserver = new TestObserver<>(); + + this.api.sendRequest(request) + .subscribe(testObserver); + + testObserver + .await(10, TimeUnit.SECONDS); + + ActiveSymbolResponse response = (ActiveSymbolResponse) testObserver.values().get(0); + + assertEquals(response.getType(), "active_symbols"); + assertNotEquals(response.getActiveSymbols(), null); + + } +} diff --git a/Trading/src/test/java/com/suneesh/trading/ApiTokenManagementTest.java b/Trading/src/test/java/com/suneesh/trading/ApiTokenManagementTest.java new file mode 100644 index 0000000..b4e2a16 --- /dev/null +++ b/Trading/src/test/java/com/suneesh/trading/ApiTokenManagementTest.java @@ -0,0 +1,47 @@ +package com.suneesh.trading; + +import com.suneesh.trading.models.requests.ApiTokenManagementRequest; +import com.suneesh.trading.models.requests.AuthorizeRequest; +import com.suneesh.trading.models.responses.ApiTokenManagementResponse; +import com.suneesh.trading.models.responses.AuthorizeResponse; +import com.suneesh.trading.models.responses.ResponseBase; +import io.reactivex.observers.TestObserver; +import org.junit.Test; + +import java.util.concurrent.TimeUnit; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertTrue; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/9/2017 + */ +public class ApiTokenManagementTest extends TestBase { + + @Test + public void getTokensTest() throws Exception { + AuthorizeRequest authRequest = new AuthorizeRequest(properties.getProperty("VRTC_ADMIN")); + ApiTokenManagementRequest request = new ApiTokenManagementRequest(); + TestObserver testObserver = new TestObserver<>(); + + this.api.sendRequest(authRequest) + .subscribe( o -> { + AuthorizeResponse auth = (AuthorizeResponse) o; + assertNotEquals(auth.getAuthorize(), null); + + this.api.sendRequest(request) + .subscribe(testObserver); + }); + + testObserver.await(5, TimeUnit.SECONDS); + + ApiTokenManagementResponse response = (ApiTokenManagementResponse) testObserver.values().get(0); + + assertEquals(response.getType(), "api_token"); + assertEquals(response.getError(), null); + assertTrue(response.getApiTokenResult().getTokens().size() > 0); + } +} diff --git a/Trading/src/test/java/com/suneesh/trading/AssetIndexTest.java b/Trading/src/test/java/com/suneesh/trading/AssetIndexTest.java new file mode 100644 index 0000000..3e10525 --- /dev/null +++ b/Trading/src/test/java/com/suneesh/trading/AssetIndexTest.java @@ -0,0 +1,43 @@ +package com.suneesh.trading; + +import com.suneesh.trading.core.ApiWrapper; +import com.suneesh.trading.models.requests.AssetIndexRequest; +import com.suneesh.trading.models.responses.AssetIndexResponse; +import com.suneesh.trading.models.responses.ResponseBase; +import io.reactivex.observers.TestObserver; +import org.junit.Before; +import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; + +import java.util.concurrent.TimeUnit; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 7/31/2017 + */ +public class AssetIndexTest { + private ApiWrapper api; + @Before + public void setup() throws Exception{ + this.api = ApiWrapper.build("10"); + } + + @Test + public void getAssetIndexTest() throws Exception{ + AssetIndexRequest request = new AssetIndexRequest(); + TestObserver testObserver = new TestObserver<>(); + + this.api.sendRequest(request) + .subscribe(testObserver); + + testObserver.await(10, TimeUnit.SECONDS); + + AssetIndexResponse response = (AssetIndexResponse) testObserver.values().get(0); + + assertEquals(response.getType(), "asset_index"); + assertNotEquals(response.getAssetIndex(), null); + + } +} diff --git a/Trading/src/test/java/com/suneesh/trading/AuthorizeTest.java b/Trading/src/test/java/com/suneesh/trading/AuthorizeTest.java new file mode 100644 index 0000000..d216cb4 --- /dev/null +++ b/Trading/src/test/java/com/suneesh/trading/AuthorizeTest.java @@ -0,0 +1,74 @@ +package com.suneesh.trading; + +import com.suneesh.trading.core.ApiWrapper; +import com.suneesh.trading.models.requests.AuthorizeRequest; +import com.suneesh.trading.models.responses.AuthorizeResponse; +import com.suneesh.trading.models.responses.ResponseBase; +import io.reactivex.observers.TestObserver; +import org.junit.Before; +import org.junit.Test; + +import java.io.IOException; +import java.io.InputStream; +import java.util.Properties; +import java.util.concurrent.TimeUnit; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; + +/** + * Created by morteza on 7/28/2017. + */ +public class AuthorizeTest { + private ApiWrapper api; + private Properties properties; + @Before + public void setup() throws Exception{ + this.properties = new Properties(); + InputStream inputStream = ClassLoader.getSystemResourceAsStream("TestEnvironment.properties"); + try{ + properties.load(inputStream); + this.api = ApiWrapper.build("10"); + } + catch (IOException ex){ + throw ex; + } + + + } + + @Test + public void validAuthorizeTest() throws Exception{ + AuthorizeRequest request = new AuthorizeRequest(properties.getProperty("CR_READ"), false); + TestObserver testObserver = new TestObserver<>(); + + this.api.sendRequest(request) + .subscribe(testObserver); + + testObserver + .await(10, TimeUnit.SECONDS); + + AuthorizeResponse response = (AuthorizeResponse) testObserver.values().get(0); + assertEquals(response.getType(), "authorize"); + assertNotEquals(response.getAuthorize(), null); + } + + @Test + public void invalidAuthorizeTest() throws Exception { + AuthorizeRequest request = new AuthorizeRequest("a1-xxxxxxxxxxxxxxxxxxxxxxxxxxxxx", false); + TestObserver testObserver = new TestObserver<>(); + + this.api.sendRequest(request) + .subscribe(testObserver); + + testObserver + .await(10, TimeUnit.SECONDS); + + AuthorizeResponse response = (AuthorizeResponse) testObserver.values().get(0); + assertEquals(response.getType(), "authorize"); + assertEquals(response.getAuthorize(), null); + assertNotEquals(response.getError(), null); + } + + +} diff --git a/Trading/src/test/java/com/suneesh/trading/BalanceTest.java b/Trading/src/test/java/com/suneesh/trading/BalanceTest.java new file mode 100644 index 0000000..692bb67 --- /dev/null +++ b/Trading/src/test/java/com/suneesh/trading/BalanceTest.java @@ -0,0 +1,58 @@ +package com.suneesh.trading; + +import com.suneesh.trading.core.ApiWrapper; +import com.suneesh.trading.models.requests.AuthorizeRequest; +import com.suneesh.trading.models.requests.BalanceRequest; +import com.suneesh.trading.models.responses.AuthorizeResponse; +import com.suneesh.trading.models.responses.BalanceResponse; +import com.suneesh.trading.models.responses.ResponseBase; +import io.reactivex.observers.TestObserver; +import org.junit.Before; +import org.junit.Test; + +import java.util.Properties; +import java.util.concurrent.TimeUnit; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/4/2017 + */ +public class BalanceTest { + private ApiWrapper api; + private Properties properties; + + @Before + public void setUp() throws Exception { + TestUtility testUtility = new TestUtility(); + this.api = testUtility.getApi(); + this.properties = testUtility.getProperties(); + } + + @Test + public void getBalanceTest() throws Exception { + AuthorizeRequest authRequest = new AuthorizeRequest(properties.getProperty("CR_READ"), false); + BalanceRequest request = new BalanceRequest(); + TestObserver testObserver = new TestObserver<>(); + + this.api.sendRequest(authRequest) + .subscribe(o -> { + AuthorizeResponse auth = (AuthorizeResponse) o; + assertNotEquals(auth.getAuthorize(), null); + + this.api.sendRequest(request) + .subscribe(testObserver); + }); + + testObserver.await(5, TimeUnit.SECONDS); + + BalanceResponse response = (BalanceResponse) testObserver.values().get(0); + + assertEquals(response.getType(), "balance"); + assertEquals(response.getError(), null); + assertNotEquals(response.getBalance(), null); + } +} diff --git a/Trading/src/test/java/com/suneesh/trading/BuyContractTest.java b/Trading/src/test/java/com/suneesh/trading/BuyContractTest.java new file mode 100644 index 0000000..d68a028 --- /dev/null +++ b/Trading/src/test/java/com/suneesh/trading/BuyContractTest.java @@ -0,0 +1,106 @@ +package com.suneesh.trading; + +import com.suneesh.trading.models.requests.AuthorizeRequest; +import com.suneesh.trading.models.requests.BuyContractForMultipleAccountsRequest; +import com.suneesh.trading.models.requests.BuyContractParameters; +import com.suneesh.trading.models.requests.BuyContractRequest; +import com.suneesh.trading.models.responses.AuthorizeResponse; +import com.suneesh.trading.models.responses.BuyContractForMultipleAccountsResponse; +import com.suneesh.trading.models.responses.BuyContractResponse; +import com.suneesh.trading.models.responses.ResponseBase; +import com.google.gson.Gson; +import io.reactivex.observers.TestObserver; +import org.junit.Test; + +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.TimeUnit; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertTrue; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/8/2017 + */ +public class BuyContractTest extends TestBase { + + @Test + public void buyContractTest() throws Exception { + + AuthorizeRequest authRequest = new AuthorizeRequest(properties.getProperty("VRTC_TRADE")); + BuyContractRequest request = new BuyContractRequest(new BigDecimal("0.35"), getParameters()); + TestObserver testObserver = new TestObserver<>(); + + this.api.sendRequest(authRequest) + .subscribe( o -> { + AuthorizeResponse auth = (AuthorizeResponse) o; + assertNotEquals(auth.getAuthorize(), null); + + this.api.sendRequest(request) + .subscribe(testObserver); + }); + + testObserver.await(5, TimeUnit.SECONDS); + + BuyContractResponse response = (BuyContractResponse) testObserver.values().get(0); + + assertEquals(response.getType(), "buy"); + assertEquals(response.getError(), null); + assertNotEquals(response.getBuyReceipt(), null); + assertEquals(response.getBuyReceipt().getBuyPrice(), request.getPrice()); + } + + @Test + public void buyContractForMultipleAccountsTest() throws Exception { + + AuthorizeRequest authRequest = new AuthorizeRequest(properties.getProperty("VRTC_TRADE")); + + List tokens = new ArrayList<>(); + tokens.add(properties.getProperty("VRTC_TRADE")); + BuyContractForMultipleAccountsRequest request = new BuyContractForMultipleAccountsRequest( + new BigDecimal("0.35"), getParameters(), + tokens); + + TestObserver testObserver = new TestObserver<>(); + + this.api.sendRequest(authRequest) + .subscribe( o -> { + AuthorizeResponse auth = (AuthorizeResponse) o; + assertNotEquals(auth.getAuthorize(), null); + + this.api.sendRequest(request) + .subscribe(testObserver); + }); + + testObserver.await(5, TimeUnit.SECONDS); + + BuyContractForMultipleAccountsResponse response = + (BuyContractForMultipleAccountsResponse) testObserver.values().get(0); + + assertEquals(response.getType(), "buy_contract_for_multiple_accounts"); + assertEquals(response.getError(), null); + assertNotEquals(response.getMassBuyContractResult(), null); + assertTrue(response.getMassBuyContractResult().getResult().size() > 0); + } + + + + private BuyContractParameters getParameters() { + String json = "{\n" + + " \"amount\": \"0.35\",\n" + + " \"basis\": \"stake\",\n" + + " \"contract_type\": \"CALL\",\n" + + " \"currency\": \"USD\",\n" + + " \"duration\": \"5\",\n" + + " \"duration_unit\": \"t\",\n" + + " \"symbol\": \"R_100\"\n" + + "}"; + + Gson gson = new Gson(); + return gson.fromJson(json, BuyContractParameters.class); + } +} diff --git a/Trading/src/test/java/com/suneesh/trading/CashierPasswordTest.java b/Trading/src/test/java/com/suneesh/trading/CashierPasswordTest.java new file mode 100644 index 0000000..88406d8 --- /dev/null +++ b/Trading/src/test/java/com/suneesh/trading/CashierPasswordTest.java @@ -0,0 +1,46 @@ +package com.suneesh.trading; + +import com.suneesh.trading.models.requests.AuthorizeRequest; +import com.suneesh.trading.models.requests.CashierPasswordRequest; +import com.suneesh.trading.models.responses.AuthorizeResponse; +import com.suneesh.trading.models.responses.CashierPasswordResponse; +import com.suneesh.trading.models.responses.ResponseBase; +import io.reactivex.observers.TestObserver; +import org.junit.Test; + +import java.util.concurrent.TimeUnit; + +import static org.junit.Assert.*; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 9/14/2017 + */ +public class CashierPasswordTest extends TestBase { + + @Test + public void cashierPasswordTest() throws Exception { + + AuthorizeRequest authRequest = new AuthorizeRequest(properties.getProperty("CR_PAYMENTS")); + CashierPasswordRequest request = new CashierPasswordRequest(); + TestObserver testObserver = new TestObserver<>(); + + this.api.sendRequest(authRequest) + .subscribe( o -> { + AuthorizeResponse auth = (AuthorizeResponse) o; + assertNotEquals(auth.getAuthorize(), null); + + this.api.sendRequest(request) + .subscribe(testObserver); + }); + + testObserver.await(10, TimeUnit.SECONDS); + + CashierPasswordResponse response = (CashierPasswordResponse) testObserver.values().get(0); + + assertEquals(response.getType(), "cashier_password"); + assertEquals(response.getError(), null); + assertFalse(response.isLock()); + } +} diff --git a/Trading/src/test/java/com/suneesh/trading/CashierURLTest.java b/Trading/src/test/java/com/suneesh/trading/CashierURLTest.java new file mode 100644 index 0000000..c3db2a8 --- /dev/null +++ b/Trading/src/test/java/com/suneesh/trading/CashierURLTest.java @@ -0,0 +1,48 @@ +package com.suneesh.trading; + +import com.suneesh.trading.models.enums.CashierTypes; +import com.suneesh.trading.models.requests.AuthorizeRequest; +import com.suneesh.trading.models.requests.CashierURLRequest; +import com.suneesh.trading.models.responses.AuthorizeResponse; +import com.suneesh.trading.models.responses.CashierURLResponse; +import com.suneesh.trading.models.responses.ResponseBase; +import io.reactivex.observers.TestObserver; +import org.junit.Test; + +import java.util.concurrent.TimeUnit; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 9/14/2017 + */ +public class CashierURLTest extends TestBase { + + @Test + public void getCashierURLTest() throws Exception { + + AuthorizeRequest authRequest = new AuthorizeRequest(properties.getProperty("CR_PAYMENTS")); + CashierURLRequest request = new CashierURLRequest(CashierTypes.DEPOSIT); + TestObserver testObserver = new TestObserver<>(); + + this.api.sendRequest(authRequest) + .subscribe( o -> { + AuthorizeResponse auth = (AuthorizeResponse) o; + assertNotEquals(auth.getAuthorize(), null); + + this.api.sendRequest(request) + .subscribe(testObserver); + }); + + testObserver.await(10, TimeUnit.SECONDS); + + CashierURLResponse response = (CashierURLResponse) testObserver.values().get(0); + + assertEquals(response.getType(), "cashier"); + assertEquals(response.getError(), null); + assertNotEquals(response.getCashierURL(), null); + } +} diff --git a/Trading/src/test/java/com/suneesh/trading/ContractForSymbolTest.java b/Trading/src/test/java/com/suneesh/trading/ContractForSymbolTest.java new file mode 100644 index 0000000..e3fad3e --- /dev/null +++ b/Trading/src/test/java/com/suneesh/trading/ContractForSymbolTest.java @@ -0,0 +1,43 @@ +package com.suneesh.trading; + +import com.suneesh.trading.core.ApiWrapper; +import com.suneesh.trading.models.requests.ContractsForSymbolRequest; +import com.suneesh.trading.models.responses.ContractsForSymbolResponse; +import com.suneesh.trading.models.responses.ResponseBase; +import io.reactivex.observers.TestObserver; +import org.junit.Before; +import org.junit.Test; + +import static org.junit.Assert.*; + +import java.util.concurrent.TimeUnit; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/1/2017 + */ +public class ContractForSymbolTest { + private ApiWrapper api; + @Before + public void setup() throws Exception{ + this.api = ApiWrapper.build("10"); + } + + @Test + public void getContractForR_50() throws Exception { + ContractsForSymbolRequest request = new ContractsForSymbolRequest("R_50"); + TestObserver testObserver = new TestObserver<>(); + + this.api.sendRequest(request) + .subscribe(testObserver); + + testObserver.await(10, TimeUnit.SECONDS); + + ContractsForSymbolResponse response = (ContractsForSymbolResponse) testObserver.values().get(0); + + assertEquals(response.getType(), "contracts_for"); + assertNotEquals(response.getContractsFor().getAvailable(), null); + + } +} diff --git a/Trading/src/test/java/com/suneesh/trading/CopyTradeTest.java b/Trading/src/test/java/com/suneesh/trading/CopyTradeTest.java new file mode 100644 index 0000000..390b153 --- /dev/null +++ b/Trading/src/test/java/com/suneesh/trading/CopyTradeTest.java @@ -0,0 +1,72 @@ +package com.suneesh.trading; + +import com.suneesh.trading.models.requests.AuthorizeRequest; +import com.suneesh.trading.models.requests.StartCopyTradeRequest; +import com.suneesh.trading.models.requests.StopCopyTradeRequest; +import com.suneesh.trading.models.responses.AuthorizeResponse; +import com.suneesh.trading.models.responses.ResponseBase; +import com.suneesh.trading.models.responses.StartCopyTradeResponse; +import com.suneesh.trading.models.responses.StopCopyTradeResponse; +import io.reactivex.observers.TestObserver; +import org.junit.Test; + +import java.util.concurrent.TimeUnit; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/9/2017 + */ +public class CopyTradeTest extends TestBase { + + @Test + public void startCopyTradeTest() throws Exception { + AuthorizeRequest authRequest = new AuthorizeRequest(properties.getProperty("VRTC_TRADE")); + StartCopyTradeRequest request = new StartCopyTradeRequest(properties.getProperty("CR_TRADE")); + TestObserver testObserver = new TestObserver<>(); + + this.api.sendRequest(authRequest) + .subscribe( o -> { + AuthorizeResponse auth = (AuthorizeResponse) o; + assertNotEquals(auth.getAuthorize(), null); + + this.api.sendRequest(request) + .subscribe(testObserver); + }); + + testObserver.await(5, TimeUnit.SECONDS); + + StartCopyTradeResponse response = (StartCopyTradeResponse) testObserver.values().get(0); + + assertEquals(response.getType(), "copy_start"); + assertNotEquals(response.getError(), null); + assertEquals(response.getError().getCode(), "CopyTradingNotAllowed"); + } + + @Test + public void stopCopyTradeTest() throws Exception { + AuthorizeRequest authRequest = new AuthorizeRequest(properties.getProperty("VRTC_TRADE")); + StopCopyTradeRequest request = new StopCopyTradeRequest(properties.getProperty("CR_TRADE")); + TestObserver testObserver = new TestObserver<>(); + + this.api.sendRequest(authRequest) + .subscribe( o -> { + AuthorizeResponse auth = (AuthorizeResponse) o; + assertNotEquals(auth.getAuthorize(), null); + + this.api.sendRequest(request) + .subscribe(testObserver); + }); + + testObserver.await(5, TimeUnit.SECONDS); + + StopCopyTradeResponse response = (StopCopyTradeResponse) testObserver.values().get(0); + + assertEquals(response.getType(), "copy_stop"); + assertEquals(response.getError(), null); + assertEquals(response.getResult(), new Integer(1)); + } +} diff --git a/Trading/src/test/java/com/suneesh/trading/CreateMaltaAccountTest.java b/Trading/src/test/java/com/suneesh/trading/CreateMaltaAccountTest.java new file mode 100644 index 0000000..dd0f2bc --- /dev/null +++ b/Trading/src/test/java/com/suneesh/trading/CreateMaltaAccountTest.java @@ -0,0 +1,47 @@ +package com.suneesh.trading; + +import com.suneesh.trading.models.requests.AuthorizeRequest; +import com.suneesh.trading.models.requests.CreateMaltaAccountRequest; +import com.suneesh.trading.models.responses.AuthorizeResponse; +import com.suneesh.trading.models.responses.CreateMaltaAccountResponse; +import com.suneesh.trading.models.responses.ResponseBase; +import io.reactivex.observers.TestObserver; +import org.junit.Test; + +import java.util.concurrent.TimeUnit; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 9/3/2017 + */ +public class CreateMaltaAccountTest extends TestBase { + + @Test + public void invalidCreateAccountRequest() throws Exception { + + AuthorizeRequest authRequest = new AuthorizeRequest(properties.getProperty("VRTC_ADMIN")); + CreateMaltaAccountRequest request = new CreateMaltaAccountRequest(); + TestObserver testObserver = new TestObserver<>(); + + this.api.sendRequest(authRequest) + .subscribe( o -> { + AuthorizeResponse auth = (AuthorizeResponse) o; + assertNotEquals(auth.getAuthorize(), null); + + this.api.sendRequest(request) + .subscribe(testObserver); + }); + + testObserver.await(10, TimeUnit.SECONDS); + + CreateMaltaAccountResponse response = (CreateMaltaAccountResponse) testObserver.values().get(0); + + assertEquals(response.getType(), "new_account_maltainvest"); + assertNotEquals(response.getError(), null); + + } +} diff --git a/Trading/src/test/java/com/suneesh/trading/CreateRealAccountTest.java b/Trading/src/test/java/com/suneesh/trading/CreateRealAccountTest.java new file mode 100644 index 0000000..4e1d581 --- /dev/null +++ b/Trading/src/test/java/com/suneesh/trading/CreateRealAccountTest.java @@ -0,0 +1,45 @@ +package com.suneesh.trading; + +import com.suneesh.trading.models.requests.AuthorizeRequest; +import com.suneesh.trading.models.requests.CreateRealAccountRequest; +import com.suneesh.trading.models.responses.AuthorizeResponse; +import com.suneesh.trading.models.responses.CreateRealAccountResponse; +import com.suneesh.trading.models.responses.ResponseBase; +import io.reactivex.observers.TestObserver; +import org.junit.Test; + +import java.util.concurrent.TimeUnit; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 9/3/2017 + */ +public class CreateRealAccountTest extends TestBase { + + @Test + public void invalidCreatRealAccountTest() throws Exception { + AuthorizeRequest authRequest = new AuthorizeRequest(properties.getProperty("VRTC_ADMIN")); + CreateRealAccountRequest request = new CreateRealAccountRequest(); + TestObserver testObserver = new TestObserver<>(); + + this.api.sendRequest(authRequest) + .subscribe( o -> { + AuthorizeResponse auth = (AuthorizeResponse) o; + assertNotEquals(auth.getAuthorize(), null); + + this.api.sendRequest(request) + .subscribe(testObserver); + }); + + testObserver.await(10, TimeUnit.SECONDS); + + CreateRealAccountResponse response = (CreateRealAccountResponse) testObserver.values().get(0); + + assertEquals(response.getType(), "new_account_real"); + assertNotEquals(response.getError(), null); + } +} diff --git a/Trading/src/test/java/com/suneesh/trading/CreateRealSubAccountTest.java b/Trading/src/test/java/com/suneesh/trading/CreateRealSubAccountTest.java new file mode 100644 index 0000000..caba6f4 --- /dev/null +++ b/Trading/src/test/java/com/suneesh/trading/CreateRealSubAccountTest.java @@ -0,0 +1,46 @@ +package com.suneesh.trading; + +import com.suneesh.trading.models.requests.AuthorizeRequest; +import com.suneesh.trading.models.requests.CreateRealSubAccountRequest; +import com.suneesh.trading.models.responses.AuthorizeResponse; +import com.suneesh.trading.models.responses.CreateRealSubAccountResponse; +import com.suneesh.trading.models.responses.ResponseBase; +import io.reactivex.observers.TestObserver; +import org.junit.Test; + +import java.util.concurrent.TimeUnit; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 9/4/2017 + */ +public class CreateRealSubAccountTest extends TestBase { + + @Test + public void createSubAccountTest() throws Exception { + + AuthorizeRequest authRequest = new AuthorizeRequest(properties.getProperty("CR_ADMIN")); + CreateRealSubAccountRequest request = new CreateRealSubAccountRequest(); + TestObserver testObserver = new TestObserver<>(); + + this.api.sendRequest(authRequest) + .subscribe( o -> { + AuthorizeResponse auth = (AuthorizeResponse) o; + assertNotEquals(auth.getAuthorize(), null); + + this.api.sendRequest(request) + .subscribe(testObserver); + }); + + testObserver.await(10, TimeUnit.SECONDS); + + CreateRealSubAccountResponse response = (CreateRealSubAccountResponse) testObserver.values().get(0); + + assertEquals(response.getType(), "new_sub_account"); + assertNotEquals(response.getError(), null); + } +} diff --git a/Trading/src/test/java/com/suneesh/trading/EmailVerficationTest.java b/Trading/src/test/java/com/suneesh/trading/EmailVerficationTest.java new file mode 100644 index 0000000..241f092 --- /dev/null +++ b/Trading/src/test/java/com/suneesh/trading/EmailVerficationTest.java @@ -0,0 +1,46 @@ +package com.suneesh.trading; + +import com.suneesh.trading.core.ApiWrapper; +import com.suneesh.trading.models.enums.EmailVerificationReasons; +import com.suneesh.trading.models.requests.EmailVerificationRequest; +import com.suneesh.trading.models.responses.EmailVerificationResponse; +import com.suneesh.trading.models.responses.ResponseBase; +import io.reactivex.observers.TestObserver; +import org.junit.Before; +import org.junit.Test; + +import java.util.concurrent.TimeUnit; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/3/2017 + */ +public class EmailVerficationTest { + private ApiWrapper api; + @Before + public void setup() throws Exception{ + this.api = ApiWrapper.build("10"); + } + + @Test + public void sendEmailVerificationTest() throws Exception { + EmailVerificationRequest request = new EmailVerificationRequest("test@local.com", + EmailVerificationReasons.ACCOUNT_OPENING); + TestObserver testObserver = new TestObserver<>(); + + this.api.sendRequest(request) + .subscribe(testObserver); + + testObserver.await(10, TimeUnit.SECONDS); + + EmailVerificationResponse response = (EmailVerificationResponse) testObserver.values().get(0); + + assertEquals(response.getType(), "verify_email"); + assertEquals(response.getError(), null); + assertTrue(response.getVerifyEmail() == 1); + } +} diff --git a/Trading/src/test/java/com/suneesh/trading/ForgetAllTest.java b/Trading/src/test/java/com/suneesh/trading/ForgetAllTest.java new file mode 100644 index 0000000..f1fd8ef --- /dev/null +++ b/Trading/src/test/java/com/suneesh/trading/ForgetAllTest.java @@ -0,0 +1,43 @@ +package com.suneesh.trading; + +import com.suneesh.trading.core.ApiWrapper; +import com.suneesh.trading.models.enums.StreamTypes; +import com.suneesh.trading.models.requests.ForgetAllRequest; +import com.suneesh.trading.models.requests.ForgetAllResponse; +import com.suneesh.trading.models.responses.ResponseBase; +import io.reactivex.observers.TestObserver; +import org.junit.Before; +import org.junit.Test; + +import java.util.concurrent.TimeUnit; + +import static org.junit.Assert.assertEquals; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/1/2017 + */ +public class ForgetAllTest { + private ApiWrapper api; + @Before + public void setup() throws Exception{ + this.api = ApiWrapper.build("10"); + } + + @Test + public void forgetAllStreamsTest() throws Exception { + ForgetAllRequest request = new ForgetAllRequest(StreamTypes.ticks); + TestObserver testObserver = new TestObserver<>(); + + this.api.sendRequest(request) + .subscribe(testObserver); + + testObserver.await(10, TimeUnit.SECONDS); + + ForgetAllResponse response = (ForgetAllResponse) testObserver.values().get(0); + + assertEquals(response.getType(), "forget_all"); + assertEquals(response.getError(), null); + } +} diff --git a/Trading/src/test/java/com/suneesh/trading/ForgetTest.java b/Trading/src/test/java/com/suneesh/trading/ForgetTest.java new file mode 100644 index 0000000..6cf5513 --- /dev/null +++ b/Trading/src/test/java/com/suneesh/trading/ForgetTest.java @@ -0,0 +1,43 @@ +package com.suneesh.trading; + +import com.suneesh.trading.core.ApiWrapper; +import com.suneesh.trading.models.requests.ForgetRequest; +import com.suneesh.trading.models.responses.ForgetResponse; +import com.suneesh.trading.models.responses.ResponseBase; +import io.reactivex.observers.TestObserver; +import org.junit.Before; +import org.junit.Test; + +import java.util.concurrent.TimeUnit; + +import static org.junit.Assert.assertEquals; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/1/2017 + */ +public class ForgetTest { + private ApiWrapper api; + @Before + public void setup() throws Exception{ + this.api = ApiWrapper.build("10"); + } + + @Test + public void forgetInvalidStreamTest() throws Exception{ + ForgetRequest request = new ForgetRequest("uw2mk7no3oktoRVVsB4Dz7TQncfABuFDgO95dlxfMxRuPUdz"); + TestObserver testObserver = new TestObserver<>(); + + this.api.sendRequest(request) + .subscribe(testObserver); + + testObserver.await(10, TimeUnit.SECONDS); + + ForgetResponse response = (ForgetResponse) testObserver.values().get(0); + + assertEquals(response.getType(), "forget"); + assertEquals(response.getForget(), 0); + assertEquals(response.getError(), null); + } +} diff --git a/Trading/src/test/java/com/suneesh/trading/FrameworkDeletionTest.java b/Trading/src/test/java/com/suneesh/trading/FrameworkDeletionTest.java new file mode 100644 index 0000000..4d00faa --- /dev/null +++ b/Trading/src/test/java/com/suneesh/trading/FrameworkDeletionTest.java @@ -0,0 +1,67 @@ +package com.suneesh.trading; + +import com.suneesh.trading.models.enums.Scopes; +import com.suneesh.trading.models.requests.ApplicationDeletionRequest; +import com.suneesh.trading.models.requests.ApplicationRegistrationRequest; +import com.suneesh.trading.models.requests.AuthorizeRequest; +import com.suneesh.trading.models.responses.ApplicationDeletionResponse; +import com.suneesh.trading.models.responses.ApplicationRegistrationResponse; +import com.suneesh.trading.models.responses.AuthorizeResponse; +import com.suneesh.trading.models.responses.ResponseBase; +import io.reactivex.observers.TestObserver; +import org.junit.Test; + +import java.util.Arrays; +import java.util.concurrent.TimeUnit; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/27/2017 + */ +public class FrameworkDeletionTest extends TestBase { + + @Test + public void deleteApplicatoinTest() throws Exception { + AuthorizeRequest authRequest = new AuthorizeRequest(properties.getProperty("VRTC_ADMIN")); + ApplicationRegistrationRequest request = new ApplicationRegistrationRequest( + "testAppRegistration", + Arrays.asList(new Scopes[]{Scopes.READ, Scopes.TRADE}), + "https://www.test.com" + ); + TestObserver testObserver = new TestObserver<>(); + + this.api.sendRequest(authRequest) + .subscribe( o -> { + AuthorizeResponse auth = (AuthorizeResponse) o; + assertNotEquals(auth.getAuthorize(), null); + + this.api.sendRequest(request) + .subscribe(testObserver); + }); + + testObserver.await(10, TimeUnit.SECONDS); + + ApplicationRegistrationResponse response = (ApplicationRegistrationResponse) testObserver.values().get(0); + + assertEquals(response.getType(), "app_register"); + assertEquals(response.getError(), null); + assertNotEquals(response.getRegisteredApplication(), null); + + // Delete the application + ApplicationDeletionRequest deleteRequest = + new ApplicationDeletionRequest(response.getRegisteredApplication().getApplicationId()); + + TestObserver testObserver2 = new TestObserver<>(); + this.api.sendRequest(deleteRequest) + .subscribe(testObserver2); + + testObserver2.await(10, TimeUnit.SECONDS); + ApplicationDeletionResponse deleteResponse = (ApplicationDeletionResponse) testObserver2.values().get(0); + assertEquals(deleteResponse.getType(), "app_delete"); + assertNotEquals(deleteResponse.getResponse(), null); + } +} diff --git a/Trading/src/test/java/com/suneesh/trading/FrameworkDetailsTest.java b/Trading/src/test/java/com/suneesh/trading/FrameworkDetailsTest.java new file mode 100644 index 0000000..ec41b47 --- /dev/null +++ b/Trading/src/test/java/com/suneesh/trading/FrameworkDetailsTest.java @@ -0,0 +1,45 @@ +package com.suneesh.trading; + +import com.suneesh.trading.models.requests.ApplicationDetailsRequest; +import com.suneesh.trading.models.requests.AuthorizeRequest; +import com.suneesh.trading.models.responses.ApplicationDetailsResponse; +import com.suneesh.trading.models.responses.AuthorizeResponse; +import com.suneesh.trading.models.responses.ResponseBase; +import io.reactivex.observers.TestObserver; +import org.junit.Test; + +import java.util.concurrent.TimeUnit; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/27/2017 + */ +public class FrameworkDetailsTest extends TestBase { + + @Test + public void getInvalidApplicationTest() throws Exception { + AuthorizeRequest authRequest = new AuthorizeRequest(properties.getProperty("VRTC_ADMIN")); + ApplicationDetailsRequest request = new ApplicationDetailsRequest(11111L); + TestObserver testObserver = new TestObserver<>(); + + this.api.sendRequest(authRequest) + .subscribe( o -> { + AuthorizeResponse auth = (AuthorizeResponse) o; + assertNotEquals(auth.getAuthorize(), null); + + this.api.sendRequest(request) + .subscribe(testObserver); + }); + + testObserver.await(10, TimeUnit.SECONDS); + + ApplicationDetailsResponse response = (ApplicationDetailsResponse) testObserver.values().get(0); + + assertEquals(response.getType(), "app_get"); + assertNotEquals(response.getError(), null); + } +} diff --git a/Trading/src/test/java/com/suneesh/trading/FrameworkListTest.java b/Trading/src/test/java/com/suneesh/trading/FrameworkListTest.java new file mode 100644 index 0000000..68e5611 --- /dev/null +++ b/Trading/src/test/java/com/suneesh/trading/FrameworkListTest.java @@ -0,0 +1,46 @@ +package com.suneesh.trading; + +import com.suneesh.trading.models.requests.ApplicationListRequest; +import com.suneesh.trading.models.requests.AuthorizeRequest; +import com.suneesh.trading.models.responses.ApplicationListResponse; +import com.suneesh.trading.models.responses.AuthorizeResponse; +import com.suneesh.trading.models.responses.ResponseBase; +import io.reactivex.observers.TestObserver; +import org.junit.Test; + +import java.util.concurrent.TimeUnit; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/27/2017 + */ +public class FrameworkListTest extends TestBase { + + @Test + public void getApplicationsListTest() throws Exception { + AuthorizeRequest authRequest = new AuthorizeRequest(properties.getProperty("VRTC_ADMIN")); + ApplicationListRequest request = new ApplicationListRequest(); + TestObserver testObserver = new TestObserver<>(); + + this.api.sendRequest(authRequest) + .subscribe( o -> { + AuthorizeResponse auth = (AuthorizeResponse) o; + assertNotEquals(auth.getAuthorize(), null); + + this.api.sendRequest(request) + .subscribe(testObserver); + }); + + testObserver.await(10, TimeUnit.SECONDS); + + ApplicationListResponse response = (ApplicationListResponse) testObserver.values().get(0); + + assertEquals(response.getType(), "app_list"); + assertEquals(response.getError(), null); + assertNotEquals(response.getApplications(), null); + } +} diff --git a/Trading/src/test/java/com/suneesh/trading/FrameworkRegistrationTest.java b/Trading/src/test/java/com/suneesh/trading/FrameworkRegistrationTest.java new file mode 100644 index 0000000..c1421c8 --- /dev/null +++ b/Trading/src/test/java/com/suneesh/trading/FrameworkRegistrationTest.java @@ -0,0 +1,82 @@ +package com.suneesh.trading; + +import com.suneesh.trading.models.enums.Scopes; +import com.suneesh.trading.models.requests.ApplicationDeletionRequest; +import com.suneesh.trading.models.requests.ApplicationRegistrationRequest; +import com.suneesh.trading.models.requests.AuthorizeRequest; +import com.suneesh.trading.models.responses.*; +import com.suneesh.trading.models.responses.ApplicationDeletionResponse; +import com.suneesh.trading.models.responses.ApplicationRegistrationResponse; +import com.suneesh.trading.models.responses.AuthorizeResponse; +import com.suneesh.trading.models.responses.ResponseBase; +import io.reactivex.observers.TestObserver; +import org.junit.Test; + +import java.util.Arrays; +import java.util.concurrent.TimeUnit; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/20/2017 + */ +public class FrameworkRegistrationTest extends TestBase { + + @Test + public void registerApplicationTest() throws Exception { + + AuthorizeRequest authRequest = new AuthorizeRequest(properties.getProperty("VRTC_ADMIN")); + // FIXME Uncomment the below lines after fixing the googleplay regex issue +// ApplicationRegistrationRequest request = new ApplicationRegistrationRequest( +// "testAppRegistration", +// Arrays.asList(new Scopes[]{Scopes.READ, Scopes.TRADE}), +// "https://www.test.com", +// "https://github.com/xx/appRegistrationTest", +// "https://itunes.apple.com/app/apple-store/id1091187567", +// "https://play.google.com/store/apps/details?id=com.binary.ticktrade", +// "https://test.com", +// "https://test.com", +// new BigDecimal("0") +// ); + ApplicationRegistrationRequest request = new ApplicationRegistrationRequest( + "testAppRegistration", + Arrays.asList(new Scopes[]{Scopes.READ, Scopes.TRADE}), + "https://www.test.com" + ); + TestObserver testObserver = new TestObserver<>(); + + this.api.sendRequest(authRequest) + .subscribe( o -> { + AuthorizeResponse auth = (AuthorizeResponse) o; + assertNotEquals(auth.getAuthorize(), null); + + this.api.sendRequest(request) + .subscribe(testObserver); + }); + + testObserver.await(10, TimeUnit.SECONDS); + + ApplicationRegistrationResponse response = (ApplicationRegistrationResponse) testObserver.values().get(0); + + assertEquals(response.getType(), "app_register"); + assertEquals(response.getError(), null); + assertNotEquals(response.getRegisteredApplication(), null); + + // Delete the application + ApplicationDeletionRequest deleteRequest = + new ApplicationDeletionRequest(response.getRegisteredApplication().getApplicationId()); + + TestObserver testObserver2 = new TestObserver<>(); + this.api.sendRequest(deleteRequest) + .subscribe(testObserver2); + + testObserver2.await(10, TimeUnit.SECONDS); + ApplicationDeletionResponse deleteResponse = (ApplicationDeletionResponse) testObserver2.values().get(0); + assertEquals(deleteResponse.getType(), "app_delete"); + assertNotEquals(deleteResponse.getResponse(), null); + + } +} diff --git a/Trading/src/test/java/com/suneesh/trading/FrameworkUpdateTest.java b/Trading/src/test/java/com/suneesh/trading/FrameworkUpdateTest.java new file mode 100644 index 0000000..c2783b7 --- /dev/null +++ b/Trading/src/test/java/com/suneesh/trading/FrameworkUpdateTest.java @@ -0,0 +1,53 @@ +package com.suneesh.trading; + +import com.suneesh.trading.models.enums.Scopes; +import com.suneesh.trading.models.requests.ApplicationUpdateRequest; +import com.suneesh.trading.models.requests.AuthorizeRequest; +import com.suneesh.trading.models.responses.ApplicationUpdateResponse; +import com.suneesh.trading.models.responses.AuthorizeResponse; +import com.suneesh.trading.models.responses.ResponseBase; +import io.reactivex.observers.TestObserver; +import org.junit.Test; + +import java.util.Arrays; +import java.util.concurrent.TimeUnit; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/27/2017 + */ +public class FrameworkUpdateTest extends TestBase { + + @Test + public void updateInvalidApplicationTest() throws Exception { + AuthorizeRequest authRequest = new AuthorizeRequest(properties.getProperty("VRTC_ADMIN")); + ApplicationUpdateRequest request = new ApplicationUpdateRequest( + 1234L, + "testAppRegistration", + Arrays.asList(new Scopes[]{Scopes.READ, Scopes.TRADE}), + "https://www.test.com" + ); + + TestObserver testObserver = new TestObserver<>(); + + this.api.sendRequest(authRequest) + .subscribe( o -> { + AuthorizeResponse auth = (AuthorizeResponse) o; + assertNotEquals(auth.getAuthorize(), null); + + this.api.sendRequest(request) + .subscribe(testObserver); + }); + + testObserver.await(10, TimeUnit.SECONDS); + + ApplicationUpdateResponse response = (ApplicationUpdateResponse) testObserver.values().get(0); + + assertEquals(response.getType(), "app_update"); + assertNotEquals(response.getError(), null); + } +} diff --git a/Trading/src/test/java/com/suneesh/trading/GetFinancialAssessmentTest.java b/Trading/src/test/java/com/suneesh/trading/GetFinancialAssessmentTest.java new file mode 100644 index 0000000..5a47c02 --- /dev/null +++ b/Trading/src/test/java/com/suneesh/trading/GetFinancialAssessmentTest.java @@ -0,0 +1,46 @@ +package com.suneesh.trading; + +import com.suneesh.trading.models.requests.AuthorizeRequest; +import com.suneesh.trading.models.requests.GetFinancialAssessmentRequest; +import com.suneesh.trading.models.responses.AuthorizeResponse; +import com.suneesh.trading.models.responses.GetFinancialAssessmentResponse; +import com.suneesh.trading.models.responses.ResponseBase; +import io.reactivex.observers.TestObserver; +import org.junit.Test; + +import java.util.concurrent.TimeUnit; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/29/2017 + */ +public class GetFinancialAssessmentTest extends TestBase { + + @Test + public void getFinancialAssessmentTest() throws Exception { + AuthorizeRequest authRequest = new AuthorizeRequest(properties.getProperty("CR_ADMIN")); + GetFinancialAssessmentRequest request = new GetFinancialAssessmentRequest(); + TestObserver testObserver = new TestObserver<>(); + + this.api.sendRequest(authRequest) + .subscribe( o -> { + AuthorizeResponse auth = (AuthorizeResponse) o; + assertNotEquals(auth.getAuthorize(), null); + + this.api.sendRequest(request) + .subscribe(testObserver); + }); + + testObserver.await(10, TimeUnit.SECONDS); + + GetFinancialAssessmentResponse response = (GetFinancialAssessmentResponse) testObserver.values().get(0); + + assertEquals(response.getType(), "get_financial_assessment"); + assertEquals(response.getError(), null); + assertNotEquals(response.getFinancialAssessment(), null); + } +} diff --git a/Trading/src/test/java/com/suneesh/trading/JapanKnowledgeTest.java b/Trading/src/test/java/com/suneesh/trading/JapanKnowledgeTest.java new file mode 100644 index 0000000..edfb81b --- /dev/null +++ b/Trading/src/test/java/com/suneesh/trading/JapanKnowledgeTest.java @@ -0,0 +1,46 @@ +package com.suneesh.trading; + +import com.suneesh.trading.models.enums.TestResult; +import com.suneesh.trading.models.requests.AuthorizeRequest; +import com.suneesh.trading.models.requests.JapanKnowledgeTestRequest; +import com.suneesh.trading.models.responses.AuthorizeResponse; +import com.suneesh.trading.models.responses.JapanKnowledgeTestResponse; +import com.suneesh.trading.models.responses.ResponseBase; +import io.reactivex.observers.TestObserver; +import org.junit.Test; + +import java.util.concurrent.TimeUnit; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/30/2017 + */ +public class JapanKnowledgeTest extends TestBase { + + @Test + public void failedJapanKnowledgeTest() throws Exception { + AuthorizeRequest authRequest = new AuthorizeRequest(properties.getProperty("VRTC_ADMIN")); + JapanKnowledgeTestRequest request = new JapanKnowledgeTestRequest(12, TestResult.PASS); + TestObserver testObserver = new TestObserver<>(); + + this.api.sendRequest(authRequest) + .subscribe( o -> { + AuthorizeResponse auth = (AuthorizeResponse) o; + assertNotEquals(auth.getAuthorize(), null); + + this.api.sendRequest(request) + .subscribe(testObserver); + }); + + testObserver.await(10, TimeUnit.SECONDS); + + JapanKnowledgeTestResponse response = (JapanKnowledgeTestResponse) testObserver.values().get(0); + + assertEquals(response.getType(), "jp_knowledge_test"); + assertNotEquals(response.getError(), null); + } +} diff --git a/Trading/src/test/java/com/suneesh/trading/LandingCompanyDetailsTest.java b/Trading/src/test/java/com/suneesh/trading/LandingCompanyDetailsTest.java new file mode 100644 index 0000000..e17c04c --- /dev/null +++ b/Trading/src/test/java/com/suneesh/trading/LandingCompanyDetailsTest.java @@ -0,0 +1,43 @@ +package com.suneesh.trading; + +import com.suneesh.trading.core.ApiWrapper; +import com.suneesh.trading.models.requests.LandingCompanyDetailsRequest; +import com.suneesh.trading.models.responses.LandingCompanyDetailsResponse; +import com.suneesh.trading.models.responses.ResponseBase; +import io.reactivex.observers.TestObserver; +import org.junit.Before; +import org.junit.Test; + +import java.util.concurrent.TimeUnit; + +import static org.junit.Assert.assertEquals; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/2/2017 + */ +public class LandingCompanyDetailsTest { + private ApiWrapper api; + @Before + public void setup() throws Exception{ + this.api = ApiWrapper.build("10"); + } + + @Test + public void getLandingCompanyDetailsTest() throws Exception { + LandingCompanyDetailsRequest request = new LandingCompanyDetailsRequest("malta"); + TestObserver testObserver = new TestObserver<>(); + + this.api.sendRequest(request) + .subscribe(testObserver); + + testObserver.await(10, TimeUnit.SECONDS); + + LandingCompanyDetailsResponse response = (LandingCompanyDetailsResponse) testObserver.values().get(0); + + assertEquals(response.getType(), "landing_company_details"); + assertEquals(response.getError(), null); + assertEquals(response.getLandingCompanyDetails().getShortCode(), "malta"); + } +} diff --git a/Trading/src/test/java/com/suneesh/trading/LandingCompanyTest.java b/Trading/src/test/java/com/suneesh/trading/LandingCompanyTest.java new file mode 100644 index 0000000..4193c72 --- /dev/null +++ b/Trading/src/test/java/com/suneesh/trading/LandingCompanyTest.java @@ -0,0 +1,61 @@ +package com.suneesh.trading; + +import com.suneesh.trading.core.ApiWrapper; +import com.suneesh.trading.models.requests.LandingCompanyRequest; +import com.suneesh.trading.models.responses.LandingCompanyResponse; +import com.suneesh.trading.models.responses.ResponseBase; +import io.reactivex.observers.TestObserver; +import org.junit.Before; +import org.junit.Test; + +import java.util.concurrent.TimeUnit; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/1/2017 + */ +public class LandingCompanyTest { + private ApiWrapper api; + @Before + public void setup() throws Exception{ + this.api = ApiWrapper.build("10"); + } + + @Test + public void getLandingCompanyTest() throws Exception{ + LandingCompanyRequest request = new LandingCompanyRequest("de"); + TestObserver testObserver = new TestObserver<>(); + + this.api.sendRequest(request) + .subscribe(testObserver); + + testObserver.await(10, TimeUnit.SECONDS); + + LandingCompanyResponse response = (LandingCompanyResponse) testObserver.values().get(0); + + assertEquals(response.getType(), "landing_company"); + assertEquals(response.getError(), null); + assertNotEquals(response.getLandingCompany(), null); + + } + + @Test + public void illegalLandingCompanyCodeTest() throws Exception { + LandingCompanyRequest request = new LandingCompanyRequest("xx"); + TestObserver testObserver = new TestObserver<>(); + + this.api.sendRequest(request) + .subscribe(testObserver); + + testObserver.await(10, TimeUnit.SECONDS); + + LandingCompanyResponse response = (LandingCompanyResponse) testObserver.values().get(0); + + assertEquals(response.getType(), "landing_company"); + assertNotEquals(response.getError(), null); + } +} diff --git a/Trading/src/test/java/com/suneesh/trading/LoginHistoryTest.java b/Trading/src/test/java/com/suneesh/trading/LoginHistoryTest.java new file mode 100644 index 0000000..862e5f2 --- /dev/null +++ b/Trading/src/test/java/com/suneesh/trading/LoginHistoryTest.java @@ -0,0 +1,59 @@ +package com.suneesh.trading; + +import com.suneesh.trading.core.ApiWrapper; +import com.suneesh.trading.models.requests.AuthorizeRequest; +import com.suneesh.trading.models.requests.LoginHistoryRequest; +import com.suneesh.trading.models.responses.AuthorizeResponse; +import com.suneesh.trading.models.responses.LoginHistoryResponse; +import com.suneesh.trading.models.responses.ResponseBase; +import io.reactivex.observers.TestObserver; +import org.junit.Before; +import org.junit.Test; + +import java.util.Properties; +import java.util.concurrent.TimeUnit; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/7/2017 + */ +public class LoginHistoryTest { + + private ApiWrapper api; + private Properties properties; + + @Before + public void setUp() throws Exception { + TestUtility testUtility = new TestUtility(); + this.api = testUtility.getApi(); + this.properties = testUtility.getProperties(); + } + + @Test + public void getLoginHistoryTest() throws Exception { + AuthorizeRequest authRequest = new AuthorizeRequest(properties.getProperty("CR_READ"), false); + LoginHistoryRequest request = new LoginHistoryRequest(); + TestObserver testObserver = new TestObserver<>(); + + this.api.sendRequest(authRequest) + .subscribe( o -> { + AuthorizeResponse auth = (AuthorizeResponse) o; + assertNotEquals(auth.getAuthorize(), null); + + this.api.sendRequest(request) + .subscribe(testObserver); + }); + + testObserver.await(10, TimeUnit.SECONDS); + + LoginHistoryResponse response = (LoginHistoryResponse) testObserver.values().get(0); + + assertEquals(response.getType(), "login_history"); + assertEquals(response.getError(), null); + assertNotEquals(response.getLoginHistories(), null); + } +} diff --git a/Trading/src/test/java/com/suneesh/trading/LogoutTest.java b/Trading/src/test/java/com/suneesh/trading/LogoutTest.java new file mode 100644 index 0000000..a1294ff --- /dev/null +++ b/Trading/src/test/java/com/suneesh/trading/LogoutTest.java @@ -0,0 +1,47 @@ +package com.suneesh.trading; + +import com.suneesh.trading.models.requests.AuthorizeRequest; +import com.suneesh.trading.models.requests.LogoutRequest; +import com.suneesh.trading.models.responses.AuthorizeResponse; +import com.suneesh.trading.models.responses.LogoutResponse; +import com.suneesh.trading.models.responses.ResponseBase; +import io.reactivex.observers.TestObserver; +import org.junit.Test; + +import java.util.concurrent.TimeUnit; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertTrue; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/7/2017 + */ +public class LogoutTest extends TestBase { + + @Test + public void logoutTest() throws Exception { + AuthorizeRequest authRequest = new AuthorizeRequest(this.properties.getProperty("CR_READ")); + LogoutRequest request = new LogoutRequest(); + TestObserver testObserver = new TestObserver<>(); + + this.api.sendRequest(authRequest) + .subscribe( o -> { + AuthorizeResponse auth = (AuthorizeResponse) o; + assertNotEquals(auth.getAuthorize(), null); + + this.api.sendRequest(request) + .subscribe(testObserver); + }); + + testObserver.await(5, TimeUnit.SECONDS); + + LogoutResponse response = (LogoutResponse) testObserver.values().get(0); + + assertEquals(response.getType(), "logout"); + assertEquals(response.getError(), null); + assertTrue(response.getLogout()); + } +} diff --git a/Trading/src/test/java/com/suneesh/trading/NewVirtualAccountTest.java b/Trading/src/test/java/com/suneesh/trading/NewVirtualAccountTest.java new file mode 100644 index 0000000..80233d2 --- /dev/null +++ b/Trading/src/test/java/com/suneesh/trading/NewVirtualAccountTest.java @@ -0,0 +1,43 @@ +package com.suneesh.trading; + +import com.suneesh.trading.core.ApiWrapper; +import com.suneesh.trading.models.requests.NewVirtualAccountRequest; +import com.suneesh.trading.models.responses.NewVirtualAccountResponse; +import com.suneesh.trading.models.responses.ResponseBase; +import io.reactivex.observers.TestObserver; +import org.junit.Before; +import org.junit.Test; + +import java.util.concurrent.TimeUnit; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/2/2017 + */ +public class NewVirtualAccountTest { + private ApiWrapper api; + @Before + public void setup() throws Exception{ + this.api = ApiWrapper.build("10"); + } + + @Test + public void invalidVerificationCodeTest() throws Exception{ + NewVirtualAccountRequest request = new NewVirtualAccountRequest("xxxxxxxx", "123456", "id"); + TestObserver testObserver = new TestObserver<>(); + + this.api.sendRequest(request) + .subscribe(testObserver); + + testObserver.await(10, TimeUnit.SECONDS); + + NewVirtualAccountResponse response = (NewVirtualAccountResponse) testObserver.values().get(0); + + assertEquals(response.getType(), "new_account_virtual"); + assertNotEquals(response.getError(), null); + } +} diff --git a/Trading/src/test/java/com/suneesh/trading/OAuthApplicationsTest.java b/Trading/src/test/java/com/suneesh/trading/OAuthApplicationsTest.java new file mode 100644 index 0000000..6fc423e --- /dev/null +++ b/Trading/src/test/java/com/suneesh/trading/OAuthApplicationsTest.java @@ -0,0 +1,46 @@ +package com.suneesh.trading; + +import com.suneesh.trading.models.requests.AuthorizeRequest; +import com.suneesh.trading.models.requests.OAuthApplicationsRequest; +import com.suneesh.trading.models.responses.AuthorizeResponse; +import com.suneesh.trading.models.responses.OAuthApplicationResponse; +import com.suneesh.trading.models.responses.ResponseBase; +import io.reactivex.observers.TestObserver; +import org.junit.Test; + +import java.util.concurrent.TimeUnit; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/7/2017 + */ +public class OAuthApplicationsTest extends TestBase { + + @Test + public void getOauthApplicationsTest() throws Exception { + AuthorizeRequest authRequest = new AuthorizeRequest(properties.getProperty("CR_READ")); + OAuthApplicationsRequest request = new OAuthApplicationsRequest(); + TestObserver testObserver = new TestObserver<>(); + + this.api.sendRequest(authRequest) + .subscribe( o -> { + AuthorizeResponse auth = (AuthorizeResponse) o; + assertNotEquals(auth.getAuthorize(), null); + + this.api.sendRequest(request) + .subscribe(testObserver); + }); + + testObserver.await(5, TimeUnit.SECONDS); + + OAuthApplicationResponse response = (OAuthApplicationResponse) testObserver.values().get(0); + + assertEquals(response.getType(), "oauth_apps"); + assertEquals(response.getError(), null); + assertNotEquals(response.getOauthApplications(), null); + } +} diff --git a/Trading/src/test/java/com/suneesh/trading/PaymentAgentListTest.java b/Trading/src/test/java/com/suneesh/trading/PaymentAgentListTest.java new file mode 100644 index 0000000..4e9ca3c --- /dev/null +++ b/Trading/src/test/java/com/suneesh/trading/PaymentAgentListTest.java @@ -0,0 +1,44 @@ +package com.suneesh.trading; + +import com.suneesh.trading.core.ApiWrapper; +import com.suneesh.trading.models.requests.PaymentAgentListRequest; +import com.suneesh.trading.models.responses.PaymentAgentListResponse; +import com.suneesh.trading.models.responses.ResponseBase; +import io.reactivex.observers.TestObserver; +import org.junit.Before; +import org.junit.Test; + +import java.util.concurrent.TimeUnit; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/2/2017 + */ +public class PaymentAgentListTest { + private ApiWrapper api; + @Before + public void setup() throws Exception{ + this.api = ApiWrapper.build("10"); + } + + @Test + public void getPaymentAgentList() throws Exception { + PaymentAgentListRequest request = new PaymentAgentListRequest("ng"); + TestObserver testObserver = new TestObserver<>(); + + this.api.sendRequest(request) + .subscribe(testObserver); + + testObserver.await(10, TimeUnit.SECONDS); + + PaymentAgentListResponse response = (PaymentAgentListResponse) testObserver.values().get(0); + + assertEquals(response.getType(), "paymentagent_list"); + assertEquals(response.getError(), null); + assertNotEquals(response.getPaymentAgentList(), null); + } +} diff --git a/Trading/src/test/java/com/suneesh/trading/PaymentAgentTransferTest.java b/Trading/src/test/java/com/suneesh/trading/PaymentAgentTransferTest.java new file mode 100644 index 0000000..861c975 --- /dev/null +++ b/Trading/src/test/java/com/suneesh/trading/PaymentAgentTransferTest.java @@ -0,0 +1,52 @@ +package com.suneesh.trading; + +import com.suneesh.trading.models.requests.AuthorizeRequest; +import com.suneesh.trading.models.requests.PaymentAgentTransferRequest; +import com.suneesh.trading.models.responses.AuthorizeResponse; +import com.suneesh.trading.models.responses.PaymentAgentTransferResponse; +import com.suneesh.trading.models.responses.ResponseBase; +import io.reactivex.observers.TestObserver; +import org.junit.Test; + +import java.math.BigDecimal; +import java.util.concurrent.TimeUnit; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 9/15/2017 + */ +public class PaymentAgentTransferTest extends TestBase { + + @Test + public void invalidTransferTest() throws Exception { + + AuthorizeRequest authRequest = new AuthorizeRequest(properties.getProperty("CR_PAYMENTS")); + PaymentAgentTransferRequest request = new PaymentAgentTransferRequest(); + TestObserver testObserver = new TestObserver<>(); + + request.setTransferTo("CR100001"); + request.setAmount(new BigDecimal("1000")); + request.setCurrency("USD"); + + this.api.sendRequest(authRequest) + .subscribe( o -> { + AuthorizeResponse auth = (AuthorizeResponse) o; + assertNotEquals(auth.getAuthorize(), null); + + this.api.sendRequest(request) + .subscribe(testObserver); + }); + + testObserver.await(10, TimeUnit.SECONDS); + + PaymentAgentTransferResponse response = (PaymentAgentTransferResponse) testObserver.values().get(0); + + assertEquals(response.getType(), "paymentagent_transfer"); + assertEquals(response.getError().getCode(), "PaymentAgentTransferError"); + assertEquals(response.getError().getMessage(), "You are not authorized for transfers via payment agents."); + } +} diff --git a/Trading/src/test/java/com/suneesh/trading/PaymentAgentWithdrawalTest.java b/Trading/src/test/java/com/suneesh/trading/PaymentAgentWithdrawalTest.java new file mode 100644 index 0000000..067b572 --- /dev/null +++ b/Trading/src/test/java/com/suneesh/trading/PaymentAgentWithdrawalTest.java @@ -0,0 +1,52 @@ +package com.suneesh.trading; + +import com.suneesh.trading.models.requests.AuthorizeRequest; +import com.suneesh.trading.models.requests.PaymentAgentWithdrawalRequest; +import com.suneesh.trading.models.responses.AuthorizeResponse; +import com.suneesh.trading.models.responses.PaymentAgentWithdrawalResponse; +import com.suneesh.trading.models.responses.ResponseBase; +import io.reactivex.observers.TestObserver; +import org.junit.Test; + +import java.math.BigDecimal; +import java.util.concurrent.TimeUnit; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 9/15/2017 + */ +public class PaymentAgentWithdrawalTest extends TestBase { + + @Test + public void invalidWithdrawalTest() throws Exception { + + AuthorizeRequest authRequest = new AuthorizeRequest(properties.getProperty("CR_PAYMENTS")); + PaymentAgentWithdrawalRequest request = new PaymentAgentWithdrawalRequest(); + TestObserver testObserver = new TestObserver<>(); + + request.setAmount(new BigDecimal(1000)); + request.setLoginId("CR494048"); + request.setCurrency("USD"); + request.setVerificationCode("1234qwer"); + + this.api.sendRequest(authRequest) + .subscribe( o -> { + AuthorizeResponse auth = (AuthorizeResponse) o; + assertNotEquals(auth.getAuthorize(), null); + + this.api.sendRequest(request) + .subscribe(testObserver); + }); + + testObserver.await(10, TimeUnit.SECONDS); + + PaymentAgentWithdrawalResponse response = (PaymentAgentWithdrawalResponse) testObserver.values().get(0); + + assertEquals(response.getType(), "paymentagent_withdraw"); + assertEquals(response.getError().getCode(), "InvalidToken"); + } +} diff --git a/Trading/src/test/java/com/suneesh/trading/PayoutCurrenciesTest.java b/Trading/src/test/java/com/suneesh/trading/PayoutCurrenciesTest.java new file mode 100644 index 0000000..3a86014 --- /dev/null +++ b/Trading/src/test/java/com/suneesh/trading/PayoutCurrenciesTest.java @@ -0,0 +1,44 @@ +package com.suneesh.trading; + +import com.suneesh.trading.core.ApiWrapper; +import com.suneesh.trading.models.requests.PayoutCurrenciesRequest; +import com.suneesh.trading.models.responses.PayoutCurrenciesResponse; +import com.suneesh.trading.models.responses.ResponseBase; +import io.reactivex.observers.TestObserver; +import org.junit.Before; +import org.junit.Test; + +import java.util.concurrent.TimeUnit; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/2/2017 + */ +public class PayoutCurrenciesTest { + private ApiWrapper api; + @Before + public void setup() throws Exception{ + this.api = ApiWrapper.build("10"); + } + + @Test + public void getPayoutCurrenciesTest() throws Exception { + PayoutCurrenciesRequest request = new PayoutCurrenciesRequest(); + TestObserver testObserver = new TestObserver<>(); + + this.api.sendRequest(request) + .subscribe(testObserver); + + testObserver.await(10, TimeUnit.SECONDS); + + PayoutCurrenciesResponse response = (PayoutCurrenciesResponse) testObserver.values().get(0); + + assertEquals(response.getType(), "payout_currencies"); + assertEquals(response.getError(), null); + assertNotEquals(response.getPayoutCurrencies(), null); + } +} diff --git a/Trading/src/test/java/com/suneesh/trading/PingTest.java b/Trading/src/test/java/com/suneesh/trading/PingTest.java new file mode 100644 index 0000000..d019f47 --- /dev/null +++ b/Trading/src/test/java/com/suneesh/trading/PingTest.java @@ -0,0 +1,43 @@ +package com.suneesh.trading; + +import com.suneesh.trading.core.ApiWrapper; +import com.suneesh.trading.models.requests.PingRequest; +import com.suneesh.trading.models.responses.PingResponse; +import com.suneesh.trading.models.responses.ResponseBase; +import io.reactivex.observers.TestObserver; +import org.junit.Before; +import org.junit.Test; + +import java.util.concurrent.TimeUnit; + +import static org.junit.Assert.assertEquals; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/2/2017 + */ +public class PingTest { + private ApiWrapper api; + @Before + public void setup() throws Exception{ + this.api = ApiWrapper.build("10"); + } + + @Test + public void pingTest() throws Exception { + PingRequest request = new PingRequest(); + TestObserver testObserver = new TestObserver<>(); + + this.api.sendRequest(request) + .subscribe(testObserver); + + testObserver.await(10, TimeUnit.SECONDS); + + PingResponse response = (PingResponse) testObserver.values().get(0); + + assertEquals(response.getType(), "ping"); + assertEquals(response.getError(), null); + assertEquals(response.getPing(), "pong"); + } +} diff --git a/Trading/src/test/java/com/suneesh/trading/PriceProposalTest.java b/Trading/src/test/java/com/suneesh/trading/PriceProposalTest.java new file mode 100644 index 0000000..291d82e --- /dev/null +++ b/Trading/src/test/java/com/suneesh/trading/PriceProposalTest.java @@ -0,0 +1,49 @@ +package com.suneesh.trading; + +import com.suneesh.trading.core.ApiWrapper; +import com.suneesh.trading.models.enums.BasisTypes; +import com.suneesh.trading.models.enums.DurationUnits; +import com.suneesh.trading.models.requests.PriceProposalRequest; +import com.suneesh.trading.models.responses.PriceProposalResponse; +import com.suneesh.trading.models.responses.ResponseBase; +import io.reactivex.observers.TestObserver; +import org.junit.Before; +import org.junit.Test; + +import java.math.BigDecimal; +import java.util.concurrent.TimeUnit; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThat; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/2/2017 + */ +public class PriceProposalTest { + private ApiWrapper api; + @Before + public void setup() throws Exception{ + this.api = ApiWrapper.build("10"); + } + + @Test + public void getPriceProposalTest() throws Exception { + PriceProposalRequest request = new PriceProposalRequest("R_100", BigDecimal.valueOf(100), BasisTypes.PAYOUT, + "CALL", "USD", 60, DurationUnits.SECONDS); + + TestObserver testObserver = new TestObserver<>(); + + this.api.sendRequest(request) + .subscribe(testObserver); + + testObserver.await(10, TimeUnit.SECONDS); + + PriceProposalResponse response = (PriceProposalResponse) testObserver.values().get(0); + + assertEquals(response.getType(), "proposal"); + assertEquals(response.getError(), null); + assertEquals(response.getProposal().getPayout(), BigDecimal.valueOf(100)); + } +} diff --git a/Trading/src/test/java/com/suneesh/trading/ProfitTableTest.java b/Trading/src/test/java/com/suneesh/trading/ProfitTableTest.java new file mode 100644 index 0000000..c1b4f07 --- /dev/null +++ b/Trading/src/test/java/com/suneesh/trading/ProfitTableTest.java @@ -0,0 +1,46 @@ +package com.suneesh.trading; + +import com.suneesh.trading.models.requests.AuthorizeRequest; +import com.suneesh.trading.models.requests.ProfitTableRequest; +import com.suneesh.trading.models.responses.AuthorizeResponse; +import com.suneesh.trading.models.responses.ProfitTableResponse; +import com.suneesh.trading.models.responses.ResponseBase; +import io.reactivex.observers.TestObserver; +import org.junit.Test; + +import java.util.concurrent.TimeUnit; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/8/2017 + */ +public class ProfitTableTest extends TestBase { + + @Test + public void getProfitTableTest() throws Exception { + AuthorizeRequest authRequest = new AuthorizeRequest(properties.getProperty("VRTC_READ")); + ProfitTableRequest request = new ProfitTableRequest(); + TestObserver testObserver = new TestObserver<>(); + + this.api.sendRequest(authRequest) + .subscribe( o -> { + AuthorizeResponse auth = (AuthorizeResponse) o; + assertNotEquals(auth.getAuthorize(), null); + + this.api.sendRequest(request) + .subscribe(testObserver); + }); + + testObserver.await(10, TimeUnit.SECONDS); + + ProfitTableResponse response = (ProfitTableResponse) testObserver.values().get(0); + + assertEquals(response.getType(), "profit_table"); + assertEquals(response.getError(), null); + assertNotEquals(response.getProfitTable(), null); + } +} diff --git a/Trading/src/test/java/com/suneesh/trading/ProposalOpenContractTest.java b/Trading/src/test/java/com/suneesh/trading/ProposalOpenContractTest.java new file mode 100644 index 0000000..a8b81a4 --- /dev/null +++ b/Trading/src/test/java/com/suneesh/trading/ProposalOpenContractTest.java @@ -0,0 +1,46 @@ +package com.suneesh.trading; + +import com.suneesh.trading.models.requests.AuthorizeRequest; +import com.suneesh.trading.models.requests.ProposalOpenContractRequest; +import com.suneesh.trading.models.responses.AuthorizeResponse; +import com.suneesh.trading.models.responses.ProposalOpenContractResponse; +import com.suneesh.trading.models.responses.ResponseBase; +import io.reactivex.observers.TestObserver; +import org.junit.Test; + +import java.util.concurrent.TimeUnit; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/8/2017 + */ +public class ProposalOpenContractTest extends TestBase { + + @Test + public void getopenContractTest() throws Exception { + AuthorizeRequest authRequest = new AuthorizeRequest(properties.getProperty("VRTC_READ")); + ProposalOpenContractRequest request = new ProposalOpenContractRequest(1111111111L); + TestObserver testObserver = new TestObserver<>(); + + this.api.sendRequest(authRequest) + .subscribe( o -> { + AuthorizeResponse auth = (AuthorizeResponse) o; + assertNotEquals(auth.getAuthorize(), null); + + this.api.sendRequest(request) + .subscribe(testObserver); + }); + + testObserver.await(5, TimeUnit.SECONDS); + + ProposalOpenContractResponse response = (ProposalOpenContractResponse) testObserver.values().get(0); + + assertEquals(response.getType(), "proposal_open_contract"); + assertEquals(response.getError(), null); + assertNotEquals(response.getOpenContract(), null); + } +} diff --git a/Trading/src/test/java/com/suneesh/trading/ProtfolioTest.java b/Trading/src/test/java/com/suneesh/trading/ProtfolioTest.java new file mode 100644 index 0000000..ecd5b26 --- /dev/null +++ b/Trading/src/test/java/com/suneesh/trading/ProtfolioTest.java @@ -0,0 +1,46 @@ +package com.suneesh.trading; + +import com.suneesh.trading.models.requests.AuthorizeRequest; +import com.suneesh.trading.models.requests.PortfolioRequest; +import com.suneesh.trading.models.responses.AuthorizeResponse; +import com.suneesh.trading.models.responses.PortfolioResponse; +import com.suneesh.trading.models.responses.ResponseBase; +import io.reactivex.observers.TestObserver; +import org.junit.Test; + +import java.util.concurrent.TimeUnit; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/7/2017 + */ +public class ProtfolioTest extends TestBase { + + @Test + public void getPortfolioTest() throws Exception { + AuthorizeRequest authRequest = new AuthorizeRequest(properties.getProperty("CR_READ")); + PortfolioRequest request = new PortfolioRequest(); + TestObserver testObserver = new TestObserver<>(); + + this.api.sendRequest(authRequest) + .subscribe(o -> { + AuthorizeResponse auth = (AuthorizeResponse) o; + assertNotEquals(auth.getAuthorize(), null); + + this.api.sendRequest(request) + .subscribe(testObserver); + }); + + testObserver.await(10, TimeUnit.SECONDS); + + PortfolioResponse response = (PortfolioResponse) testObserver.values().get(0); + + assertEquals(response.getType(), "portfolio"); + assertEquals(response.getError(), null); + assertNotEquals(response.getPortfolio(), null); + } +} diff --git a/Trading/src/test/java/com/suneesh/trading/RealityCheckTest.java b/Trading/src/test/java/com/suneesh/trading/RealityCheckTest.java new file mode 100644 index 0000000..6b6e8e3 --- /dev/null +++ b/Trading/src/test/java/com/suneesh/trading/RealityCheckTest.java @@ -0,0 +1,46 @@ +package com.suneesh.trading; + +import com.suneesh.trading.models.requests.AuthorizeRequest; +import com.suneesh.trading.models.requests.RealityCheckRequest; +import com.suneesh.trading.models.responses.AuthorizeResponse; +import com.suneesh.trading.models.responses.RealityCheckResponse; +import com.suneesh.trading.models.responses.ResponseBase; +import io.reactivex.observers.TestObserver; +import org.junit.Test; + +import java.util.concurrent.TimeUnit; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/8/2017 + */ +public class RealityCheckTest extends TestBase { + + @Test + public void getRealityCheckTest() throws Exception { + AuthorizeRequest authRequest = new AuthorizeRequest(properties.getProperty("CR_READ")); + RealityCheckRequest request = new RealityCheckRequest(); + TestObserver testObserver = new TestObserver<>(); + + this.api.sendRequest(authRequest) + .subscribe( o -> { + AuthorizeResponse auth = (AuthorizeResponse) o; + assertNotEquals(auth.getAuthorize(), null); + + this.api.sendRequest(request) + .subscribe(testObserver); + }); + + testObserver.await(5, TimeUnit.SECONDS); + + RealityCheckResponse response = (RealityCheckResponse) testObserver.values().get(0); + + assertEquals(response.getType(), "reality_check"); + assertEquals(response.getError(), null); + assertNotEquals(response.getRealityCheck(), null); + } +} diff --git a/Trading/src/test/java/com/suneesh/trading/ResidenceListTest.java b/Trading/src/test/java/com/suneesh/trading/ResidenceListTest.java new file mode 100644 index 0000000..f21946f --- /dev/null +++ b/Trading/src/test/java/com/suneesh/trading/ResidenceListTest.java @@ -0,0 +1,44 @@ +package com.suneesh.trading; + +import com.suneesh.trading.core.ApiWrapper; +import com.suneesh.trading.models.requests.ResidenceListRequest; +import com.suneesh.trading.models.responses.ResidenceListResponce; +import com.suneesh.trading.models.responses.ResponseBase; +import io.reactivex.observers.TestObserver; +import org.junit.Before; +import org.junit.Test; + +import java.util.concurrent.TimeUnit; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/2/2017 + */ +public class ResidenceListTest { + private ApiWrapper api; + @Before + public void setup() throws Exception{ + this.api = ApiWrapper.build("10"); + } + + @Test + public void getResidencesTest() throws Exception { + ResidenceListRequest request = new ResidenceListRequest(); + TestObserver testObserver = new TestObserver<>(); + + this.api.sendRequest(request) + .subscribe(testObserver); + + testObserver.await(10, TimeUnit.SECONDS); + + ResidenceListResponce responce = (ResidenceListResponce) testObserver.values().get(0); + + assertEquals(responce.getType(), "residence_list"); + assertEquals(responce.getError(), null); + assertTrue(responce.getResidenceList().size() > 0); + } +} diff --git a/Trading/src/test/java/com/suneesh/trading/RevokeOauthFrameworkTest.java b/Trading/src/test/java/com/suneesh/trading/RevokeOauthFrameworkTest.java new file mode 100644 index 0000000..f0ef408 --- /dev/null +++ b/Trading/src/test/java/com/suneesh/trading/RevokeOauthFrameworkTest.java @@ -0,0 +1,46 @@ +package com.suneesh.trading; + +import com.suneesh.trading.models.requests.AuthorizeRequest; +import com.suneesh.trading.models.requests.RevokeOauthApplicationRequest; +import com.suneesh.trading.models.responses.AuthorizeResponse; +import com.suneesh.trading.models.responses.ResponseBase; +import com.suneesh.trading.models.responses.RevokeOauthApplicationResponse; +import io.reactivex.observers.TestObserver; +import org.junit.Test; + +import java.util.concurrent.TimeUnit; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 9/4/2017 + */ +public class RevokeOauthFrameworkTest extends TestBase { + + @Test + public void revokeInvalidApplicationTest() throws Exception { + AuthorizeRequest authRequest = new AuthorizeRequest(properties.getProperty("VRTC_ADMIN")); + RevokeOauthApplicationRequest request = new RevokeOauthApplicationRequest(1234L); + TestObserver testObserver = new TestObserver<>(); + + this.api.sendRequest(authRequest) + .subscribe( o -> { + AuthorizeResponse auth = (AuthorizeResponse) o; + assertNotEquals(auth.getAuthorize(), null); + + this.api.sendRequest(request) + .subscribe(testObserver); + }); + + testObserver.await(10, TimeUnit.SECONDS); + + RevokeOauthApplicationResponse response = (RevokeOauthApplicationResponse) testObserver.values().get(0); + + assertEquals(response.getType(), "revoke_oauth_app"); + assertEquals(response.getError(), null); + assertEquals(response.getResult(), new Integer(1)); + } +} diff --git a/Trading/src/test/java/com/suneesh/trading/SelfExcludeTest.java b/Trading/src/test/java/com/suneesh/trading/SelfExcludeTest.java new file mode 100644 index 0000000..ca61a83 --- /dev/null +++ b/Trading/src/test/java/com/suneesh/trading/SelfExcludeTest.java @@ -0,0 +1,60 @@ +package com.suneesh.trading; + +import com.suneesh.trading.core.ApiWrapper; +import com.suneesh.trading.models.requests.AuthorizeRequest; +import com.suneesh.trading.models.requests.GetSelfExclusionRequest; +import com.suneesh.trading.models.responses.AuthorizeResponse; +import com.suneesh.trading.models.responses.GetSelfExclusionResponse; +import com.suneesh.trading.models.responses.ResponseBase; +import io.reactivex.observers.TestObserver; +import org.junit.Before; +import org.junit.Test; + +import java.util.Properties; +import java.util.concurrent.TimeUnit; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/4/2017 + */ +public class SelfExcludeTest { + private ApiWrapper api; + private Properties properties; + + @Before + public void setUp() throws Exception { + TestUtility testUtility = new TestUtility(); + this.api = testUtility.getApi(); + this.properties = testUtility.getProperties(); + } + + @Test + public void getSelfExcludeTest() throws Exception { + AuthorizeRequest authRequest = new AuthorizeRequest(properties.getProperty("CR_READ"), false); + GetSelfExclusionRequest request = new GetSelfExclusionRequest(); + TestObserver testObserver = new TestObserver<>(); + + this.api.sendRequest(authRequest) + .subscribe(o -> { + AuthorizeResponse auth = (AuthorizeResponse) o; + assertNotEquals(auth.getAuthorize(), null); + + this.api.sendRequest(request) + .subscribe(testObserver); + }); + + testObserver.await(5, TimeUnit.SECONDS); + + GetSelfExclusionResponse response = (GetSelfExclusionResponse) testObserver.values().get(0); + + assertEquals(response.getType(), "get_self_exclusion"); + assertEquals(response.getError(), null); + assertNotEquals(response.getSelfExclusion(), null); + } + + +} diff --git a/Trading/src/test/java/com/suneesh/trading/SellContractTest.java b/Trading/src/test/java/com/suneesh/trading/SellContractTest.java new file mode 100644 index 0000000..4dfd95e --- /dev/null +++ b/Trading/src/test/java/com/suneesh/trading/SellContractTest.java @@ -0,0 +1,130 @@ +package com.suneesh.trading; + +import com.suneesh.trading.models.requests.AuthorizeRequest; +import com.suneesh.trading.models.requests.SellContractForMultipleAccountsRequest; +import com.suneesh.trading.models.requests.SellContractRequest; +import com.suneesh.trading.models.requests.SellExpiredContractsRequest; +import com.suneesh.trading.models.responses.*; +import com.google.gson.Gson; +import com.suneesh.trading.models.responses.*; +import io.reactivex.observers.TestObserver; +import org.junit.Test; + +import java.math.BigDecimal; +import java.util.concurrent.TimeUnit; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertTrue; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/9/2017 + */ +public class SellContractTest extends TestBase { + + // FIXME Test it through websocket instead of static data + @Test + public void sellContractForMultipleAccounts() throws Exception { + Gson gson = new Gson(); + SellContractForMultipleAccountsRequest request = gson.fromJson(getMassJsonRequest(), + SellContractForMultipleAccountsRequest.class); + SellContractForMultipleAccountsResponse response = gson.fromJson(getMassJsonResult(), + SellContractForMultipleAccountsResponse.class); + + assertEquals(request.getPrice(), response.getRequest().getPrice()); + } + + @Test + public void failedSellContractTest() throws Exception { + AuthorizeRequest authRequest = new AuthorizeRequest(properties.getProperty("CR_TRADE")); + SellContractRequest request = new SellContractRequest(11542203588L, new BigDecimal("50")); + TestObserver testObserver = new TestObserver<>(); + + this.api.sendRequest(authRequest) + .subscribe( o -> { + AuthorizeResponse auth = (AuthorizeResponse) o; + assertNotEquals(auth.getAuthorize(), null); + + this.api.sendRequest(request) + .subscribe(testObserver); + }); + + testObserver.await(5, TimeUnit.SECONDS); + + SellContractResponse response = (SellContractResponse) testObserver.values().get(0); + + assertEquals(response.getType(), "sell"); + assertNotEquals(response.getError(), null); + assertEquals(response.getError().getCode(), "InvalidSellContractProposal"); + } + + @Test + public void sellExpiredContractTest() throws Exception { + AuthorizeRequest authRequest = new AuthorizeRequest(properties.getProperty("CR_TRADE")); + SellExpiredContractsRequest request = new SellExpiredContractsRequest(); + TestObserver testObserver = new TestObserver<>(); + + this.api.sendRequest(authRequest) + .subscribe( o -> { + AuthorizeResponse auth = (AuthorizeResponse) o; + assertNotEquals(auth.getAuthorize(), null); + + this.api.sendRequest(request) + .subscribe(testObserver); + }); + + testObserver.await(5, TimeUnit.SECONDS); + + SellExpiredContractsResponse response = (SellExpiredContractsResponse) testObserver.values().get(0); + + assertEquals(response.getType(), "sell_expired"); + assertEquals(response.getError(), null); + assertTrue(response.getResult() >= new Integer(0)); + } + + private String getMassJsonRequest() { + return "{\n" + + " \"sell_contract_for_multiple_accounts\": 1,\n" + + " \"shortcode\": \"CALL_R_100_0.66_1502244892_1502245012_S0P_0\",\n" + + " \"tokens\": [\n" + + " \"yyvDHKC9cl6eErL\",\n" + + " \"JUBibibkebiuwbeCNEc\"\n" + + " ],\n" + + " \"price\": 0.35\n" + + "}"; + } + + private String getMassJsonResult() { + return "{\n" + + " \"echo_req\": {\n" + + " \"price\": 0.35,\n" + + " \"sell_contract_for_multiple_accounts\": 1,\n" + + " \"shortcode\": \"CALL_R_100_0.66_1502244892_1502245012_S0P_0\",\n" + + " \"tokens\": [\n" + + " \"yyvDHKC9cl6eErL\",\n" + + " \"JUBibibkebiuwbeCNEc\"\n" + + " ]\n" + + " },\n" + + " \"msg_type\": \"sell_contract_for_multiple_accounts\",\n" + + " \"sell_contract_for_multiple_accounts\": {\n" + + " \"result\": [\n" + + " {\n" + + " \"balance_after\": \"9997.92\",\n" + + " \"contract_id\": \"16752745128\",\n" + + " \"reference_id\": \"33427748228\",\n" + + " \"sell_price\": \"0.49\",\n" + + " \"sell_time\": \"2017-08-09 02:15:42\",\n" + + " \"transaction_id\": \"33427792408\"\n" + + " },\n" + + " {\n" + + " \"code\": \"InvalidToken\",\n" + + " \"message_to_client\": {},\n" + + " \"token\": \"JUBibibkebiuwbeCNEc\"\n" + + " }\n" + + " ]\n" + + " }\n" + + "}"; + } +} diff --git a/Trading/src/test/java/com/suneesh/trading/SetAccountCurrencyTest.java b/Trading/src/test/java/com/suneesh/trading/SetAccountCurrencyTest.java new file mode 100644 index 0000000..4b437d9 --- /dev/null +++ b/Trading/src/test/java/com/suneesh/trading/SetAccountCurrencyTest.java @@ -0,0 +1,49 @@ +package com.suneesh.trading; + +import com.suneesh.trading.models.requests.AuthorizeRequest; +import com.suneesh.trading.models.requests.SetAccountCurrencyRequest; +import com.suneesh.trading.models.responses.AuthorizeResponse; +import com.suneesh.trading.models.responses.ResponseBase; +import com.suneesh.trading.models.responses.SetAccountCurrencyResponse; +import io.reactivex.observers.TestObserver; +import org.junit.Test; + +import java.util.concurrent.TimeUnit; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertTrue; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 9/4/2017 + */ +public class SetAccountCurrencyTest extends TestBase { + + @Test + public void setCurrencyTest() throws Exception { + AuthorizeRequest authRequest = new AuthorizeRequest(properties.getProperty("CR_ADMIN")); + SetAccountCurrencyRequest request = new SetAccountCurrencyRequest("USD"); + TestObserver testObserver = new TestObserver<>(); + + this.api.sendRequest(authRequest) + .subscribe( o -> { + AuthorizeResponse auth = (AuthorizeResponse) o; + assertNotEquals(auth.getAuthorize(), null); + + this.api.sendRequest(request) + .subscribe(testObserver); + + }); + + testObserver.await(10, TimeUnit.SECONDS); + + SetAccountCurrencyResponse response = (SetAccountCurrencyResponse) testObserver.values().get(0); + + assertEquals(response.getType(), "set_account_currency"); + assertEquals(response.getError(), null); + assertTrue(response.getResult() >= 0); + + } +} diff --git a/Trading/src/test/java/com/suneesh/trading/SetAccountSettingsTest.java b/Trading/src/test/java/com/suneesh/trading/SetAccountSettingsTest.java new file mode 100644 index 0000000..3ab9de1 --- /dev/null +++ b/Trading/src/test/java/com/suneesh/trading/SetAccountSettingsTest.java @@ -0,0 +1,54 @@ +package com.suneesh.trading; + +import com.suneesh.trading.models.requests.AuthorizeRequest; +import com.suneesh.trading.models.requests.SetAccountSettingsRequest; +import com.suneesh.trading.models.responses.AuthorizeResponse; +import com.suneesh.trading.models.responses.ResponseBase; +import com.suneesh.trading.models.responses.SetAccountSettingsResponse; +import io.reactivex.observers.TestObserver; +import org.junit.Test; + +import java.util.concurrent.TimeUnit; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 9/14/2017 + */ +public class SetAccountSettingsTest extends TestBase { + + @Test + public void setAccountSettingsTest() throws Exception { + + AuthorizeRequest authRequest = new AuthorizeRequest(properties.getProperty("CR_ADMIN")); + SetAccountSettingsRequest request = new SetAccountSettingsRequest(); + TestObserver testObserver = new TestObserver<>(); + + request.setFirstLineAddress("Test Address Line 1"); + request.setSecondLineAddress("Test Address Line 2"); + request.setCity("Test City"); + request.setState("Test State"); + request.setPostcode("123456"); + request.setPhone("1234567890"); + + this.api.sendRequest(authRequest) + .subscribe( o -> { + AuthorizeResponse auth = (AuthorizeResponse) o; + assertNotEquals(auth.getAuthorize(), null); + + this.api.sendRequest(request) + .subscribe(testObserver); + }); + + testObserver.await(10, TimeUnit.SECONDS); + + SetAccountSettingsResponse response = (SetAccountSettingsResponse) testObserver.values().get(0); + + assertEquals(response.getType(), "set_settings"); + assertEquals(response.getError(), null); + assertEquals(response.getResult(), new Integer(1)); + } +} diff --git a/Trading/src/test/java/com/suneesh/trading/SetFinancialAssessmentRequestTest.java b/Trading/src/test/java/com/suneesh/trading/SetFinancialAssessmentRequestTest.java new file mode 100644 index 0000000..bc77660 --- /dev/null +++ b/Trading/src/test/java/com/suneesh/trading/SetFinancialAssessmentRequestTest.java @@ -0,0 +1,70 @@ +package com.suneesh.trading; + +import com.suneesh.trading.models.enums.*; +import com.suneesh.trading.models.requests.AuthorizeRequest; +import com.suneesh.trading.models.requests.SetFinancialAssessmentRequest; +import com.suneesh.trading.models.responses.AuthorizeResponse; +import com.suneesh.trading.models.responses.ResponseBase; +import com.suneesh.trading.models.responses.SetFinancialAssessmentResponse; +import com.suneesh.trading.models.enums.*; +import io.reactivex.observers.TestObserver; +import org.junit.Test; + +import java.util.concurrent.TimeUnit; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 9/11/2017 + */ +public class SetFinancialAssessmentRequestTest extends TestBase { + + @Test + public void setFinancialAssessmentTest() throws Exception { + AuthorizeRequest authRequest = new AuthorizeRequest(properties.getProperty("CR_ADMIN")); + SetFinancialAssessmentRequest request = new SetFinancialAssessmentRequest(); + request.setForexTradingExperience(ExperienceDuration.ONE_TO_TWO_YEARS); + request.setForexTradingFrequency(TradeFrequency.OVER_FORTY_TRANSACTIONS); + request.setIndicesTradingExperience(ExperienceDuration.ONE_TO_TWO_YEARS); + request.setIndicesTradingFrequency(TradeFrequency.OVER_FORTY_TRANSACTIONS); + request.setCommoditiesTradingExperience(ExperienceDuration.ONE_TO_TWO_YEARS); + request.setCommoditiesTradingFrequency(TradeFrequency.OVER_FORTY_TRANSACTIONS); + request.setStocksTradingExperience(ExperienceDuration.ONE_TO_TWO_YEARS); + request.setStocksTradingFrequency(TradeFrequency.OVER_FORTY_TRANSACTIONS); + request.setOtherDerivativesTradingExperience(ExperienceDuration.ONE_TO_TWO_YEARS); + request.setOtherDerivativesTradingFrequency(TradeFrequency.OVER_FORTY_TRANSACTIONS); + request.setOtherInstrumentsTradingExperience(ExperienceDuration.ONE_TO_TWO_YEARS); + request.setOtherInstrumentsTradingFrequency(TradeFrequency.OVER_FORTY_TRANSACTIONS); + request.setEmploymentIndustry(EmploymentIndustries.CONSTRUCTION); + request.setEducationLevel(EducationLevels.PRIMARY); + request.setIncomeSource(IncomeSources.INVESTMENTS_AND_DIVIDENDS); + request.setNetIncome(TurnoverRanges.FIFTY_TO_ONE_HUNDRED); + request.setEstimatedWorth(EstimatedWorth.FIVE_HUNDREDS_TO_ONE_MILLION); + request.setAccountTurnover(TurnoverRanges.FIFTY_TO_ONE_HUNDRED); + request.setOccupation(Occupations.AGRICULTURAL_FORESTRY_FISHERY_WORKERS); + request.setEmploymentStatus(EmploymentStatuses.EMPLOYED); + request.setSourceOfWealth(WealthSources.ACCUMULATION_INCOME_SAVINGS); + + TestObserver testObserver = new TestObserver<>(); + + this.api.sendRequest(authRequest) + .subscribe( o -> { + AuthorizeResponse auth = (AuthorizeResponse) o; + assertNotEquals(auth.getAuthorize(), null); + + this.api.sendRequest(request) + .subscribe(testObserver); + }); + + testObserver.await(10, TimeUnit.SECONDS); + + SetFinancialAssessmentResponse response = (SetFinancialAssessmentResponse) testObserver.values().get(0); + + assertEquals(response.getType(), "set_financial_assessment"); + assertEquals(response.getError(), null); + assertNotEquals(response.getResult(), null); + } +} diff --git a/Trading/src/test/java/com/suneesh/trading/SetSelfExlcusionSettingsRequestTest.java b/Trading/src/test/java/com/suneesh/trading/SetSelfExlcusionSettingsRequestTest.java new file mode 100644 index 0000000..f829960 --- /dev/null +++ b/Trading/src/test/java/com/suneesh/trading/SetSelfExlcusionSettingsRequestTest.java @@ -0,0 +1,48 @@ +package com.suneesh.trading; + +import com.suneesh.trading.models.requests.AuthorizeRequest; +import com.suneesh.trading.models.requests.SetSelfExclusionSettingsRequest; +import com.suneesh.trading.models.responses.AuthorizeResponse; +import com.suneesh.trading.models.responses.ResponseBase; +import com.suneesh.trading.models.responses.SetSelfExclusionSettingsResponse; +import io.reactivex.observers.TestObserver; +import org.junit.Test; + +import java.math.BigDecimal; +import java.util.concurrent.TimeUnit; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 9/12/2017 + */ +public class SetSelfExlcusionSettingsRequestTest extends TestBase { + + @Test + public void setSelfExclusionSettingsTest() throws Exception { + AuthorizeRequest authRequest = new AuthorizeRequest(properties.getProperty("CR_ADMIN")); + SetSelfExclusionSettingsRequest request = new SetSelfExclusionSettingsRequest(); + request.setMaxBalance(new BigDecimal("1000000")); + TestObserver testObserver = new TestObserver<>(); + + this.api.sendRequest(authRequest) + .subscribe( o -> { + AuthorizeResponse auth = (AuthorizeResponse) o; + assertNotEquals(auth.getAuthorize(), null); + + this.api.sendRequest(request) + .subscribe(testObserver); + }); + + testObserver.await(10, TimeUnit.SECONDS); + + SetSelfExclusionSettingsResponse response = (SetSelfExclusionSettingsResponse) testObserver.values().get(0); + + assertEquals(response.getType(), "set_self_exclusion"); + assertEquals(response.getError(), null); + assertEquals(response.getResult(), new Integer(1)); + } +} diff --git a/Trading/src/test/java/com/suneesh/trading/StatementTest.java b/Trading/src/test/java/com/suneesh/trading/StatementTest.java new file mode 100644 index 0000000..aba7be5 --- /dev/null +++ b/Trading/src/test/java/com/suneesh/trading/StatementTest.java @@ -0,0 +1,46 @@ +package com.suneesh.trading; + +import com.suneesh.trading.models.requests.AuthorizeRequest; +import com.suneesh.trading.models.requests.StatementRequest; +import com.suneesh.trading.models.responses.AuthorizeResponse; +import com.suneesh.trading.models.responses.ResponseBase; +import com.suneesh.trading.models.responses.StatementResponse; +import io.reactivex.observers.TestObserver; +import org.junit.Test; + +import java.util.concurrent.TimeUnit; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/7/2017 + */ +public class StatementTest extends TestBase { + + @Test + public void getStatement() throws Exception { + AuthorizeRequest authRequest = new AuthorizeRequest(properties.getProperty("CR_READ")); + StatementRequest request = new StatementRequest(); + TestObserver testObserver = new TestObserver<>(); + + this.api.sendRequest(authRequest) + .subscribe( o -> { + AuthorizeResponse auth = (AuthorizeResponse) o; + assertNotEquals(auth.getAuthorize(), null); + + this.api.sendRequest(request) + .subscribe(testObserver); + }); + + testObserver.await(5, TimeUnit.SECONDS); + + StatementResponse response = (StatementResponse) testObserver.values().get(0); + + assertEquals(response.getType(), "statement"); + assertEquals(response.getError(), null); + assertNotEquals(response.getStatement(), null); + } +} diff --git a/Trading/src/test/java/com/suneesh/trading/StatesListTest.java b/Trading/src/test/java/com/suneesh/trading/StatesListTest.java new file mode 100644 index 0000000..7b780f4 --- /dev/null +++ b/Trading/src/test/java/com/suneesh/trading/StatesListTest.java @@ -0,0 +1,44 @@ +package com.suneesh.trading; + +import com.suneesh.trading.core.ApiWrapper; +import com.suneesh.trading.models.requests.StatesListRequest; +import com.suneesh.trading.models.responses.ResponseBase; +import com.suneesh.trading.models.responses.StatesListResponse; +import io.reactivex.observers.TestObserver; +import org.junit.Before; +import org.junit.Test; + +import java.util.concurrent.TimeUnit; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/2/2017 + */ +public class StatesListTest { + private ApiWrapper api; + @Before + public void setup() throws Exception{ + this.api = ApiWrapper.build("10"); + } + + @Test + public void getStatesListTest() throws Exception { + StatesListRequest request = new StatesListRequest("de"); + TestObserver testObserver = new TestObserver<>(); + + this.api.sendRequest(request) + .subscribe(testObserver); + + testObserver.await(10, TimeUnit.SECONDS); + + StatesListResponse response = (StatesListResponse) testObserver.values().get(0); + + assertEquals(response.getType(), "states_list"); + assertEquals(response.getError(), null); + assertTrue(response.getStatesList().size() > 0); + } +} diff --git a/Trading/src/test/java/com/suneesh/trading/TNCApprovalTest.java b/Trading/src/test/java/com/suneesh/trading/TNCApprovalTest.java new file mode 100644 index 0000000..a0ee229 --- /dev/null +++ b/Trading/src/test/java/com/suneesh/trading/TNCApprovalTest.java @@ -0,0 +1,48 @@ +package com.suneesh.trading; + +import com.suneesh.trading.models.requests.AuthorizeRequest; +import com.suneesh.trading.models.requests.TNCApprovalRequest; +import com.suneesh.trading.models.responses.AuthorizeResponse; +import com.suneesh.trading.models.responses.ResponseBase; +import com.suneesh.trading.models.responses.TNCApprovalResponse; +import io.reactivex.observers.TestObserver; +import org.junit.Test; + +import java.util.concurrent.TimeUnit; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertTrue; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 9/4/2017 + */ +public class TNCApprovalTest extends TestBase { + + @Test + public void tncApprovalTest() throws Exception { + + AuthorizeRequest authRequest = new AuthorizeRequest(properties.getProperty("CR_ADMIN")); + TNCApprovalRequest request = new TNCApprovalRequest(); + TestObserver testObserver = new TestObserver<>(); + + this.api.sendRequest(authRequest) + .subscribe( o -> { + AuthorizeResponse auth = (AuthorizeResponse) o; + assertNotEquals(auth.getAuthorize(), null); + + this.api.sendRequest(request) + .subscribe(testObserver); + }); + + testObserver.await(10, TimeUnit.SECONDS); + + TNCApprovalResponse response = (TNCApprovalResponse) testObserver.values().get(0); + + assertEquals(response.getType(), "tnc_approval"); + assertEquals(response.getError(), null); + assertTrue(response.getResult() >= 0); + } +} diff --git a/Trading/src/test/java/com/suneesh/trading/TestBase.java b/Trading/src/test/java/com/suneesh/trading/TestBase.java new file mode 100644 index 0000000..05bd796 --- /dev/null +++ b/Trading/src/test/java/com/suneesh/trading/TestBase.java @@ -0,0 +1,30 @@ +package com.suneesh.trading; + +import com.suneesh.trading.core.ApiWrapper; +import org.junit.After; +import org.junit.Before; + +import java.util.Properties; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/7/2017 + */ +public class TestBase { + + protected ApiWrapper api; + protected Properties properties; + + @Before + public void setUp() throws Exception { + TestUtility testUtility = new TestUtility(); + this.api = testUtility.getApi(); + this.properties = testUtility.getProperties(); + } + + @After + public void cleanUp() throws Exception { + this.api.closeConnection(); + } +} diff --git a/Trading/src/test/java/com/suneesh/trading/TestUtility.java b/Trading/src/test/java/com/suneesh/trading/TestUtility.java new file mode 100644 index 0000000..6fdeeee --- /dev/null +++ b/Trading/src/test/java/com/suneesh/trading/TestUtility.java @@ -0,0 +1,37 @@ +package com.suneesh.trading; + +import com.suneesh.trading.core.ApiWrapper; + +import java.io.IOException; +import java.io.InputStream; +import java.util.Properties; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/4/2017 + */ +public class TestUtility { + private ApiWrapper api; + private Properties properties; + + public TestUtility() throws Exception { + this.properties = new Properties(); + InputStream inputStream = ClassLoader.getSystemResourceAsStream("TestEnvironment.properties"); + try{ + properties.load(inputStream); + this.api = ApiWrapper.build("10"); + } + catch (IOException ex){ + throw ex; + } + } + + public ApiWrapper getApi() { + return api; + } + + public Properties getProperties() { + return properties; + } +} diff --git a/Trading/src/test/java/com/suneesh/trading/TickHistoryTest.java b/Trading/src/test/java/com/suneesh/trading/TickHistoryTest.java new file mode 100644 index 0000000..c547c15 --- /dev/null +++ b/Trading/src/test/java/com/suneesh/trading/TickHistoryTest.java @@ -0,0 +1,67 @@ +package com.suneesh.trading; + +import com.suneesh.trading.core.ApiWrapper; +import com.suneesh.trading.models.enums.TickStyles; +import com.suneesh.trading.models.requests.TickHistoryRequest; +import com.suneesh.trading.models.responses.ResponseBase; +import com.suneesh.trading.models.responses.TickHistoryResponse; +import io.reactivex.observers.TestObserver; +import org.junit.Before; +import org.junit.Test; + +import java.util.concurrent.TimeUnit; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertTrue; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/3/2017 + */ +public class TickHistoryTest { + private ApiWrapper api; + @Before + public void setup() throws Exception{ + this.api = ApiWrapper.build("10"); + } + + @Test + public void getTickHistory() throws Exception { + TickHistoryRequest request = new TickHistoryRequest("R_50", "latest"); + TestObserver testObserver = new TestObserver<>(); + request.setCount(10); + + this.api.sendRequest(request) + .subscribe(testObserver); + + testObserver.await(10, TimeUnit.SECONDS); + + TickHistoryResponse response = (TickHistoryResponse) testObserver.values().get(0); + + assertEquals(response.getType(), "history"); + assertEquals(response.getError(), null); + assertTrue(response.getHistory().getPrices().size() == response.getHistory().getTimes().size()); + } + + @Test + public void getCandles() throws Exception { + TickHistoryRequest request = new TickHistoryRequest("R_50", "latest"); + TestObserver testObserver = new TestObserver<>(); + request.setStyle(TickStyles.CANDLES); + + this.api.sendRequest(request) + .subscribe(testObserver); + + testObserver.await(10, TimeUnit.SECONDS); + + TickHistoryResponse response = (TickHistoryResponse) testObserver.values().get(0); + + assertEquals(response.getType(), "candles"); + assertEquals(response.getError(), null); + assertTrue(response.getCandles().size() > 0); + } + + // TODO Test subscribe for TickHistory in both styles (Candles, Tick) +} diff --git a/Trading/src/test/java/com/suneesh/trading/TickRequestTest.java b/Trading/src/test/java/com/suneesh/trading/TickRequestTest.java new file mode 100644 index 0000000..091cd9f --- /dev/null +++ b/Trading/src/test/java/com/suneesh/trading/TickRequestTest.java @@ -0,0 +1,41 @@ +package com.suneesh.trading; + +import com.suneesh.trading.core.ApiWrapper; +import com.suneesh.trading.models.requests.TickRequest; +import com.suneesh.trading.models.responses.ResponseBase; +import io.reactivex.observers.TestObserver; +import io.reactivex.schedulers.TestScheduler; +import org.junit.Before; +import org.junit.Test; + +import java.util.concurrent.TimeUnit; + +import static org.junit.Assert.assertEquals; + +/** + * Created by morteza on 7/25/2017. + */ +public class TickRequestTest { + private ApiWrapper api; + @Before + public void setup() throws Exception{ + this.api = ApiWrapper.build("21829"); + } + + @Test + public void getTickTest() throws Exception { + TickRequest request = new TickRequest("R_10"); + TestObserver testSubscriber = new TestObserver<>(); + TestScheduler testScheduler = new TestScheduler(); + + this.api.sendRequest(request) + .subscribe(testSubscriber); + + testSubscriber + .await(10, TimeUnit.SECONDS); + ResponseBase responseBase = testSubscriber + .values().get(0); + + assertEquals(responseBase.getType(), "tick"); + } +} diff --git a/Trading/src/test/java/com/suneesh/trading/TimeTest.java b/Trading/src/test/java/com/suneesh/trading/TimeTest.java new file mode 100644 index 0000000..a953556 --- /dev/null +++ b/Trading/src/test/java/com/suneesh/trading/TimeTest.java @@ -0,0 +1,44 @@ +package com.suneesh.trading; + +import com.suneesh.trading.core.ApiWrapper; +import com.suneesh.trading.models.requests.TimeRequest; +import com.suneesh.trading.models.responses.ResponseBase; +import com.suneesh.trading.models.responses.TimeResponse; +import io.reactivex.observers.TestObserver; +import org.junit.Before; +import org.junit.Test; + +import java.util.concurrent.TimeUnit; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/3/2017 + */ +public class TimeTest { + private ApiWrapper api; + @Before + public void setup() throws Exception{ + this.api = ApiWrapper.build("10"); + } + + @Test + public void getTime() throws Exception { + TimeRequest request = new TimeRequest(); + TestObserver testObserver = new TestObserver<>(); + + this.api.sendRequest(request) + .subscribe(testObserver); + + testObserver.await(10, TimeUnit.SECONDS); + + TimeResponse response = (TimeResponse) testObserver.values().get(0); + + assertEquals(response.getType(), "time"); + assertEquals(response.getError(), null); + assertTrue(response.getTime() > 0); + } +} diff --git a/Trading/src/test/java/com/suneesh/trading/TopUpVritualMoneyTest.java b/Trading/src/test/java/com/suneesh/trading/TopUpVritualMoneyTest.java new file mode 100644 index 0000000..0e4e0a9 --- /dev/null +++ b/Trading/src/test/java/com/suneesh/trading/TopUpVritualMoneyTest.java @@ -0,0 +1,45 @@ +package com.suneesh.trading; + +import com.suneesh.trading.models.requests.AuthorizeRequest; +import com.suneesh.trading.models.requests.TopUpVirtualMoneyAccountRequest; +import com.suneesh.trading.models.responses.AuthorizeResponse; +import com.suneesh.trading.models.responses.ResponseBase; +import com.suneesh.trading.models.responses.TopUpVirtualMoneyAccountResponse; +import io.reactivex.observers.TestObserver; +import org.junit.Test; + +import java.util.concurrent.TimeUnit; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertTrue; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/9/2017 + */ +public class TopUpVritualMoneyTest extends TestBase { + + @Test + public void topUpVirtualMoneyTest() throws Exception { + AuthorizeRequest authRequest = new AuthorizeRequest(properties.getProperty("VRTC_TRADE")); + TopUpVirtualMoneyAccountRequest request = new TopUpVirtualMoneyAccountRequest(); + TestObserver testObserver = new TestObserver<>(); + + this.api.sendRequest(authRequest) + .subscribe( o -> { + AuthorizeResponse auth = (AuthorizeResponse) o; + assertNotEquals(auth.getAuthorize(), null); + + this.api.sendRequest(request) + .subscribe(testObserver); + }); + + testObserver.await(5, TimeUnit.SECONDS); + + TopUpVirtualMoneyAccountResponse response = (TopUpVirtualMoneyAccountResponse) testObserver.values().get(0); + + assertEquals(response.getType(), "topup_virtual"); + } +} diff --git a/Trading/src/test/java/com/suneesh/trading/TradingTimesTest.java b/Trading/src/test/java/com/suneesh/trading/TradingTimesTest.java new file mode 100644 index 0000000..f362034 --- /dev/null +++ b/Trading/src/test/java/com/suneesh/trading/TradingTimesTest.java @@ -0,0 +1,46 @@ +package com.suneesh.trading; + +import com.suneesh.trading.core.ApiWrapper; +import com.suneesh.trading.models.requests.TradingTimesRequest; +import com.suneesh.trading.models.responses.ResponseBase; +import com.suneesh.trading.models.responses.TradingTimesResponse; +import io.reactivex.observers.TestObserver; +import org.junit.Before; +import org.junit.Test; + +import java.util.concurrent.TimeUnit; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertTrue; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/3/2017 + */ +public class TradingTimesTest { + private ApiWrapper api; + @Before + public void setup() throws Exception{ + this.api = ApiWrapper.build("10"); + } + + @Test + public void getTradingTimesTest() throws Exception { + TradingTimesRequest request = new TradingTimesRequest("2017-08-03"); + TestObserver testObserver = new TestObserver<>(); + + this.api.sendRequest(request) + .subscribe(testObserver); + + testObserver.await(10, TimeUnit.SECONDS); + + TradingTimesResponse response = (TradingTimesResponse) testObserver.values().get(0); + + assertEquals(response.getType(), "trading_times"); + assertEquals(response.getError(), null); + assertNotEquals(response.getTradingTimes(), null); + assertTrue(response.getTradingTimes().getMarkets().size() > 0); + } +} diff --git a/Trading/src/test/java/com/suneesh/trading/TransactionStreamTest.java b/Trading/src/test/java/com/suneesh/trading/TransactionStreamTest.java new file mode 100644 index 0000000..e10091f --- /dev/null +++ b/Trading/src/test/java/com/suneesh/trading/TransactionStreamTest.java @@ -0,0 +1,46 @@ +package com.suneesh.trading; + +import com.suneesh.trading.models.requests.AuthorizeRequest; +import com.suneesh.trading.models.requests.TransactionsStreamRequest; +import com.suneesh.trading.models.responses.AuthorizeResponse; +import com.suneesh.trading.models.responses.ResponseBase; +import com.suneesh.trading.models.responses.TransactionsStreamResponse; +import io.reactivex.observers.TestObserver; +import org.junit.Test; + +import java.util.concurrent.TimeUnit; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/8/2017 + */ +public class TransactionStreamTest extends TestBase { + + @Test + public void subscribeTransactionsTest() throws Exception { + AuthorizeRequest authRequest = new AuthorizeRequest(properties.getProperty("VRTC_READ")); + TransactionsStreamRequest request = new TransactionsStreamRequest(); + TestObserver testObserver = new TestObserver<>(); + + this.api.sendRequest(authRequest) + .subscribe( o -> { + AuthorizeResponse auth = (AuthorizeResponse) o; + assertNotEquals(auth.getAuthorize(), null); + + this.api.sendRequest(request) + .subscribe(testObserver); + }); + + testObserver.await(5, TimeUnit.SECONDS); + + TransactionsStreamResponse response = (TransactionsStreamResponse) testObserver.values().get(0); + + assertEquals(response.getType(), "transaction"); + assertEquals(response.getError(), null); + assertNotEquals(response.getTransaction().getId(), null); + } +} diff --git a/Trading/src/test/java/com/suneesh/trading/TransferBetweenAccountsTest.java b/Trading/src/test/java/com/suneesh/trading/TransferBetweenAccountsTest.java new file mode 100644 index 0000000..9d9c917 --- /dev/null +++ b/Trading/src/test/java/com/suneesh/trading/TransferBetweenAccountsTest.java @@ -0,0 +1,54 @@ +package com.suneesh.trading; + +import com.suneesh.trading.models.requests.AuthorizeRequest; +import com.suneesh.trading.models.requests.TransferBetweenAccountsRequest; +import com.suneesh.trading.models.responses.AuthorizeResponse; +import com.suneesh.trading.models.responses.ResponseBase; +import com.suneesh.trading.models.responses.TransferBetweenAccountsResponse; +import io.reactivex.observers.TestObserver; +import org.junit.Test; + +import java.math.BigDecimal; +import java.util.concurrent.TimeUnit; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 9/15/2017 + */ +public class TransferBetweenAccountsTest extends TestBase { + + @Test + public void invalidTransfer() throws Exception { + + AuthorizeRequest authRequest = new AuthorizeRequest(properties.getProperty("CR_PAYMENTS")); + TransferBetweenAccountsRequest request = new TransferBetweenAccountsRequest(); + TestObserver testObserver = new TestObserver<>(); + + request.setAccountFrom("CR494048"); + request.setAccountTo("CR494048"); + request.setAmount(new BigDecimal(1000)); + request.setCurrency("USD"); + + this.api.sendRequest(authRequest) + .subscribe( o -> { + AuthorizeResponse auth = (AuthorizeResponse) o; + assertNotEquals(auth.getAuthorize(), null); + + this.api.sendRequest(request) + .subscribe(testObserver); + }); + + + testObserver.await(10, TimeUnit.SECONDS); + + TransferBetweenAccountsResponse response = (TransferBetweenAccountsResponse) testObserver.values().get(0); + + assertEquals(response.getType(), "transfer_between_accounts"); + assertEquals(response.getError().getCode(), "TransferBetweenAccountsError"); + assertEquals(response.getError().getMessage(), "Account transfers are not available within same account."); + } +} diff --git a/Trading/src/test/java/com/suneesh/trading/WebsiteStatusTest.java b/Trading/src/test/java/com/suneesh/trading/WebsiteStatusTest.java new file mode 100644 index 0000000..a669914 --- /dev/null +++ b/Trading/src/test/java/com/suneesh/trading/WebsiteStatusTest.java @@ -0,0 +1,44 @@ +package com.suneesh.trading; + +import com.suneesh.trading.core.ApiWrapper; +import com.suneesh.trading.models.requests.WebsiteStatusRequest; +import com.suneesh.trading.models.responses.ResponseBase; +import com.suneesh.trading.models.responses.WebsiteStatusResponse; +import io.reactivex.observers.TestObserver; +import org.junit.Before; +import org.junit.Test; + +import java.util.concurrent.TimeUnit; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; + +/** + * @author Morteza Tavanarad + * @version 1.0.0 + * @since 8/3/2017 + */ +public class WebsiteStatusTest { + private ApiWrapper api; + @Before + public void setup() throws Exception{ + this.api = ApiWrapper.build("10"); + } + + @Test + public void getWebsiteStatusTest() throws Exception { + WebsiteStatusRequest request = new WebsiteStatusRequest(); + TestObserver testObserver = new TestObserver<>(); + + this.api.sendRequest(request) + .subscribe(testObserver); + + testObserver.await(10, TimeUnit.SECONDS); + + WebsiteStatusResponse response = (WebsiteStatusResponse) testObserver.values().get(0); + + assertEquals(response.getType(), "website_status"); + assertEquals(response.getError(), null); + assertNotEquals(response.getWebsiteStatus(), null); + } +} diff --git a/Trading/src/test/java/com/suneesh/trading/core/BlackScholesPricingTest.java b/Trading/src/test/java/com/suneesh/trading/core/BlackScholesPricingTest.java new file mode 100644 index 0000000..f2630af --- /dev/null +++ b/Trading/src/test/java/com/suneesh/trading/core/BlackScholesPricingTest.java @@ -0,0 +1,77 @@ +package com.suneesh.trading.core; + +import com.suneesh.trading.core.calculations.BlackScholes; +import com.suneesh.trading.core.calculations.DeltaPercentage; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.math3.distribution.NormalDistribution; +import org.junit.Test; + +import java.time.LocalDateTime; +import java.time.ZoneOffset; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Optional; + +@Slf4j +public class BlackScholesPricingTest { + + @Test + public void testBlackScholes() { + HashMap inputMap = new HashMap<>(); + + // Instantaneous price + inputMap.put("stock", 188.6181); + // Barrier + inputMap.put("strike", 188.5267); + inputMap.put("volatility", 0.05D); + inputMap.put("interest", 0.01D); + + Double aDouble = Double.valueOf(((4 * 60) + 47) / 365); + log.info("aDouble = {}", aDouble); +// inputMap.put("timehorizon",Double.valueOf(((4*60)+47)/365)); + inputMap.put("timehorizon", 1.5863); + + BlackScholes bs = new BlackScholes(inputMap); + double call = bs.getCall(); + + log.info("call = {}", call); + } + + @Test + public void EpochTest() { + log.info("{}", Math.toIntExact(LocalDateTime.now().toEpochSecond(ZoneOffset.UTC) % 60)); + log.info("{}", Math.toIntExact(LocalDateTime.now().toEpochSecond(ZoneOffset.UTC))); + log.info("{}", LocalDateTime.now()); + + int epochTime = Math.toIntExact(LocalDateTime.now().toEpochSecond(ZoneOffset.UTC)); + log.info("{}", epochTime); + log.info("{}", epochTime % 60); + + } + + @Test + public void calcDeltaPercentage() { + HashMap inputMap = new HashMap<>(); + final double VOLATILITY = 0.03D; + final double INTEREST = 0.01D; + final double TRADE_DURATION = 600D; + +// double timeLeftOnTrade = TRADE_DURATION - 21; + double timeHorizon = (555.0 / 365.0) / 365.0; + + + inputMap.put("stock", 189.2041); + inputMap.put("strike", 189.3979); + inputMap.put("volatility", VOLATILITY); + inputMap.put("interest", INTEREST); + inputMap.put("timehorizon", timeHorizon); + + log.info(inputMap.toString()); + + DeltaPercentage dp = new DeltaPercentage(inputMap); + double tradeDeltaPercentage = dp.calculate(); + log.info("Trade's Delta Percentage = {}", tradeDeltaPercentage); + + + } +} \ No newline at end of file diff --git a/Trading/src/test/java/com/suneesh/trading/core/CalculationTest.java b/Trading/src/test/java/com/suneesh/trading/core/CalculationTest.java new file mode 100644 index 0000000..f9ac99b --- /dev/null +++ b/Trading/src/test/java/com/suneesh/trading/core/CalculationTest.java @@ -0,0 +1,128 @@ +package com.suneesh.trading.core; + +import lombok.Data; +import lombok.extern.slf4j.Slf4j; +import org.junit.Test; + +import java.util.*; + +@Slf4j +//@Data +public class CalculationTest{ + + @Data + class Trade{ + public Trade(Boolean tradeResult, Double amount) { + this.tradeResult = tradeResult; + this.amount = amount; + } + + Boolean tradeResult; + Double amount; + }; + + List testResultList = new ArrayList<>(); + + Map stepBidResultAmountMap = new HashMap<>(); + + double initialBidAmount = 1.0D; + double nextBidMultiple = 2.5D; + double maxBidAmount = 40.0D; + + boolean useRecoverStrategyFlag = false; + double recoveryAmount = 10.0D; + int maxRecoveryAttemptCount = 0 ; + int recoveryCount = 0 ; + + Random random = new Random(); + int counter = 0; + double value = initialBidAmount; + + public CalculationTest(){ + maxRecoveryAttemptCount = (int) Math.ceil( maxBidAmount*nextBidMultiple / recoveryAmount); + testResultList = Arrays.asList(false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false); +// testResultList = Arrays.asList(false,false,true,false,false,false,false,false,false,false,false,false,false,false,false,false); + } + + + @Test + public void calculationTest() { + String type = random.nextBoolean()?"CALL":"PUT"; + Double prevBidAmount = initialBidAmount; + + for(Boolean result : testResultList){ + Double nextBidAmount = getNextBidAmount(result, stepBidResultAmountMap); + log.info("Last Option Result / Last Amount / Next Amount = {} / {} /{}",result, prevBidAmount, nextBidAmount); + + } + + log.info("Test finished."); + } + + public Double getNextBidAmount(Boolean islastBidSuccessful, Map stepTradeMap) { + Trade newTrade = new Trade(islastBidSuccessful,1.0D); + + Integer mapSize = Integer.valueOf(stepTradeMap.size()); + Trade prevTrade = new Trade(islastBidSuccessful,1.0D); + if( mapSize > 0 ) { + prevTrade = stepTradeMap.get(counter); + } + + counter = ++mapSize; + stepTradeMap.put(counter, newTrade); + + if (useRecoverStrategyFlag){ + if (recoveryCount < maxRecoveryAttemptCount) { + newTrade.setAmount(recoveryAmount); +// log.info("Using Recovery strategy. NextBidAmount / Recovery Amount = {}. , recoveryCount / maxRecoveryAttemptCount = ", newTrade.getAmount(), recoveryCount, maxRecoveryAttemptCount); + recoveryCount++; + } else { + useRecoverStrategyFlag=false; + newTrade.setAmount(initialBidAmount); + stepTradeMap.clear(); + stepTradeMap.put(counter, newTrade); + + +// log.info("Stopping Recovery strategy. Resetting value to start Value of {}., recoveryCount/ maxRecoveryAttemptCount = {}/{} ", newTrade.getAmount(), recoveryCount, maxRecoveryAttemptCount); + } + } + else{ + if (islastBidSuccessful) { + newTrade.setAmount(initialBidAmount); +// log.info("Last Binary Option succeeded. Resetting Bid amount to initial value of {}.", newTrade.getAmount()); + } + else { +// log.info("Last Binary Option failed..."); + Double newTradeAmount; + if(counter>1) { + newTradeAmount = prevTrade.getAmount() * nextBidMultiple; + } + else{ + newTradeAmount = initialBidAmount; + } + + if (newTradeAmount < maxBidAmount) { + value = Double.valueOf(String.format("%.2f", value).replace(",", ".")); + newTrade.setAmount(newTradeAmount); +// log.info("Next bid amount = {}.", newTradeAmount); + } else { + useRecoverStrategyFlag = true; + recoveryCount++; + newTrade.setAmount(recoveryAmount); + } + } + } + displayMap(stepTradeMap); + + Double result = newTrade.getAmount(); + return result; + + } + + private void displayMap( Map stepTradeMap){ + for(Map.Entry entry : stepTradeMap.entrySet()){ + log.info("{} : {} - {}", entry.getKey(),entry.getValue().getTradeResult(),entry.getValue().getAmount()); + } + + } +} diff --git a/Trading/src/test/java/com/suneesh/trading/database/DatabaseApplicationTest.java b/Trading/src/test/java/com/suneesh/trading/database/DatabaseApplicationTest.java new file mode 100644 index 0000000..045af79 --- /dev/null +++ b/Trading/src/test/java/com/suneesh/trading/database/DatabaseApplicationTest.java @@ -0,0 +1,92 @@ +package com.suneesh.trading.database; + +import com.suneesh.trading.utils.AutoTradingUtility; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.CollectionUtils; +import org.junit.Test; + +import java.io.File; +import java.io.IOException; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; + +@Slf4j +public class DatabaseApplicationTest { + PostgreSQLDatabaseConnection postgreSQLDatabaseConnection = null; + + @Test + public void databaseTest() { + + String databaseServer = AutoTradingUtility.getPropertyFromPropertyFile("DatabaseServerEngine"); + String dbURL = AutoTradingUtility.getPropertyFromPropertyFile("DatabaseURL"); + + + postgreSQLDatabaseConnection = new PostgreSQLDatabaseConnection("jdbc:postgresql://192.168.99.100:5432/automated_trading"); + postgreSQLDatabaseConnection.createConnection(); + + List tableNameList = Arrays.asList("authorize", + "balance", + "candle", + "portfolio_transaction", + "strategy", + "strategy_steps", + "tick", + "transaction", + "trade"); + + tableNameList.stream().forEach(table -> { + if(postgreSQLDatabaseConnection.checkTableExists(table)){ + log.info("Table {} Exists.", table); + } + else{ + log.info("Table {} does not Exist.", table); + File file = AutoTradingUtility.getFileFromResources(table+".sql"); + try { + postgreSQLDatabaseConnection.executeNoResultSet(AutoTradingUtility.readFile(file)); + } catch (IOException e) { + e.printStackTrace(); + } + + log.info("Checking after Create table query..."); + if(postgreSQLDatabaseConnection.checkTableExists(table)){ + log.info("Table {} Exists.", table); + } + else { + log.info("Table {} still does not Exists.", table); + } + + } + + + }); + + checkAndPopulateTables(); + } + + private void checkAndPopulateTables(){ + List> result = (List>)postgreSQLDatabaseConnection.executeQuery("select * from strategy"); + + if(CollectionUtils.isEmpty(result)){ + log.info("Strategy Table not populated."); + File file = AutoTradingUtility.getFileFromResources("populate_strategy_steps.sql"); + try { + postgreSQLDatabaseConnection.executeNoResultSet(AutoTradingUtility.readFile(file)); + if( !CollectionUtils.isEmpty(postgreSQLDatabaseConnection.executeQuery("select * from strategy") )) + { + log.info("strategy & strategy_steps tables populated."); + } + else{ + log.error("ERROR! strategy & strategy_steps tables NOT populated."); + } + } catch (IOException e) { + e.printStackTrace(); + } + + } + else { + result.forEach(f -> log.info(String.valueOf(f))); + } + + } +} diff --git a/Trading/target/classes/com/suneesh/trading/ApiWrapper.class b/Trading/target/classes/com/suneesh/trading/ApiWrapper.class new file mode 100644 index 0000000..a5c2b48 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/ApiWrapper.class differ diff --git a/Trading/target/classes/com/suneesh/trading/MainApplication.class b/Trading/target/classes/com/suneesh/trading/MainApplication.class new file mode 100644 index 0000000..84580c9 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/MainApplication.class differ diff --git a/Trading/target/classes/com/suneesh/trading/WebsocketListener.class b/Trading/target/classes/com/suneesh/trading/WebsocketListener.class new file mode 100644 index 0000000..a688d85 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/WebsocketListener.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/WebsocketEvent.class b/Trading/target/classes/com/suneesh/trading/models/WebsocketEvent.class new file mode 100644 index 0000000..e8e6e55 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/WebsocketEvent.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/enums/AccountOpeningReasons.class b/Trading/target/classes/com/suneesh/trading/models/enums/AccountOpeningReasons.class new file mode 100644 index 0000000..62f7ada Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/enums/AccountOpeningReasons.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/enums/BasisTypes.class b/Trading/target/classes/com/suneesh/trading/models/enums/BasisTypes.class new file mode 100644 index 0000000..c9c895b Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/enums/BasisTypes.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/enums/CashierProviders.class b/Trading/target/classes/com/suneesh/trading/models/enums/CashierProviders.class new file mode 100644 index 0000000..c5dc1bb Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/enums/CashierProviders.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/enums/CashierTypes.class b/Trading/target/classes/com/suneesh/trading/models/enums/CashierTypes.class new file mode 100644 index 0000000..a07cf50 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/enums/CashierTypes.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/enums/DurationUnits.class b/Trading/target/classes/com/suneesh/trading/models/enums/DurationUnits.class new file mode 100644 index 0000000..18a40c0 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/enums/DurationUnits.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/enums/EducationLevels.class b/Trading/target/classes/com/suneesh/trading/models/enums/EducationLevels.class new file mode 100644 index 0000000..fd8eb55 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/enums/EducationLevels.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/enums/EmailVerificationReasons.class b/Trading/target/classes/com/suneesh/trading/models/enums/EmailVerificationReasons.class new file mode 100644 index 0000000..0b52502 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/enums/EmailVerificationReasons.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/enums/EmploymentIndustries.class b/Trading/target/classes/com/suneesh/trading/models/enums/EmploymentIndustries.class new file mode 100644 index 0000000..0b9269b Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/enums/EmploymentIndustries.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/enums/EmploymentStatuses.class b/Trading/target/classes/com/suneesh/trading/models/enums/EmploymentStatuses.class new file mode 100644 index 0000000..de01205 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/enums/EmploymentStatuses.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/enums/EstimatedWorth.class b/Trading/target/classes/com/suneesh/trading/models/enums/EstimatedWorth.class new file mode 100644 index 0000000..7f5a589 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/enums/EstimatedWorth.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/enums/ExperienceDuration.class b/Trading/target/classes/com/suneesh/trading/models/enums/ExperienceDuration.class new file mode 100644 index 0000000..52f5a06 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/enums/ExperienceDuration.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/enums/Gender.class b/Trading/target/classes/com/suneesh/trading/models/enums/Gender.class new file mode 100644 index 0000000..4a3dbf2 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/enums/Gender.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/enums/HedgeAssets.class b/Trading/target/classes/com/suneesh/trading/models/enums/HedgeAssets.class new file mode 100644 index 0000000..b3b8992 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/enums/HedgeAssets.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/enums/IncomeSources.class b/Trading/target/classes/com/suneesh/trading/models/enums/IncomeSources.class new file mode 100644 index 0000000..3a66cf6 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/enums/IncomeSources.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/enums/JPAnnualIncomes.class b/Trading/target/classes/com/suneesh/trading/models/enums/JPAnnualIncomes.class new file mode 100644 index 0000000..9b75e02 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/enums/JPAnnualIncomes.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/enums/JPOccupations.class b/Trading/target/classes/com/suneesh/trading/models/enums/JPOccupations.class new file mode 100644 index 0000000..bbc1651 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/enums/JPOccupations.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/enums/JPStatus.class b/Trading/target/classes/com/suneesh/trading/models/enums/JPStatus.class new file mode 100644 index 0000000..89dd023 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/enums/JPStatus.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/enums/JPTradingExperiences.class b/Trading/target/classes/com/suneesh/trading/models/enums/JPTradingExperiences.class new file mode 100644 index 0000000..eba73ae Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/enums/JPTradingExperiences.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/enums/JPTradingPurposes.class b/Trading/target/classes/com/suneesh/trading/models/enums/JPTradingPurposes.class new file mode 100644 index 0000000..ff0f9df Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/enums/JPTradingPurposes.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/enums/Occupations.class b/Trading/target/classes/com/suneesh/trading/models/enums/Occupations.class new file mode 100644 index 0000000..e8332cf Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/enums/Occupations.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/enums/Salutation.class b/Trading/target/classes/com/suneesh/trading/models/enums/Salutation.class new file mode 100644 index 0000000..5daf9ed Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/enums/Salutation.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/enums/Scopes.class b/Trading/target/classes/com/suneesh/trading/models/enums/Scopes.class new file mode 100644 index 0000000..ae9d8f1 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/enums/Scopes.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/enums/SecretQuestions.class b/Trading/target/classes/com/suneesh/trading/models/enums/SecretQuestions.class new file mode 100644 index 0000000..8f0acb1 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/enums/SecretQuestions.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/enums/SortTypes.class b/Trading/target/classes/com/suneesh/trading/models/enums/SortTypes.class new file mode 100644 index 0000000..62b3cd8 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/enums/SortTypes.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/enums/StreamTypes.class b/Trading/target/classes/com/suneesh/trading/models/enums/StreamTypes.class new file mode 100644 index 0000000..026b659 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/enums/StreamTypes.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/enums/TestResult.class b/Trading/target/classes/com/suneesh/trading/models/enums/TestResult.class new file mode 100644 index 0000000..3638950 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/enums/TestResult.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/enums/TickStyles.class b/Trading/target/classes/com/suneesh/trading/models/enums/TickStyles.class new file mode 100644 index 0000000..0308dc5 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/enums/TickStyles.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/enums/TradeFrequency.class b/Trading/target/classes/com/suneesh/trading/models/enums/TradeFrequency.class new file mode 100644 index 0000000..2175e33 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/enums/TradeFrequency.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/enums/TransactionType.class b/Trading/target/classes/com/suneesh/trading/models/enums/TransactionType.class new file mode 100644 index 0000000..df44412 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/enums/TransactionType.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/enums/TurnoverRanges.class b/Trading/target/classes/com/suneesh/trading/models/enums/TurnoverRanges.class new file mode 100644 index 0000000..dfe6e81 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/enums/TurnoverRanges.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/enums/WealthSources.class b/Trading/target/classes/com/suneesh/trading/models/enums/WealthSources.class new file mode 100644 index 0000000..0a88296 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/enums/WealthSources.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/enums/WorthRanges.class b/Trading/target/classes/com/suneesh/trading/models/enums/WorthRanges.class new file mode 100644 index 0000000..ae052a1 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/enums/WorthRanges.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/requests/AccountLimitsRequest.class b/Trading/target/classes/com/suneesh/trading/models/requests/AccountLimitsRequest.class new file mode 100644 index 0000000..4a8bb9b Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/requests/AccountLimitsRequest.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/requests/AccountSettingsRequest.class b/Trading/target/classes/com/suneesh/trading/models/requests/AccountSettingsRequest.class new file mode 100644 index 0000000..a70f23b Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/requests/AccountSettingsRequest.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/requests/AccountStatusRequest.class b/Trading/target/classes/com/suneesh/trading/models/requests/AccountStatusRequest.class new file mode 100644 index 0000000..7fa27f2 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/requests/AccountStatusRequest.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/requests/ActiveSymbolRequest.class b/Trading/target/classes/com/suneesh/trading/models/requests/ActiveSymbolRequest.class new file mode 100644 index 0000000..7938e43 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/requests/ActiveSymbolRequest.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/requests/ApiTokenManagementRequest.class b/Trading/target/classes/com/suneesh/trading/models/requests/ApiTokenManagementRequest.class new file mode 100644 index 0000000..a0fe31b Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/requests/ApiTokenManagementRequest.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/requests/ApplicationDeletionRequest.class b/Trading/target/classes/com/suneesh/trading/models/requests/ApplicationDeletionRequest.class new file mode 100644 index 0000000..9c2175e Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/requests/ApplicationDeletionRequest.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/requests/ApplicationDetailsRequest.class b/Trading/target/classes/com/suneesh/trading/models/requests/ApplicationDetailsRequest.class new file mode 100644 index 0000000..2bddad7 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/requests/ApplicationDetailsRequest.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/requests/ApplicationListRequest.class b/Trading/target/classes/com/suneesh/trading/models/requests/ApplicationListRequest.class new file mode 100644 index 0000000..d925ef7 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/requests/ApplicationListRequest.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/requests/ApplicationRegistrationRequest.class b/Trading/target/classes/com/suneesh/trading/models/requests/ApplicationRegistrationRequest.class new file mode 100644 index 0000000..9225e4f Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/requests/ApplicationRegistrationRequest.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/requests/ApplicationUpdateRequest.class b/Trading/target/classes/com/suneesh/trading/models/requests/ApplicationUpdateRequest.class new file mode 100644 index 0000000..3f45524 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/requests/ApplicationUpdateRequest.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/requests/AssetIndexRequest.class b/Trading/target/classes/com/suneesh/trading/models/requests/AssetIndexRequest.class new file mode 100644 index 0000000..ed46f6f Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/requests/AssetIndexRequest.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/requests/AuthorizeRequest.class b/Trading/target/classes/com/suneesh/trading/models/requests/AuthorizeRequest.class new file mode 100644 index 0000000..9ef8eb7 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/requests/AuthorizeRequest.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/requests/BalanceRequest.class b/Trading/target/classes/com/suneesh/trading/models/requests/BalanceRequest.class new file mode 100644 index 0000000..3fb1a2f Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/requests/BalanceRequest.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/requests/BuyContractForMultipleAccountsRequest.class b/Trading/target/classes/com/suneesh/trading/models/requests/BuyContractForMultipleAccountsRequest.class new file mode 100644 index 0000000..23b988d Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/requests/BuyContractForMultipleAccountsRequest.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/requests/BuyContractParameters.class b/Trading/target/classes/com/suneesh/trading/models/requests/BuyContractParameters.class new file mode 100644 index 0000000..0fd489a Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/requests/BuyContractParameters.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/requests/BuyContractRequest.class b/Trading/target/classes/com/suneesh/trading/models/requests/BuyContractRequest.class new file mode 100644 index 0000000..e579096 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/requests/BuyContractRequest.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/requests/CashierPasswordRequest.class b/Trading/target/classes/com/suneesh/trading/models/requests/CashierPasswordRequest.class new file mode 100644 index 0000000..ecd7244 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/requests/CashierPasswordRequest.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/requests/CashierURLRequest.class b/Trading/target/classes/com/suneesh/trading/models/requests/CashierURLRequest.class new file mode 100644 index 0000000..ed45af7 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/requests/CashierURLRequest.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/requests/ContractsForSymbolRequest.class b/Trading/target/classes/com/suneesh/trading/models/requests/ContractsForSymbolRequest.class new file mode 100644 index 0000000..bebf1a5 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/requests/ContractsForSymbolRequest.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/requests/CreateMaltaAccountRequest.class b/Trading/target/classes/com/suneesh/trading/models/requests/CreateMaltaAccountRequest.class new file mode 100644 index 0000000..81ab544 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/requests/CreateMaltaAccountRequest.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/requests/CreateRealAccountRequest.class b/Trading/target/classes/com/suneesh/trading/models/requests/CreateRealAccountRequest.class new file mode 100644 index 0000000..d656db7 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/requests/CreateRealAccountRequest.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/requests/CreateRealSubAccountRequest.class b/Trading/target/classes/com/suneesh/trading/models/requests/CreateRealSubAccountRequest.class new file mode 100644 index 0000000..cc60828 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/requests/CreateRealSubAccountRequest.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/requests/EmailVerificationRequest.class b/Trading/target/classes/com/suneesh/trading/models/requests/EmailVerificationRequest.class new file mode 100644 index 0000000..01b8ee3 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/requests/EmailVerificationRequest.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/requests/ForgetAllRequest.class b/Trading/target/classes/com/suneesh/trading/models/requests/ForgetAllRequest.class new file mode 100644 index 0000000..6d8d4af Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/requests/ForgetAllRequest.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/requests/ForgetAllResponse.class b/Trading/target/classes/com/suneesh/trading/models/requests/ForgetAllResponse.class new file mode 100644 index 0000000..5ddbdfc Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/requests/ForgetAllResponse.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/requests/ForgetRequest.class b/Trading/target/classes/com/suneesh/trading/models/requests/ForgetRequest.class new file mode 100644 index 0000000..73b033b Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/requests/ForgetRequest.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/requests/GetFinancialAssessmentRequest.class b/Trading/target/classes/com/suneesh/trading/models/requests/GetFinancialAssessmentRequest.class new file mode 100644 index 0000000..39a837a Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/requests/GetFinancialAssessmentRequest.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/requests/GetSelfExclusionRequest.class b/Trading/target/classes/com/suneesh/trading/models/requests/GetSelfExclusionRequest.class new file mode 100644 index 0000000..37c2275 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/requests/GetSelfExclusionRequest.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/requests/JapanAccountSetting.class b/Trading/target/classes/com/suneesh/trading/models/requests/JapanAccountSetting.class new file mode 100644 index 0000000..1083d70 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/requests/JapanAccountSetting.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/requests/JapanKnowledgeTestQuestion.class b/Trading/target/classes/com/suneesh/trading/models/requests/JapanKnowledgeTestQuestion.class new file mode 100644 index 0000000..32edb04 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/requests/JapanKnowledgeTestQuestion.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/requests/JapanKnowledgeTestRequest.class b/Trading/target/classes/com/suneesh/trading/models/requests/JapanKnowledgeTestRequest.class new file mode 100644 index 0000000..14ceb89 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/requests/JapanKnowledgeTestRequest.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/requests/LandingCompanyDetailsRequest.class b/Trading/target/classes/com/suneesh/trading/models/requests/LandingCompanyDetailsRequest.class new file mode 100644 index 0000000..cd2456d Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/requests/LandingCompanyDetailsRequest.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/requests/LandingCompanyRequest.class b/Trading/target/classes/com/suneesh/trading/models/requests/LandingCompanyRequest.class new file mode 100644 index 0000000..d56a1ae Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/requests/LandingCompanyRequest.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/requests/LoginHistoryRequest.class b/Trading/target/classes/com/suneesh/trading/models/requests/LoginHistoryRequest.class new file mode 100644 index 0000000..9951c07 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/requests/LoginHistoryRequest.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/requests/LogoutRequest.class b/Trading/target/classes/com/suneesh/trading/models/requests/LogoutRequest.class new file mode 100644 index 0000000..8ec1dd4 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/requests/LogoutRequest.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/requests/NewVirtualAccountRequest.class b/Trading/target/classes/com/suneesh/trading/models/requests/NewVirtualAccountRequest.class new file mode 100644 index 0000000..6120907 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/requests/NewVirtualAccountRequest.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/requests/OAuthApplicationsRequest.class b/Trading/target/classes/com/suneesh/trading/models/requests/OAuthApplicationsRequest.class new file mode 100644 index 0000000..067fa01 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/requests/OAuthApplicationsRequest.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/requests/PaymentAgentListRequest.class b/Trading/target/classes/com/suneesh/trading/models/requests/PaymentAgentListRequest.class new file mode 100644 index 0000000..705e308 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/requests/PaymentAgentListRequest.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/requests/PaymentAgentTransferRequest.class b/Trading/target/classes/com/suneesh/trading/models/requests/PaymentAgentTransferRequest.class new file mode 100644 index 0000000..2b58caf Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/requests/PaymentAgentTransferRequest.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/requests/PaymentAgentWithdrawalRequest.class b/Trading/target/classes/com/suneesh/trading/models/requests/PaymentAgentWithdrawalRequest.class new file mode 100644 index 0000000..f5d5a05 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/requests/PaymentAgentWithdrawalRequest.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/requests/PayoutCurrenciesRequest.class b/Trading/target/classes/com/suneesh/trading/models/requests/PayoutCurrenciesRequest.class new file mode 100644 index 0000000..9789150 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/requests/PayoutCurrenciesRequest.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/requests/PingRequest.class b/Trading/target/classes/com/suneesh/trading/models/requests/PingRequest.class new file mode 100644 index 0000000..71e5e4d Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/requests/PingRequest.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/requests/PortfolioRequest.class b/Trading/target/classes/com/suneesh/trading/models/requests/PortfolioRequest.class new file mode 100644 index 0000000..ffde382 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/requests/PortfolioRequest.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/requests/PriceProposalRequest.class b/Trading/target/classes/com/suneesh/trading/models/requests/PriceProposalRequest.class new file mode 100644 index 0000000..dd7fd42 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/requests/PriceProposalRequest.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/requests/ProfitTableRequest.class b/Trading/target/classes/com/suneesh/trading/models/requests/ProfitTableRequest.class new file mode 100644 index 0000000..fc6b306 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/requests/ProfitTableRequest.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/requests/ProposalOpenContractRequest.class b/Trading/target/classes/com/suneesh/trading/models/requests/ProposalOpenContractRequest.class new file mode 100644 index 0000000..40911b7 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/requests/ProposalOpenContractRequest.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/requests/RealityCheckRequest.class b/Trading/target/classes/com/suneesh/trading/models/requests/RealityCheckRequest.class new file mode 100644 index 0000000..e2b5089 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/requests/RealityCheckRequest.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/requests/RequestBase.class b/Trading/target/classes/com/suneesh/trading/models/requests/RequestBase.class new file mode 100644 index 0000000..cef05c9 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/requests/RequestBase.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/requests/ResidenceListRequest.class b/Trading/target/classes/com/suneesh/trading/models/requests/ResidenceListRequest.class new file mode 100644 index 0000000..2df2b33 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/requests/ResidenceListRequest.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/requests/RevokeOauthApplicationRequest.class b/Trading/target/classes/com/suneesh/trading/models/requests/RevokeOauthApplicationRequest.class new file mode 100644 index 0000000..5f4932d Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/requests/RevokeOauthApplicationRequest.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/requests/SellContractForMultipleAccountsRequest.class b/Trading/target/classes/com/suneesh/trading/models/requests/SellContractForMultipleAccountsRequest.class new file mode 100644 index 0000000..e49fe36 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/requests/SellContractForMultipleAccountsRequest.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/requests/SellContractRequest.class b/Trading/target/classes/com/suneesh/trading/models/requests/SellContractRequest.class new file mode 100644 index 0000000..1165f15 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/requests/SellContractRequest.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/requests/SellExpiredContractsRequest.class b/Trading/target/classes/com/suneesh/trading/models/requests/SellExpiredContractsRequest.class new file mode 100644 index 0000000..b3992c1 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/requests/SellExpiredContractsRequest.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/requests/SetAccountCurrencyRequest.class b/Trading/target/classes/com/suneesh/trading/models/requests/SetAccountCurrencyRequest.class new file mode 100644 index 0000000..e99aa9e Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/requests/SetAccountCurrencyRequest.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/requests/SetAccountSettingsRequest.class b/Trading/target/classes/com/suneesh/trading/models/requests/SetAccountSettingsRequest.class new file mode 100644 index 0000000..c0ae22c Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/requests/SetAccountSettingsRequest.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/requests/SetFinancialAssessmentRequest.class b/Trading/target/classes/com/suneesh/trading/models/requests/SetFinancialAssessmentRequest.class new file mode 100644 index 0000000..77e1e94 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/requests/SetFinancialAssessmentRequest.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/requests/SetSelfExclusionSettingsRequest.class b/Trading/target/classes/com/suneesh/trading/models/requests/SetSelfExclusionSettingsRequest.class new file mode 100644 index 0000000..fcc06ca Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/requests/SetSelfExclusionSettingsRequest.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/requests/StartCopyTradeRequest.class b/Trading/target/classes/com/suneesh/trading/models/requests/StartCopyTradeRequest.class new file mode 100644 index 0000000..035916c Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/requests/StartCopyTradeRequest.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/requests/StatementRequest.class b/Trading/target/classes/com/suneesh/trading/models/requests/StatementRequest.class new file mode 100644 index 0000000..f0646ed Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/requests/StatementRequest.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/requests/StatesListRequest.class b/Trading/target/classes/com/suneesh/trading/models/requests/StatesListRequest.class new file mode 100644 index 0000000..b95e96b Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/requests/StatesListRequest.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/requests/StopCopyTradeRequest.class b/Trading/target/classes/com/suneesh/trading/models/requests/StopCopyTradeRequest.class new file mode 100644 index 0000000..b8fc33b Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/requests/StopCopyTradeRequest.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/requests/TNCApprovalRequest.class b/Trading/target/classes/com/suneesh/trading/models/requests/TNCApprovalRequest.class new file mode 100644 index 0000000..70109d2 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/requests/TNCApprovalRequest.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/requests/TickHistoryRequest.class b/Trading/target/classes/com/suneesh/trading/models/requests/TickHistoryRequest.class new file mode 100644 index 0000000..0d73275 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/requests/TickHistoryRequest.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/requests/TickRequest.class b/Trading/target/classes/com/suneesh/trading/models/requests/TickRequest.class new file mode 100644 index 0000000..1201977 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/requests/TickRequest.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/requests/TimeRequest.class b/Trading/target/classes/com/suneesh/trading/models/requests/TimeRequest.class new file mode 100644 index 0000000..b6ec701 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/requests/TimeRequest.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/requests/TopUpVirtualMoneyAccountRequest.class b/Trading/target/classes/com/suneesh/trading/models/requests/TopUpVirtualMoneyAccountRequest.class new file mode 100644 index 0000000..419f785 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/requests/TopUpVirtualMoneyAccountRequest.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/requests/TradingTimesRequest.class b/Trading/target/classes/com/suneesh/trading/models/requests/TradingTimesRequest.class new file mode 100644 index 0000000..6a8b28d Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/requests/TradingTimesRequest.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/requests/TransactionsStreamRequest.class b/Trading/target/classes/com/suneesh/trading/models/requests/TransactionsStreamRequest.class new file mode 100644 index 0000000..086edaa Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/requests/TransactionsStreamRequest.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/requests/TransferBetweenAccountsRequest.class b/Trading/target/classes/com/suneesh/trading/models/requests/TransferBetweenAccountsRequest.class new file mode 100644 index 0000000..534ea0f Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/requests/TransferBetweenAccountsRequest.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/requests/WebsiteStatusRequest.class b/Trading/target/classes/com/suneesh/trading/models/requests/WebsiteStatusRequest.class new file mode 100644 index 0000000..f41eb11 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/requests/WebsiteStatusRequest.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/responses/AccountLimits.class b/Trading/target/classes/com/suneesh/trading/models/responses/AccountLimits.class new file mode 100644 index 0000000..f397d90 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/responses/AccountLimits.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/responses/AccountLimitsResponse.class b/Trading/target/classes/com/suneesh/trading/models/responses/AccountLimitsResponse.class new file mode 100644 index 0000000..262b86e Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/responses/AccountLimitsResponse.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/responses/AccountSettings.class b/Trading/target/classes/com/suneesh/trading/models/responses/AccountSettings.class new file mode 100644 index 0000000..1f2a305 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/responses/AccountSettings.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/responses/AccountSettingsResponse.class b/Trading/target/classes/com/suneesh/trading/models/responses/AccountSettingsResponse.class new file mode 100644 index 0000000..13a6c09 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/responses/AccountSettingsResponse.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/responses/AccountStatus.class b/Trading/target/classes/com/suneesh/trading/models/responses/AccountStatus.class new file mode 100644 index 0000000..251137d Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/responses/AccountStatus.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/responses/AccountStatusResponse.class b/Trading/target/classes/com/suneesh/trading/models/responses/AccountStatusResponse.class new file mode 100644 index 0000000..db363cf Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/responses/AccountStatusResponse.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/responses/ActiveSymbol.class b/Trading/target/classes/com/suneesh/trading/models/responses/ActiveSymbol.class new file mode 100644 index 0000000..015f71d Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/responses/ActiveSymbol.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/responses/ActiveSymbolResponse.class b/Trading/target/classes/com/suneesh/trading/models/responses/ActiveSymbolResponse.class new file mode 100644 index 0000000..9b46085 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/responses/ActiveSymbolResponse.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/responses/ApiCallLimit.class b/Trading/target/classes/com/suneesh/trading/models/responses/ApiCallLimit.class new file mode 100644 index 0000000..12f34b0 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/responses/ApiCallLimit.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/responses/ApiToken.class b/Trading/target/classes/com/suneesh/trading/models/responses/ApiToken.class new file mode 100644 index 0000000..d124ffb Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/responses/ApiToken.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/responses/ApiTokenManagementResponse$ApiTokenResult.class b/Trading/target/classes/com/suneesh/trading/models/responses/ApiTokenManagementResponse$ApiTokenResult.class new file mode 100644 index 0000000..5b49916 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/responses/ApiTokenManagementResponse$ApiTokenResult.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/responses/ApiTokenManagementResponse.class b/Trading/target/classes/com/suneesh/trading/models/responses/ApiTokenManagementResponse.class new file mode 100644 index 0000000..2812cb6 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/responses/ApiTokenManagementResponse.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/responses/Application.class b/Trading/target/classes/com/suneesh/trading/models/responses/Application.class new file mode 100644 index 0000000..b4f3292 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/responses/Application.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/responses/ApplicationDeletionResponse.class b/Trading/target/classes/com/suneesh/trading/models/responses/ApplicationDeletionResponse.class new file mode 100644 index 0000000..445c939 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/responses/ApplicationDeletionResponse.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/responses/ApplicationDetailsResponse.class b/Trading/target/classes/com/suneesh/trading/models/responses/ApplicationDetailsResponse.class new file mode 100644 index 0000000..13673c3 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/responses/ApplicationDetailsResponse.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/responses/ApplicationListResponse.class b/Trading/target/classes/com/suneesh/trading/models/responses/ApplicationListResponse.class new file mode 100644 index 0000000..879110b Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/responses/ApplicationListResponse.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/responses/ApplicationRegistrationResponse.class b/Trading/target/classes/com/suneesh/trading/models/responses/ApplicationRegistrationResponse.class new file mode 100644 index 0000000..cf3fb91 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/responses/ApplicationRegistrationResponse.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/responses/ApplicationUpdateResponse.class b/Trading/target/classes/com/suneesh/trading/models/responses/ApplicationUpdateResponse.class new file mode 100644 index 0000000..1e38b9f Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/responses/ApplicationUpdateResponse.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/responses/AssetIndex.class b/Trading/target/classes/com/suneesh/trading/models/responses/AssetIndex.class new file mode 100644 index 0000000..f1035e5 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/responses/AssetIndex.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/responses/AssetIndexResponse.class b/Trading/target/classes/com/suneesh/trading/models/responses/AssetIndexResponse.class new file mode 100644 index 0000000..f71b194 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/responses/AssetIndexResponse.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/responses/Authorize.class b/Trading/target/classes/com/suneesh/trading/models/responses/Authorize.class new file mode 100644 index 0000000..563e48c Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/responses/Authorize.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/responses/AuthorizeResponse.class b/Trading/target/classes/com/suneesh/trading/models/responses/AuthorizeResponse.class new file mode 100644 index 0000000..1874332 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/responses/AuthorizeResponse.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/responses/Balance.class b/Trading/target/classes/com/suneesh/trading/models/responses/Balance.class new file mode 100644 index 0000000..ce42e3d Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/responses/Balance.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/responses/BalanceResponse.class b/Trading/target/classes/com/suneesh/trading/models/responses/BalanceResponse.class new file mode 100644 index 0000000..7675b10 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/responses/BalanceResponse.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/responses/BuyContractForMultipleAccountsResponse$MassBuyContractResult.class b/Trading/target/classes/com/suneesh/trading/models/responses/BuyContractForMultipleAccountsResponse$MassBuyContractResult.class new file mode 100644 index 0000000..f166d40 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/responses/BuyContractForMultipleAccountsResponse$MassBuyContractResult.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/responses/BuyContractForMultipleAccountsResponse.class b/Trading/target/classes/com/suneesh/trading/models/responses/BuyContractForMultipleAccountsResponse.class new file mode 100644 index 0000000..39349fd Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/responses/BuyContractForMultipleAccountsResponse.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/responses/BuyContractResponse.class b/Trading/target/classes/com/suneesh/trading/models/responses/BuyContractResponse.class new file mode 100644 index 0000000..08feeb5 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/responses/BuyContractResponse.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/responses/BuyReceipt.class b/Trading/target/classes/com/suneesh/trading/models/responses/BuyReceipt.class new file mode 100644 index 0000000..9292f01 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/responses/BuyReceipt.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/responses/Candle.class b/Trading/target/classes/com/suneesh/trading/models/responses/Candle.class new file mode 100644 index 0000000..79eec84 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/responses/Candle.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/responses/CashierPasswordResponse.class b/Trading/target/classes/com/suneesh/trading/models/responses/CashierPasswordResponse.class new file mode 100644 index 0000000..2a84db9 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/responses/CashierPasswordResponse.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/responses/CashierURLResponse.class b/Trading/target/classes/com/suneesh/trading/models/responses/CashierURLResponse.class new file mode 100644 index 0000000..d0a0f39 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/responses/CashierURLResponse.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/responses/Company.class b/Trading/target/classes/com/suneesh/trading/models/responses/Company.class new file mode 100644 index 0000000..56ec143 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/responses/Company.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/responses/Contract.class b/Trading/target/classes/com/suneesh/trading/models/responses/Contract.class new file mode 100644 index 0000000..88426ea Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/responses/Contract.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/responses/ContractForSymbol.class b/Trading/target/classes/com/suneesh/trading/models/responses/ContractForSymbol.class new file mode 100644 index 0000000..dd4204c Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/responses/ContractForSymbol.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/responses/ContractInfo.class b/Trading/target/classes/com/suneesh/trading/models/responses/ContractInfo.class new file mode 100644 index 0000000..8e32e35 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/responses/ContractInfo.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/responses/ContractsForSymbolResponse.class b/Trading/target/classes/com/suneesh/trading/models/responses/ContractsForSymbolResponse.class new file mode 100644 index 0000000..2faf4e9 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/responses/ContractsForSymbolResponse.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/responses/CreateMaltaAccountResponse.class b/Trading/target/classes/com/suneesh/trading/models/responses/CreateMaltaAccountResponse.class new file mode 100644 index 0000000..c082997 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/responses/CreateMaltaAccountResponse.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/responses/CreateRealAccountResponse.class b/Trading/target/classes/com/suneesh/trading/models/responses/CreateRealAccountResponse.class new file mode 100644 index 0000000..e95b813 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/responses/CreateRealAccountResponse.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/responses/CreateRealSubAccountResponse.class b/Trading/target/classes/com/suneesh/trading/models/responses/CreateRealSubAccountResponse.class new file mode 100644 index 0000000..708c63f Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/responses/CreateRealSubAccountResponse.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/responses/CurrencyConfig.class b/Trading/target/classes/com/suneesh/trading/models/responses/CurrencyConfig.class new file mode 100644 index 0000000..5dfad17 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/responses/CurrencyConfig.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/responses/DateStructure.class b/Trading/target/classes/com/suneesh/trading/models/responses/DateStructure.class new file mode 100644 index 0000000..7df801a Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/responses/DateStructure.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/responses/EmailVerificationResponse.class b/Trading/target/classes/com/suneesh/trading/models/responses/EmailVerificationResponse.class new file mode 100644 index 0000000..b42e331 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/responses/EmailVerificationResponse.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/responses/Error.class b/Trading/target/classes/com/suneesh/trading/models/responses/Error.class new file mode 100644 index 0000000..63c6998 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/responses/Error.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/responses/FinancialAssessment.class b/Trading/target/classes/com/suneesh/trading/models/responses/FinancialAssessment.class new file mode 100644 index 0000000..430380e Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/responses/FinancialAssessment.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/responses/ForgetResponse.class b/Trading/target/classes/com/suneesh/trading/models/responses/ForgetResponse.class new file mode 100644 index 0000000..305e463 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/responses/ForgetResponse.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/responses/ForwardStartingOption.class b/Trading/target/classes/com/suneesh/trading/models/responses/ForwardStartingOption.class new file mode 100644 index 0000000..b8db2a5 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/responses/ForwardStartingOption.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/responses/GetFinancialAssessmentResponse.class b/Trading/target/classes/com/suneesh/trading/models/responses/GetFinancialAssessmentResponse.class new file mode 100644 index 0000000..dc85816 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/responses/GetFinancialAssessmentResponse.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/responses/GetSelfExclusionResponse.class b/Trading/target/classes/com/suneesh/trading/models/responses/GetSelfExclusionResponse.class new file mode 100644 index 0000000..d4455d2 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/responses/GetSelfExclusionResponse.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/responses/History.class b/Trading/target/classes/com/suneesh/trading/models/responses/History.class new file mode 100644 index 0000000..0ea7053 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/responses/History.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/responses/JPAccountStatus.class b/Trading/target/classes/com/suneesh/trading/models/responses/JPAccountStatus.class new file mode 100644 index 0000000..3978007 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/responses/JPAccountStatus.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/responses/JPSettings.class b/Trading/target/classes/com/suneesh/trading/models/responses/JPSettings.class new file mode 100644 index 0000000..80faf45 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/responses/JPSettings.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/responses/JapanKnowledgeTestResponse.class b/Trading/target/classes/com/suneesh/trading/models/responses/JapanKnowledgeTestResponse.class new file mode 100644 index 0000000..7721c12 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/responses/JapanKnowledgeTestResponse.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/responses/LandingCompany.class b/Trading/target/classes/com/suneesh/trading/models/responses/LandingCompany.class new file mode 100644 index 0000000..9257b78 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/responses/LandingCompany.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/responses/LandingCompanyDetails.class b/Trading/target/classes/com/suneesh/trading/models/responses/LandingCompanyDetails.class new file mode 100644 index 0000000..1fa4963 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/responses/LandingCompanyDetails.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/responses/LandingCompanyDetailsResponse.class b/Trading/target/classes/com/suneesh/trading/models/responses/LandingCompanyDetailsResponse.class new file mode 100644 index 0000000..a23497a Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/responses/LandingCompanyDetailsResponse.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/responses/LandingCompanyResponse.class b/Trading/target/classes/com/suneesh/trading/models/responses/LandingCompanyResponse.class new file mode 100644 index 0000000..abcc337 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/responses/LandingCompanyResponse.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/responses/LoginHistory.class b/Trading/target/classes/com/suneesh/trading/models/responses/LoginHistory.class new file mode 100644 index 0000000..e83a36d Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/responses/LoginHistory.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/responses/LoginHistoryResponse.class b/Trading/target/classes/com/suneesh/trading/models/responses/LoginHistoryResponse.class new file mode 100644 index 0000000..5cfc740 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/responses/LoginHistoryResponse.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/responses/LogoutResponse.class b/Trading/target/classes/com/suneesh/trading/models/responses/LogoutResponse.class new file mode 100644 index 0000000..8efa15a Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/responses/LogoutResponse.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/responses/Market.class b/Trading/target/classes/com/suneesh/trading/models/responses/Market.class new file mode 100644 index 0000000..f78ee84 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/responses/Market.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/responses/MarketSpecific.class b/Trading/target/classes/com/suneesh/trading/models/responses/MarketSpecific.class new file mode 100644 index 0000000..c464c64 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/responses/MarketSpecific.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/responses/MassSellReceipt.class b/Trading/target/classes/com/suneesh/trading/models/responses/MassSellReceipt.class new file mode 100644 index 0000000..d17960b Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/responses/MassSellReceipt.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/responses/NewAccountVirtual.class b/Trading/target/classes/com/suneesh/trading/models/responses/NewAccountVirtual.class new file mode 100644 index 0000000..1b8330a Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/responses/NewAccountVirtual.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/responses/NewVirtualAccountResponse.class b/Trading/target/classes/com/suneesh/trading/models/responses/NewVirtualAccountResponse.class new file mode 100644 index 0000000..18b1cec Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/responses/NewVirtualAccountResponse.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/responses/OAuthApplication.class b/Trading/target/classes/com/suneesh/trading/models/responses/OAuthApplication.class new file mode 100644 index 0000000..f32efd0 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/responses/OAuthApplication.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/responses/OAuthApplicationResponse.class b/Trading/target/classes/com/suneesh/trading/models/responses/OAuthApplicationResponse.class new file mode 100644 index 0000000..51bb71f Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/responses/OAuthApplicationResponse.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/responses/OpenContract.class b/Trading/target/classes/com/suneesh/trading/models/responses/OpenContract.class new file mode 100644 index 0000000..f06b525 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/responses/OpenContract.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/responses/PaymentAgent.class b/Trading/target/classes/com/suneesh/trading/models/responses/PaymentAgent.class new file mode 100644 index 0000000..727a386 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/responses/PaymentAgent.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/responses/PaymentAgentListResponse$PaymentAgentList.class b/Trading/target/classes/com/suneesh/trading/models/responses/PaymentAgentListResponse$PaymentAgentList.class new file mode 100644 index 0000000..ebabd38 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/responses/PaymentAgentListResponse$PaymentAgentList.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/responses/PaymentAgentListResponse.class b/Trading/target/classes/com/suneesh/trading/models/responses/PaymentAgentListResponse.class new file mode 100644 index 0000000..3946f5d Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/responses/PaymentAgentListResponse.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/responses/PaymentAgentTransferResponse.class b/Trading/target/classes/com/suneesh/trading/models/responses/PaymentAgentTransferResponse.class new file mode 100644 index 0000000..34b590e Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/responses/PaymentAgentTransferResponse.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/responses/PaymentAgentWithdrawalResponse.class b/Trading/target/classes/com/suneesh/trading/models/responses/PaymentAgentWithdrawalResponse.class new file mode 100644 index 0000000..a136dcc Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/responses/PaymentAgentWithdrawalResponse.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/responses/PayoutCurrenciesResponse.class b/Trading/target/classes/com/suneesh/trading/models/responses/PayoutCurrenciesResponse.class new file mode 100644 index 0000000..7a109ed Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/responses/PayoutCurrenciesResponse.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/responses/PingResponse.class b/Trading/target/classes/com/suneesh/trading/models/responses/PingResponse.class new file mode 100644 index 0000000..a8d3a4d Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/responses/PingResponse.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/responses/Portfolio.class b/Trading/target/classes/com/suneesh/trading/models/responses/Portfolio.class new file mode 100644 index 0000000..5b11aed Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/responses/Portfolio.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/responses/PortfolioResponse.class b/Trading/target/classes/com/suneesh/trading/models/responses/PortfolioResponse.class new file mode 100644 index 0000000..8120f70 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/responses/PortfolioResponse.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/responses/PortfolioTransaction.class b/Trading/target/classes/com/suneesh/trading/models/responses/PortfolioTransaction.class new file mode 100644 index 0000000..b9bc70b Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/responses/PortfolioTransaction.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/responses/PriceProposalResponse.class b/Trading/target/classes/com/suneesh/trading/models/responses/PriceProposalResponse.class new file mode 100644 index 0000000..6fc5695 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/responses/PriceProposalResponse.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/responses/ProfitTable.class b/Trading/target/classes/com/suneesh/trading/models/responses/ProfitTable.class new file mode 100644 index 0000000..fd3f698 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/responses/ProfitTable.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/responses/ProfitTableResponse.class b/Trading/target/classes/com/suneesh/trading/models/responses/ProfitTableResponse.class new file mode 100644 index 0000000..4f1740b Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/responses/ProfitTableResponse.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/responses/ProfitTableTransaction.class b/Trading/target/classes/com/suneesh/trading/models/responses/ProfitTableTransaction.class new file mode 100644 index 0000000..e745c1c Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/responses/ProfitTableTransaction.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/responses/Proposal.class b/Trading/target/classes/com/suneesh/trading/models/responses/Proposal.class new file mode 100644 index 0000000..6ff6d23 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/responses/Proposal.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/responses/ProposalOpenContractResponse.class b/Trading/target/classes/com/suneesh/trading/models/responses/ProposalOpenContractResponse.class new file mode 100644 index 0000000..ae63fa9 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/responses/ProposalOpenContractResponse.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/responses/RealityCheck.class b/Trading/target/classes/com/suneesh/trading/models/responses/RealityCheck.class new file mode 100644 index 0000000..4d016dc Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/responses/RealityCheck.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/responses/RealityCheckResponse.class b/Trading/target/classes/com/suneesh/trading/models/responses/RealityCheckResponse.class new file mode 100644 index 0000000..4d39a11 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/responses/RealityCheckResponse.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/responses/Residence.class b/Trading/target/classes/com/suneesh/trading/models/responses/Residence.class new file mode 100644 index 0000000..e9c447d Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/responses/Residence.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/responses/ResidenceListResponce.class b/Trading/target/classes/com/suneesh/trading/models/responses/ResidenceListResponce.class new file mode 100644 index 0000000..0019cf4 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/responses/ResidenceListResponce.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/responses/ResponseBase.class b/Trading/target/classes/com/suneesh/trading/models/responses/ResponseBase.class new file mode 100644 index 0000000..a346316 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/responses/ResponseBase.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/responses/RevokeOauthApplicationResponse.class b/Trading/target/classes/com/suneesh/trading/models/responses/RevokeOauthApplicationResponse.class new file mode 100644 index 0000000..2f07e22 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/responses/RevokeOauthApplicationResponse.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/responses/SelfExclusion.class b/Trading/target/classes/com/suneesh/trading/models/responses/SelfExclusion.class new file mode 100644 index 0000000..eef5e90 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/responses/SelfExclusion.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/responses/SellContractForMultipleAccountsResponse$MassSellContractResult.class b/Trading/target/classes/com/suneesh/trading/models/responses/SellContractForMultipleAccountsResponse$MassSellContractResult.class new file mode 100644 index 0000000..78f7cce Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/responses/SellContractForMultipleAccountsResponse$MassSellContractResult.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/responses/SellContractForMultipleAccountsResponse.class b/Trading/target/classes/com/suneesh/trading/models/responses/SellContractForMultipleAccountsResponse.class new file mode 100644 index 0000000..fcb5b45 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/responses/SellContractForMultipleAccountsResponse.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/responses/SellContractResponse.class b/Trading/target/classes/com/suneesh/trading/models/responses/SellContractResponse.class new file mode 100644 index 0000000..ce6bda5 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/responses/SellContractResponse.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/responses/SellExpiredContractsResponse.class b/Trading/target/classes/com/suneesh/trading/models/responses/SellExpiredContractsResponse.class new file mode 100644 index 0000000..d983a20 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/responses/SellExpiredContractsResponse.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/responses/SellReceipt.class b/Trading/target/classes/com/suneesh/trading/models/responses/SellReceipt.class new file mode 100644 index 0000000..311dd4c Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/responses/SellReceipt.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/responses/SetAccountCurrencyResponse.class b/Trading/target/classes/com/suneesh/trading/models/responses/SetAccountCurrencyResponse.class new file mode 100644 index 0000000..9a78ac0 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/responses/SetAccountCurrencyResponse.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/responses/SetAccountSettingsResponse.class b/Trading/target/classes/com/suneesh/trading/models/responses/SetAccountSettingsResponse.class new file mode 100644 index 0000000..3abdb75 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/responses/SetAccountSettingsResponse.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/responses/SetFinancialAssessmentResponse.class b/Trading/target/classes/com/suneesh/trading/models/responses/SetFinancialAssessmentResponse.class new file mode 100644 index 0000000..ecfe18d Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/responses/SetFinancialAssessmentResponse.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/responses/SetSelfExclusionSettingsResponse.class b/Trading/target/classes/com/suneesh/trading/models/responses/SetSelfExclusionSettingsResponse.class new file mode 100644 index 0000000..736a780 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/responses/SetSelfExclusionSettingsResponse.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/responses/StartCopyTradeResponse.class b/Trading/target/classes/com/suneesh/trading/models/responses/StartCopyTradeResponse.class new file mode 100644 index 0000000..f57f870 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/responses/StartCopyTradeResponse.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/responses/State.class b/Trading/target/classes/com/suneesh/trading/models/responses/State.class new file mode 100644 index 0000000..3f69417 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/responses/State.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/responses/Statement.class b/Trading/target/classes/com/suneesh/trading/models/responses/Statement.class new file mode 100644 index 0000000..151da42 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/responses/Statement.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/responses/StatementResponse.class b/Trading/target/classes/com/suneesh/trading/models/responses/StatementResponse.class new file mode 100644 index 0000000..7536c68 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/responses/StatementResponse.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/responses/StatementTransaction.class b/Trading/target/classes/com/suneesh/trading/models/responses/StatementTransaction.class new file mode 100644 index 0000000..21ccae3 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/responses/StatementTransaction.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/responses/StatesListResponse.class b/Trading/target/classes/com/suneesh/trading/models/responses/StatesListResponse.class new file mode 100644 index 0000000..06bdf76 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/responses/StatesListResponse.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/responses/StopCopyTradeResponse.class b/Trading/target/classes/com/suneesh/trading/models/responses/StopCopyTradeResponse.class new file mode 100644 index 0000000..81dd3b6 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/responses/StopCopyTradeResponse.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/responses/SubAccount.class b/Trading/target/classes/com/suneesh/trading/models/responses/SubAccount.class new file mode 100644 index 0000000..e15f5de Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/responses/SubAccount.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/responses/SubMarket.class b/Trading/target/classes/com/suneesh/trading/models/responses/SubMarket.class new file mode 100644 index 0000000..0bae75f Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/responses/SubMarket.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/responses/TNCApprovalResponse.class b/Trading/target/classes/com/suneesh/trading/models/responses/TNCApprovalResponse.class new file mode 100644 index 0000000..5a62756 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/responses/TNCApprovalResponse.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/responses/Tick.class b/Trading/target/classes/com/suneesh/trading/models/responses/Tick.class new file mode 100644 index 0000000..a660a14 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/responses/Tick.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/responses/TickHistoryResponse.class b/Trading/target/classes/com/suneesh/trading/models/responses/TickHistoryResponse.class new file mode 100644 index 0000000..beccb4c Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/responses/TickHistoryResponse.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/responses/TickResponse.class b/Trading/target/classes/com/suneesh/trading/models/responses/TickResponse.class new file mode 100644 index 0000000..b9ae0e9 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/responses/TickResponse.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/responses/TimeResponse.class b/Trading/target/classes/com/suneesh/trading/models/responses/TimeResponse.class new file mode 100644 index 0000000..50adbc3 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/responses/TimeResponse.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/responses/TopUpVirtualMoneyAccountResponse.class b/Trading/target/classes/com/suneesh/trading/models/responses/TopUpVirtualMoneyAccountResponse.class new file mode 100644 index 0000000..b873e4e Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/responses/TopUpVirtualMoneyAccountResponse.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/responses/TradingPeriod.class b/Trading/target/classes/com/suneesh/trading/models/responses/TradingPeriod.class new file mode 100644 index 0000000..af6887d Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/responses/TradingPeriod.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/responses/TradingTimesResponse$TradingTimes.class b/Trading/target/classes/com/suneesh/trading/models/responses/TradingTimesResponse$TradingTimes.class new file mode 100644 index 0000000..ba097dd Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/responses/TradingTimesResponse$TradingTimes.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/responses/TradingTimesResponse.class b/Trading/target/classes/com/suneesh/trading/models/responses/TradingTimesResponse.class new file mode 100644 index 0000000..d1d29e6 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/responses/TradingTimesResponse.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/responses/Transaction.class b/Trading/target/classes/com/suneesh/trading/models/responses/Transaction.class new file mode 100644 index 0000000..5514e3f Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/responses/Transaction.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/responses/TransactionsStreamResponse.class b/Trading/target/classes/com/suneesh/trading/models/responses/TransactionsStreamResponse.class new file mode 100644 index 0000000..b31bc40 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/responses/TransactionsStreamResponse.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/responses/TransferBetweenAccountsResponse.class b/Trading/target/classes/com/suneesh/trading/models/responses/TransferBetweenAccountsResponse.class new file mode 100644 index 0000000..6324ff7 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/responses/TransferBetweenAccountsResponse.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/responses/Underlying$UnderlyingEvent.class b/Trading/target/classes/com/suneesh/trading/models/responses/Underlying$UnderlyingEvent.class new file mode 100644 index 0000000..d6dfb60 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/responses/Underlying$UnderlyingEvent.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/responses/Underlying$UnderlyingTimes.class b/Trading/target/classes/com/suneesh/trading/models/responses/Underlying$UnderlyingTimes.class new file mode 100644 index 0000000..112d90d Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/responses/Underlying$UnderlyingTimes.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/responses/Underlying.class b/Trading/target/classes/com/suneesh/trading/models/responses/Underlying.class new file mode 100644 index 0000000..f2678b7 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/responses/Underlying.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/responses/WebsiteStatus.class b/Trading/target/classes/com/suneesh/trading/models/responses/WebsiteStatus.class new file mode 100644 index 0000000..3afe59f Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/responses/WebsiteStatus.class differ diff --git a/Trading/target/classes/com/suneesh/trading/models/responses/WebsiteStatusResponse.class b/Trading/target/classes/com/suneesh/trading/models/responses/WebsiteStatusResponse.class new file mode 100644 index 0000000..4d09302 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/models/responses/WebsiteStatusResponse.class differ diff --git a/Trading/target/classes/com/suneesh/trading/utils/AssetIndexDeserializer.class b/Trading/target/classes/com/suneesh/trading/utils/AssetIndexDeserializer.class new file mode 100644 index 0000000..daaf011 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/utils/AssetIndexDeserializer.class differ diff --git a/Trading/target/classes/com/suneesh/trading/utils/ClassUtils.class b/Trading/target/classes/com/suneesh/trading/utils/ClassUtils.class new file mode 100644 index 0000000..09ed48f Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/utils/ClassUtils.class differ diff --git a/Trading/target/classes/com/suneesh/trading/utils/Validator.class b/Trading/target/classes/com/suneesh/trading/utils/Validator.class new file mode 100644 index 0000000..7c256a9 Binary files /dev/null and b/Trading/target/classes/com/suneesh/trading/utils/Validator.class differ diff --git a/Trading/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst b/Trading/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst new file mode 100644 index 0000000..a802869 --- /dev/null +++ b/Trading/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst @@ -0,0 +1,234 @@ +com\suneesh\trading\models\responses\Tick.class +com\suneesh\trading\models\requests\ApplicationUpdateRequest.class +com\suneesh\trading\models\responses\LandingCompanyDetails.class +com\suneesh\trading\models\requests\StatesListRequest.class +com\suneesh\trading\models\responses\SellContractResponse.class +com\suneesh\trading\models\responses\CreateRealSubAccountResponse.class +com\suneesh\trading\models\enums\EducationLevels.class +com\suneesh\trading\ApiWrapper.class +com\suneesh\trading\models\responses\StatementResponse.class +com\suneesh\trading\models\requests\AccountSettingsRequest.class +com\suneesh\trading\models\responses\SubAccount.class +com\suneesh\trading\models\responses\EmailVerificationResponse.class +com\suneesh\trading\models\responses\AccountStatus.class +com\suneesh\trading\models\responses\StatesListResponse.class +com\suneesh\trading\models\requests\GetSelfExclusionRequest.class +com\suneesh\trading\models\requests\EmailVerificationRequest.class +com\suneesh\trading\models\requests\AccountStatusRequest.class +com\suneesh\trading\models\enums\JPAnnualIncomes.class +com\suneesh\trading\models\requests\ApplicationListRequest.class +com\suneesh\trading\models\responses\Underlying$UnderlyingEvent.class +com\suneesh\trading\models\responses\CreateMaltaAccountResponse.class +com\suneesh\trading\models\requests\BuyContractParameters.class +com\suneesh\trading\models\responses\ContractInfo.class +com\suneesh\trading\models\responses\ProposalOpenContractResponse.class +com\suneesh\trading\models\responses\RevokeOauthApplicationResponse.class +com\suneesh\trading\models\requests\AuthorizeRequest.class +com\suneesh\trading\models\responses\SetFinancialAssessmentResponse.class +com\suneesh\trading\models\enums\JPTradingExperiences.class +com\suneesh\trading\models\responses\TickHistoryResponse.class +com\suneesh\trading\models\responses\SetSelfExclusionSettingsResponse.class +com\suneesh\trading\models\requests\AssetIndexRequest.class +com\suneesh\trading\models\requests\PaymentAgentWithdrawalRequest.class +com\suneesh\trading\models\responses\Contract.class +com\suneesh\trading\models\responses\RealityCheck.class +com\suneesh\trading\models\responses\PortfolioTransaction.class +com\suneesh\trading\models\responses\LandingCompanyResponse.class +com\suneesh\trading\models\responses\OAuthApplication.class +com\suneesh\trading\models\requests\SetSelfExclusionSettingsRequest.class +com\suneesh\trading\utils\ClassUtils.class +com\suneesh\trading\models\responses\TransactionsStreamResponse.class +com\suneesh\trading\models\responses\JPAccountStatus.class +com\suneesh\trading\models\responses\AccountSettings.class +com\suneesh\trading\models\requests\BalanceRequest.class +com\suneesh\trading\models\enums\HedgeAssets.class +com\suneesh\trading\models\requests\PriceProposalRequest.class +com\suneesh\trading\models\responses\OpenContract.class +com\suneesh\trading\models\requests\TradingTimesRequest.class +com\suneesh\trading\models\responses\ForgetResponse.class +com\suneesh\trading\models\enums\WorthRanges.class +com\suneesh\trading\models\responses\ResponseBase.class +com\suneesh\trading\WebsocketListener.class +com\suneesh\trading\models\requests\LoginHistoryRequest.class +com\suneesh\trading\models\enums\EmailVerificationReasons.class +com\suneesh\trading\models\responses\AccountStatusResponse.class +com\suneesh\trading\models\responses\LandingCompany.class +com\suneesh\trading\models\responses\AssetIndex.class +com\suneesh\trading\models\requests\PaymentAgentListRequest.class +com\suneesh\trading\models\responses\LogoutResponse.class +com\suneesh\trading\models\enums\WealthSources.class +com\suneesh\trading\models\requests\ProfitTableRequest.class +com\suneesh\trading\models\responses\SetAccountSettingsResponse.class +com\suneesh\trading\models\responses\SetAccountCurrencyResponse.class +com\suneesh\trading\models\responses\Proposal.class +com\suneesh\trading\models\responses\RealityCheckResponse.class +com\suneesh\trading\models\requests\OAuthApplicationsRequest.class +com\suneesh\trading\models\responses\LoginHistoryResponse.class +com\suneesh\trading\models\responses\TimeResponse.class +com\suneesh\trading\models\requests\TransferBetweenAccountsRequest.class +com\suneesh\trading\models\responses\History.class +com\suneesh\trading\models\responses\Authorize.class +com\suneesh\trading\models\responses\Balance.class +com\suneesh\trading\models\responses\MarketSpecific.class +com\suneesh\trading\models\responses\NewAccountVirtual.class +com\suneesh\trading\models\requests\ApiTokenManagementRequest.class +com\suneesh\trading\models\requests\CreateRealSubAccountRequest.class +com\suneesh\trading\models\requests\SellContractForMultipleAccountsRequest.class +com\suneesh\trading\models\responses\Underlying.class +com\suneesh\trading\models\responses\ProfitTable.class +com\suneesh\trading\models\requests\NewVirtualAccountRequest.class +com\suneesh\trading\models\responses\SellExpiredContractsResponse.class +com\suneesh\trading\models\requests\SetFinancialAssessmentRequest.class +com\suneesh\trading\models\requests\PingRequest.class +com\suneesh\trading\models\enums\JPOccupations.class +com\suneesh\trading\models\requests\ActiveSymbolRequest.class +com\suneesh\trading\models\requests\ContractsForSymbolRequest.class +com\suneesh\trading\models\responses\ActiveSymbolResponse.class +com\suneesh\trading\models\requests\ProposalOpenContractRequest.class +com\suneesh\trading\models\responses\PortfolioResponse.class +com\suneesh\trading\models\requests\SellExpiredContractsRequest.class +com\suneesh\trading\models\requests\CreateRealAccountRequest.class +com\suneesh\trading\models\responses\WebsiteStatusResponse.class +com\suneesh\trading\models\requests\JapanKnowledgeTestQuestion.class +com\suneesh\trading\models\responses\BuyReceipt.class +com\suneesh\trading\models\requests\JapanKnowledgeTestRequest.class +com\suneesh\trading\models\enums\CashierProviders.class +com\suneesh\trading\models\requests\TNCApprovalRequest.class +com\suneesh\trading\models\responses\TickResponse.class +com\suneesh\trading\models\enums\TurnoverRanges.class +com\suneesh\trading\models\responses\OAuthApplicationResponse.class +com\suneesh\trading\models\enums\EmploymentIndustries.class +com\suneesh\trading\models\requests\CashierPasswordRequest.class +com\suneesh\trading\models\responses\ApiTokenManagementResponse$ApiTokenResult.class +com\suneesh\trading\models\responses\AccountSettingsResponse.class +com\suneesh\trading\models\responses\AssetIndexResponse.class +com\suneesh\trading\models\responses\JapanKnowledgeTestResponse.class +com\suneesh\trading\models\requests\StartCopyTradeRequest.class +com\suneesh\trading\models\enums\Occupations.class +com\suneesh\trading\utils\AssetIndexDeserializer.class +com\suneesh\trading\models\responses\ActiveSymbol.class +com\suneesh\trading\models\responses\ApiCallLimit.class +com\suneesh\trading\models\responses\PaymentAgent.class +com\suneesh\trading\models\responses\TransferBetweenAccountsResponse.class +com\suneesh\trading\models\responses\AccountLimitsResponse.class +com\suneesh\trading\models\requests\ForgetAllRequest.class +com\suneesh\trading\models\requests\SetAccountSettingsRequest.class +com\suneesh\trading\models\responses\ApiToken.class +com\suneesh\trading\models\responses\State.class +com\suneesh\trading\models\responses\NewVirtualAccountResponse.class +com\suneesh\trading\models\responses\Statement.class +com\suneesh\trading\models\responses\WebsiteStatus.class +com\suneesh\trading\models\responses\ProfitTableTransaction.class +com\suneesh\trading\models\requests\RealityCheckRequest.class +com\suneesh\trading\models\responses\ResidenceListResponce.class +com\suneesh\trading\utils\Validator.class +com\suneesh\trading\models\responses\TopUpVirtualMoneyAccountResponse.class +com\suneesh\trading\models\responses\AuthorizeResponse.class +com\suneesh\trading\models\enums\JPStatus.class +com\suneesh\trading\models\responses\CashierURLResponse.class +com\suneesh\trading\models\responses\TradingTimesResponse.class +com\suneesh\trading\models\requests\RevokeOauthApplicationRequest.class +com\suneesh\trading\models\requests\LandingCompanyDetailsRequest.class +com\suneesh\trading\models\requests\AccountLimitsRequest.class +com\suneesh\trading\models\requests\LogoutRequest.class +com\suneesh\trading\models\responses\GetSelfExclusionResponse.class +com\suneesh\trading\models\responses\StartCopyTradeResponse.class +com\suneesh\trading\models\enums\Gender.class +com\suneesh\trading\models\responses\CashierPasswordResponse.class +com\suneesh\trading\models\responses\GetFinancialAssessmentResponse.class +com\suneesh\trading\models\responses\Portfolio.class +com\suneesh\trading\models\requests\ApplicationDeletionRequest.class +com\suneesh\trading\models\responses\BalanceResponse.class +com\suneesh\trading\models\responses\LandingCompanyDetailsResponse.class +com\suneesh\trading\models\responses\BuyContractForMultipleAccountsResponse.class +com\suneesh\trading\models\responses\ApplicationListResponse.class +com\suneesh\trading\models\enums\TradeFrequency.class +com\suneesh\trading\models\responses\ApplicationDeletionResponse.class +com\suneesh\trading\models\requests\TransactionsStreamRequest.class +com\suneesh\trading\models\requests\TimeRequest.class +com\suneesh\trading\models\enums\Salutation.class +com\suneesh\trading\models\responses\PaymentAgentListResponse.class +com\suneesh\trading\models\responses\ContractsForSymbolResponse.class +com\suneesh\trading\models\responses\ForwardStartingOption.class +com\suneesh\trading\models\responses\StatementTransaction.class +com\suneesh\trading\models\responses\MassSellReceipt.class +com\suneesh\trading\models\requests\RequestBase.class +com\suneesh\trading\models\responses\PriceProposalResponse.class +com\suneesh\trading\models\responses\PaymentAgentTransferResponse.class +com\suneesh\trading\models\requests\ApplicationDetailsRequest.class +com\suneesh\trading\models\responses\ApplicationUpdateResponse.class +com\suneesh\trading\models\requests\PaymentAgentTransferRequest.class +com\suneesh\trading\models\enums\TickStyles.class +com\suneesh\trading\models\responses\PaymentAgentListResponse$PaymentAgentList.class +com\suneesh\trading\models\enums\TransactionType.class +com\suneesh\trading\models\requests\BuyContractForMultipleAccountsRequest.class +com\suneesh\trading\models\responses\Error.class +com\suneesh\trading\models\responses\Residence.class +com\suneesh\trading\models\requests\ForgetAllResponse.class +com\suneesh\trading\models\responses\ApplicationDetailsResponse.class +com\suneesh\trading\models\requests\TickHistoryRequest.class +com\suneesh\trading\models\requests\LandingCompanyRequest.class +com\suneesh\trading\models\responses\Underlying$UnderlyingTimes.class +com\suneesh\trading\models\responses\SubMarket.class +com\suneesh\trading\models\enums\JPTradingPurposes.class +com\suneesh\trading\models\responses\JPSettings.class +com\suneesh\trading\models\enums\TestResult.class +com\suneesh\trading\models\responses\ContractForSymbol.class +com\suneesh\trading\models\responses\PingResponse.class +com\suneesh\trading\models\requests\ForgetRequest.class +com\suneesh\trading\models\requests\TopUpVirtualMoneyAccountRequest.class +com\suneesh\trading\models\responses\FinancialAssessment.class +com\suneesh\trading\models\responses\StopCopyTradeResponse.class +com\suneesh\trading\models\enums\SortTypes.class +com\suneesh\trading\models\responses\SellReceipt.class +com\suneesh\trading\models\responses\PayoutCurrenciesResponse.class +com\suneesh\trading\models\responses\TradingTimesResponse$TradingTimes.class +com\suneesh\trading\models\WebsocketEvent.class +com\suneesh\trading\models\responses\ApplicationRegistrationResponse.class +com\suneesh\trading\models\enums\EstimatedWorth.class +com\suneesh\trading\models\responses\TradingPeriod.class +com\suneesh\trading\models\responses\CurrencyConfig.class +com\suneesh\trading\models\requests\WebsiteStatusRequest.class +com\suneesh\trading\models\enums\ExperienceDuration.class +com\suneesh\trading\models\enums\AccountOpeningReasons.class +com\suneesh\trading\models\requests\SetAccountCurrencyRequest.class +com\suneesh\trading\models\responses\TNCApprovalResponse.class +com\suneesh\trading\models\requests\TickRequest.class +com\suneesh\trading\models\responses\Company.class +com\suneesh\trading\models\responses\Application.class +com\suneesh\trading\MainApplication.class +com\suneesh\trading\models\requests\ResidenceListRequest.class +com\suneesh\trading\models\requests\BuyContractRequest.class +com\suneesh\trading\models\requests\CashierURLRequest.class +com\suneesh\trading\models\requests\StatementRequest.class +com\suneesh\trading\models\responses\PaymentAgentWithdrawalResponse.class +com\suneesh\trading\models\responses\ProfitTableResponse.class +com\suneesh\trading\models\requests\ApplicationRegistrationRequest.class +com\suneesh\trading\models\responses\Candle.class +com\suneesh\trading\models\responses\DateStructure.class +com\suneesh\trading\models\requests\JapanAccountSetting.class +com\suneesh\trading\models\responses\CreateRealAccountResponse.class +com\suneesh\trading\models\requests\SellContractRequest.class +com\suneesh\trading\models\enums\StreamTypes.class +com\suneesh\trading\models\responses\LoginHistory.class +com\suneesh\trading\models\responses\SellContractForMultipleAccountsResponse$MassSellContractResult.class +com\suneesh\trading\models\enums\BasisTypes.class +com\suneesh\trading\models\enums\DurationUnits.class +com\suneesh\trading\models\enums\EmploymentStatuses.class +com\suneesh\trading\models\enums\IncomeSources.class +com\suneesh\trading\models\enums\CashierTypes.class +com\suneesh\trading\models\requests\CreateMaltaAccountRequest.class +com\suneesh\trading\models\responses\SellContractForMultipleAccountsResponse.class +com\suneesh\trading\models\responses\BuyContractForMultipleAccountsResponse$MassBuyContractResult.class +com\suneesh\trading\models\requests\PayoutCurrenciesRequest.class +com\suneesh\trading\models\responses\Market.class +com\suneesh\trading\models\enums\Scopes.class +com\suneesh\trading\models\responses\ApiTokenManagementResponse.class +com\suneesh\trading\models\requests\GetFinancialAssessmentRequest.class +com\suneesh\trading\models\responses\AccountLimits.class +com\suneesh\trading\models\responses\Transaction.class +com\suneesh\trading\models\enums\SecretQuestions.class +com\suneesh\trading\models\requests\StopCopyTradeRequest.class +com\suneesh\trading\models\responses\SelfExclusion.class +com\suneesh\trading\models\responses\BuyContractResponse.class +com\suneesh\trading\models\requests\PortfolioRequest.class diff --git a/Trading/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst b/Trading/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst new file mode 100644 index 0000000..74d5bd1 --- /dev/null +++ b/Trading/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst @@ -0,0 +1,227 @@ +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\responses\ApiCallLimit.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\MainApplication.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\requests\PortfolioRequest.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\responses\StartCopyTradeResponse.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\responses\JPSettings.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\responses\CreateRealAccountResponse.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\enums\WealthSources.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\requests\AuthorizeRequest.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\requests\JapanKnowledgeTestQuestion.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\responses\Underlying.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\requests\LandingCompanyRequest.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\requests\StatementRequest.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\responses\MassSellReceipt.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\requests\SetFinancialAssessmentRequest.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\responses\OAuthApplication.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\WebsocketListener.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\responses\LogoutResponse.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\responses\PayoutCurrenciesResponse.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\responses\AssetIndex.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\requests\TransferBetweenAccountsRequest.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\responses\TNCApprovalResponse.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\responses\Proposal.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\enums\EducationLevels.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\responses\SubMarket.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\requests\BuyContractParameters.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\responses\Company.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\enums\Scopes.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\utils\ClassUtils.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\requests\JapanAccountSetting.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\responses\TradingTimesResponse.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\enums\ExperienceDuration.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\enums\Occupations.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\enums\TradeFrequency.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\requests\CreateRealAccountRequest.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\requests\SetAccountSettingsRequest.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\requests\ActiveSymbolRequest.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\requests\StopCopyTradeRequest.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\utils\Validator.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\ApiWrapper.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\responses\ContractForSymbol.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\requests\AccountLimitsRequest.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\responses\RevokeOauthApplicationResponse.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\enums\JPTradingPurposes.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\enums\TransactionType.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\requests\ProfitTableRequest.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\responses\GetFinancialAssessmentResponse.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\responses\SellExpiredContractsResponse.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\enums\IncomeSources.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\responses\ForwardStartingOption.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\requests\LogoutRequest.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\responses\TransferBetweenAccountsResponse.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\requests\TopUpVirtualMoneyAccountRequest.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\responses\AccountSettingsResponse.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\requests\ApplicationDeletionRequest.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\responses\TradingPeriod.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\enums\WorthRanges.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\requests\LandingCompanyDetailsRequest.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\responses\AccountStatusResponse.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\responses\JPAccountStatus.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\responses\EmailVerificationResponse.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\enums\EmploymentStatuses.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\responses\PriceProposalResponse.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\responses\History.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\responses\MarketSpecific.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\responses\LoginHistory.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\responses\Authorize.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\responses\NewAccountVirtual.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\responses\ForgetResponse.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\enums\SortTypes.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\responses\ApplicationDetailsResponse.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\enums\DurationUnits.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\responses\ResponseBase.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\enums\Salutation.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\requests\PaymentAgentListRequest.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\responses\ApiTokenManagementResponse.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\responses\PortfolioResponse.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\responses\AccountStatus.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\requests\LoginHistoryRequest.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\requests\WebsiteStatusRequest.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\responses\Application.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\responses\State.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\requests\ApiTokenManagementRequest.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\responses\ApplicationListResponse.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\requests\TickRequest.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\responses\Market.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\responses\Residence.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\WebsocketEvent.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\requests\ForgetAllResponse.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\requests\TickHistoryRequest.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\responses\AssetIndexResponse.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\requests\PayoutCurrenciesRequest.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\responses\Portfolio.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\enums\Gender.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\responses\FinancialAssessment.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\requests\PingRequest.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\responses\ProfitTableTransaction.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\requests\PaymentAgentWithdrawalRequest.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\requests\OAuthApplicationsRequest.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\enums\AccountOpeningReasons.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\requests\TimeRequest.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\responses\ApplicationRegistrationResponse.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\responses\Candle.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\requests\TransactionsStreamRequest.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\responses\WebsiteStatusResponse.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\requests\EmailVerificationRequest.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\requests\BalanceRequest.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\requests\RealityCheckRequest.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\requests\ProposalOpenContractRequest.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\responses\AccountSettings.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\responses\AccountLimitsResponse.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\responses\PaymentAgentWithdrawalResponse.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\responses\BalanceResponse.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\requests\SetAccountCurrencyRequest.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\requests\ApplicationListRequest.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\responses\Contract.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\responses\JapanKnowledgeTestResponse.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\enums\CashierTypes.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\responses\AuthorizeResponse.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\enums\StreamTypes.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\requests\RequestBase.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\enums\EmploymentIndustries.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\responses\Statement.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\responses\StatementResponse.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\responses\SelfExclusion.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\responses\ContractsForSymbolResponse.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\responses\ContractInfo.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\responses\TickHistoryResponse.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\responses\Balance.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\requests\ForgetAllRequest.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\responses\Error.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\responses\RealityCheck.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\responses\Tick.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\enums\JPOccupations.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\responses\SellReceipt.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\requests\SellContractRequest.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\responses\CurrencyConfig.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\responses\ActiveSymbol.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\responses\ProposalOpenContractResponse.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\requests\SellExpiredContractsRequest.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\responses\LandingCompanyDetailsResponse.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\responses\AccountLimits.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\responses\StatesListResponse.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\responses\SubAccount.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\responses\SetFinancialAssessmentResponse.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\responses\RealityCheckResponse.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\requests\AccountSettingsRequest.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\responses\CashierURLResponse.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\requests\SellContractForMultipleAccountsRequest.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\responses\ResidenceListResponce.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\enums\TestResult.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\requests\PriceProposalRequest.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\responses\SetSelfExclusionSettingsResponse.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\requests\ApplicationRegistrationRequest.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\responses\SetAccountSettingsResponse.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\enums\TickStyles.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\responses\PingResponse.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\enums\SecretQuestions.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\requests\BuyContractRequest.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\requests\AssetIndexRequest.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\requests\JapanKnowledgeTestRequest.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\responses\CashierPasswordResponse.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\enums\EstimatedWorth.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\enums\CashierProviders.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\responses\PaymentAgentTransferResponse.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\responses\ApplicationDeletionResponse.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\responses\BuyContractForMultipleAccountsResponse.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\enums\EmailVerificationReasons.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\requests\ApplicationUpdateRequest.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\responses\ApplicationUpdateResponse.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\requests\GetFinancialAssessmentRequest.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\requests\ForgetRequest.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\responses\SetAccountCurrencyResponse.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\responses\StopCopyTradeResponse.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\requests\TNCApprovalRequest.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\responses\LandingCompanyResponse.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\responses\WebsiteStatus.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\responses\OpenContract.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\responses\SellContractResponse.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\responses\Transaction.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\enums\JPTradingExperiences.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\requests\RevokeOauthApplicationRequest.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\responses\CreateMaltaAccountResponse.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\requests\TradingTimesRequest.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\enums\JPAnnualIncomes.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\responses\CreateRealSubAccountResponse.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\requests\CreateMaltaAccountRequest.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\responses\BuyReceipt.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\utils\AssetIndexDeserializer.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\responses\PortfolioTransaction.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\requests\BuyContractForMultipleAccountsRequest.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\requests\StatesListRequest.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\requests\GetSelfExclusionRequest.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\responses\LandingCompanyDetails.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\responses\StatementTransaction.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\requests\CreateRealSubAccountRequest.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\requests\AccountStatusRequest.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\responses\GetSelfExclusionResponse.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\responses\TickResponse.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\requests\ApplicationDetailsRequest.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\responses\ProfitTableResponse.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\responses\BuyContractResponse.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\enums\TurnoverRanges.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\requests\SetSelfExclusionSettingsRequest.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\requests\StartCopyTradeRequest.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\requests\CashierPasswordRequest.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\responses\LandingCompany.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\responses\TopUpVirtualMoneyAccountResponse.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\responses\ApiToken.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\requests\ContractsForSymbolRequest.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\responses\LoginHistoryResponse.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\requests\ResidenceListRequest.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\requests\CashierURLRequest.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\enums\BasisTypes.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\responses\ActiveSymbolResponse.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\responses\PaymentAgent.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\responses\SellContractForMultipleAccountsResponse.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\enums\HedgeAssets.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\responses\OAuthApplicationResponse.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\requests\PaymentAgentTransferRequest.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\responses\NewVirtualAccountResponse.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\responses\PaymentAgentListResponse.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\responses\TimeResponse.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\enums\JPStatus.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\responses\ProfitTable.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\responses\DateStructure.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\requests\NewVirtualAccountRequest.java +G:\Development\GitHub\Trading\src\main\java\com\suneesh\trading\models\responses\TransactionsStreamResponse.java diff --git a/lambdaKinesis/.classpath b/lambdaKinesis/.classpath new file mode 100644 index 0000000..ceec4b7 --- /dev/null +++ b/lambdaKinesis/.classpath @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/lambdaKinesis/.project b/lambdaKinesis/.project new file mode 100644 index 0000000..517ce0e --- /dev/null +++ b/lambdaKinesis/.project @@ -0,0 +1,23 @@ + + + lambdaKinesis + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.eclipse.jdt.core.javanature + org.eclipse.m2e.core.maven2Nature + + diff --git a/lambdaKinesis/.settings/org.eclipse.core.resources.prefs b/lambdaKinesis/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000..5b781ec --- /dev/null +++ b/lambdaKinesis/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,3 @@ +eclipse.preferences.version=1 +encoding//src/main/java=UTF-8 +encoding//src/test/java=UTF-8 diff --git a/lambdaKinesis/.settings/org.eclipse.jdt.core.prefs b/lambdaKinesis/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..b8947ec --- /dev/null +++ b/lambdaKinesis/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,6 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning +org.eclipse.jdt.core.compiler.release=disabled +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/lambdaKinesis/.settings/org.eclipse.m2e.core.prefs b/lambdaKinesis/.settings/org.eclipse.m2e.core.prefs new file mode 100644 index 0000000..f897a7f --- /dev/null +++ b/lambdaKinesis/.settings/org.eclipse.m2e.core.prefs @@ -0,0 +1,4 @@ +activeProfiles= +eclipse.preferences.version=1 +resolveWorkspaceProjects=true +version=1 diff --git a/lambdaKinesis/README.html b/lambdaKinesis/README.html new file mode 100644 index 0000000..689d5d2 --- /dev/null +++ b/lambdaKinesis/README.html @@ -0,0 +1,201 @@ + + + + +
+
+ +
+ +

Welcome to AWS Lambda Eclipse Plugin

+ +

Congratulations! You have created your first AWS Lambda project. So what's next?

+ +
+ +
+ +
+ +

Step 1: Implement your function

+ +

Open up LambdaFunctionHandler.java and implement the handleRequest method. This method is the entry point for your Lambda function, and it will be invoked by Lambda in response to input from the event sources of your function.

+ +
+

Note: You can add new classes and additional external dependencies in your project if needed.

+
+ +
+ +
+ +
+ +

Step 2: Test your function

+ +

Open up LambdaFunctionHandlerTest.java. Fill in your test logic to validate the input and output of your function handler, and then run it locally as a normal JUnit test.

+ +
+

Note: The unit test provides a sample JSON input file if you have chosen a predefined event type as your function input. You can modify the JSON file, or create new ones based on it.

+
+ +
+ +
+ +
+ +

Step 3: Upload your function

+ +

+Under Project or Package Explorer View, right-click on your project and select Amazon Web Services -> Upload Function to AWS Lambda. +Then follow the steps to create a new Lambda function or upload your code to an existing function. +

+ + +
+ +
+ +
+ +

Step 4: Invoke your function

+ +

Now we are ready to run the function in the cloud. Right-click on your project again and select Amazon Web Services -> Run on AWS Lambda.
+In the input dialog, enter the JSON input for your function, or select one of the JSON files in your project.

+ +
+

Tip: You can add new JSON input files in your project, and they will show up in this dialog as long as the file name ends with ".json".

+
+ +

Click Invoke and check the output of your function in the Eclipse Console View.

+ +
+ +
+ +
+ +

What's next?

+ +

If you want to know more about AWS Lambda, check out the following links:

+ + + +

Contact us to send bug reports and feedbacks.

+ +

AWS SDK for Java team

+ +
+ +
+ +
+ \ No newline at end of file diff --git a/lambdaKinesis/dependency-reduced-pom.xml b/lambdaKinesis/dependency-reduced-pom.xml new file mode 100644 index 0000000..65da0e7 --- /dev/null +++ b/lambdaKinesis/dependency-reduced-pom.xml @@ -0,0 +1,59 @@ + + + 4.0.0 + com.amazonaws.lambda + demo + 1.0.0 + + + + maven-compiler-plugin + 3.6.0 + + 1.8 + 1.8 + UTF-8 + true + + + + maven-shade-plugin + 3.0.0 + + + package + + shade + + + + + + + + + junit + junit + 4.12 + test + + + hamcrest-core + org.hamcrest + + + + + + + + com.amazonaws + aws-java-sdk-bom + 1.11.573 + pom + import + + + + + diff --git a/lambdaKinesis/pom.xml b/lambdaKinesis/pom.xml new file mode 100644 index 0000000..f25e380 --- /dev/null +++ b/lambdaKinesis/pom.xml @@ -0,0 +1,70 @@ + + 4.0.0 + + com.amazonaws.lambda + demo + 1.0.0 + jar + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.6.0 + + 1.8 + 1.8 + UTF-8 + true + + + + org.apache.maven.plugins + maven-shade-plugin + 3.0.0 + + + package + + shade + + + + + + + + + + + com.amazonaws + aws-java-sdk-bom + 1.11.573 + pom + import + + + + + + + junit + junit + 4.12 + test + + + + com.amazonaws + aws-lambda-java-events + 1.3.0 + + + com.amazonaws + aws-lambda-java-core + 1.1.0 + + + diff --git a/lambdaKinesis/src/main/java/com/amazonaws/lambda/demo/LambdaFunctionHandler.java b/lambdaKinesis/src/main/java/com/amazonaws/lambda/demo/LambdaFunctionHandler.java new file mode 100644 index 0000000..2f5d810 --- /dev/null +++ b/lambdaKinesis/src/main/java/com/amazonaws/lambda/demo/LambdaFunctionHandler.java @@ -0,0 +1,25 @@ +package com.amazonaws.lambda.demo; + +import com.amazonaws.services.lambda.runtime.Context; +import com.amazonaws.services.lambda.runtime.RequestHandler; +import com.amazonaws.services.lambda.runtime.events.KinesisEvent; +import com.amazonaws.services.lambda.runtime.events.KinesisEvent.KinesisEventRecord; + +public class LambdaFunctionHandler implements RequestHandler { + + @Override + public Integer handleRequest(KinesisEvent event, Context context) { + context.getLogger().log("Input: " + event); + System.out.println("Input = " + event); + + for (KinesisEventRecord record : event.getRecords()) { + + String payload = new String(record.getKinesis().getData().array()); + context.getLogger().log("Payload: " + payload); + System.out.println("Payload = " + record.getKinesis().toString()); + } + + System.out.println("event.getRecords().size() = " + event.getRecords().size()); + return event.getRecords().size(); + } +} diff --git a/lambdaKinesis/src/test/java/com/amazonaws/lambda/demo/LambdaFunctionHandlerTest.java b/lambdaKinesis/src/test/java/com/amazonaws/lambda/demo/LambdaFunctionHandlerTest.java new file mode 100644 index 0000000..52df718 --- /dev/null +++ b/lambdaKinesis/src/test/java/com/amazonaws/lambda/demo/LambdaFunctionHandlerTest.java @@ -0,0 +1,43 @@ +package com.amazonaws.lambda.demo; + +import java.io.IOException; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +import com.amazonaws.services.lambda.runtime.Context; +import com.amazonaws.services.lambda.runtime.events.KinesisEvent; + +/** + * A simple test harness for locally invoking your Lambda function handler. + */ +public class LambdaFunctionHandlerTest { + + private KinesisEvent input; + + @Before + public void createInput() throws IOException { + input = TestUtils.parse("/kinesis-event.json", KinesisEvent.class); + } + + private Context createContext() { + TestContext ctx = new TestContext(); + + // TODO: customize your context here if needed. + ctx.setFunctionName("Your Function Name"); + + return ctx; + } + + @Test + public void testLambdaFunctionHandler() { + LambdaFunctionHandler handler = new LambdaFunctionHandler(); + Context ctx = createContext(); + + Integer output = handler.handleRequest(input, ctx); + + // TODO: validate output here if needed. + Assert.assertEquals(1, output.intValue()); + } +} diff --git a/lambdaKinesis/src/test/java/com/amazonaws/lambda/demo/TestContext.java b/lambdaKinesis/src/test/java/com/amazonaws/lambda/demo/TestContext.java new file mode 100644 index 0000000..57bdbdb --- /dev/null +++ b/lambdaKinesis/src/test/java/com/amazonaws/lambda/demo/TestContext.java @@ -0,0 +1,136 @@ +package com.amazonaws.lambda.demo; + +import com.amazonaws.services.lambda.runtime.ClientContext; +import com.amazonaws.services.lambda.runtime.CognitoIdentity; +import com.amazonaws.services.lambda.runtime.Context; +import com.amazonaws.services.lambda.runtime.LambdaLogger; + +/** + * A simple mock implementation of the {@code Context} interface. Default + * values are stubbed out, and setters are provided so you can customize + * the context before passing it to your function. + */ +public class TestContext implements Context { + + private String awsRequestId = "EXAMPLE"; + private ClientContext clientContext; + private String functionName = "EXAMPLE"; + private CognitoIdentity identity; + private String logGroupName = "EXAMPLE"; + private String logStreamName = "EXAMPLE"; + private LambdaLogger logger = new TestLogger(); + private int memoryLimitInMB = 128; + private int remainingTimeInMillis = 15000; + private String functionVersion = "EXAMPLE"; + private String invokedFunctionArn = "EXAMPLE"; + + @Override + public String getAwsRequestId() { + return awsRequestId; + } + + public void setAwsRequestId(String value) { + awsRequestId = value; + } + + @Override + public ClientContext getClientContext() { + return clientContext; + } + + public void setClientContext(ClientContext value) { + clientContext = value; + } + + @Override + public String getFunctionName() { + return functionName; + } + + public void setFunctionName(String value) { + functionName = value; + } + + @Override + public CognitoIdentity getIdentity() { + return identity; + } + + public void setIdentity(CognitoIdentity value) { + identity = value; + } + + @Override + public String getLogGroupName() { + return logGroupName; + } + + public void setLogGroupName(String value) { + logGroupName = value; + } + + @Override + public String getLogStreamName() { + return logStreamName; + } + + public void setLogStreamName(String value) { + logStreamName = value; + } + + @Override + public LambdaLogger getLogger() { + return logger; + } + + public void setLogger(LambdaLogger value) { + logger = value; + } + + @Override + public int getMemoryLimitInMB() { + return memoryLimitInMB; + } + + public void setMemoryLimitInMB(int value) { + memoryLimitInMB = value; + } + + @Override + public int getRemainingTimeInMillis() { + return remainingTimeInMillis; + } + + public void setRemainingTimeInMillis(int value) { + remainingTimeInMillis = value; + } + + @Override + public String getFunctionVersion() { + return functionVersion; + } + + public void setFunctionVersion(String value) { + functionVersion = value; + } + + @Override + public String getInvokedFunctionArn() { + return invokedFunctionArn; + } + + public void setInvokedFunctionArn(String value) { + invokedFunctionArn = value; + } + + /** + * A simple {@code LambdaLogger} that prints everything to stderr. + */ + private static class TestLogger implements LambdaLogger { + + @Override + public void log(String message) { + System.err.println(message); + } + } +} diff --git a/lambdaKinesis/src/test/java/com/amazonaws/lambda/demo/TestUtils.java b/lambdaKinesis/src/test/java/com/amazonaws/lambda/demo/TestUtils.java new file mode 100644 index 0000000..59d66f4 --- /dev/null +++ b/lambdaKinesis/src/test/java/com/amazonaws/lambda/demo/TestUtils.java @@ -0,0 +1,233 @@ +package com.amazonaws.lambda.demo; + +import java.io.IOException; +import java.io.InputStream; +import java.nio.ByteBuffer; +import java.util.Date; +import java.util.List; +import java.util.Map; + +import org.joda.time.DateTime; +import org.joda.time.format.DateTimeFormatter; +import org.joda.time.format.ISODateTimeFormat; +import org.joda.time.tz.FixedDateTimeZone; + +import com.amazonaws.services.dynamodbv2.model.AttributeValue; +import com.amazonaws.services.dynamodbv2.model.Record; +import com.amazonaws.services.dynamodbv2.model.StreamRecord; +import com.amazonaws.services.lambda.runtime.events.DynamodbEvent; +import com.amazonaws.services.lambda.runtime.events.S3Event; +import com.amazonaws.services.lambda.runtime.events.SNSEvent; +import com.amazonaws.services.s3.event.S3EventNotification; +import com.amazonaws.util.IOUtils; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.JsonDeserializer; +import com.fasterxml.jackson.databind.JsonSerializer; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.PropertyNamingStrategy; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.module.SimpleModule; + +/** + * Helper utilities for testing Lambda functions. + */ +public class TestUtils { + + private static final ObjectMapper mapper = new ObjectMapper(); + private static final ObjectMapper snsEventMapper = new ObjectMapper(); + private static final ObjectMapper dynamodbEventMapper = new ObjectMapper(); + + static { + mapper.configure(JsonParser.Feature.ALLOW_COMMENTS, true); + mapper.setPropertyNamingStrategy(new UpperCaseRecordsPropertyNamingStrategy()); + mapper.registerModule(new TestJacksonMapperModule()); + + snsEventMapper.configure(JsonParser.Feature.ALLOW_COMMENTS, true); + snsEventMapper.setPropertyNamingStrategy(PropertyNamingStrategy.PASCAL_CASE_TO_CAMEL_CASE); + snsEventMapper.registerModule(new TestJacksonMapperModule()); + + dynamodbEventMapper.configure(JsonParser.Feature.ALLOW_COMMENTS, true); + dynamodbEventMapper.setPropertyNamingStrategy(new UpperCaseRecordsPropertyNamingStrategy()); + dynamodbEventMapper.registerModule(new TestJacksonMapperModule()); + dynamodbEventMapper.addMixIn(Record.class, DynamodbEventMixin.RecordMixin.class); + dynamodbEventMapper.addMixIn(StreamRecord.class, DynamodbEventMixin.StreamRecordMixin.class); + dynamodbEventMapper.addMixIn(AttributeValue.class, DynamodbEventMixin.AttributeValueMixIn.class); + } + + private static final DateTimeFormatter dateTimeFormatter = + ISODateTimeFormat.dateTime() + .withZone(new FixedDateTimeZone("GMT", "GMT", 0, 0)); + + /** + * Helper method that parses a JSON object from a resource on the classpath + * as an instance of the provided type. + * + * @param resource the path to the resource (relative to this class) + * @param clazz the type to parse the JSON into + */ + public static T parse(String resource, Class clazz) + throws IOException { + + InputStream stream = TestUtils.class.getResourceAsStream(resource); + try { + if (clazz == S3Event.class) { + String json = IOUtils.toString(stream); + S3EventNotification event = S3EventNotification.parseJson(json); + + @SuppressWarnings("unchecked") + T result = (T) new S3Event(event.getRecords()); + return result; + + } else if (clazz == SNSEvent.class) { + return snsEventMapper.readValue(stream, clazz); + } else if (clazz == DynamodbEvent.class) { + return dynamodbEventMapper.readValue(stream, clazz); + } else { + return mapper.readValue(stream, clazz); + } + } finally { + stream.close(); + } + } + + private static class TestJacksonMapperModule extends SimpleModule { + + private static final long serialVersionUID = 1L; + + public TestJacksonMapperModule() { + super("TestJacksonMapperModule"); + + super.addSerializer(DateTime.class, new DateTimeSerializer()); + super.addDeserializer(DateTime.class, new DateTimeDeserializer()); + } + } + + private static class DateTimeSerializer extends JsonSerializer { + + @Override + public void serialize( + DateTime value, + JsonGenerator gen, + SerializerProvider provider) throws IOException { + + gen.writeString(dateTimeFormatter.print(value)); + } + } + + private static class DateTimeDeserializer + extends JsonDeserializer { + + @Override + public DateTime deserialize( + JsonParser parser, + DeserializationContext context) throws IOException { + + return dateTimeFormatter.parseDateTime(parser.getText()); + } + } + + private static class UpperCaseRecordsPropertyNamingStrategy + extends PropertyNamingStrategy.PropertyNamingStrategyBase { + + private static final long serialVersionUID = 1L; + + @Override + public String translate(String propertyName) { + if (propertyName.equals("records")) { + return "Records"; + } + return propertyName; + } + } + + private static interface DynamodbEventMixin { + public static final String L = "L"; + public static final String M = "M"; + public static final String BS = "BS"; + public static final String NS = "NS"; + public static final String SS = "SS"; + public static final String BOOL = "BOOL"; + public static final String NULL = "NULL"; + public static final String B = "B"; + public static final String N = "N"; + public static final String S = "S"; + public static final String OLD_IMAGE = "OldImage"; + public static final String NEW_IMAGE = "NewImage"; + public static final String STREAM_VIEW_TYPE = "StreamViewType"; + public static final String SEQUENCE_NUMBER = "SequenceNumber"; + public static final String SIZE_BYTES = "SizeBytes"; + public static final String KEYS = "Keys"; + public static final String AWS_REGION = "awsRegion"; + public static final String DYNAMODB = "dynamodb"; + public static final String EVENT_ID = "eventID"; + public static final String EVENT_NAME = "eventName"; + public static final String EVENT_SOURCE = "eventSource"; + public static final String EVENT_VERSION = "eventVersion"; + public static final String EVENT_SOURCE_ARN = "eventSourceARN"; + public static final String APPROXIMATE_CREATION_DATE_TIME = "ApproximateCreationDateTime"; + + @JsonProperty(value = "Records") + public List getRecords(); + + static interface RecordMixin { + @JsonProperty(AWS_REGION) public String getAwsRegion(); + @JsonProperty(AWS_REGION) public void setAwsRegion(String awsRegion); + @JsonProperty(DYNAMODB) public Object getDynamodb(); + @JsonProperty(DYNAMODB) public void setDynamodb(Object dynamodb); + @JsonProperty(EVENT_ID) public String getEventID(); + @JsonProperty(EVENT_ID) public void setEventID(String eventID); + @JsonProperty(EVENT_NAME) public String getEventName(); + @JsonProperty(EVENT_NAME) public void setEventName(String eventName); + @JsonProperty(EVENT_SOURCE) public String getEventSource(); + @JsonProperty(EVENT_SOURCE) public void setEventSource(String eventSource); + @JsonProperty(EVENT_VERSION) public String getEventVersion(); + @JsonProperty(EVENT_VERSION) public void setEventVersion(String eventVersion); + @JsonProperty(EVENT_SOURCE_ARN) public String getEventSourceArn(); + @JsonProperty(EVENT_SOURCE_ARN) public void setEventSourceArn(String eventSourceArn); + } + + static interface StreamRecordMixin { + + @JsonProperty(KEYS) public Map getKeys(); + @JsonProperty(KEYS) public void setKeys(Map keys); + @JsonProperty(SIZE_BYTES) public Long getSizeBytes(); + @JsonProperty(SIZE_BYTES) public void setSizeBytes(Long sizeBytes); + @JsonProperty(SEQUENCE_NUMBER) public String getSequenceNumber(); + @JsonProperty(SEQUENCE_NUMBER) public void setSequenceNumber(String sequenceNumber); + @JsonProperty(STREAM_VIEW_TYPE) public String getStreamViewType(); + @JsonProperty(STREAM_VIEW_TYPE) public void setStreamViewType(String streamViewType); + @JsonProperty(NEW_IMAGE) public Map getNewImage(); + @JsonProperty(NEW_IMAGE) public void setNewImage(Map newImage); + @JsonProperty(OLD_IMAGE) public Map getOldImage(); + @JsonProperty(OLD_IMAGE) public void setOldImage(Map oldImage); + @JsonProperty(APPROXIMATE_CREATION_DATE_TIME) public Date getApproximateCreationDateTime(); + @JsonProperty(APPROXIMATE_CREATION_DATE_TIME) public void setApproximateCreationDateTime(Date approximateCreationDateTime); + } + + static interface AttributeValueMixIn { + @JsonProperty(S) public String getS(); + @JsonProperty(S) public void setS(String s); + @JsonProperty(N) public String getN(); + @JsonProperty(N) public void setN(String n); + @JsonProperty(B) public ByteBuffer getB(); + @JsonProperty(B) public void setB(ByteBuffer b); + @JsonProperty(NULL) public Boolean isNULL(); + @JsonProperty(NULL) public void setNULL(Boolean nU); + @JsonProperty(BOOL) public Boolean getBOOL(); + @JsonProperty(BOOL) public void setBOOL(Boolean bO); + @JsonProperty(SS) public List getSS(); + @JsonProperty(SS) public void setSS(List sS); + @JsonProperty(NS) public List getNS(); + @JsonProperty(NS) public void setNS(List nS); + @JsonProperty(BS) public List getBS(); + @JsonProperty(BS) public void setBS(List bS); + @JsonProperty(M) public Map getM(); + @JsonProperty(M) public void setM(Map val); + @JsonProperty(L) public List getL(); + @JsonProperty(L) public void setL(List val); + } + } +} diff --git a/lambdaKinesis/src/test/resources/kinesis-event.json b/lambdaKinesis/src/test/resources/kinesis-event.json new file mode 100644 index 0000000..dde8cb9 --- /dev/null +++ b/lambdaKinesis/src/test/resources/kinesis-event.json @@ -0,0 +1,19 @@ +{ + "Records": [ + { + "kinesis": { + "partitionKey": "partitionKey-3", + "kinesisSchemaVersion": "1.0", + "data": "SGVsbG8sIHRoaXMgaXMgYSB0ZXN0IDEyMy4=", + "sequenceNumber": "49545115243490985018280067714973144582180062593244200961" + }, + "eventSource": "aws:kinesis", + "eventID": "shardId-000000000000:49545115243490985018280067714973144582180062593244200961", + "invokeIdentityArn": "arn:aws:iam::EXAMPLE", + "eventVersion": "1.0", + "eventName": "aws:kinesis:record", + "eventSourceARN": "arn:aws:kinesis:EXAMPLE", + "awsRegion": "us-east-1" + } + ] +} \ No newline at end of file diff --git a/lambdaKinesis/target/classes/com/amazonaws/lambda/demo/LambdaFunctionHandler.class b/lambdaKinesis/target/classes/com/amazonaws/lambda/demo/LambdaFunctionHandler.class new file mode 100644 index 0000000..313100d Binary files /dev/null and b/lambdaKinesis/target/classes/com/amazonaws/lambda/demo/LambdaFunctionHandler.class differ diff --git a/lambdaKinesis/target/demo-1.0.0.jar b/lambdaKinesis/target/demo-1.0.0.jar new file mode 100644 index 0000000..e918e57 Binary files /dev/null and b/lambdaKinesis/target/demo-1.0.0.jar differ diff --git a/lambdaKinesis/target/maven-archiver/pom.properties b/lambdaKinesis/target/maven-archiver/pom.properties new file mode 100644 index 0000000..e95de64 --- /dev/null +++ b/lambdaKinesis/target/maven-archiver/pom.properties @@ -0,0 +1,5 @@ +#Generated by Maven +#Fri Jun 14 23:25:43 BST 2019 +groupId=com.amazonaws.lambda +artifactId=demo +version=1.0.0 diff --git a/lambdaKinesis/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst b/lambdaKinesis/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst new file mode 100644 index 0000000..9a9e2c1 --- /dev/null +++ b/lambdaKinesis/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst @@ -0,0 +1 @@ +com\amazonaws\lambda\demo\LambdaFunctionHandler.class diff --git a/lambdaKinesis/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst b/lambdaKinesis/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst new file mode 100644 index 0000000..c2e2ea5 --- /dev/null +++ b/lambdaKinesis/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst @@ -0,0 +1 @@ +G:\Development\GitHub\JavaDevelopment\lambdaKinesis\src\main\java\com\amazonaws\lambda\demo\LambdaFunctionHandler.java diff --git a/lambdaKinesis/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst b/lambdaKinesis/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst new file mode 100644 index 0000000..e667738 --- /dev/null +++ b/lambdaKinesis/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst @@ -0,0 +1,14 @@ +com\amazonaws\lambda\demo\TestContext.class +com\amazonaws\lambda\demo\TestUtils$DateTimeDeserializer.class +com\amazonaws\lambda\demo\TestUtils$DynamodbEventMixin$RecordMixin.class +com\amazonaws\lambda\demo\TestUtils$DynamodbEventMixin.class +com\amazonaws\lambda\demo\LambdaFunctionHandlerTest.class +com\amazonaws\lambda\demo\TestContext$1.class +com\amazonaws\lambda\demo\TestUtils$UpperCaseRecordsPropertyNamingStrategy.class +com\amazonaws\lambda\demo\TestUtils$DateTimeSerializer.class +com\amazonaws\lambda\demo\TestUtils$DynamodbEventMixin$AttributeValueMixIn.class +com\amazonaws\lambda\demo\TestUtils$DynamodbEventMixin$StreamRecordMixin.class +com\amazonaws\lambda\demo\TestContext$TestLogger.class +com\amazonaws\lambda\demo\TestUtils.class +com\amazonaws\lambda\demo\TestUtils$1.class +com\amazonaws\lambda\demo\TestUtils$TestJacksonMapperModule.class diff --git a/lambdaKinesis/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst b/lambdaKinesis/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst new file mode 100644 index 0000000..0553023 --- /dev/null +++ b/lambdaKinesis/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst @@ -0,0 +1,3 @@ +G:\Development\GitHub\JavaDevelopment\lambdaKinesis\src\test\java\com\amazonaws\lambda\demo\LambdaFunctionHandlerTest.java +G:\Development\GitHub\JavaDevelopment\lambdaKinesis\src\test\java\com\amazonaws\lambda\demo\TestContext.java +G:\Development\GitHub\JavaDevelopment\lambdaKinesis\src\test\java\com\amazonaws\lambda\demo\TestUtils.java diff --git a/lambdaKinesis/target/original-demo-1.0.0.jar b/lambdaKinesis/target/original-demo-1.0.0.jar new file mode 100644 index 0000000..dc6a680 Binary files /dev/null and b/lambdaKinesis/target/original-demo-1.0.0.jar differ diff --git a/lambdaKinesis/target/surefire-reports/TEST-com.amazonaws.lambda.demo.LambdaFunctionHandlerTest.xml b/lambdaKinesis/target/surefire-reports/TEST-com.amazonaws.lambda.demo.LambdaFunctionHandlerTest.xml new file mode 100644 index 0000000..90bd396 --- /dev/null +++ b/lambdaKinesis/target/surefire-reports/TEST-com.amazonaws.lambda.demo.LambdaFunctionHandlerTest.xml @@ -0,0 +1,64 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/lambdaKinesis/target/surefire-reports/com.amazonaws.lambda.demo.LambdaFunctionHandlerTest.txt b/lambdaKinesis/target/surefire-reports/com.amazonaws.lambda.demo.LambdaFunctionHandlerTest.txt new file mode 100644 index 0000000..62e1d37 --- /dev/null +++ b/lambdaKinesis/target/surefire-reports/com.amazonaws.lambda.demo.LambdaFunctionHandlerTest.txt @@ -0,0 +1,4 @@ +------------------------------------------------------------------------------- +Test set: com.amazonaws.lambda.demo.LambdaFunctionHandlerTest +------------------------------------------------------------------------------- +Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.228 sec diff --git a/lambdaKinesis/target/test-classes/com/amazonaws/lambda/demo/LambdaFunctionHandlerTest.class b/lambdaKinesis/target/test-classes/com/amazonaws/lambda/demo/LambdaFunctionHandlerTest.class new file mode 100644 index 0000000..946fe78 Binary files /dev/null and b/lambdaKinesis/target/test-classes/com/amazonaws/lambda/demo/LambdaFunctionHandlerTest.class differ diff --git a/lambdaKinesis/target/test-classes/com/amazonaws/lambda/demo/TestContext$1.class b/lambdaKinesis/target/test-classes/com/amazonaws/lambda/demo/TestContext$1.class new file mode 100644 index 0000000..216a9b4 Binary files /dev/null and b/lambdaKinesis/target/test-classes/com/amazonaws/lambda/demo/TestContext$1.class differ diff --git a/lambdaKinesis/target/test-classes/com/amazonaws/lambda/demo/TestContext$TestLogger.class b/lambdaKinesis/target/test-classes/com/amazonaws/lambda/demo/TestContext$TestLogger.class new file mode 100644 index 0000000..ff6cc22 Binary files /dev/null and b/lambdaKinesis/target/test-classes/com/amazonaws/lambda/demo/TestContext$TestLogger.class differ diff --git a/lambdaKinesis/target/test-classes/com/amazonaws/lambda/demo/TestContext.class b/lambdaKinesis/target/test-classes/com/amazonaws/lambda/demo/TestContext.class new file mode 100644 index 0000000..5ec1faf Binary files /dev/null and b/lambdaKinesis/target/test-classes/com/amazonaws/lambda/demo/TestContext.class differ diff --git a/lambdaKinesis/target/test-classes/com/amazonaws/lambda/demo/TestUtils$1.class b/lambdaKinesis/target/test-classes/com/amazonaws/lambda/demo/TestUtils$1.class new file mode 100644 index 0000000..f9fd287 Binary files /dev/null and b/lambdaKinesis/target/test-classes/com/amazonaws/lambda/demo/TestUtils$1.class differ diff --git a/lambdaKinesis/target/test-classes/com/amazonaws/lambda/demo/TestUtils$DateTimeDeserializer.class b/lambdaKinesis/target/test-classes/com/amazonaws/lambda/demo/TestUtils$DateTimeDeserializer.class new file mode 100644 index 0000000..c62e8af Binary files /dev/null and b/lambdaKinesis/target/test-classes/com/amazonaws/lambda/demo/TestUtils$DateTimeDeserializer.class differ diff --git a/lambdaKinesis/target/test-classes/com/amazonaws/lambda/demo/TestUtils$DateTimeSerializer.class b/lambdaKinesis/target/test-classes/com/amazonaws/lambda/demo/TestUtils$DateTimeSerializer.class new file mode 100644 index 0000000..c3d7fb3 Binary files /dev/null and b/lambdaKinesis/target/test-classes/com/amazonaws/lambda/demo/TestUtils$DateTimeSerializer.class differ diff --git a/lambdaKinesis/target/test-classes/com/amazonaws/lambda/demo/TestUtils$DynamodbEventMixin$AttributeValueMixIn.class b/lambdaKinesis/target/test-classes/com/amazonaws/lambda/demo/TestUtils$DynamodbEventMixin$AttributeValueMixIn.class new file mode 100644 index 0000000..89b3a6d Binary files /dev/null and b/lambdaKinesis/target/test-classes/com/amazonaws/lambda/demo/TestUtils$DynamodbEventMixin$AttributeValueMixIn.class differ diff --git a/lambdaKinesis/target/test-classes/com/amazonaws/lambda/demo/TestUtils$DynamodbEventMixin$RecordMixin.class b/lambdaKinesis/target/test-classes/com/amazonaws/lambda/demo/TestUtils$DynamodbEventMixin$RecordMixin.class new file mode 100644 index 0000000..77bb9c1 Binary files /dev/null and b/lambdaKinesis/target/test-classes/com/amazonaws/lambda/demo/TestUtils$DynamodbEventMixin$RecordMixin.class differ diff --git a/lambdaKinesis/target/test-classes/com/amazonaws/lambda/demo/TestUtils$DynamodbEventMixin$StreamRecordMixin.class b/lambdaKinesis/target/test-classes/com/amazonaws/lambda/demo/TestUtils$DynamodbEventMixin$StreamRecordMixin.class new file mode 100644 index 0000000..3a48aee Binary files /dev/null and b/lambdaKinesis/target/test-classes/com/amazonaws/lambda/demo/TestUtils$DynamodbEventMixin$StreamRecordMixin.class differ diff --git a/lambdaKinesis/target/test-classes/com/amazonaws/lambda/demo/TestUtils$DynamodbEventMixin.class b/lambdaKinesis/target/test-classes/com/amazonaws/lambda/demo/TestUtils$DynamodbEventMixin.class new file mode 100644 index 0000000..b0066d3 Binary files /dev/null and b/lambdaKinesis/target/test-classes/com/amazonaws/lambda/demo/TestUtils$DynamodbEventMixin.class differ diff --git a/lambdaKinesis/target/test-classes/com/amazonaws/lambda/demo/TestUtils$TestJacksonMapperModule.class b/lambdaKinesis/target/test-classes/com/amazonaws/lambda/demo/TestUtils$TestJacksonMapperModule.class new file mode 100644 index 0000000..c786aaf Binary files /dev/null and b/lambdaKinesis/target/test-classes/com/amazonaws/lambda/demo/TestUtils$TestJacksonMapperModule.class differ diff --git a/lambdaKinesis/target/test-classes/com/amazonaws/lambda/demo/TestUtils$UpperCaseRecordsPropertyNamingStrategy.class b/lambdaKinesis/target/test-classes/com/amazonaws/lambda/demo/TestUtils$UpperCaseRecordsPropertyNamingStrategy.class new file mode 100644 index 0000000..fb19242 Binary files /dev/null and b/lambdaKinesis/target/test-classes/com/amazonaws/lambda/demo/TestUtils$UpperCaseRecordsPropertyNamingStrategy.class differ diff --git a/lambdaKinesis/target/test-classes/com/amazonaws/lambda/demo/TestUtils.class b/lambdaKinesis/target/test-classes/com/amazonaws/lambda/demo/TestUtils.class new file mode 100644 index 0000000..eb02e28 Binary files /dev/null and b/lambdaKinesis/target/test-classes/com/amazonaws/lambda/demo/TestUtils.class differ diff --git a/lambdaKinesis/target/test-classes/kinesis-event.json b/lambdaKinesis/target/test-classes/kinesis-event.json new file mode 100644 index 0000000..dde8cb9 --- /dev/null +++ b/lambdaKinesis/target/test-classes/kinesis-event.json @@ -0,0 +1,19 @@ +{ + "Records": [ + { + "kinesis": { + "partitionKey": "partitionKey-3", + "kinesisSchemaVersion": "1.0", + "data": "SGVsbG8sIHRoaXMgaXMgYSB0ZXN0IDEyMy4=", + "sequenceNumber": "49545115243490985018280067714973144582180062593244200961" + }, + "eventSource": "aws:kinesis", + "eventID": "shardId-000000000000:49545115243490985018280067714973144582180062593244200961", + "invokeIdentityArn": "arn:aws:iam::EXAMPLE", + "eventVersion": "1.0", + "eventName": "aws:kinesis:record", + "eventSourceARN": "arn:aws:kinesis:EXAMPLE", + "awsRegion": "us-east-1" + } + ] +} \ No newline at end of file diff --git a/lambda_s3/.classpath b/lambda_s3/.classpath new file mode 100644 index 0000000..441d9c3 --- /dev/null +++ b/lambda_s3/.classpath @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/lambda_s3/.project b/lambda_s3/.project new file mode 100644 index 0000000..d8a6fcc --- /dev/null +++ b/lambda_s3/.project @@ -0,0 +1,23 @@ + + + lambda_s3 + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.eclipse.jdt.core.javanature + org.eclipse.m2e.core.maven2Nature + + diff --git a/lambda_s3/.settings/org.eclipse.core.resources.prefs b/lambda_s3/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000..2b76340 --- /dev/null +++ b/lambda_s3/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding//src/main/java=UTF-8 diff --git a/lambda_s3/.settings/org.eclipse.jdt.core.prefs b/lambda_s3/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..b8947ec --- /dev/null +++ b/lambda_s3/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,6 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning +org.eclipse.jdt.core.compiler.release=disabled +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/lambda_s3/.settings/org.eclipse.m2e.core.prefs b/lambda_s3/.settings/org.eclipse.m2e.core.prefs new file mode 100644 index 0000000..f897a7f --- /dev/null +++ b/lambda_s3/.settings/org.eclipse.m2e.core.prefs @@ -0,0 +1,4 @@ +activeProfiles= +eclipse.preferences.version=1 +resolveWorkspaceProjects=true +version=1 diff --git a/lambda_s3/README.html b/lambda_s3/README.html new file mode 100644 index 0000000..689d5d2 --- /dev/null +++ b/lambda_s3/README.html @@ -0,0 +1,201 @@ + + + + +
+
+ +
+ +

Welcome to AWS Lambda Eclipse Plugin

+ +

Congratulations! You have created your first AWS Lambda project. So what's next?

+ +
+ +
+ +
+ +

Step 1: Implement your function

+ +

Open up LambdaFunctionHandler.java and implement the handleRequest method. This method is the entry point for your Lambda function, and it will be invoked by Lambda in response to input from the event sources of your function.

+ +
+

Note: You can add new classes and additional external dependencies in your project if needed.

+
+ +
+ +
+ +
+ +

Step 2: Test your function

+ +

Open up LambdaFunctionHandlerTest.java. Fill in your test logic to validate the input and output of your function handler, and then run it locally as a normal JUnit test.

+ +
+

Note: The unit test provides a sample JSON input file if you have chosen a predefined event type as your function input. You can modify the JSON file, or create new ones based on it.

+
+ +
+ +
+ +
+ +

Step 3: Upload your function

+ +

+Under Project or Package Explorer View, right-click on your project and select Amazon Web Services -> Upload Function to AWS Lambda. +Then follow the steps to create a new Lambda function or upload your code to an existing function. +

+ + +
+ +
+ +
+ +

Step 4: Invoke your function

+ +

Now we are ready to run the function in the cloud. Right-click on your project again and select Amazon Web Services -> Run on AWS Lambda.
+In the input dialog, enter the JSON input for your function, or select one of the JSON files in your project.

+ +
+

Tip: You can add new JSON input files in your project, and they will show up in this dialog as long as the file name ends with ".json".

+
+ +

Click Invoke and check the output of your function in the Eclipse Console View.

+ +
+ +
+ +
+ +

What's next?

+ +

If you want to know more about AWS Lambda, check out the following links:

+ + + +

Contact us to send bug reports and feedbacks.

+ +

AWS SDK for Java team

+ +
+ +
+ +
+ \ No newline at end of file diff --git a/lambda_s3/dependency-reduced-pom.xml b/lambda_s3/dependency-reduced-pom.xml new file mode 100644 index 0000000..0603702 --- /dev/null +++ b/lambda_s3/dependency-reduced-pom.xml @@ -0,0 +1,79 @@ + + + 4.0.0 + com.amazonaws.lambda + demo + 1.0.0 + + + + maven-compiler-plugin + 3.6.0 + + 1.8 + 1.8 + UTF-8 + true + + + + maven-shade-plugin + 3.0.0 + + + package + + shade + + + + + + + + + junit + junit + 4.12 + test + + + hamcrest-core + org.hamcrest + + + + + org.mockito + mockito-core + 2.7.22 + test + + + byte-buddy + net.bytebuddy + + + byte-buddy-agent + net.bytebuddy + + + objenesis + org.objenesis + + + + + + + + com.amazonaws + aws-java-sdk-bom + 1.11.568 + pom + import + + + + + diff --git a/lambda_s3/pom.xml b/lambda_s3/pom.xml new file mode 100644 index 0000000..1ad90eb --- /dev/null +++ b/lambda_s3/pom.xml @@ -0,0 +1,95 @@ + + 4.0.0 + + com.amazonaws.lambda + demo + 1.0.0 + jar + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.6.0 + + 1.8 + 1.8 + UTF-8 + true + + + + org.apache.maven.plugins + maven-shade-plugin + 3.0.0 + + + package + + shade + + + + + + + + + + + com.amazonaws + aws-java-sdk-bom + 1.11.568 + pom + import + + + + + + + junit + junit + 4.12 + test + + + org.mockito + mockito-core + 2.7.22 + test + + + + org.slf4j + slf4j-api + 1.7.26 + + + + com.amazonaws + aws-java-sdk-s3 + + + com.amazonaws + aws-lambda-java-events + 1.3.0 + + + com.amazonaws + aws-lambda-java-core + 1.1.0 + + + + + com.amazonaws + aws-lambda-java-log4j + 1.0.0 + + + + + diff --git a/lambda_s3/src/main/java/com/test/LambdaFunctionHandler.java b/lambda_s3/src/main/java/com/test/LambdaFunctionHandler.java new file mode 100644 index 0000000..634ed4e --- /dev/null +++ b/lambda_s3/src/main/java/com/test/LambdaFunctionHandler.java @@ -0,0 +1,15 @@ +package com.test; + +import com.amazonaws.services.lambda.runtime.Context; +import com.amazonaws.services.lambda.runtime.RequestHandler; +import com.amazonaws.services.s3.event.S3EventNotification; + +public class LambdaFunctionHandler implements RequestHandler { + + @Override + public String handleRequest(S3EventNotification event, Context context) { + System.out.println("I AM HERE" + event.toJson()); + return "lambda_triggered"; + } + +} \ No newline at end of file diff --git a/lambda_s3/target/classes/META-INF/MANIFEST.MF b/lambda_s3/target/classes/META-INF/MANIFEST.MF new file mode 100644 index 0000000..0ec3330 --- /dev/null +++ b/lambda_s3/target/classes/META-INF/MANIFEST.MF @@ -0,0 +1,5 @@ +Manifest-Version: 1.0 +Built-By: sunee +Build-Jdk: 9.0.1 +Created-By: Maven Integration for Eclipse + diff --git a/lambda_s3/target/classes/META-INF/maven/com.amazonaws.lambda/demo/pom.properties b/lambda_s3/target/classes/META-INF/maven/com.amazonaws.lambda/demo/pom.properties new file mode 100644 index 0000000..cacce23 --- /dev/null +++ b/lambda_s3/target/classes/META-INF/maven/com.amazonaws.lambda/demo/pom.properties @@ -0,0 +1,7 @@ +#Generated by Maven Integration for Eclipse +#Tue Jun 11 23:15:38 BST 2019 +m2e.projectLocation=G\:\\Development\\GitHub\\JavaDevelopment\\lambda_s3 +m2e.projectName=lambda_s3 +groupId=com.amazonaws.lambda +artifactId=demo +version=1.0.0 diff --git a/lambda_s3/target/classes/META-INF/maven/com.amazonaws.lambda/demo/pom.xml b/lambda_s3/target/classes/META-INF/maven/com.amazonaws.lambda/demo/pom.xml new file mode 100644 index 0000000..1ad90eb --- /dev/null +++ b/lambda_s3/target/classes/META-INF/maven/com.amazonaws.lambda/demo/pom.xml @@ -0,0 +1,95 @@ + + 4.0.0 + + com.amazonaws.lambda + demo + 1.0.0 + jar + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.6.0 + + 1.8 + 1.8 + UTF-8 + true + + + + org.apache.maven.plugins + maven-shade-plugin + 3.0.0 + + + package + + shade + + + + + + + + + + + com.amazonaws + aws-java-sdk-bom + 1.11.568 + pom + import + + + + + + + junit + junit + 4.12 + test + + + org.mockito + mockito-core + 2.7.22 + test + + + + org.slf4j + slf4j-api + 1.7.26 + + + + com.amazonaws + aws-java-sdk-s3 + + + com.amazonaws + aws-lambda-java-events + 1.3.0 + + + com.amazonaws + aws-lambda-java-core + 1.1.0 + + + + + com.amazonaws + aws-lambda-java-log4j + 1.0.0 + + + + + diff --git a/lambda_s3/target/classes/com/test/LambdaFunctionHandler.class b/lambda_s3/target/classes/com/test/LambdaFunctionHandler.class new file mode 100644 index 0000000..c9a1bcb Binary files /dev/null and b/lambda_s3/target/classes/com/test/LambdaFunctionHandler.class differ diff --git a/lambda_s3/target/demo-1.0.0.jar b/lambda_s3/target/demo-1.0.0.jar new file mode 100644 index 0000000..6a4c1f3 Binary files /dev/null and b/lambda_s3/target/demo-1.0.0.jar differ diff --git a/lambda_s3/target/maven-archiver/pom.properties b/lambda_s3/target/maven-archiver/pom.properties new file mode 100644 index 0000000..8278818 --- /dev/null +++ b/lambda_s3/target/maven-archiver/pom.properties @@ -0,0 +1,5 @@ +#Generated by Maven +#Tue Jun 11 22:35:57 BST 2019 +groupId=com.amazonaws.lambda +artifactId=demo +version=1.0.0 diff --git a/lambda_s3/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst b/lambda_s3/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst new file mode 100644 index 0000000..2d45d3e --- /dev/null +++ b/lambda_s3/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst @@ -0,0 +1 @@ +com\test\LambdaFunctionHandler.class diff --git a/lambda_s3/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst b/lambda_s3/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst new file mode 100644 index 0000000..659ef54 --- /dev/null +++ b/lambda_s3/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst @@ -0,0 +1 @@ +G:\Development\GitHub\JavaDevelopment\lambda_s3\src\main\java\com\test\LambdaFunctionHandler.java diff --git a/lambda_s3/target/original-demo-1.0.0.jar b/lambda_s3/target/original-demo-1.0.0.jar new file mode 100644 index 0000000..c7ce199 Binary files /dev/null and b/lambda_s3/target/original-demo-1.0.0.jar differ diff --git a/myJavaSqsApp/.classpath b/myJavaSqsApp/.classpath new file mode 100644 index 0000000..4b374ab --- /dev/null +++ b/myJavaSqsApp/.classpath @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/myJavaSqsApp/.project b/myJavaSqsApp/.project new file mode 100644 index 0000000..aa18660 --- /dev/null +++ b/myJavaSqsApp/.project @@ -0,0 +1,23 @@ + + + myJavaSqsApp + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.eclipse.jdt.core.javanature + org.eclipse.m2e.core.maven2Nature + + diff --git a/myJavaSqsApp/.settings/org.eclipse.jdt.core.prefs b/myJavaSqsApp/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..e72b08b --- /dev/null +++ b/myJavaSqsApp/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,6 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=9 +org.eclipse.jdt.core.compiler.compliance=9 +org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning +org.eclipse.jdt.core.compiler.release=disabled +org.eclipse.jdt.core.compiler.source=9 diff --git a/myJavaSqsApp/.settings/org.eclipse.m2e.core.prefs b/myJavaSqsApp/.settings/org.eclipse.m2e.core.prefs new file mode 100644 index 0000000..f897a7f --- /dev/null +++ b/myJavaSqsApp/.settings/org.eclipse.m2e.core.prefs @@ -0,0 +1,4 @@ +activeProfiles= +eclipse.preferences.version=1 +resolveWorkspaceProjects=true +version=1 diff --git a/myJavaSqsApp/pom.xml b/myJavaSqsApp/pom.xml new file mode 100644 index 0000000..d30420f --- /dev/null +++ b/myJavaSqsApp/pom.xml @@ -0,0 +1,20 @@ + + 4.0.0 + com.amazonaws + samples + 1.0.0 + + + com.amazonaws + aws-java-sdk + 1.11.568 + compile + + + com.amazonaws + amazon-kinesis-client + 1.2.1 + compile + + + \ No newline at end of file diff --git a/myJavaSqsApp/src/main/java/com/amazonaws/samples/SimpleQueueServiceSample.java b/myJavaSqsApp/src/main/java/com/amazonaws/samples/SimpleQueueServiceSample.java new file mode 100644 index 0000000..d1ea9c8 --- /dev/null +++ b/myJavaSqsApp/src/main/java/com/amazonaws/samples/SimpleQueueServiceSample.java @@ -0,0 +1,132 @@ +package com.amazonaws.samples; + +/* + * Copyright 2010-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +import java.util.List; +import java.util.Map.Entry; + +import com.amazonaws.AmazonClientException; +import com.amazonaws.AmazonServiceException; +import com.amazonaws.auth.profile.ProfileCredentialsProvider; +import com.amazonaws.regions.Regions; +import com.amazonaws.services.sqs.AmazonSQS; +import com.amazonaws.services.sqs.AmazonSQSClientBuilder; +import com.amazonaws.services.sqs.model.CreateQueueRequest; +import com.amazonaws.services.sqs.model.DeleteMessageRequest; +import com.amazonaws.services.sqs.model.DeleteQueueRequest; +import com.amazonaws.services.sqs.model.Message; +import com.amazonaws.services.sqs.model.ReceiveMessageRequest; +import com.amazonaws.services.sqs.model.SendMessageRequest; + +/** + * This sample demonstrates how to make basic requests to Amazon SQS using the + * AWS SDK for Java. + *

+ * Prerequisites: You must have a valid Amazon Web Services developer + * account, and be signed up to use Amazon SQS. For more information on Amazon + * SQS, see http://aws.amazon.com/sqs. + *

+ * Fill in your AWS access credentials in the provided credentials file + * template, and be sure to move the file to the default location + * (C:\\Users\\sunee\\.aws\\credentials) where the sample code will load the + * credentials from. + *

+ * WARNING: To avoid accidental leakage of your credentials, DO NOT keep + * the credentials file in your source directory. + */ +public class SimpleQueueServiceSample { + + public static void main(String[] args) throws Exception { + + /* + * The ProfileCredentialsProvider will return your [default] credential profile + * by reading from the credentials file located at + * (C:\\Users\\sunee\\.aws\\credentials). + */ + ProfileCredentialsProvider credentialsProvider = new ProfileCredentialsProvider(); + try { + credentialsProvider.getCredentials(); + } catch (Exception e) { + throw new AmazonClientException("Cannot load the credentials from the credential profiles file. " + + "Please make sure that your credentials file is at the correct " + + "location (C:\\Users\\sunee\\.aws\\credentials), and is in valid format.", e); + } + + AmazonSQS sqs = AmazonSQSClientBuilder.standard().withCredentials(credentialsProvider) + .withRegion(Regions.US_WEST_2).build(); + + System.out.println("==========================================="); + System.out.println("Getting Started with Amazon SQS"); + System.out.println("===========================================\n"); + + try { + // Create a queue + System.out.println("Creating a new SQS queue called MyQueue2.\n"); + CreateQueueRequest createQueueRequest = new CreateQueueRequest("MyQueue2"); + String MyQueue2Url = sqs.createQueue(createQueueRequest).getQueueUrl(); + + // List queues + System.out.println("Listing all queues in your account.\n"); + for (String queueUrl : sqs.listQueues().getQueueUrls()) { + System.out.println(" QueueUrl: " + queueUrl); + } + System.out.println(); + + // Send a message + System.out.println("Sending a message to MyQueue2.\n"); + sqs.sendMessage(new SendMessageRequest(MyQueue2Url, "This is my message text.")); + + // Receive messages + System.out.println("Receiving messages from MyQueue2.\n"); + ReceiveMessageRequest receiveMessageRequest = new ReceiveMessageRequest(MyQueue2Url); + List messages = sqs.receiveMessage(receiveMessageRequest).getMessages(); + for (Message message : messages) { + System.out.println(" Message"); + System.out.println(" MessageId: " + message.getMessageId()); + System.out.println(" ReceiptHandle: " + message.getReceiptHandle()); + System.out.println(" MD5OfBody: " + message.getMD5OfBody()); + System.out.println(" Body: " + message.getBody()); + for (Entry entry : message.getAttributes().entrySet()) { + System.out.println(" Attribute"); + System.out.println(" Name: " + entry.getKey()); + System.out.println(" Value: " + entry.getValue()); + } + } + System.out.println(); + + // Delete a message + System.out.println("Deleting a message.\n"); + String messageReceiptHandle = messages.get(0).getReceiptHandle(); + sqs.deleteMessage(new DeleteMessageRequest(MyQueue2Url, messageReceiptHandle)); + + // Delete a queue + System.out.println("Deleting the test queue.\n"); + sqs.deleteQueue(new DeleteQueueRequest(MyQueue2Url)); + } catch (AmazonServiceException ase) { + System.out.println("Caught an AmazonServiceException, which means your request made it " + + "to Amazon SQS, but was rejected with an error response for some reason."); + System.out.println("Error Message: " + ase.getMessage()); + System.out.println("HTTP Status Code: " + ase.getStatusCode()); + System.out.println("AWS Error Code: " + ase.getErrorCode()); + System.out.println("Error Type: " + ase.getErrorType()); + System.out.println("Request ID: " + ase.getRequestId()); + } catch (AmazonClientException ace) { + System.out.println("Caught an AmazonClientException, which means the client encountered " + + "a serious internal problem while trying to communicate with SQS, such as not " + + "being able to access the network."); + System.out.println("Error Message: " + ace.getMessage()); + } + } +} diff --git a/myJavaSqsApp/target/classes/META-INF/MANIFEST.MF b/myJavaSqsApp/target/classes/META-INF/MANIFEST.MF new file mode 100644 index 0000000..0ec3330 --- /dev/null +++ b/myJavaSqsApp/target/classes/META-INF/MANIFEST.MF @@ -0,0 +1,5 @@ +Manifest-Version: 1.0 +Built-By: sunee +Build-Jdk: 9.0.1 +Created-By: Maven Integration for Eclipse + diff --git a/myJavaSqsApp/target/classes/META-INF/maven/com.amazonaws/samples/pom.properties b/myJavaSqsApp/target/classes/META-INF/maven/com.amazonaws/samples/pom.properties new file mode 100644 index 0000000..ff3d50b --- /dev/null +++ b/myJavaSqsApp/target/classes/META-INF/maven/com.amazonaws/samples/pom.properties @@ -0,0 +1,7 @@ +#Generated by Maven Integration for Eclipse +#Mon Jun 10 21:47:43 BST 2019 +m2e.projectLocation=G\:\\Development\\GitHub\\JavaDevelopment\\myJavaSqsApp +m2e.projectName=myJavaSqsApp +groupId=com.amazonaws +artifactId=samples +version=1.0.0 diff --git a/myJavaSqsApp/target/classes/META-INF/maven/com.amazonaws/samples/pom.xml b/myJavaSqsApp/target/classes/META-INF/maven/com.amazonaws/samples/pom.xml new file mode 100644 index 0000000..d30420f --- /dev/null +++ b/myJavaSqsApp/target/classes/META-INF/maven/com.amazonaws/samples/pom.xml @@ -0,0 +1,20 @@ + + 4.0.0 + com.amazonaws + samples + 1.0.0 + + + com.amazonaws + aws-java-sdk + 1.11.568 + compile + + + com.amazonaws + amazon-kinesis-client + 1.2.1 + compile + + + \ No newline at end of file diff --git a/myJavaSqsApp/target/classes/com/amazonaws/samples/SimpleQueueServiceSample.class b/myJavaSqsApp/target/classes/com/amazonaws/samples/SimpleQueueServiceSample.class new file mode 100644 index 0000000..4654c4e Binary files /dev/null and b/myJavaSqsApp/target/classes/com/amazonaws/samples/SimpleQueueServiceSample.class differ