Skip to main content

Python client package for trading within BTG Solutions platform.

Project description

BTG Solutions Trade API package

BTG solutions trade api package.

Usage

Get your token and use it in the examples below.

Instantiate an order controller. Provide your token, account number, execution broker and entity to start sending orders. sampleInterval is optional

controller = OrderController(
    token="TOKEN",
    order_api_host="URL",
    account="YOUR_ACCOUNT_NUMBER",
    execBroker="YOUR_EXEC_BROKER",
    entity="YOUR_ENTITY",
    sampleInterval = None
)

One can provide a custom order update callback function.

def order_update_callback(order):
    print(f"Order update: {order}")

controller = OrderController(
    token=token,
    order_api_host="URL",
    account="YOUR_ACCOUNT_NUMBER",
    execBroker="YOUR_EXEC_BROKER",
    entity="YOUR_ENTITY",
    order_update_callback=order_update_callback,
    sampleInterval = 5
    )

Create an order and receive the resulting order ID.

orderId = controller.create_order(
    symbol="PETR4",
    side="S",
    qty="5000",
    price="20.41",
    timeInForce="Day",
    isDMA="true"
)

Create an order and receive the resulting order ID. This signature allow user to use different account, entity and broker of Controller session

orderId = controller.create_order(
    symbol="PETR4",
    side="S",
    qty="5000",
    price="20.41",
    timeInForce="Day",
    isDMA="true",
    account="ACCOUNT", 
    execBroker="NUMBER_OF_BROKER", 
    entity="ENTITY",
    memo = "memo"
)

Create an order using strategy and receive the resulting order ID. This signature allow user to use different account, entity and broker of Controller session

strategyParameter = { 
"max-floor": "100",    
"start-time": "20240614-19:00:00",
"end-time": "20240614-20:00:00"
}

orderId = controller.create_order(
    symbol="PETR4",
    side="S",
    qty="5000",
    price="20.41",
    timeInForce="Day",
    isDMA="true",
    account="ACCOUNT", 
    execBroker="NUMBER_OF_BROKER", 
    entity="ENTITY",
    strategy = "twap",
    strategyParameter = strategyParameter
)

Change order.

controller.change_order(
    id="YOUR_ORDER_ID",
    qty="5000",
    price="20.43",
    timeInForce="Day",
    ordType="Limit"
)

Cancel order.

controller.cancel_order(
    id="YOUR_ORDER_ID",
)

Cancel ALL order.

controller.cancel_all_orders()

Get Trades.

controller.get_trades()

Get Orders.

controller.get_orders()

Get Orders by Params. All params are optional

controller.get_orders(complete = True, symbol = "WEGE3", status = "New", side = "Sell", memo = "memo", parent = True)

Get Orders.

controller.get_order(
		id = "ORDER ID"
)

Get a summary of all your orders.

controller.summary()

Support

Get help at support@btgpactualsolutions.com

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

File details

Details for the file btgsolutions_tradeservices_python_client-0.1.12.tar.gz.

File metadata

File hashes

Hashes for btgsolutions_tradeservices_python_client-0.1.12.tar.gz
Algorithm Hash digest
SHA256 3cdf28c3f827ee6597aa8b8cbc53034fb4e08b4ead5ade8d5ec7a5a94200cb4d
MD5 5ea92ab3e7c379838cfc197da431c3d0
BLAKE2b-256 30ccfe90b150bfc3228b2ed07a06f34d24e3737d085a698644c8a847e16dc565

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page