Question about Java implementations and frameworks for algorithmic trading, and relevant techniques?

Discussion in 'App Development' started by Blonde, Mar 15, 2021.

  1. Butterfly

    Butterfly

    of course you don't need Java to run trading robots, the guy has no clue and is obviously not interested in alternatives input or recommendations.

    The key to systematic trading is to be flexible and make changes quickly when needed, and for that you need a language that is clear and simple to read. Unlike Java :)
     
    #51     Mar 22, 2021
  2. Blonde

    Blonde


    Hiya @fan27



    Looks like a good short-term solution for robot development. I know C# too. When we use C#, do the option for compile is the NT8, or can we use an external compiler for creating a standalone robot application as well? Is there any compile faster than the C# compiler of NT8?


    Tnx and bets of luck
     
    #52     Mar 22, 2021
  3. fan27

    fan27

    I use QuantTerminal.
     
    #53     Mar 22, 2021
    Blonde likes this.
  4. merdontv

    merdontv

    if I understood your question. there is no framework for trading written in java.
    https://en.wikipedia.org/wiki/List_of_Java_frameworks
    why? there are a lot of trading platforms in the world. many have their own API.
    Еveryone writes this API in their own way and in different languages.
    No matter what language this API is in, because you can getting this data by stream and processing it in your external code.
    You can write this data to a database or a text file.
    Speed is not important to you, you will not be faster than man, who trade in billions.
    For example NT8. C # and java:
    1. You get data in C #. write them to a text file
    (this code is very simple sw = File.AppendText(path); see their help for details).
    2. Read this data from this file from your code
    (java : BufferReader with Thread.sleep(some time)).
    3. Parse and process them.
    (line.split(",") to get array)
    4. Received a signal? you write the ticker, price, number of lots to another text file(Files.write(path and some parameters).
    5. NT8 reads data. parses. and submits an application
    (File.ReadAllText(path);).
    6. Need you to draw on a chart your signal? to do the same. in java code, you get pivot points and write them to some file.txt. NT8 reads, parse and API draws whatever arrows, lines, etc.
    *******************************************************
    for:
    1. skeleton of your Java program, you can use a maven, gradle.
    2. dekstop to use Swing or javaFX. if the Web to use Spring.
    3. database to use postgresql(may be Oracle cloud, firebase) and Hibernate.
    4. Logging log4j.
    5. alert Telegramm bot.
    ******************************************************
    You can see the API by Java on this platform, you may like:
    https://www.motivewave.com/support/sdk.htm
    https://www.motivewave.com/sdk/MotiveWave_SDK_Programming_Guide.pdf
    For me, API NT8 has simplest API for used.
    PS. this is the overall picture. details omitted.
     
    #54     Apr 25, 2021
    Blonde likes this.
  5. Blonde

    Blonde



    Hiya @merdontv



    Thanks. Regarding,
    Database optimization for high speed and high bandwidth read/write is a professional subject. Also, why can't we get the data from the broker when we need it as they have historic data and why develop a Database while the broker has servers with live access to historical data and live data and tick data? What is the purpose of this?


    I don't get this completely? Do you mind elaborating how can I highlight the entry and exit positions(buy and sell positions) location on a candlestick chart while on API programming? I mean do I need NT8 to do this? What about MultiCharts v14? And what about plain JNL Java development on IDEA and connection by API to broker, how can I highlight the entry and exit positions(buy and sell positions) location on a candlestick chart?


    I used Maven for repository management on my previous Java Robot, and I may use JavaFX for drawing one single candlestick chart that highlights the entry and exit location of my positions on candlestick charts if it has the capacity to do this on financial markets?

    I prefer Oracle for DBMS?

    What shall I log with Log4J?

    I don't get how can I use Telegram-bot for alerts? Do I need to install the Telegram App on my mobile(I can install it) and receive the Alerts on the Telegram App? How shall I do this Telegram-bot part, please?

    About the MotiveWave platform, its ultimate package price is 'One-Time Payment of $2295 USD' but it only has 'Ultimate Edition - Purchased License (Includes 1 Year of Updates and Support)', thus what shall I do if I purchased the Ultimate lifetime license, but while I don't have the update after one year? Maybe after OS major upgrade, the MotiveWave gets a critical error that can't be executed or partially become dysfunctional, if you know what I mean? What shall I do for this part? Please help? Does MotiveWave have an annual Sale?


    Tnx and best of luck [​IMG]
     
    Last edited: Apr 27, 2021
    #55     Apr 27, 2021
  6. merdontv

    merdontv

    1. Forget about high speed. it is not available to you by default.
    2. Are you going to request data every time for the next 1000 run of the test? this movement is unnecessary. plus you need to store logging and statistics for each ticker somewhere. if it is a couple of tickers, it can be a text file, and if there are 1000 tickers and 5 exchanges? (I don't know your goals).
    3. You can use any platform that has an api for data management. and use it to draw whatever your heart desires.
    4. If this is not a requirement of the customer under the contract, then it makes no sense to make your own charts. any platform already has charts. and you do not write a single line of code for this, you do not test or maintain this code. plus if your strategy requires indicators, they are installed by default in each platform. time is priceless.
    5. I don’t know what JNL is.
    6. job4j. Q?: your program is ready to work and launched into production and unexpectedly crashed on the first day of work. how will you understand what happened and when and what you will do so that it does not happen again?
    7. Telegram bot. you should read the api help and some examples of how to create a bot. install telegram on your phone. in the telegram you activate the bot. the robot requires token settings, etc. and when robot receive a signal, it send an alert to your phone.
    8. MotiveVawe I read their help. but didn't work with them. showed as an example java api.
     
    #56     Apr 27, 2021
    Blonde likes this.
  7. Blonde

    Blonde


    Hiya @merdontv



    Thanks. Regarding,
    A1- I want to keep my speed on edge of real-time computing as this is one of my goals in implementation. Thus I want to go the routes that keep my speed as well?
    A2 & A4- My Robots in Java are different. They made for different goals. But the fully automatic one is in need of sophisticated analysis. I go with semi-automated Robots to start. Thus in this semi-automated one, I need only real-time tick data calculations of all indicators in different Tick-periods to use their values in my sophisticated mathematical analysis. I don't think the implementation of this does need DBMS?
    Regarding logging, I prefer to debug live values thus the final algorithm is error-free. I don't think this semi-dedicated strategy does in need for loggings for now?
    The reason I need to Algorithmic-trading highlight and mark m trades on candlestick charts is to see the entries and exits to verify the errors later to analyze what is the source f the error? Otherwise, I clear my point by the example below:
    Considering if months are 4 weeks and 12 months in total in one year, we have about 240 working days per year. In case my Algorithmic-Trading Robot have 45 loss to 55 success rate, then if Algorithmic-trading Robot place 1000 trades per day in average have about 108,000 loss to analysis at the end of the year? If there is a candlesticks chart that can highlight the entry and exits of these trades and connects them to each other(connect entry to exit) with a very thin line. Then I can visually debug the sophisticated mathematical logic and strategy of this Algorithmic trading Robot, otherwise, how shall I analyze why these losses happened manually?
    A3- How can I highlight my losses in the example above for 108,000 annual loss in a charting platform by API?
    A5- Java Native Language
    A6- Regarding logging, I prefer to debug live values thus the final algorithm is error-free. I don't think this semi-dedicated strategy does in need for loggings for now? But I will implement this for the fully automated Robot that I develop later?
    A4 & A8- If I can draw by Multicharts v14 for charting the losses trades by API, this would be greater than MotiveWave, may please help me with this?


    Tnx and best of luck [​IMG]
     
    #57     May 4, 2021
  8. dholliday

    dholliday

    Hi Blonde,

    Your approach seems reasonable.

    A5- Maybe this should be JNI (Java Native Interface)?

    As to how to debug. One of the things I do is write out a file (JSON) when I make/close a trade. This file has a name that includes the symbol, the date/time of opening the trade, the date/time of closing the trade. In this file, I include anything that may be useful. Signal price, bid/ask price, average trade price (from the broker), etc. From MultiCharts and C#, you should be able to read the JSON file and create/display the charts with the buy/sell information. I have not done this so...
    What I do if I see a problem is I get the info from the files, open any charting program and see if it makes sense. If the charting program is using my data supplier (DTN) then great, if not (like TradingView) I download the data from DTN and look at it at the time of the trade.

    As you know, I don't use a database for anything (not completely true). Data is almost always saved (and backed up) in its raw form. It is put in a database via scripts for use by/for those who need it.

    A better way may be to write your trades info into a log file. This has the advantage of being able to write the information to your local and a remote machine at the same time (plus other advantages). You could also use a message service or a remote data-structure library like Invinispan.
    As before, your can write some code to parse the logs to get what information you need to annotate charts.
     
    #58     May 4, 2021
    Blonde likes this.
  9. merdontv

    merdontv

    A1, I didn't understand the question. the limit of your computing capabilities depends on the processor and RAM and disk of your computer. You will not be able to control the speed of the data channel, cause it depends on the data providers (broker, several exchanges) and the Internet channel provider. you are not The Blackstone Group. then you can forget about the speed.
    A2 DB. you can pass data directly into memory. but if something goes wrong and the robot starts showing false entries (you will not immediately understand these are false entries or program errors), how do you determine from the problem? and when??
    1. price or the time of the received ticks?
    2. a program?
    3. a channel?
    4. a providers?
    For simplicity, you can receive data, write to one file, then read.
    (if algo needs some ticks for one or two minutes ago? from what does it take this data, if your hav't a storage for data?)
    Second file is logging if something wrong.
    it's better than nothing at the end of the trading day.
    A3
    1. write down the table of deals.
    2. In the trading platform, start simulated trading at an increased speed.
    3. The trading platform, during this simulated trade, reads from the file of transactions (item 1).
    3.1 compares times and prices with your data in the file.
    3.2 if the entry or exit prices are equal (file == platform), then it places markers (line arrows, etc.).
    ps. (if it is futures) -> prices on the glued chart will not match.
    A6 I do not believe in final programs that do not contain errors in production. I live in the real world.
    A7 I don’t know.
     
    #59     May 6, 2021
    Blonde likes this.
  10. dholliday

    dholliday

    Blonde
    merdontv makes some good points.
    A1, speed on your machine should not be your big problem. Pretty much any language/scripting language should be able to receive, process, and send out an order in milliseconds. So what's slow? Graphics, keep graphics to a minimum. Reading/Writing to disk. If you are looking to save milliseconds don't do it. Otherwise, go ahead.
    That said, I wrote my platform to be crazy fast, but writing your own platform is a huge job. For the time being, using MultiCharts with C# seems like a fine choice

    A2. I do use tick data directly. But the point about how you know when something is wrong is very important. In my platform for example I have three levels of sub-systems to prevent my programs from buying wildly via some bug. As an example, I have code that checks to see that I don't exceed buying 10 different symbols with a maximum of $10,000 each. Also, I have code that when a system/symbol places an order it can never place another one.

    I really like #3 - 3.2. I may implement this in the future.

    Loggin is good. Log4j is good.
     
    #60     May 6, 2021
    Blonde likes this.