Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
wiseplat
GitHub Repository: wiseplat/python-code
Path: blob/master/ invest-robot-contest_trading_bot-master/trading/add_money_sandbox.py
5932 views
1
from tinkoff.invest import Client
2
from trading.trade_help import to_quotation
3
from config.personal_data import get_token, get_account
4
from tinkoff.invest import MoneyValue
5
6
7
def add_money_sandbox(user_id, sum, currency, account_id=""):
8
with Client(get_token(user_id)) as client:
9
10
if account_id == "":
11
account_id = get_account(user_id=user_id)
12
13
units = to_quotation(float(sum)).units
14
nano = to_quotation(float(sum)).nano
15
16
pay_in = client.sandbox.sandbox_pay_in(
17
account_id=account_id,
18
amount=MoneyValue(units=units, nano=nano, currency=f"{currency}")
19
)
20
21
return pay_in
22
23