ohls work
This commit is contained in:
parent
af6acdbab1
commit
b2680fa71d
@ -105,9 +105,12 @@ public class Chart extends javax.swing.JPanel implements QuoteReceiver {
|
||||
|
||||
}
|
||||
|
||||
|
||||
protected AbstractXYDataset getDataSet(String stockSymbol) {
|
||||
|
||||
//This is the dataset we are going to create
|
||||
DefaultOHLCDataset result = null;
|
||||
DefaultOHLCDataset result;
|
||||
|
||||
//This is the data needed for the dataset
|
||||
OHLCDataItem[] data;
|
||||
|
||||
@ -174,12 +177,18 @@ public class Chart extends javax.swing.JPanel implements QuoteReceiver {
|
||||
List<OHLCDataItem> data = new ArrayList<>();
|
||||
|
||||
long ct;
|
||||
ct = Exchange.getCurrentTimeSeconds(10);
|
||||
ct = Exchange.getCurrentTimeSeconds();
|
||||
|
||||
int step=5;
|
||||
long start = (ct - 60)/step*step;
|
||||
|
||||
SortedSet<Quote> h = MainWin.se.getQuoteHistory(ct - 60);
|
||||
|
||||
for (long i = (ct - 60) * 1000; i < (ct + 10) * 1000; i += 10 * 1000) {
|
||||
OHLCDataItem d = getOhlcData(i, i + 10 * 1000, h);
|
||||
SortedSet<Quote> h = MainWin.se.getQuoteHistory(start);
|
||||
|
||||
for (long i = start * 1000; i < ct * 1000; i += step * 1000) {
|
||||
OHLCDataItem d = getOhlcData(i, i + step * 1000, h);
|
||||
|
||||
|
||||
data.add(d);
|
||||
}
|
||||
|
||||
@ -258,12 +267,33 @@ public class Chart extends javax.swing.JPanel implements QuoteReceiver {
|
||||
|
||||
// q.print();
|
||||
long ct;
|
||||
ct = Exchange.getCurrentTimeSeconds(5);
|
||||
SortedSet<Quote> h = MainWin.se.getQuoteHistory(ct - 15);
|
||||
ct = Exchange.getCurrentTimeSeconds();
|
||||
|
||||
|
||||
OHLCDataItem[] data = this.getData();
|
||||
OHLCDataItem di=data[data.length-1];
|
||||
|
||||
System.out.print(
|
||||
String.format(
|
||||
"O:%.2f H:%.2f L:%.2f C:%.2f (%d)\n",
|
||||
|
||||
|
||||
di.getOpen(),
|
||||
di.getHigh(),
|
||||
di.getLow(),
|
||||
di.getClose(),
|
||||
data.length
|
||||
)
|
||||
|
||||
);
|
||||
|
||||
long start = (ct - 60)/5*5;
|
||||
SortedSet<Quote> h = MainWin.se.getQuoteHistory(start);
|
||||
|
||||
System.out.print("Number of quotes" + ct + "\n");
|
||||
|
||||
System.out.print("Number of quotes" + start + ":" + ct + "\n");
|
||||
System.out.print("Number of quotes:" + h.size() + "\n");
|
||||
|
||||
|
||||
|
||||
/* SortedSet h = MainWin.se.getQuoteHistory(60);
|
||||
System.out.print(
|
||||
|
@ -27,15 +27,16 @@ public class Exchange extends Thread {
|
||||
|
||||
}
|
||||
|
||||
public static long getCurrentTimeSeconds(long div) {
|
||||
long ct = System.currentTimeMillis() / (1000 * div) * div;
|
||||
return ct * div;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static long getCurrentTimeSeconds() {
|
||||
return getCurrentTimeSeconds(1);
|
||||
long ct = System.currentTimeMillis();
|
||||
return ct/1000 ;
|
||||
}
|
||||
|
||||
|
||||
public SortedSet<Quote> getQuoteHistory(long start) {
|
||||
|
||||
Quote s = new Quote();
|
||||
|
Loading…
Reference in New Issue
Block a user