Demo strategies: QuotesDelta Indicator
-
- Posts: 67
- Joined: Thu Nov 01, 2018 1:50 pm
- Has thanked: 38 times
- Been thanked: 9 times
Re: Demo strategies: QuotesDelta Indicator
Hi Serg,
Is it possible to export the Quotes data in the same way that I can export the trades data to a csv. Basically it would be interesting to see the effect of Quotes being added and pulled with Time/Price/Size, exactly like the trades data. It is being displayed in the Quotes delta column, so I guess that since this data is being generated, it will be possible to access this data and export it?
Also, as an addition it might be great if one can access this data programmatically? so maybe write to a file oneself or do calculations.
A limit on the number of levels will be good idea otherwise with MBO, this will be crazy file sizes.
I am aware of the Quotes Delta indicator and its code, But that sums up ALL the quotes(up to a limit level), whereas here one is interested in individual quotes being added or pulled. I have tried this another platform but the incoming data is not granular enough to record all(most) of the quotes.
TIA
Is it possible to export the Quotes data in the same way that I can export the trades data to a csv. Basically it would be interesting to see the effect of Quotes being added and pulled with Time/Price/Size, exactly like the trades data. It is being displayed in the Quotes delta column, so I guess that since this data is being generated, it will be possible to access this data and export it?
Also, as an addition it might be great if one can access this data programmatically? so maybe write to a file oneself or do calculations.
A limit on the number of levels will be good idea otherwise with MBO, this will be crazy file sizes.
I am aware of the Quotes Delta indicator and its code, But that sums up ALL the quotes(up to a limit level), whereas here one is interested in individual quotes being added or pulled. I have tried this another platform but the incoming data is not granular enough to record all(most) of the quotes.
TIA
- Attachments
-
- Capture2.JPG (78.18 KiB) Viewed 22571 times
-
- Capture.JPG (112.73 KiB) Viewed 22574 times
-
- Posts: 67
- Joined: Thu Nov 01, 2018 1:50 pm
- Has thanked: 38 times
- Been thanked: 9 times
-
- Posts: 548
- Joined: Mon Jul 09, 2018 11:18 am
- Has thanked: 25 times
- Been thanked: 85 times
Re: Demo strategies: QuotesDelta Indicator
Hi SuperDriveGuy,
currently, it is impossible to export the Quotes data from the Quotes Data Column.
Sorry if I am getting it wrong, since the code you attached is able(?) to calculate individual level deltas you can turn that output into whatever you want.
currently, it is impossible to export the Quotes data from the Quotes Data Column.
Sorry if I am getting it wrong, since the code you attached is able(?) to calculate individual level deltas you can turn that output into whatever you want.
-
- Posts: 67
- Joined: Thu Nov 01, 2018 1:50 pm
- Has thanked: 38 times
- Been thanked: 9 times
Re: Demo strategies: QuotesDelta Indicator
Hi AndreyR,
Thanks for your reply.
Sorry, maybe I explained it wrong.
The code(copied below too), sums up individual adds/pulls upto the number of levels defined. I need the individual pull and add, same as displayed in the time&sales window
--------------
public long getInterval()
{
return Intervals.INTERVAL_100_MILLISECONDS;
}
public void onDepth(boolean isBid, int price, int size)
{
TreeMap<Integer, Integer> halfBook = isBid ? book.bids : book.asks;
int bestPrice = halfBook.isEmpty() ? price : ((Integer)halfBook.firstKey()).intValue();
int priceLevel = isBid ? bestPrice - price : price - bestPrice;
int prevSize = book.onDepth(isBid, price, size);
if ((limitNumPriceLevels.booleanValue()) && (priceLevel >= maxPriceLevels.intValue())) {
return;
}
if (snapshotCompleted) {
int delta = size - prevSize;
if (isBid) {
bidDeltaSize += delta;
bidDeltaCount += 1;
} else {
askDeltaSize += delta;
askDeltaCount += 1;
}
int lastBestPrice = isBid ? lastBidPrice : lastAskPrice;
bestPrice = halfBook.isEmpty() ? price : ((Integer)halfBook.firstKey()).intValue();
if ((resetOnPriceChange.booleanValue()) && (bestPrice != lastBestPrice)) {
if (isBid) {
lastBidPrice = bestPrice;
bidDeltaSize = 0;
bidDeltaCount = 0;
} else {
lastAskPrice = bestPrice;
askDeltaSize = 0;
askDeltaCount = 0;
}
}
}
}
public void onSnapshotEnd()
{
snapshotCompleted = true;
}
-----------------------
Thanks
Thanks for your reply.
Sorry, maybe I explained it wrong.
The code(copied below too), sums up individual adds/pulls upto the number of levels defined. I need the individual pull and add, same as displayed in the time&sales window
--------------
public long getInterval()
{
return Intervals.INTERVAL_100_MILLISECONDS;
}
public void onDepth(boolean isBid, int price, int size)
{
TreeMap<Integer, Integer> halfBook = isBid ? book.bids : book.asks;
int bestPrice = halfBook.isEmpty() ? price : ((Integer)halfBook.firstKey()).intValue();
int priceLevel = isBid ? bestPrice - price : price - bestPrice;
int prevSize = book.onDepth(isBid, price, size);
if ((limitNumPriceLevels.booleanValue()) && (priceLevel >= maxPriceLevels.intValue())) {
return;
}
if (snapshotCompleted) {
int delta = size - prevSize;
if (isBid) {
bidDeltaSize += delta;
bidDeltaCount += 1;
} else {
askDeltaSize += delta;
askDeltaCount += 1;
}
int lastBestPrice = isBid ? lastBidPrice : lastAskPrice;
bestPrice = halfBook.isEmpty() ? price : ((Integer)halfBook.firstKey()).intValue();
if ((resetOnPriceChange.booleanValue()) && (bestPrice != lastBestPrice)) {
if (isBid) {
lastBidPrice = bestPrice;
bidDeltaSize = 0;
bidDeltaCount = 0;
} else {
lastAskPrice = bestPrice;
askDeltaSize = 0;
askDeltaCount = 0;
}
}
}
}
public void onSnapshotEnd()
{
snapshotCompleted = true;
}
-----------------------
Thanks
-
- Posts: 67
- Joined: Thu Nov 01, 2018 1:50 pm
- Has thanked: 38 times
- Been thanked: 9 times
Re: Demo strategies: QuotesDelta Indicator
Hi AndreyR,
I have taken the output from Time&Sales and changed it to reflect how it would look when the data is derived from the Quotes being added or pulled.
TIME,B/S,PRICE,DELTA
09:38:17:344,S,11785.0,1
09:38:17:417,B,11786.0,1
09:38:18:509,S,11785.0,1
09:38:18:510,S,11785.0,1
09:38:19:066,B,11786.0,-4
09:38:19:756,S,11786.0,1
09:38:20:380,B,11785.5,1
09:38:20:483,B,11786.0,1
09:38:20:860,B,11785.5,-1
09:38:21:218,S,11785.0,1
09:38:23:562,B,11785.0,1
09:38:23:563,B,11785.0,1
09:38:24:055,S,11784.5,-2
09:38:24:157,S,11784.0,1
Thanks
I have taken the output from Time&Sales and changed it to reflect how it would look when the data is derived from the Quotes being added or pulled.
TIME,B/S,PRICE,DELTA
09:38:17:344,S,11785.0,1
09:38:17:417,B,11786.0,1
09:38:18:509,S,11785.0,1
09:38:18:510,S,11785.0,1
09:38:19:066,B,11786.0,-4
09:38:19:756,S,11786.0,1
09:38:20:380,B,11785.5,1
09:38:20:483,B,11786.0,1
09:38:20:860,B,11785.5,-1
09:38:21:218,S,11785.0,1
09:38:23:562,B,11785.0,1
09:38:23:563,B,11785.0,1
09:38:24:055,S,11784.5,-2
09:38:24:157,S,11784.0,1
Thanks
-
- Posts: 548
- Joined: Mon Jul 09, 2018 11:18 am
- Has thanked: 25 times
- Been thanked: 85 times
Re: Demo strategies: QuotesDelta Indicator
This should work for you. Yor output file will be at your C: drive (change the code if you need to).
Add TimeListener to implemented interfaces.
Add these fields to your class
some lines to your initialize method
implement a method for the TimeListener interface
create a method to write a csv
and add these in the end of your onDepth method
add this to onStop() method
Add TimeListener to implemented interfaces.
Add these fields to your class
Code: Select all
long t;
File output = new File("C:\\qd-" + System.currentTimeMillis() + ".csv" );
PrintWriter pw;
Code: Select all
try {
pw = new PrintWriter(output);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
Code: Select all
@Override
public void onTimestamp(long t) {
this.t = t;
}
Code: Select all
void writeToCsv(Object... args) {
for (Object arg : args) {
pw.print(arg.toString());
pw.append(';');
}
pw.print('\n');
}
Code: Select all
if (snapshotCompleted) {
String side = isBid? "BID" : "ASK";
writeToCsv(Instant.ofEpochMilli(t/1_000_000), side, price, (size - prevSize));
}
Code: Select all
pw.close();
-
- Posts: 67
- Joined: Thu Nov 01, 2018 1:50 pm
- Has thanked: 38 times
- Been thanked: 9 times
-
- Posts: 2
- Joined: Sat Apr 18, 2020 8:37 am
Re: Demo strategies: QuotesDelta Indicator
Hi Serg,
Thanks for the awesome QuotesDelta Indicator. Can I ask a favour. Can you please provide a very high level summarised explanation of how to interpret the plot from Quotes Count Delta indicator with the 'reset when best price changes' active and how to interpret the plot when the reset best price is NOT checked. Just wanted a different perspective to interpreting the plot generated by this indicator. Thanks a lot for this, much appreciated.
Re: Demo strategies: QuotesDelta Indicator
Dear Serg
I worked with this indicator and have some confusion in calculation of bid, ask and Delta
I even add bid and ask lines to graph
Looks like bidDelta and Delta very alike in both scenarios - buyers dominate or sales dominate
Not sure how to insert screenshot to this msg
Best AG
I worked with this indicator and have some confusion in calculation of bid, ask and Delta
I even add bid and ask lines to graph
Looks like bidDelta and Delta very alike in both scenarios - buyers dominate or sales dominate
Not sure how to insert screenshot to this msg
Best AG