Demo strategies: QuotesDelta Indicator
Re: Demo strategies: QuotesDelta Indicator
Hi
I try to see OrderID for MBO
I add MarketbyOrderDepthListener and use proper method
package com.bookmap.api.simple.demo.indicators;
import java.awt.Color;
import com.bookmap.api.simple.demo.utils.data.OrderBookBase;
import velox.api.layer1.annotations.Layer1ApiVersion;
import velox.api.layer1.annotations.Layer1ApiVersionValue;
import velox.api.layer1.annotations.Layer1SimpleAttachable;
import velox.api.layer1.annotations.Layer1StrategyName;
import velox.api.layer1.data.InstrumentInfo;
import velox.api.layer1.layers.utils.OrderBook;
import velox.api.layer1.messages.indicators.Layer1ApiUserMessageModifyIndicator.GraphType;
import velox.api.layer1.simplified.Api;
import velox.api.layer1.simplified.Bar;
import velox.api.layer1.simplified.BarDataListener;
import velox.api.layer1.simplified.CustomModule;
import velox.api.layer1.simplified.DepthDataListener;
import velox.api.layer1.simplified.Indicator;
import velox.api.layer1.simplified.InitialState;
import velox.api.layer1.simplified.Intervals;
import velox.api.layer1.simplified.MarketByOrderDepthDataListener;
import velox.api.layer1.simplified.SnapshotEndListener;
@Layer1SimpleAttachable
@Layer1StrategyName("MBO Order ID2")
@Layer1ApiVersion(Layer1ApiVersionValue.VERSION1)
public class MBOOrderID2 implements CustomModule, BarDataListener, SnapshotEndListener,
MarketByOrderDepthDataListener , DepthDataListener{
protected final OrderBookBase book = new OrderBookBase();
private int bidSUM = 0;
private int askSUM = 0;
private boolean snapshotCompleted = false;
**** public void send(java.lang.String orderId,
boolean isBid,
int price,
int size)
{
int prevSize = book.onDepth(isBid, price, size);
if (snapshotCompleted)
{
int delta = size - prevSize;
if (isBid)
{
bidSUM += delta;
} else {
askSUM += delta;
}
System.out.println( orderId);
}
}***********
Indicator works, but I can not get output - nothing in log
How I can see my output value
Thank you
AG
I try to see OrderID for MBO
I add MarketbyOrderDepthListener and use proper method
package com.bookmap.api.simple.demo.indicators;
import java.awt.Color;
import com.bookmap.api.simple.demo.utils.data.OrderBookBase;
import velox.api.layer1.annotations.Layer1ApiVersion;
import velox.api.layer1.annotations.Layer1ApiVersionValue;
import velox.api.layer1.annotations.Layer1SimpleAttachable;
import velox.api.layer1.annotations.Layer1StrategyName;
import velox.api.layer1.data.InstrumentInfo;
import velox.api.layer1.layers.utils.OrderBook;
import velox.api.layer1.messages.indicators.Layer1ApiUserMessageModifyIndicator.GraphType;
import velox.api.layer1.simplified.Api;
import velox.api.layer1.simplified.Bar;
import velox.api.layer1.simplified.BarDataListener;
import velox.api.layer1.simplified.CustomModule;
import velox.api.layer1.simplified.DepthDataListener;
import velox.api.layer1.simplified.Indicator;
import velox.api.layer1.simplified.InitialState;
import velox.api.layer1.simplified.Intervals;
import velox.api.layer1.simplified.MarketByOrderDepthDataListener;
import velox.api.layer1.simplified.SnapshotEndListener;
@Layer1SimpleAttachable
@Layer1StrategyName("MBO Order ID2")
@Layer1ApiVersion(Layer1ApiVersionValue.VERSION1)
public class MBOOrderID2 implements CustomModule, BarDataListener, SnapshotEndListener,
MarketByOrderDepthDataListener , DepthDataListener{
protected final OrderBookBase book = new OrderBookBase();
private int bidSUM = 0;
private int askSUM = 0;
private boolean snapshotCompleted = false;
**** public void send(java.lang.String orderId,
boolean isBid,
int price,
int size)
{
int prevSize = book.onDepth(isBid, price, size);
if (snapshotCompleted)
{
int delta = size - prevSize;
if (isBid)
{
bidSUM += delta;
} else {
askSUM += delta;
}
System.out.println( orderId);
}
}***********
Indicator works, but I can not get output - nothing in log
How I can see my output value
Thank you
AG
-
- Posts: 548
- Joined: Mon Jul 09, 2018 11:18 am
- Has thanked: 25 times
- Been thanked: 85 times
Re: Demo strategies: QuotesDelta Indicator
Hi Serg, all
Awesome indicator!
I have a couple of questions. Is it possible to have an option for chart range/session range so values are shown for chart range. And also, it is possible to measure only stacking and have a filter for size? I think this may be helpful.
Many thanks!!
Awesome indicator!
I have a couple of questions. Is it possible to have an option for chart range/session range so values are shown for chart range. And also, it is possible to measure only stacking and have a filter for size? I think this may be helpful.
Many thanks!!
-
- Posts: 548
- Joined: Mon Jul 09, 2018 11:18 am
- Has thanked: 25 times
- Been thanked: 85 times
Re: Demo strategies: QuotesDelta Indicator
Hi!
1) QuotesDelta example is written using Simplified API. Unfortunately, Simplified API will not support reporting chart ranges to a custom module. It is just designed for limited scope of actions. Please use Core API if you need chart ranges to be reported to your module. Here are examples written with Core API. If you have never used Core API we would recomment to start with markers demo.
2) this is onDepth method from the original QuotesDelta module
If you need stacking only (I recognize it as adding liquidity only and not reacting to decreasing liquidity) you may want to add delta only if is > 0.
You can add some other conditions for adding delta (size change value?).
1) QuotesDelta example is written using Simplified API. Unfortunately, Simplified API will not support reporting chart ranges to a custom module. It is just designed for limited scope of actions. Please use Core API if you need chart ranges to be reported to your module. Here are examples written with Core API. If you have never used Core API we would recomment to start with markers demo.
2) this is onDepth method from the original QuotesDelta module
Code: Select all
@Override
public void onDepth(boolean isBid, int price, int size) {
int prevSize = book.onDepth(isBid, price, size);
if (snapshotCompleted) {
int delta = size - prevSize;
if (isBid) {
bidDelta += delta;
} else {
askDelta += delta;
}
}
}
Code: Select all
@Override
public void onDepth(boolean isBid, int price, int size) {
int prevSize = book.onDepth(isBid, price, size);
if (snapshotCompleted) {
int delta = size - prevSize;
if (delta > 0){
if (isBid) {
bidDelta += delta;
} else {
askDelta += delta;
}
}
}
}
Code: Select all
@Override
public void onDepth(boolean isBid, int price, int size) {
int prevSize = book.onDepth(isBid, price, size);
if (snapshotCompleted) {
int delta = size - prevSize;
if (delta >= 100){//delta is a size change so here we are filtering out deltas below 100
-
- Posts: 548
- Joined: Mon Jul 09, 2018 11:18 am
- Has thanked: 25 times
- Been thanked: 85 times
Re: Demo strategies: QuotesDelta Indicator
Getting unexpected results is pretty common in programming. You need to figure out what data causes the wrong behavior. The simplest way to do it is to write some extra info to your log and to study the log once the incorrect behavior is reproduced. In your case, you may want to add this line inside the if (delta > ...) { block so you know what exactly it is triggererd by.So, with literally zero coding knowledge except some visual basic on a C64 when I think I managed to edit the Quotes Delta 5 to be just stacking, I think I used this version as wanted to be able to edit the depth levels too. I notice though that when I try this for the size, it fires off on random times I have not defined. Did I do something wrong here? - snippet from the code, highlights are my amends
a link to the image
Code: Select all
Log.info("delta " + delta + " isBid " + " price " + price + " size " + size );
Just for your information, price and size you are getting in the onDepth method are specified in pips/sizeMultiplier. To get the price(size) you need to multiply(divide) the price(size) by pips(sizeMultiplier) respectively. You can get the pips or minSize values from InstrumentInfo info in your module's initialize method.