Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #85 from ssoper/features/revamped-client
Simplify client creation
- Loading branch information
Showing
8 changed files
with
104 additions
and
44 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
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
group = "com.seansoper" | ||
version = "1.0.1" | ||
version = "1.0.2" | ||
|
||
/** | ||
* To publish | ||
|
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,44 @@ | ||
package com.seansoper.batil.brokers.etrade | ||
|
||
import com.seansoper.batil.brokers.etrade.auth.Authorization | ||
import com.seansoper.batil.brokers.etrade.auth.Session | ||
import com.seansoper.batil.brokers.etrade.services.Accounts | ||
import com.seansoper.batil.brokers.etrade.services.Alerts | ||
import com.seansoper.batil.brokers.etrade.services.Market | ||
import com.seansoper.batil.brokers.etrade.services.Orders | ||
|
||
// TODO: Replace verbose with logger interface | ||
|
||
class EtradeClient( | ||
val key: String, | ||
val secret: String, | ||
val username: String, | ||
val password: String, | ||
val endpoint: Endpoint, | ||
val verbose: Boolean = false | ||
) { | ||
|
||
enum class Endpoint(val url: String) { | ||
SANDBOX("https://apisb.etrade.com"), | ||
LIVE("https://api.etrade.com") | ||
} | ||
|
||
private val production = endpoint == Endpoint.LIVE | ||
|
||
private val authorization = Authorization( | ||
key = key, | ||
secret = secret, | ||
username = username, | ||
password = password, | ||
production = production, | ||
verbose = verbose, | ||
baseUrl = endpoint.url | ||
) | ||
|
||
private val session: Session = authorization.renewSession() ?: authorization.createSession() | ||
|
||
val accounts = Accounts(session, production = production, verbose = verbose) | ||
val market = Market(session, production = production, verbose = verbose) | ||
val alerts = Alerts(session, production = production, verbose = verbose) | ||
val orders = Orders(session, production = production, verbose = verbose) | ||
} |
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
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