Skip to content

Commit

Permalink
Downgraded to Java17 for compatibility
Browse files Browse the repository at this point in the history
Rerouted new GlowLib utils. Specifically TimeUtil
  • Loading branch information
evanobenauer committed Jan 13, 2024
1 parent 21f58a6 commit 8f11ad0
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 42 deletions.
6 changes: 3 additions & 3 deletions jitpack.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
jdk:
- openjdk18
- openjdk17

before_install:
- sdk install java 18.0.2-open
- sdk use java 18.0.2-open
- sdk install java 17.0.2-open
- sdk use java 17.0.2-open
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.ejo.glowlib.setting.Container;
import com.ejo.glowlib.time.DateTime;
import com.ejo.glowlib.time.StopWatch;
import com.ejo.glowlib.util.TimeUtil;
import com.ejo.stockdownloader.util.DownloadStockUtil;
import com.ejo.stockdownloader.util.DownloadTimeFrame;

Expand Down Expand Up @@ -78,7 +79,7 @@ public LiveDownloadStock(String ticker, DownloadTimeFrame timeFrame, boolean ext
*/
public void updateLiveData(double liveDelayS, boolean includePriceUpdate) {
//Updates the progress bar of each segmentation
if (DownloadStockUtil.isPriceActive(isExtendedHours(), DownloadStockUtil.getAdjustedCurrentTime())) updateClosePercent();
if (DownloadStockUtil.isPriceActive(isExtendedHours(), TimeUtil.getAdjustedCurrentTime())) updateClosePercent();

//Check if the stock should update. If not, don't run the method
if (!shouldUpdate()) return;
Expand Down Expand Up @@ -146,7 +147,7 @@ public void updateLivePrice(double liveDelayS) {
*/
private void updateOpen() {
this.doOpen.run(() -> {
this.openTime = DownloadStockUtil.getAdjustedCurrentTime();
this.openTime = TimeUtil.getAdjustedCurrentTime();
setAllData(getPrice());
});
}
Expand All @@ -161,7 +162,7 @@ private void updateClose() {
return;
}
this.doClose.run(() -> {
DateTime ct = DownloadStockUtil.getAdjustedCurrentTime();
DateTime ct = TimeUtil.getAdjustedCurrentTime();
//Save Live Data as Historical [Data is stored as (DATETIME,OPEN,CLOSE,MIN,MAX)]
float[] timeFrameData = {getOpen(), getPrice(), getMin(), getMax()};
DateTime openTime = new DateTime(ct.getYear(), ct.getMonth(), ct.getDay(), ct.getHour(), ct.getMinute(), ct.getSecond() - getTimeFrame().getSeconds());
Expand All @@ -187,7 +188,7 @@ private void updateMinMax() {
* Updates the percentage complete for the current stock candle
*/
private void updateClosePercent() {
DateTime ct = DownloadStockUtil.getAdjustedCurrentTime();
DateTime ct = TimeUtil.getAdjustedCurrentTime();
double totalPercent = 0;

//Second Percent
Expand Down Expand Up @@ -277,7 +278,7 @@ public boolean shouldUpdate() {
if (!this.shouldStartUpdates) return false;

//Only allows for data collection during trading hours
return DownloadStockUtil.isPriceActive(isExtendedHours(), DownloadStockUtil.getAdjustedCurrentTime());
return DownloadStockUtil.isPriceActive(isExtendedHours(), TimeUtil.getAdjustedCurrentTime());
}

/**
Expand All @@ -286,7 +287,7 @@ public boolean shouldUpdate() {
* @return
*/
public boolean shouldClose() {
DateTime ct = DownloadStockUtil.getAdjustedCurrentTime();
DateTime ct = TimeUtil.getAdjustedCurrentTime();
return switch (getTimeFrame()) {
case ONE_SECOND -> true;
case FIVE_SECONDS -> ct.getSecond() % 5 == 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
import com.ejo.glowlib.file.FileManager;
import com.ejo.glowlib.setting.Container;
import com.ejo.glowlib.time.DateTime;
import com.ejo.glowlib.util.TimeUtil;
import com.ejo.stockdownloader.util.DownloadStockUtil;
import com.ejo.stockdownloader.util.DownloadTimeFrame;
import com.ejo.stockdownloader.util.TimeUtil;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.CloseableHttpClient;
Expand Down Expand Up @@ -145,7 +145,7 @@ public void download(int startYear, int startMonth, int endYear, int endMonth) {
}

public void downloadAll() {
download(2000, 1, DownloadStockUtil.getAdjustedCurrentTime().getYear(), DownloadStockUtil.getAdjustedCurrentTime().getMonth());
download(2000, 1, TimeUtil.getAdjustedCurrentTime().getYear(), TimeUtil.getAdjustedCurrentTime().getMonth());
}

public static void formatStockCSV(String directory, String name) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.ejo.glowlib.misc.ColorE;
import com.ejo.glowlib.setting.Container;
import com.ejo.glowlib.time.StopWatch;
import com.ejo.glowlib.util.TimeUtil;
import com.ejo.glowui.scene.Scene;
import com.ejo.glowui.scene.elements.ProgressBarUI;
import com.ejo.glowui.scene.elements.SideBarUI;
Expand Down Expand Up @@ -58,8 +59,8 @@ public LiveDownloadScene(LiveDownloadStock stock) {
barBottomBar = new SideBarUI(SideBarUI.Type.BOTTOM, 60,true,new ColorE(25, 25, 25, 255),
progressBarCandlePercent = new ProgressBarUI<>(new Vector(10,22), new Vector(200, 20), ColorE.BLUE, stock.getClosePercent(), 0, 1),
sliderPriceScale = new SliderUI<>("Scale", Vector.NULL, new Vector(200, 22), ColorE.BLUE, priceScale, 1d, 2000d, 10d, SliderUI.Type.FLOAT, true),
sliderSecAdjust = new SliderUI<>("Seconds", new Vector(145, 8), new Vector(65, 10), ColorE.BLUE, DownloadStockUtil.SECOND_ADJUST, -10, 10, 1, SliderUI.Type.INTEGER, true),
textDateTime = new TextUI(String.valueOf(DownloadStockUtil.getAdjustedCurrentTime()),new Font("Arial",Font.PLAIN,14), progressBarCandlePercent.getPos().getAdded(0,-18),ColorE.WHITE))
sliderSecAdjust = new SliderUI<>("Seconds", new Vector(145, 8), new Vector(65, 10), ColorE.BLUE, TimeUtil.SECOND_ADJUST, -10, 10, 1, SliderUI.Type.INTEGER, true),
textDateTime = new TextUI(String.valueOf(TimeUtil.getAdjustedCurrentTime()),new Font("Arial",Font.PLAIN,14), progressBarCandlePercent.getPos().getAdded(0,-18),ColorE.WHITE))
);
}

Expand All @@ -75,7 +76,7 @@ public void draw() {
double focusY = getSize().getY() / 2;
double focusPrice = stock.getPrice();
Vector candleScale = new Vector(1, priceScale.get());
DownloadDrawUtil.drawDownloadCandles(this,stock, DownloadStockUtil.getAdjustedCurrentTime(),focusPrice,focusY,candleSpace,candleWidth,candleScale);
DownloadDrawUtil.drawDownloadCandles(this,stock, TimeUtil.getAdjustedCurrentTime(),focusPrice,focusY,candleSpace,candleWidth,candleScale);

double linePriceBoxHeight = 15;

Expand Down Expand Up @@ -119,7 +120,7 @@ public void tick() {
sliderPriceScale.setPos(new Vector(getSize().getX() - sliderPriceScale.getSize().getX() - 10, 20));

//Update Current Time Text
textDateTime.setText(String.valueOf(DownloadStockUtil.getAdjustedCurrentTime()));
textDateTime.setText(String.valueOf(TimeUtil.getAdjustedCurrentTime()));

//Update all stock data (Have this be either .5s or 1s depending on how often the internet can handle)
stock.updateLiveData(1,true);
Expand All @@ -135,7 +136,7 @@ public void tick() {
}

//Forces the program to run at 2fps even in economic mode
if (DownloadStockUtil.isPriceActive(stock.isExtendedHours(), DownloadStockUtil.getAdjustedCurrentTime())) {
if (DownloadStockUtil.isPriceActive(stock.isExtendedHours(), TimeUtil.getAdjustedCurrentTime())) {
stopWatchForceFrame.start();
if (stopWatchForceFrame.hasTimePassedS(.5)) {
UIUtil.forceEconRenderFrame();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.ejo.glowlib.math.Vector;
import com.ejo.glowlib.misc.ColorE;
import com.ejo.glowlib.time.DateTime;
import com.ejo.glowlib.util.TimeUtil;
import com.ejo.glowui.scene.Scene;
import com.ejo.glowui.util.render.QuickDraw;
import com.ejo.stockdownloader.data.LiveDownloadStock;
Expand All @@ -20,7 +21,7 @@ public static void drawDownloadCandles(Scene scene, LiveDownloadStock stock, Dat
//Define Candle List
ArrayList<LiveDownloadCandle> listCandle = new ArrayList<>();

DateTime openTime = endTime.equals(DownloadStockUtil.getAdjustedCurrentTime()) ? stock.getOpenTime() : endTime;
DateTime openTime = endTime.equals(TimeUtil.getAdjustedCurrentTime()) ? stock.getOpenTime() : endTime;

//Create Historical Candles
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@

public class DownloadStockUtil {

@Deprecated
public static final Container<Integer> SECOND_ADJUST = new Container<>(0);

private static final String WEB_USER_AGENT = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36";

public static float getWebScrapePrice(String url, String attributeKey, String attributeValue, int priceIndex) throws IOException {
Expand Down Expand Up @@ -54,10 +51,4 @@ public static boolean isPriceActive(boolean extendedHours, DateTime currentTime)
return isTradingHours(currentTime);
}

@Deprecated
public static DateTime getAdjustedCurrentTime() {
DateTime ct = DateTime.getCurrentDateTime();
return new DateTime(ct.getYear(), ct.getMonth(), ct.getDay(), ct.getHour(), ct.getMinute(), ct.getSecond() + SECOND_ADJUST.get());
}

}
16 changes: 0 additions & 16 deletions src/main/java/com/ejo/stockdownloader/util/TimeUtil.java

This file was deleted.

0 comments on commit 8f11ad0

Please sign in to comment.