Tag Archives: Java

Use Redis NOSQL streams with Java and Python

This Redis streaming in new version 5 is very revolutionary. It is similar to Apache

Kafka

For the cloud

https://aws.amazon.com/redis/Redis_Streams/

https://www.alibabacloud.com/blog/redis-streams-–-redis-5-0%27s-newest-data-type_593816

Tutorial

https://redis.io/topics/streams-intro

Java

https://www.javacodegeeks.com/2018/05/a-first-look-at-redis-streams-and-how-to-use-them-with-java.html

Python

http://charlesleifer.com/blog/redis-streams-with-python/

HOW DO YOU START A PROFITABLE TRADING BUSINESS? Read more NOW >>>

NOTE I now post my TRADING ALERTS into my personal FACEBOOK ACCOUNT and TWITTER. Don't worry as I don't post stupid cat videos or what I eat!

MotiveWave SDK Java no 3rd party coding problems so far

Here they are as there are few 3rd party examples

BIG UPDATE BELOW which means I got this partially working!!

I tested to add a Redis NOSQL (3rd party) using simple Jedis Jar. This was done fairly easily with another Mac OS based proprietary platform like Dukascopy JForex. I could see the Redis update when running the strategy or study within MotiveWave. This builds fine. but there does not seem debugging log capabilities for a strategy but there is for studies. Also, when making changes in the Java in Eclipse, the MotiveWave platform does not seem to pick up the latest changes  in a dynamically changed class.  The only way for this to be picked up is by reseting the platform.

My opinion but it is looking good but …

I think there needs to a be lot more samples from MotiveWave instead of just 3 simple studies and 1 strategy. I could only find one other 3rd party providing further examples. Unfortunately, I am not  in the business of spinning my wheels to figure this out as compared to other brokers/platform who provide flawless coding experiences. I think I need to see a demo or better examples.

Until then, I am may just use MotiveWave for charting or connecting with IQFeed only. I can do that with the entry level MotionWave edition. This platform is very exciting indeed but I need to get to see improvements in the above area before I get serious with it from a coding point for view.

BIG UPDATE on getting Java coding! (Nov 29)

See the video to see what is working including text writing and CSV reading files

Here is working Java code as hinted in the video

package study_examples;

import com.motivewave.platform.sdk.common.Coordinate;

import com.motivewave.platform.sdk.common.DataContext;

import com.motivewave.platform.sdk.common.DataSeries;

import com.motivewave.platform.sdk.common.Defaults;

import com.motivewave.platform.sdk.common.Enums;

import com.motivewave.platform.sdk.common.Inputs;

import com.motivewave.platform.sdk.common.MarkerInfo;

import com.motivewave.platform.sdk.common.desc.InputDescriptor;

import com.motivewave.platform.sdk.common.desc.IntegerDescriptor;

import com.motivewave.platform.sdk.common.desc.MAMethodDescriptor;

import com.motivewave.platform.sdk.common.desc.MarkerDescriptor;

import com.motivewave.platform.sdk.common.desc.PathDescriptor;

import com.motivewave.platform.sdk.common.desc.SettingGroup;

import com.motivewave.platform.sdk.common.desc.SettingTab;

import com.motivewave.platform.sdk.common.desc.SettingsDescriptor;

import com.motivewave.platform.sdk.common.desc.ValueDescriptor;

import com.motivewave.platform.sdk.draw.Marker;

import com.motivewave.platform.sdk.study.RuntimeDescriptor;

import com.motivewave.platform.sdk.study.Study;

import com.motivewave.platform.sdk.study.StudyHeader;

import java.io.File;

import java.io.FileWriter;

import java.io.IOException;

import redis.clients.jedis.Jedis;

import java.io.BufferedReader;

import java.io.FileNotFoundException;

import java.io.FileReader;

import java.io.IOException;

/** Moving Average Cross. This study consists of two moving averages: 

    Fast MA (shorter period), Slow MA. Signals are generated when the 

    Fast MA moves above or below the Slow MA. Markers are also displayed 

    where these crosses occur. */

