-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Transaction and Instrument Subcommands (#3)
* Update Readme.md * Updated to get only refresh from code * cargo fmt and minor alignment tdameritradeclient * working on instruments subcommand * finished instrument and started transaction * finished adding transaction history
- Loading branch information
Showing
8 changed files
with
234 additions
and
76 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,12 +1,9 @@ | ||
[package] | ||
name = "tdacli" | ||
version = "0.2.1" | ||
version = "0.2.2" | ||
authors = ["Jas Bertovic <[email protected]>"] | ||
edition = "2018" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
#tdameritradeclient = { path = "../tdameritradeclient" } | ||
tdameritradeclient = { git = "https://github.com/jbertovic/tdameritradeclient.git", tag = "v0.2.1" } | ||
tdameritradeclient = { git = "https://github.com/jbertovic/tdameritradeclient.git", tag = "v0.2.2" } | ||
clap = "2.33" |
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,33 +1,66 @@ | ||
use clap::ArgMatches; | ||
use tdameritradeclient::{TDAClient, Account}; | ||
use tdameritradeclient::{Account, TDAClient, Transactions}; | ||
|
||
/// Grabs the userprincipals data from tdameritrade | ||
/// calls `tdameritradeclient::getuserprincipals()` | ||
pub fn userprincipals(c: &TDAClient) { | ||
let resp: String = c.getuserprincipals(); | ||
println!("{}", &resp); | ||
} | ||
|
||
/// Grabs the account information with options for Positions, Orders or both | ||
/// calls `tdameritradeclient::getaccount(account_id, Account param) | ||
pub fn account(c: &TDAClient, args: &ArgMatches) { | ||
match args.value_of("account_id") { | ||
Some(account) => { | ||
let resp: String; | ||
if args.is_present("positions")&&args.is_present("orders") { | ||
if args.is_present("positions") && args.is_present("orders") { | ||
resp = c.getaccount(&account, &[Account::PositionsAndOrders]); | ||
} | ||
else if args.is_present("positions") { | ||
} else if args.is_present("positions") { | ||
resp = c.getaccount(&account, &[Account::Positions]); | ||
} | ||
else if args.is_present("orders") { | ||
} else if args.is_present("orders") { | ||
resp = c.getaccount(&account, &[Account::Orders]); | ||
} | ||
else { | ||
} else { | ||
resp = c.getaccount(&account, &[]); | ||
} | ||
println!("{}", resp) | ||
} | ||
None => println!("{{ \"error\": \"Missing account_id\" }}"), | ||
} | ||
} | ||
/// Grabs transaction detail with options for date range, or one transaction id | ||
/// or restricted to symbol or type | ||
/// calls `tdameritradeclient::transactions(account_id, transaction param) | ||
/// or calls `tdameritradeclient::transaction(account_id, transaction_id) | ||
pub fn transaction(c: &TDAClient, args: &ArgMatches) { | ||
match args.value_of("account_id") { | ||
Some(account) => { | ||
let resp: String; | ||
// if transaction_id is supplied than just grab that transaction and | ||
// ignore all other options | ||
if args.is_present("trans_id") { | ||
resp = c.gettransaction(&account, args.value_of("trans_id").unwrap()); | ||
} else { | ||
let mut param: Vec<Transactions> = Vec::new(); | ||
if args.is_present("transaction_type") { | ||
param.push(Transactions::TransactionType( | ||
args.value_of("transaction_type").unwrap(), | ||
)); | ||
} | ||
if args.is_present("symbol") { | ||
param.push(Transactions::Symbol(args.value_of("symbol").unwrap())); | ||
} | ||
if args.is_present("start_date") { | ||
param.push(Transactions::StartDate( | ||
args.value_of("start_date").unwrap(), | ||
)); | ||
} | ||
if args.is_present("end_date") { | ||
param.push(Transactions::EndDate(args.value_of("end_date").unwrap())); | ||
} | ||
resp = c.gettransactions(&account, ¶m); | ||
} | ||
println!("{}", resp) | ||
} | ||
None => println!("{{ \"error\": \"Missing account_id\" }}"), | ||
} | ||
} |
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
Oops, something went wrong.