DO NOT use for production
```rust use tinkoff_invest::TinkoffInvest;
async fn main() -> Result<(), Box
let mut tinkoff = TinkoffInvest::new(token.into())?;
let accounts = tinkoff.accounts().await?;
println!("accounts: {:?}", accounts);
Ok(())
} ```
```rust use tinkoff_invest::{enums::MarketInstrumentKind, TinkoffInvest};
async fn main() -> Result<(), Box
let mut tinkoff = TinkoffInvest::new(token.into())?;
let market_instruments = tinkoff
.market_instruments(MarketInstrumentKind::Share)
.await?;
println!("{:?}", market_instruments);
Ok(())
} ```
```rust use tinkoff_invest::{enums::CandlestickInterval, extra::chrono, types::Figi, TinkoffInvest};
async fn main() -> Result<(), Box
let mut tinkoff = TinkoffInvest::new(token.into())?;
let figi = Figi::from("BBG004730N88");
let from = chrono::NaiveDate::from_ymd(2020, 1, 10);
let to = chrono::NaiveDate::from_ymd(2020, 1, 11);
let candlesticks = tinkoff
.candlesticks(&figi, CandlestickInterval::Min, from.into(), to.into())
.await?;
println!("{:?}", candlesticks);
Ok(())
} ```
```rust use tinkoff_invest::{types::Figi, TinkoffInvest};
async fn main() -> Result<(), Box
let mut tinkoff = TinkoffInvest::new(token.into())?;
let figi = Figi::from("BBG004730N88");
let order_book = tinkoff.order_book(&figi, 10).await?;
println!("{:?}", order_book);
Ok(())
} ```
```rust use tinkoff_invest::{enums::OperationState, extra::chrono, types::Figi, TinkoffInvest};
async fn main() -> Result<(), Box
let mut tinkoff = TinkoffInvest::new(token.into())?;
let accounts = tinkoff.accounts().await?;
let first_account = accounts.get(0).unwrap().clone();
tinkoff.set_account(Some(first_account));
let figi = Figi::from("BBG004730N88");
let from = chrono::NaiveDate::from_ymd(2020, 1, 1);
let to = chrono::NaiveDate::from_ymd(2023, 1, 1);
let operations = tinkoff
.operations(&figi, OperationState::Unspecified, from.into(), to.into())
.await?;
println!("{:?}", operations);
Ok(())
} ```
```rust use tinkoff_invest::TinkoffInvest;
async fn main() -> Result<(), Box
let mut tinkoff = TinkoffInvest::new(token.into())?;
let accounts = tinkoff.accounts().await?;
let first_account = accounts.get(0).unwrap().clone();
tinkoff.set_account(Some(first_account));
let portfolio = tinkoff.portfolio().await?;
println!("{:?}", portfolio);
Ok(())
} ```
```rust use tinkoff_invest::{ enums::{ClassCode, MarketInstrumentKind}, types::{Figi, Ticker}, CachedMarketInstruments, TinkoffInvest, };
async fn main() -> Result<(), Box
let mut tinkoff = TinkoffInvest::new(token.into())?;
let market_instruments = tinkoff
.market_instruments(MarketInstrumentKind::Share)
.await?;
let cached_market_instruments = CachedMarketInstruments::from(market_instruments);
// find by figi
{
let figi = Figi::from("BBG004730N88");
let market_instrument = cached_market_instruments.by_figi(&figi).unwrap();
println!("{:?}", market_instrument);
}
// find by class code and ticker
{
let class_code_ticker = (ClassCode::TQBR, Ticker::from("SBER"));
let market_instrument = cached_market_instruments
.by_class_code_and_ticker(&class_code_ticker)
.unwrap();
println!("{:?}", market_instrument);
}
// find by ticker
{
let ticker = Ticker::from("SBER");
let market_instrument = cached_market_instruments.by_ticker(&ticker).unwrap();
println!("{:?}", market_instrument);
}
Ok(())
} ```