@StudyHeader(

  namespace=”com.mycompany”, 

  id=”MACROSS”, 

  name=”Sample Moving Average Cross”,

  label=”MA Cross”,

  desc=”Displays a signal arrow when two moving averages (fast and slow) cross.”,

  menu=”Examples”,

  overlay=true,

  signals=true)

public class SampleMACross extends Study

{

  enum Values { FAST_MA, SLOW_MA };

  enum Signals { CROSS_ABOVE, CROSS_BELOW };

  @Override

  public void initialize(Defaults defaults)

  {

try {

File file = new File(“/Users/quantlabsnet/atestfile1.txt”);

FileWriter fileWriter = new FileWriter(file);

fileWriter.write(“This is “);

fileWriter.write(“a test”);

fileWriter.flush();

fileWriter.close();

} catch (IOException e) {

this.debug(e.toString());

e.printStackTrace();

}

//https://www.mkyong.com/java/how-to-read-and-parse-csv-file-in-java/

String csvFile = “/Users/quantlabsnet/country.csv”;

    BufferedReader br = null;

    String line = “”;

    String cvsSplitBy = “,”;

    try {

        br = new BufferedReader(new FileReader(csvFile));

        while ((line = br.readLine()) != null) {

            // use comma as separator

            String[] country = line.split(cvsSplitBy);

            this.debug(“Country [code= ” + country[4] + ” , name=” + country[5] + “]”);

        }

    } catch (FileNotFoundException e) {

        e.printStackTrace();

        this.debug(e.toString());

    } catch (IOException e) {

        e.printStackTrace();

        this.debug(e.toString());

    } finally {

        if (br != null) {

            try {

                br.close();

            } catch (IOException e) {

                e.printStackTrace();

                this.debug(e.toString());

            }

        }

    }

// Jedis jedis = new Jedis(“localhost”); 

//    this.debug(“Connection to server sucessfully”); 

//    //check whether server is running or not 

//    this.debug(“Server is running: “+jedis.ping()); 

 

this.debug(“hello debug from SampleMACross()”);

 

    // User Settings

    SettingsDescriptor sd=new SettingsDescriptor();

    setSettingsDescriptor(sd);

    SettingTab tab=new SettingTab(“General”);

    sd.addTab(tab);

    // Fast MA (shorter period)

    SettingGroup ma1=new SettingGroup(“Fast MA”);

    tab.addGroup(ma1);

    ma1.addRow(new InputDescriptor(Inputs.INPUT, “Fast Input”, Enums.BarInput.CLOSE));

    ma1.addRow(new MAMethodDescriptor(Inputs.METHOD, “Fast Method”, Enums.MAMethod.EMA));

    ma1.addRow(new IntegerDescriptor(Inputs.PERIOD, “Fast Period”, 10, 1, 9999, 1));

    // Slow MA (shorter period)

    SettingGroup ma2=new SettingGroup(“Slow MA”);

    tab.addGroup(ma2);

    ma2.addRow(new InputDescriptor(Inputs.INPUT2, “Slow Input”, Enums.BarInput.CLOSE));

    ma2.addRow(new MAMethodDescriptor(Inputs.METHOD2, “Slow Method”, Enums.MAMethod.EMA));

    ma2.addRow(new IntegerDescriptor(Inputs.PERIOD2, “Slow Period”, 20, 1, 9999, 1));

    tab=new SettingTab(“Display”);

    sd.addTab(tab);

    SettingGroup lines=new SettingGroup(“Lines”);

    tab.addGroup(lines);

    lines.addRow(new PathDescriptor(Inputs.PATH, “Fast MA”, defaults.getGreenLine(), 1.0f, null, true, false, false));

    lines.addRow(new PathDescriptor(Inputs.PATH2, “Slow MA”, defaults.getBlueLine(), 1.0f, null, true, false, false));

    SettingGroup markers=new SettingGroup(“Markers”);

    tab.addGroup(markers);

    markers.addRow(new MarkerDescriptor(Inputs.UP_MARKER, “Up Marker”, Enums.MarkerType.TRIANGLE, Enums.Size.SMALL, defaults.getGreen(), defaults.getLineColor(), true, true));

    markers.addRow(new MarkerDescriptor(Inputs.DOWN_MARKER, “Down Marker”, Enums.MarkerType.TRIANGLE, Enums.Size.SMALL, defaults.getRed(), defaults.getLineColor(), true, true));

    // Runtime Settings

    RuntimeDescriptor desc=new RuntimeDescriptor();

    setRuntimeDescriptor(desc);

    desc.setLabelSettings(Inputs.INPUT, Inputs.METHOD, Inputs.PERIOD, Inputs.INPUT2, Inputs.METHOD2, Inputs.PERIOD2);

    desc.exportValue(new ValueDescriptor(Values.FAST_MA, “Fast MA”, new String[] { Inputs.INPUT, Inputs.METHOD, Inputs.PERIOD }));

    desc.exportValue(new ValueDescriptor(Values.SLOW_MA, “Slow MA”, new String[] { Inputs.INPUT2, Inputs.METHOD2, Inputs.PERIOD2 }));

    desc.exportValue(new ValueDescriptor(Signals.CROSS_ABOVE, Enums.ValueType.BOOLEAN, “Cross Above”, null));

    desc.exportValue(new ValueDescriptor(Signals.CROSS_BELOW, Enums.ValueType.BOOLEAN, “Cross Below”, null));

    desc.declarePath(Values.FAST_MA, Inputs.PATH);

    desc.declarePath(Values.SLOW_MA, Inputs.PATH2);

    // Signals

    desc.declareSignal(Signals.CROSS_ABOVE, “Fast MA Cross Above”);

    desc.declareSignal(Signals.CROSS_BELOW, “Fast MA Cross Below”);

    desc.setRangeKeys(Values.FAST_MA, Values.SLOW_MA);

  }

