Skip to content

Masha/tinkoff-invest-haskell

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Haskell LISENCE

tinkoff-invest-haskell

Haskell gRPC based SDK for Tinkoff Invest API V2

Preparations

Project dependency

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

API Token

Tinkoff Invest API requires access token for comunications. There is instructions of generating personal token.

Examples

Unary queries

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"
    }

Stream queries

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

TODO

  • Cyrillic encoding support
  • More enhanced calculation monad
  • Trading stratagies

Contribution

Build project steps

  1. Install Stack tool
  2. Install ProtoBuff Compiller
  3. Run stack build from project root directory

Releases

No releases published

Packages

No packages published

Languages

  • Haskell 100.0%