Skip to content

galimru/tinkoff-invest-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

18 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿš€ tinkoff-invest-api

Build Status Gitter License

Tinkoff Invest client written on Java.


Installation

Import the library to your project using jitpack repository

Gradle

  1. Add the JitPack repository to your build file
repositories {
    ...
    maven { url 'https://jitpack.io' }
}
  1. Add the tinkoff-invest-api library dependency
implementation 'com.github.galimru:tinkoff-invest-api:1.1.5'

Note: The JitPack supports both Gradle/Maven build tools, please refer to jitpack documentation if you want use Maven

Dead simple example

        // create api client for sandbox environment
        TinkoffInvestClient client = TinkoffInvestClient.create(TestConstants.TOKEN, true);
        // register new sandbox broker account
        client.sandbox()
                .register(BrokerAccountType.TINKOFF);
        // set broker account balance to $1000.55
        client.sandbox()
                .setCurrencyBalance(Currency.USD, BigDecimal.valueOf(1000.55));
        // search figi by ticker TSLA (Tesla)
        MarketInstrumentList resultList = client.market()
                .searchByTicker("TSLA");
        String figi = resultList.getInstruments().get(0).getFigi();
        // buy 1 lot of Tesla using market order
        client.orders()
                .place(MarketOrder
                        .buy(figi)
                        .quantity(1));
        // sell 1 lot of Tesla using limit order
        client.orders()
                .place(LimitOrder
                        .sell(figi)
                        .quantity(1)
                        .price(BigDecimal.valueOf(800.45)));
        // add streaming listener for candle events
        client.streaming()
                .addCandleListener(event ->
                        System.out.println("High: " + event.getHigh()));
        // subscribe on candle events for TSLA
        client.streaming()
                .subscribe(CandleSubscription
                        .on(figi)
                        .withInterval(CandleResolution.FIVE_MINUTES));
        // clear all sandbox accounts
        client.sandbox()
                .clear();

License

Apache License 2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Links

OpenAPI Documentation

Swagger API

Official OpenAPI Java SDK