Skip to content

Commit

Permalink
Time Series endpoint impl (#76)
Browse files Browse the repository at this point in the history
* Time Series endpoint impl

* Update to version 3.3.1
  • Loading branch information
WojciechZankowski committed Nov 9, 2019
1 parent 311aa62 commit 0dee394
Show file tree
Hide file tree
Showing 24 changed files with 826 additions and 20 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
# Change Log
All notable changes to this project will be documented in this file.

## [3.3.1] - 2019-11-03

### Added

- Time Series endpoint (TimeSeriesRequestBuilder.class)

## [3.3.0] - 2019-10-26

### Added
Expand Down Expand Up @@ -338,3 +344,4 @@ All notable changes to this project will be documented in this file.
[3.2.7]: https://github.com/WojciechZankowski/iextrading4j/compare/IT4J_RELEASE_3_2_6...IT4J_RELEASE_3_2_7
[3.2.8]: https://github.com/WojciechZankowski/iextrading4j/compare/IT4J_RELEASE_3_2_7...IT4J_RELEASE_3_2_8
[3.3.0]: https://github.com/WojciechZankowski/iextrading4j/compare/IT4J_RELEASE_3_2_8...IT4J_RELEASE_3_3_0
[3.3.1]: https://github.com/WojciechZankowski/iextrading4j/compare/IT4J_RELEASE_3_3_0...IT4J_RELEASE_3_3_1
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,22 +29,22 @@ Maven:
<dependency>
<groupId>pl.zankowski</groupId>
<artifactId>iextrading4j-all</artifactId>
<version>3.3.0</version>
<version>3.3.1</version>
</dependency>
```

Gradle:

```
dependencies {
compile 'pl.zankowski:iextrading4j-all:3.3.0'
compile 'pl.zankowski:iextrading4j-all:3.3.1'
}
```

Library is up to:

* IEX Trading API version [1.24] - 09.11.2018
* IEX Cloud API version [1.0] - 26.10.2019
* IEX Cloud API version [1.0] - 03.11.2019

Supported versions: Java SE 8, Java SE 9, Java SE 10, Java SE 11, Java SE 12

Expand Down
2 changes: 1 addition & 1 deletion iextrading4j-acceptance/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>iextrading4j</artifactId>
<groupId>pl.zankowski</groupId>
<version>3.3.0</version>
<version>3.3.1</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@
import org.junit.Ignore;
import org.junit.Test;
import pl.zankowski.iextrading4j.api.datapoint.DataPoint;
import pl.zankowski.iextrading4j.api.datapoint.TimeSeriesMetadata;
import pl.zankowski.iextrading4j.client.rest.manager.RestRequest;
import pl.zankowski.iextrading4j.client.rest.request.datapoint.DataPointsRequestBuilder;
import pl.zankowski.iextrading4j.client.rest.request.datapoint.TimeSeriesRequestBuilder;

import java.util.List;
import java.util.Map;

import static org.assertj.core.api.Assertions.assertThat;

Expand All @@ -23,17 +26,35 @@ public void dataPointsTest() {
assertThat(dataPoints).isNotNull();
}

@Ignore // The requested data requires a Scale account and granted permission to access.
@Test
public void keyDataPointTest() {
final RestRequest<String> request = new DataPointsRequestBuilder()
.withSymbol("AAPL")
.withKey("QUOTE-CLOSE")
.withKey("EMPLOYEES")
.build();

final String response = cloudClient.executeRequest(request);

assertThat(response).isNotNull();
}

@Ignore // Obfuscated datetime object in sandbox, not possible to map it
@Test
public void timeSeriesTest() {
final List<TimeSeriesMetadata> result = cloudClient.executeRequest(new TimeSeriesRequestBuilder()
.build());

assertThat(result).isNotNull();
}

@Test
public void keyTimeSeriesTest() {
final List<Map<String, String>> result = cloudClient.executeRequest(new TimeSeriesRequestBuilder()
.withId("REPORTED_FINANCIALS")
.withKey("AAPL")
.withSubKey("10-Q")
.build());
assertThat(result).isNotNull();
}

}
2 changes: 1 addition & 1 deletion iextrading4j-all/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>iextrading4j</artifactId>
<groupId>pl.zankowski</groupId>
<version>3.3.0</version>
<version>3.3.1</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion iextrading4j-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>iextrading4j</artifactId>
<groupId>pl.zankowski</groupId>
<version>3.3.0</version>
<version>3.3.1</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package pl.zankowski.iextrading4j.api.datapoint;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import com.google.common.base.MoreObjects;
import com.google.common.base.Objects;

import java.io.Serializable;

@JsonPropertyOrder({"type"})
public class FieldMetadata implements Serializable {

private static final long serialVersionUID = -4105749852777766636L;

private final String type;

@JsonCreator
public FieldMetadata(
@JsonProperty("type") final String type) {
this.type = type;
}

public String getType() {
return type;
}

@Override
public boolean equals(final Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
final FieldMetadata that = (FieldMetadata) o;
return Objects.equal(type, that.type);
}

@Override
public int hashCode() {
return Objects.hashCode(type);
}

@Override
public String toString() {
return MoreObjects.toStringHelper(this)
.add("type", type)
.toString();
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
package pl.zankowski.iextrading4j.api.datapoint;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import com.google.common.base.MoreObjects;
import com.google.common.base.Objects;

import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;

@JsonPropertyOrder({"id", "description", "schema", "weightKey",
"weight", "created", "lastUpdated"})
public class TimeSeriesMetadata implements Serializable {

private static final long serialVersionUID = -6089147392234388332L;

private final String id;
private final String description;
private final TimeSeriesSchema schema;
private final String weightKey;
private final BigDecimal weight;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private final LocalDateTime created;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private final LocalDateTime lastUpdated;

@JsonCreator
public TimeSeriesMetadata(
@JsonProperty("id") final String id,
@JsonProperty("description") final String description,
@JsonProperty("schema") final TimeSeriesSchema schema,
@JsonProperty("weightKey") final String weightKey,
@JsonProperty("weight") final BigDecimal weight,
@JsonProperty("created") final LocalDateTime created,
@JsonProperty("lastUpdated") final LocalDateTime lastUpdated) {
this.id = id;
this.description = description;
this.schema = schema;
this.weightKey = weightKey;
this.weight = weight;
this.created = created;
this.lastUpdated = lastUpdated;
}

public String getId() {
return id;
}

public String getDescription() {
return description;
}

public TimeSeriesSchema getSchema() {
return schema;
}

public String getWeightKey() {
return weightKey;
}

public BigDecimal getWeight() {
return weight;
}

public LocalDateTime getCreated() {
return created;
}

public LocalDateTime getLastUpdated() {
return lastUpdated;
}

@Override
public boolean equals(final Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
final TimeSeriesMetadata that = (TimeSeriesMetadata) o;
return Objects.equal(id, that.id) &&
Objects.equal(description, that.description) &&
Objects.equal(schema, that.schema) &&
Objects.equal(weightKey, that.weightKey) &&
Objects.equal(weight, that.weight) &&
Objects.equal(created, that.created) &&
Objects.equal(lastUpdated, that.lastUpdated);
}

@Override
public int hashCode() {
return Objects.hashCode(id, description, schema, weightKey, weight, created, lastUpdated);
}

@Override
public String toString() {
return MoreObjects.toStringHelper(this)
.add("id", id)
.add("description", description)
.add("schema", schema)
.add("weightKey", weightKey)
.add("weight", weight)
.add("created", created)
.add("lastUpdated", lastUpdated)
.toString();
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
package pl.zankowski.iextrading4j.api.datapoint;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import com.google.common.base.MoreObjects;
import com.google.common.base.Objects;

import java.io.Serializable;
import java.util.List;
import java.util.Map;

import static pl.zankowski.iextrading4j.api.util.ListUtil.immutableList;
import static pl.zankowski.iextrading4j.api.util.MapUtil.immutableMap;

@JsonPropertyOrder({"type", "properties", "required", "additionalProperties"})
public class TimeSeriesSchema implements Serializable {

private static final long serialVersionUID = 925614403539934677L;

private final String type;
private final Map<String, FieldMetadata> properties;
private final List<String> required;
private final boolean additionalProperties;

@JsonCreator
public TimeSeriesSchema(
@JsonProperty("type") final String type,
@JsonProperty("properties") final Map<String, FieldMetadata> properties,
@JsonProperty("required") final List<String> required,
@JsonProperty("additionalProperties") final boolean additionalProperties) {
this.type = type;
this.properties = immutableMap(properties);
this.required = immutableList(required);
this.additionalProperties = additionalProperties;
}

public String getType() {
return type;
}

public Map<String, FieldMetadata> getProperties() {
return properties;
}

public List<String> getRequired() {
return required;
}

public boolean isAdditionalProperties() {
return additionalProperties;
}

@Override
public boolean equals(final Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
final TimeSeriesSchema that = (TimeSeriesSchema) o;
return additionalProperties == that.additionalProperties &&
Objects.equal(type, that.type) &&
Objects.equal(properties, that.properties) &&
Objects.equal(required, that.required);
}

@Override
public int hashCode() {
return Objects.hashCode(type, properties, required, additionalProperties);
}

@Override
public String toString() {
return MoreObjects.toStringHelper(this)
.add("type", type)
.add("properties", properties)
.add("required", required)
.add("additionalProperties", additionalProperties)
.toString();
}

}
Loading

0 comments on commit 0dee394

Please sign in to comment.