Skip to content

This Java project interacts with Binance REST APIs to perform automated and optimized staking. It consists of multiple jobs that run overnight to execute automated actions, maximizing staking efficiency.

Notifications You must be signed in to change notification settings

dokor/trading-java-bot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

java-trading

How to run the project

1 - Add secret configuration file in src/main/resources/conf/secret.conf whit the following content :

swagger.access.password = "XXXXXXXXXXXXXXX"

# Binance Lecture
# api.binance.key.public = "XXXXXXXXXXXXXXX"
# api.binance.key.secret = "XXXXXXXXXXXXXXX"

# Binance Lecture & Ecriture
api.binance.key.public = "XXXXXXXXXXXXXXX"
api.binance.key.secret = "XXXXXXXXXXXXXXX"

# SLACK
# Url du channel "XXXXXXXXXXXXXXX"
api.slack.url = "XXXXXXXXXXXXXXX"
api.slack.token = "XXXXXXXXXXXXXXX"

Welcome to your Plume project! Here are some reminders to get your project up and running.

Configuring your IDE

Install Lombok: http://jnb.ociweb.com/jnb/jnbJan2010.html#installation

Launching the server

Just run the fr.lelouet.WebApplication class, you can then open your browser to http://localhost:8080.

Configuration

The configuration file is located in src/main/resources/application.conf. If you have any doubt, check out the configuration documentation.

Database

To connect to a database, the Plume Querydsl module must be configured:

  1. Setup the database connector in the pom.xml file (look for the "PUT YOUR DATABASE CONNECTOR HERE" comment
  2. Setup the database connection parameters in the application.conf file, see the Plume Querydsl documentation for details
  3. Add the Plume Querydsl module in the Guice configuration class ApplicationModule by uncommenting the line install(new GuiceQuerydslModule());

To generate classes corresponding to the database tables, you can run the fr.lelouet.db.QuerydslGenerator.main() method. Before the first run, do not forget to configure the TABLES_PREFIX constant in QuerydslGenerator, to match your tables prefix. For example, if your tables are named abc_film and abc_actor, then your prefix will be abc_.

See the detailed documentations:

Removing Qurerydsl

To completly get rid of the database component:

  1. Remove the line install(new GuiceQuerydslModule()); in the ApplicationModule class,
  2. Remove the package db in the project,
  3. Remove the dependencies plume-db-querydsl and plume-db-querydsl-codegen in the pom.xml file.

Swagger

Swagger is pre-configured to provide documentation about the project web-services. This documentation is protected by credentials that should be configured in the application.conf file.

To access this documentation, start the project and go to http://localhost:8080/webjars/swagger-ui/4.1.2/index.html?url=/api/swagger. As a reminder, the default Swagger credentials are: swagger//password.

More modules

Check the demo project to see an example with these modules.

Deploying to production

In the default mode, when mvn package is executed, a zip files is generated. This file contains all the projects jar files and startup BAT/Bash files. These startup files will not work since they are built only for Play Framework. This solution is not ideal, eventually we should make our own Maven plugin so that the startup files works correctly with Plume Framework.

If appserver is used, then configure the server with export SERVER=javazip, it will correctly build and launch the project. If not there are 3 solutions:

  • switch back to the WAR file generation: see the Plume War archetype,
  • create a maven plugin like play2-maven-plugin that produce Plume compatible startup scripts (if you choose this option, please share your work :),
  • replace in the pom.xml file the play2-maven-plugin and the maven-jar-plugin plugins by
<!-- single jar executable with all dependencies -->
<plugin>
	<groupId>org.apache.maven.plugins</groupId>
	<artifactId>maven-shade-plugin</artifactId>
	<version>3.1.0</version>
	<configuration>
		<filters>
			<filter>
				<artifact>*:*</artifact>
				<excludes>
					<exclude>META-INF/*.SF</exclude>
					<exclude>META-INF/*.DSA</exclude>
					<exclude>META-INF/*.RSA</exclude>
				</excludes>
			</filter>
		</filters>
	</configuration>
	<executions>
		<execution>
			<phase>package</phase>
			<goals>
				<goal>shade</goal>
			</goals>
			<configuration>
				<transformers>
					<transformer
						implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer" />
					<transformer
						implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
						<mainClass>fr.lelouet.WebApplication</mainClass>
					</transformer>
				</transformers>
			</configuration>
		</execution>
	</executions>
</plugin>

With this solution, mvn package will produce an executable jar file. Note that this last solution may produce side effects: files that share the same name can be overriden. However all Plume modules will work as expected with this solution.

/**
 * Info trade:
 * "base asset" refers to the asset that is the "quantity" of a symbol. For the symbol BTCUSDT, BTC would be the base asset.
 * "quote asset" refers to the asset that is the "price" of a symbol. For the symbol BTCUSDT, USDT would be the quote asset.
 */

/**
 * Base endpoint without auth for market info :
 * The base endpoint https://data.binance.com can be used to access the following API endpoints that have NONE as security type:
 * GET /api/v3/aggTrades
 * GET /api/v3/avgPrice
 * GET /api/v3/depth
 * GET /api/v3/exchangeInfo
 * GET /api/v3/klines
 * GET /api/v3/ping
 * GET /api/v3/ticker
 * GET /api/v3/ticker/24hr
 * GET /api/v3/ticker/bookTicker
 * GET /api/v3/ticker/price
 * GET /api/v3/time
 * GET /api/v3/trades
 * GET /api/v3/uiKlines
 */

About

This Java project interacts with Binance REST APIs to perform automated and optimized staking. It consists of multiple jobs that run overnight to execute automated actions, maximizing staking efficiency.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published