  @Override

  protected void calculate(int index, DataContext ctx)

  {

    int fastPeriod=getSettings().getInteger(Inputs.PERIOD);

    int slowPeriod=getSettings().getInteger(Inputs.PERIOD2);

    if (index < Math.max(fastPeriod, slowPeriod)) return; // not enough data

    DataSeries series=ctx.getDataSeries();

    // Calculate and store the fast and slow MAs

    Double fastMA=series.ma(getSettings().getMAMethod(Inputs.METHOD), index, fastPeriod, getSettings().getInput(Inputs.INPUT));

    Double slowMA=series.ma(getSettings().getMAMethod(Inputs.METHOD2), index, slowPeriod, getSettings().getInput(Inputs.INPUT2));

    if (fastMA == null || slowMA == null) return;

    series.setDouble(index, Values.FAST_MA, fastMA);

    series.setDouble(index, Values.SLOW_MA, slowMA);

    if (!series.isBarComplete(index)) return;

    // Check to see if a cross occurred and raise signal.

    Coordinate c=new Coordinate(series.getStartTime(index), slowMA);

    if (crossedAbove(series, index, Values.FAST_MA, Values.SLOW_MA)) {

      MarkerInfo marker=getSettings().getMarker(Inputs.UP_MARKER);

      if (marker.isEnabled()) addFigure(new Marker(c, Enums.Position.BOTTOM, marker));

      ctx.signal(index, Signals.CROSS_ABOVE, “Fast MA Crossed Above!”, series.getClose(index));

    }

    else if (crossedBelow(series, index, Values.FAST_MA, Values.SLOW_MA)) {

      MarkerInfo marker=getSettings().getMarker(Inputs.DOWN_MARKER);

      if (marker.isEnabled()) addFigure(new Marker(c, Enums.Position.TOP, marker));

      ctx.signal(index, Signals.CROSS_BELOW, “Fast MA Crossed Below!”, series.getClose(index));

    }

    series.setComplete(index);

  }

}

 

 

