Haskell gRPC based SDK for Tinkoff Invest API V2
The library is distributed via Hackage module. To use this SDK in your project you should add folowing line to dependencies block of package.yaml
dependencies:
- tinkoff-invest-sdk
Tinkoff Invest API requires access token for comunications. There is instructions of generating personal token.
getBaseShares :: GrpcClient -> GrpcIO [Share]
getBaseShares gc = shares gc (defMessage & I.instrumentStatus .~ INSTRUMENT_STATUS_BASE)
main :: IO ()
main = void . runExceptT $ initClient <#> getBaseShares #> (liftIO . print)
where initClient = initGrpcClient $ ClientConfig {
token = "your_token",
appName = Just "your_app_name"
}
main :: IO ()
main = do
let config = ClientConfig { token = "your_token", appName = Just "your_app_name" }
client <- runClient config
stream <- marketDataStream client
subscribeOrderBook stream "BBG004730RP0" 10 \resp -> case resp ^. MD.maybe'payload of
Just (MarketDataResponse'SubscribeOrderBookResponse r) -> logResponse r >> pure Next
Just (MarketDataResponse'Orderbook r) -> logResponse r >> pure Next
_ -> pure Break
wait stream
See more examples here
- Cyrillic encoding support
- More enhanced calculation monad
- Trading stratagies
- Install Stack tool
- Install ProtoBuff Compiller
- Run
stack build
from project root directory