working ...
This commit is contained in:
@ -118,14 +118,31 @@ public class Chart extends javax.swing.JPanel implements QuoteReceiver {
|
||||
|
||||
|
||||
|
||||
protected OHLCDataItem getOhlcData(long first, long last, TreeSet quotes ){
|
||||
protected OHLCDataItem getOhlcData(long first, long last, SortedSet <Quote> quotes ){
|
||||
Quote e=new Quote();
|
||||
e.time=first;
|
||||
e.id=0;
|
||||
|
||||
Quote qq = quotes.first();
|
||||
System.out.print(String.format
|
||||
("Quote First %f %d %d \n", qq.price,qq.time,qq.id)
|
||||
);
|
||||
|
||||
SortedSet<Quote> l = quotes.tailSet(e);
|
||||
|
||||
System.out.print("Qzitesn"+quotes.size() +"\n");
|
||||
|
||||
|
||||
|
||||
|
||||
Quote z = new Quote();
|
||||
z.id=-1;
|
||||
z.time=0;
|
||||
|
||||
|
||||
SortedSet<Quote> l = quotes.tailSet(z);
|
||||
|
||||
System.exit(0);
|
||||
|
||||
double open=0;
|
||||
double high=0;
|
||||
double low=0;
|
||||
@ -169,11 +186,15 @@ public class Chart extends javax.swing.JPanel implements QuoteReceiver {
|
||||
protected OHLCDataItem[] getData() {
|
||||
List<OHLCDataItem> data = new ArrayList<>();
|
||||
|
||||
TreeSet <Quote>s = MainWin.se.getQuoteHistory(60);
|
||||
SortedSet <Quote>s = MainWin.se.getQuoteHistory(60);
|
||||
this.getOhlcData(0, System.currentTimeMillis(), s);
|
||||
|
||||
|
||||
|
||||
Iterator <Quote>i = s.iterator();
|
||||
|
||||
|
||||
this.getOhlcData(0, System.currentTimeMillis(), s);
|
||||
|
||||
|
||||
|
||||
// OHLCDataItem item = new OHLCDataItem();
|
||||
|
49
src/Gui/test.java
Normal file
49
src/Gui/test.java
Normal file
@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright (c) 2017, tobias
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package Gui;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author tobias
|
||||
*/
|
||||
public class test {
|
||||
public static void main(String args[]){
|
||||
SortedSet <String>s = new TreeSet<>();
|
||||
s.add("b");
|
||||
s.add("e");
|
||||
s.add("z");
|
||||
|
||||
SortedSet <String> ts = s.tailSet("d");
|
||||
|
||||
SortedSet <String> ts2 = ts.tailSet("n");
|
||||
|
||||
|
||||
System.out.print(String.format("First: %s\n", ts2.first()));
|
||||
}
|
||||
}
|
@ -27,13 +27,27 @@ public class Exchange extends Thread {
|
||||
|
||||
}
|
||||
|
||||
public TreeSet <Quote> getQuoteHistory(int seconds){
|
||||
public SortedSet <Quote> getQuoteHistory(int seconds){
|
||||
Quote last = quoteHistory.last();
|
||||
long ct = last.time - seconds * 1000;
|
||||
Quote e = new Quote();
|
||||
e.time=ct;
|
||||
e.time=-1;
|
||||
e.id=3;
|
||||
SortedSet <Quote> qqq =this.quoteHistory;
|
||||
|
||||
|
||||
SortedSet<Quote> l = quoteHistory.tailSet(e);
|
||||
return (TreeSet)l;
|
||||
e.id=-1;
|
||||
SortedSet<Quote> ll = l.tailSet(e);
|
||||
|
||||
int size = qqq.size();
|
||||
long fid = qqq.first().id;
|
||||
|
||||
System.out.print("SS0: "+qqq.first().id+"\n");
|
||||
|
||||
|
||||
return ll;
|
||||
|
||||
}
|
||||
|
||||
|
@ -61,9 +61,10 @@ public class Quote implements Comparable {
|
||||
int ret;
|
||||
Quote q = (Quote)o;
|
||||
|
||||
ret = (int)(this.time-q.time);
|
||||
/* ret = (int)(this.time-q.time);
|
||||
if (ret !=0)
|
||||
return ret;
|
||||
*/
|
||||
return (int)(this.id-q.id);
|
||||
}
|
||||
|
||||
|
@ -48,15 +48,15 @@ public class RandomTraderConfig extends TraderConfig {
|
||||
* the minimum and maximum volume to be selled
|
||||
*/
|
||||
public float[] sell_volume= {100,100};
|
||||
public float[] sell_limit = {-15,100};
|
||||
public int[] sell_order_wait = {5,33};
|
||||
public int[] wait_after_sell = {2,10};
|
||||
public float[] sell_limit = {-15,15};
|
||||
public int[] sell_order_wait = {15,33};
|
||||
public int[] wait_after_sell = {10,30};
|
||||
|
||||
|
||||
public float[] buy_volume={100,100};
|
||||
public float[] buy_limit = {-5,115};
|
||||
public float[] buy_limit = {-15,15};
|
||||
public int[] buy_order_wait = {15,33};
|
||||
public int[] wait_after_buy = {20,33};
|
||||
public int[] wait_after_buy = {10,30};
|
||||
|
||||
|
||||
@Override
|
||||
|
Reference in New Issue
Block a user