HOW DO YOU START A PROFITABLE TRADING BUSINESS? Read more NOW >>>

NOTE I now post my TRADING ALERTS into my personal FACEBOOK ACCOUNT and TWITTER. Don't worry as I don't post stupid cat videos or what I eat!

Implementing MotiveWave Java samples and IQFeed data provider with no issue

Wow. What can I say? This Java software developers kit is quite powerful. In this video, I show how easy it is implement this with a Java Integrated Development Environment (IDE) like Eclipse. This is all explained in the document PDF you can easily download. This API looks pretty straightforward.

I have demonstrated the out of box strategies and studies. You can easily get these working them in the MotiveWave trading software.

I have also confirmed you can use DTN IQFeed as your data provider with Interactive Brokers as your broker for orders. You can open an account with literally nothing with IB so you don’t need data as you would a data providers like IQFeed. You can trade all major asset classes like stock, options/future, forex, crypto CFD, etc.

CryptoCompare or Coinogy can be your cyrpto data provider as well. Do realize you cannot trade in this asset class at this point.

Different pricing levels are available based on what you want to do but it can start at $99. Cheap when you think about it.

HOW DO YOU START A PROFITABLE TRADING BUSINESS? Read more NOW >>>

NOTE I now post my TRADING ALERTS into my personal FACEBOOK ACCOUNT and TWITTER. Don't worry as I don't post stupid cat videos or what I eat!

MotiveWave and IQFeed with Java will be game changer and crypto support

This is brand new mainstream trading software from MotiveWave and IQFeed

Search here for various IQfeed topics.

Game changer

To run IQFeed with Java on Mac OS is a dream come true. You can also use an IDE like Javabeans or Eclipse to the coding with this data. Here I demo using option chain data, tick data streaming, and news items. You can also get Level 2 for all data.

Hint: Interactive Brokers can be used for orders only but using the IQFeed if you want. All access classes can be covered here with futures and options. Oanda is supported as well.

 

As for Coinogy which appears to support big exchanges including Binance.

https://www.motivewave.com

HOW DO YOU START A PROFITABLE TRADING BUSINESS? Read more NOW >>>

NOTE I now post my TRADING ALERTS into my personal FACEBOOK ACCOUNT and TWITTER. Don't worry as I don't post stupid cat videos or what I eat!

Algo forex Questions about Python Java Dukascopy I use with algo crypto trading

Algo forex Questions about Python Java Dukascopy I use with algo crypto trading

This is set of queries came in from someone on Facebook:

Dear Bryan. Thanks for the great job you do. My objective is to make MVP for crypto algorithm trading in Python with ccxt and Ta-Lib packages, and probably with Flask

In your youtube channel, I went through Ta-lib, ccxt videos. It was great. Could you please advise how to proceed.

THere is no such info on web. 

Many thanks in advance ,

I answer via video found on my Youtube channel

Helpful links I include

My Podbean page for podcasts 

Shopify store for preview videos 

Link to call external libraries for Dukascopy JForex

Questions and answers new to forex trading

Popular indicators from TA-Lib Python wrapper

HOW DO YOU START A PROFITABLE TRADING BUSINESS? Read more NOW >>>

NOTE I now post my TRADING ALERTS into my personal FACEBOOK ACCOUNT and TWITTER. Don't worry as I don't post stupid cat videos or what I eat!

Learn how to work Interactive Brokers API like ib java test client demo

 

4 5 hr workshop live recorded to learn how to work Interactive Brokers API and TWS

Get your latest deal now with full details below
Buy Now
A super duper cheap deal for Interactive Brokers API and TWS
https://quantlabs.net/blog/2018/01/4-5-hr-workshop-live-recorded-learn-work-interactive-brokers-api-tws/
Video details:Interative Brokers 4.5 hour Workshop Bootcamp

