RAPTOR v18.4: Исправлена отчетность, активированы выходные

This commit is contained in:
root
2026-04-18 23:26:45 +03:00
commit ef0958239e
312 changed files with 54247 additions and 0 deletions

View File

@@ -0,0 +1,40 @@
import asyncio
import os
from _decimal import Decimal
from t_tech.invest import utils
from t_tech.invest.sandbox.async_client import AsyncSandboxClient
from t_tech.invest.schemas import (
GetOrderPriceRequest,
GetOrderPriceResponse,
OrderDirection,
)
async def main():
token = os.environ["INVEST_TOKEN"]
async with AsyncSandboxClient(token) as client:
accounts = await client.users.get_accounts()
account_id = accounts.accounts[0].id
response = await get_async_order_price(client, account_id, 105)
print(utils.money_to_decimal(response.total_order_amount))
async def get_async_order_price(
sandbox_service, account_id, price
) -> GetOrderPriceResponse:
return await sandbox_service.sandbox.get_sandbox_order_price(
request=GetOrderPriceRequest(
account_id=account_id,
instrument_id="BBG004730ZJ9",
direction=OrderDirection.ORDER_DIRECTION_BUY,
quantity=1,
price=utils.decimal_to_quotation(Decimal(price)),
)
)
if __name__ == "__main__":
asyncio.run(main())

View File

@@ -0,0 +1,41 @@
import os
from t_tech.invest.sandbox.client import SandboxClient
from t_tech.invest.schemas import (
CancelStopOrderRequest,
CancelStopOrderResponse,
GetStopOrdersRequest,
StopOrderStatusOption,
)
def main():
token = os.environ["INVEST_TOKEN"]
with SandboxClient(token) as client:
accounts = client.users.get_accounts()
account_id = accounts.accounts[0].id
stop_orders = client.sandbox.get_sandbox_stop_orders(
request=GetStopOrdersRequest(
account_id=account_id,
status=StopOrderStatusOption.STOP_ORDER_STATUS_ACTIVE,
)
)
stop_order_id = stop_orders.stop_orders[0].stop_order_id
response = cancel_stop_order(client, account_id, stop_order_id)
print(f"Отменена отложенная заявка id={stop_order_id}: {response}")
def cancel_stop_order(
sandbox_service, account_id, stop_order_id
) -> CancelStopOrderResponse:
return sandbox_service.sandbox.cancel_sandbox_stop_order(
request=CancelStopOrderRequest(
account_id=account_id,
stop_order_id=stop_order_id,
)
)
if __name__ == "__main__":
main()

View File

@@ -0,0 +1,39 @@
import os
from _decimal import Decimal
from t_tech.invest import utils
from t_tech.invest.sandbox.client import SandboxClient
from t_tech.invest.schemas import (
GetOrderPriceRequest,
GetOrderPriceResponse,
OrderDirection,
)
def main():
token = os.environ["INVEST_TOKEN"]
with SandboxClient(token) as client:
accounts = client.users.get_accounts()
account_id = accounts.accounts[0].id
response = get_order_price(client, account_id, "BBG004730ZJ9", 105)
print(utils.money_to_decimal(response.total_order_amount))
def get_order_price(
sandbox_service, account_id, instrument_id, price
) -> GetOrderPriceResponse:
return sandbox_service.sandbox.get_sandbox_order_price(
request=GetOrderPriceRequest(
account_id=account_id,
instrument_id=instrument_id,
direction=OrderDirection.ORDER_DIRECTION_BUY,
quantity=1,
price=utils.decimal_to_quotation(Decimal(price)),
)
)
if __name__ == "__main__":
main()

View File

@@ -0,0 +1,36 @@
import os
from t_tech.invest.sandbox.client import SandboxClient
from t_tech.invest.schemas import (
GetStopOrdersRequest,
GetStopOrdersResponse,
StopOrderStatusOption,
)
def main():
token = os.environ["INVEST_TOKEN"]
with SandboxClient(token) as client:
accounts = client.users.get_accounts()
account_id = accounts.accounts[0].id
response = get_stop_orders(
client, account_id, StopOrderStatusOption.STOP_ORDER_STATUS_ACTIVE
)
if len(response.stop_orders) > 0:
print(response.stop_orders)
else:
print("Активных отложенных заявок не найдено")
def get_stop_orders(sandbox_service, account_id, status) -> GetStopOrdersResponse:
return sandbox_service.sandbox.get_sandbox_stop_orders(
request=GetStopOrdersRequest(
account_id=account_id,
status=status,
)
)
if __name__ == "__main__":
main()

View File

@@ -0,0 +1,58 @@
import os
import uuid
from _decimal import Decimal
from t_tech.invest import (
PostStopOrderRequest,
PostStopOrderRequestTrailingData,
PostStopOrderResponse,
StopOrderExpirationType,
StopOrderType,
)
from t_tech.invest.sandbox.client import SandboxClient
from t_tech.invest.schemas import Quotation, StopOrderDirection, TrailingValueType
from t_tech.invest.utils import decimal_to_quotation
def main():
token = os.environ["INVEST_TOKEN"]
with SandboxClient(token) as client:
accounts = client.users.get_accounts()
account_id = accounts.accounts[0].id
response = post_stop_order(
client,
account_id,
"BBG004730ZJ9",
stop_order_direction=StopOrderDirection.STOP_ORDER_DIRECTION_BUY,
quantity=1,
price=Quotation(units=10, nano=0),
)
print(response)
def post_stop_order(
sandbox_service, account_id, instrument_id, stop_order_direction, quantity, price
) -> PostStopOrderResponse:
return sandbox_service.sandbox.post_sandbox_stop_order(
request=PostStopOrderRequest(
account_id=account_id,
instrument_id=instrument_id,
direction=stop_order_direction,
quantity=quantity,
price=price,
order_id=str(uuid.uuid4()),
expiration_type=StopOrderExpirationType.STOP_ORDER_EXPIRATION_TYPE_GOOD_TILL_CANCEL,
stop_price=price,
stop_order_type=StopOrderType.STOP_ORDER_TYPE_TAKE_PROFIT,
trailing_data=PostStopOrderRequestTrailingData(
indent_type=TrailingValueType.TRAILING_VALUE_RELATIVE,
indent=decimal_to_quotation(Decimal(1)),
),
)
)
if __name__ == "__main__":
main()