This post provides some experiences from making a simple Java app (well, the actual app does something this is just a demo) that connects to Bitfinex to  get the funding rates run as a GraalVM native image.

xChange is one of the most famous Java libraries for integrating with a large number of crypto exchanges. It provides a simple API that Continue reading

During the past few months I have been creating some EAs in MQL5. I have also created some microservice like functions for other FinTech related projects (e.g. Market News / custom indicators). All those services are exposed with REST APIs. So there is the need to reuse this functionality from MQL5 Expert Advisors.

There are numerous examples in MQL5 that use WebRequest, however it’s not possible to use them from within backtesting. An error is raised in such cases. The other obvious alternative was to use a custom DLL that will be used from within MQL5 and delegate the REST call to the DLL.

In this direction I have created an opensource library rest-mql and an example on how to use it through MQL5. The library can be found here: https://github.com/cyrus13/rest-mql

The example MQL code can be found here: https://github.com/cyrus13/rest-mql/blob/master/mql5-sample-code/testmqldll.mq5

It is worth mentioning that REST calls certainly slow down the EA and should be used judiciously.

It’s been ages since I have posted some sample code. It’s mainly because I don’t have time to collect and post sample code anymore. This once was a bit more challenging and googling wasn’t help much, so now that I have some time I though I would post some sample code that achieves batch inserts with spring data.

For example this link:
http://forum.spring.io/forum/spring-projects/data/118203-bulk-insert-with-crudrepository indicated that I had to manually get the session and iterate/flush (which was true when using Spring/Hibernate/JPA). But when using the CRUDRepository it appears it’s much simpler.

FULL CODE

Full code sample (maven project) can be found on github: https://github.com/cyrus13/anastasakis-net-sample-code/tree/master/spring-data-batch

You basically need to have the following elements:

  • Add: ?rewriteBatchedStatements=true to the end of the connectionstring.
  • Make sure you use a generator that supports batching in your entity. E.g.
@Id
@GeneratedValue(generator = "generator")
@GenericGenerator(name = "generator", strategy = "increment")
  • Use the: save(Iterable<S> paramIterable); method of the JpaRepository to save the data.
  • Use the: hibernate.jdbc.batch_size configuration.

RESULT

So enabling the query log in MySQL:

SET global general_log = 1;
SET global log_output = 'table';

we can see the following mysql code is executed:

SET autocommit=0;
select max(id) from ExampleEntity;
SHOW WARNINGS;
select @@session.tx_read_only;
insert into ExampleEntity (exampleText, id) values 
('de32bec8-1cf9-4f14-b816-0ab7a00b1539', 4),
('c0c85b32-eb2d-4a69-ade4-ac70ea94241c', 5);
commit;
SET autocommit=1;

Note: Don’t forget to stop logging statements into MySQL general log!

SET global general_log = 0;