-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c3d4be1
commit 3b5a39c
Showing
3 changed files
with
145 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Manifest-Version: 1.0 | ||
|
13 changes: 7 additions & 6 deletions
13
src/main/java/com/crazzyghost/alphavantage/exchangerate/ExchangeRate.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
import com.crazzyghost.alphavantage.AlphaVantage; | ||
import com.crazzyghost.alphavantage.Config; | ||
import com.crazzyghost.alphavantage.Fetcher; | ||
import com.crazzyghost.alphavantage.parameters.OutputSize; | ||
import com.crazzyghost.alphavantage.timeseries.response.TimeSeriesResponse; | ||
import org.junit.AfterClass; | ||
import org.junit.BeforeClass; | ||
import org.junit.Test; | ||
import static org.junit.Assert.*; | ||
|
||
import java.util.concurrent.CountDownLatch; | ||
import java.util.concurrent.TimeUnit; | ||
import java.util.concurrent.atomic.AtomicReference; | ||
|
||
|
||
public class TestTimeSeries { | ||
|
||
private CountDownLatch lock = new CountDownLatch(1); | ||
|
||
@BeforeClass | ||
public static void setUp(){ | ||
|
||
Config config = Config.builder() | ||
.key("M77PQNYAVBG0MB5N") | ||
.timeOut(10) | ||
.build(); | ||
|
||
AlphaVantage.api().init(config); | ||
|
||
} | ||
|
||
@AfterClass | ||
public static void tearDown(){ | ||
|
||
} | ||
|
||
@Test | ||
public void timeSeriesDaily() throws InterruptedException { | ||
|
||
AtomicReference<TimeSeriesResponse> response = new AtomicReference<>(); | ||
|
||
Fetcher.FailureCallback failureCallback = (e) -> lock.countDown(); | ||
|
||
Fetcher.SuccessCallback<TimeSeriesResponse> successCallback = (e) -> { | ||
lock.countDown(); | ||
response.set(e); | ||
}; | ||
|
||
AlphaVantage.api() | ||
.timeSeries() | ||
.daily() | ||
.forSymbol("GOOGL") | ||
.outputSize(OutputSize.COMPACT) | ||
.onFailure(failureCallback) | ||
.onSuccess(successCallback) | ||
.fetch(); | ||
|
||
lock.await(10, TimeUnit.SECONDS); | ||
assertNotNull(response.get()); | ||
} | ||
|
||
@Test | ||
public void timeSeriesDailyAdjusted() throws InterruptedException { | ||
|
||
AtomicReference<TimeSeriesResponse> response = new AtomicReference<>(); | ||
|
||
Fetcher.FailureCallback failureCallback = (e) -> lock.countDown(); | ||
|
||
Fetcher.SuccessCallback<TimeSeriesResponse> successCallback = (e) -> { | ||
lock.countDown(); | ||
response.set(e); | ||
}; | ||
|
||
AlphaVantage.api() | ||
.timeSeries() | ||
.daily() | ||
.adjusted() | ||
.forSymbol("GOOGL") | ||
.outputSize(OutputSize.COMPACT) | ||
.onFailure(failureCallback) | ||
.onSuccess(successCallback) | ||
.fetch(); | ||
|
||
lock.await(10, TimeUnit.SECONDS); | ||
assertNotNull(response.get()); | ||
} | ||
|
||
@Test | ||
public void timeSeriesWeekly() throws InterruptedException { | ||
|
||
AtomicReference<TimeSeriesResponse> response = new AtomicReference<>(); | ||
|
||
Fetcher.FailureCallback failureCallback = (e) -> lock.countDown(); | ||
|
||
Fetcher.SuccessCallback<TimeSeriesResponse> successCallback = (e) -> { | ||
lock.countDown(); | ||
response.set(e); | ||
}; | ||
|
||
AlphaVantage.api() | ||
.timeSeries() | ||
.weekly() | ||
.forSymbol("GOOGL") | ||
.onFailure(failureCallback) | ||
.onSuccess(successCallback) | ||
.fetch(); | ||
|
||
lock.await(10, TimeUnit.SECONDS); | ||
assertNotNull(response.get()); | ||
} | ||
|
||
@Test | ||
public void timeSeriesWeeklyAdjusted() throws InterruptedException { | ||
|
||
AtomicReference<TimeSeriesResponse> response = new AtomicReference<>(); | ||
|
||
Fetcher.FailureCallback failureCallback = (e) -> lock.countDown(); | ||
|
||
Fetcher.SuccessCallback<TimeSeriesResponse> successCallback = (e) -> { | ||
lock.countDown(); | ||
response.set(e); | ||
}; | ||
|
||
AlphaVantage.api() | ||
.timeSeries() | ||
.weekly() | ||
.adjusted() | ||
.forSymbol("GOOGL") | ||
.onFailure(failureCallback) | ||
.onSuccess(successCallback) | ||
.fetch(); | ||
|
||
lock.await(10, TimeUnit.SECONDS); | ||
assertNotNull(response.get()); | ||
} | ||
} |