This is an eire 4.5 hour online LIVE workshop of the following online course

INTERACTIVE BROKERS API

Source code sample and files can be found  by purchasing here

 

PREREQUISITES AND REQUIREMENTS

Depending on your language of choice, these demos with source code are useful for those who want take advantage of  the Interactive Bokers TWS software.

WHAT WILL YOU LEARN?

This course will give you an overview of the critical components needed for your own algo trading system. This will give thought on pieces that will make you successful as indie automated trader to control your own destiny.

MODULE 1: WHY REDIS

Here is an introduction to the world’s in memory NOSQL database. This demo introduce why it should be used with source code.

MODULE 2:  WHY PYTHON FOR MY ALGOS AND AUTOMATED TRADING

Simple demo of Interactive Brokers Python integration with iBPy package. Sample code incuded.

MODULE 3: DEMO OF JAVA AND PYTHON WITH REDIS PUB SUB

MODULE 4: IB JAVA TEST CLIENT DEMO

IB Java Test Client demo

Netbeans IDE Java project ibredis2-tar

LRANGE Python demo found in this directory redis-chat

MODULE 5: JAVA PUSH LPUSH PYTHON LRANGE

Java Push LPUSH Python LRANGE

MODULE 6: PYTHON PUB TO JAVA SUB IB TWS ORDER

Python pub to Java sub IB TWS Order

Python code under

Netbeans Java Project

MODULE 7: TWS API C++ LIBRARY AND IB C++ ON POSIX MAC

C++ source is made available from IB API sample package as hinted in video

 

HOW DO YOU START A PROFITABLE TRADING BUSINESS? Read more NOW >>>

NOTE I now post my TRADING ALERTS into my personal FACEBOOK ACCOUNT and TWITTER. Don't worry as I don't post stupid cat videos or what I eat!

Let’s start coding the entire forex trading strategy in Dukascopy Jforex Java today

Let’s start coding the entire forex trading strategy in Dukascopy Jforex Java today

I will be combining all the items I have talked about over the last few weeks.

HOW DO YOU START A PROFITABLE TRADING BUSINESS? Read more NOW >>>

NOTE I now post my TRADING ALERTS into my personal FACEBOOK ACCOUNT and TWITTER. Don't worry as I don't post stupid cat videos or what I eat!

How to create technical indicator like ATR with Visual Jforex to Java

How to create technical indicator like ATR with Visual Jforex to Java

Lazy conversion from Visual JForex to Java to JForex so let’s hope this works

 

HOW DO YOU START A PROFITABLE TRADING BUSINESS? Read more NOW >>>

NOTE I now post my TRADING ALERTS into my personal FACEBOOK ACCOUNT and TWITTER. Don't worry as I don't post stupid cat videos or what I eat!

Dukascopy provides source code Java examples of optimal timing forex trading

Dukascopy provides source code Java examples of optimal timing forex trading

More indicator with better coding examples

https://www.dukascopy.com/wiki/en/development/strategy-api/indicators/indicator-catalog#hilbert-transform-instantaneous-trendline

https://www.dukascopy.com/wiki/en/development/strategy-api/indicators/indicator-calculation

 

HOW DO YOU START A PROFITABLE TRADING BUSINESS? Read more NOW >>>

NOTE I now post my TRADING ALERTS into my personal FACEBOOK ACCOUNT and TWITTER. Don't worry as I don't post stupid cat videos or what I eat!

Analyzing Dukascopy bid ask forex volume in JForex with Java

Analyzing Dukascopy bid ask forex volume in JForex with Java

This can help to build an oscillator on market buy or sell at tick level

https://www.dukascopy.com/wiki/en/development/strategy-api/practices/get-full-market-depth

 

 

HOW DO YOU START A PROFITABLE TRADING BUSINESS? Read more NOW >>>

NOTE I now post my TRADING ALERTS into my personal FACEBOOK ACCOUNT and TWITTER. Don't worry as I don't post stupid cat videos or what I eat!