TKSBrokerAPI is the trading platform for automation and simplifying the implementation of trading scenarios, as well as working with Tinkoff Invest API server via the REST protocol. The TKSBrokerAPI platform may be used in two ways: from the console, it has a rich keys and commands, or you can use it as Python module.
CalculateLotsForDeal() method calculates maximum lots for deal depends on current price and volume of instrument in one lot.
Formula: lots = maxCost // (currentPrice * volumeInLot), it means max count of lots, for which will be:
cost = lots * currentPrice * volumeInLot <= maxCost.
If costOneLot = currentPrice * volumeInLot > maxCost, then returned lots = 1.
If an error occurred then returned lots = 0.
This method can be used when you need to calculate lots to open position.
CalculateLotsForDeal()
method calculates maximum lots for deal depends on current price and volume of instrument in one lot.Formula:
lots = maxCost // (currentPrice * volumeInLot)
, it means max count of lots, for which will be:cost = lots * currentPrice * volumeInLot <= maxCost
.If
costOneLot = currentPrice * volumeInLot > maxCost
, then returnedlots = 1
.If an error occurred then returned
lots = 0
.This method can be used when you need to calculate lots to open position.