Petersoj / alpaca-java

A Java API for Alpaca, the commission free, algo friendly, stock trading broker. https://alpaca.markets
https://petersoj.github.io/alpaca-java/
MIT License
198 stars 84 forks source link

account activities #53

Closed cloudygeek closed 4 years ago

cloudygeek commented 4 years ago

adding support for payment transfers (TRANS,CSR,CSD) on account activities currently they don't match the JSON POJO for any payments in or out as they don't match in doesGsonPOJOMatch

Petersoj commented 4 years ago

Hey nice catch! I think we should fix the underlying doesGsonPOJOMatch method instead of adding a new JSON POJO object though. All the JSON POJO files inside schema_json are meant to be directly associated with the JSON entities outlined in the Alpaca and Polygon docs (only with a few exceptions, and this PR could be one of them, but this problem can likely be fixed). By changing the doesGsonPOJOMatch method to compare the passed in JsonObject with the passed in jsonPOJOClass (to see if all the fields in the JsonObject simply exist in the jsonPOJOClass) and NOT by comparing the passed in jsonPOJOClass with the JsonObject (which is the way it currently is). This allows a JsonObject with a smaller number of fields than the jsonPOJOClass (like the payment transfer (TRANS,CSR,CSD) activities) to still return true for this method and be deserialized properly because the Gson instance is set to be lenient. @actainvestments Thoughts?

cloudygeek commented 4 years ago

yep I thought about doing it that way, but figured as you already bifurcated on two why not three! I'll have a look.