### Power.Trade WebSocket API documents
See here for WS API documents
See here for an explanation of the WS API authentication process @ power.trade.
-
Balance and Position data
See here for power.trade API docs on balances & positions
-
Single Leg Orders/RFQs (streaming quotes)
See here for power.trade API docs on streaming data.
The WS message format can be found at new order order deleted order executed order update
-
Multi Leg orders/RFQs (streaming quotes)
See here for power.trade API docs on streaming data.
The WS message format for multi-leg orders can be found at: new order order deleted order executed order updated
See this page for sample data feed requests
-
Download code from this repo
-
Cd to the folder containing the code downloaded from repo
-
Run 'build' command:
cargo build
to update linked libraries and compile code. The version built by default is 'dev'
-
To build the 'release' version which is more optimized reduced in size run this command
cargo build --release
-
Before running the code configuration should be added to files (one per env)
=> Running app on Test env requires env file in root folder named ".env.test". Can be created by copying "env.example" sample file and renaming to ".env.test" to setup test env
``` cp .env.example .env.test ``` Once the env file is created add values for: * Api Key * Api Secret * WS Server address & port API key to be used must be one of the Read-Only ones issued under '' dropdown for API type. See example of UI fopr generating API Key below with correct settings for the WS Balance/Position API
=> Running app on Prod env requires a .env file in root folder named ".env.prod". This file can be created by copying "env.example" sample file and and renaming to ".env.prod"
``` cp .env.example .env.prod ``` Once the env file is created add values for: * Api Key * Api Secret * WS Server address & port
-
Run the code by this command "cargo run --ENV" where ENV is either 'test' or 'production'
cargo run -- --env test
or
cargo run -- --env production
-
Some debug messages are printed at console, but most are copied to a logging file named "app.log" which is located in the root folder.
-
App runs for XX cycles as it runs a loop sleeping and checking messages.
Change the 'PT_EPOCH_COUNT' environment value in .env files to make the app run longer or shorter duration. The loop is to be replaced by event-driven code shortly. Check this repo for changes
- Step 8 above can be replaced by running the generated binary which will be copied to the "target" folder under project root/home folder.
There will be a "debug" folder generated by running "cargo build" command and a "release" folder created when "cargo build --release" command is run
To run "debug" version execute command
./target/debug/client-rust-ws --env test
in the project root/home folder. The environment can be changed to "production" also as follows
./target/debug/client-rust-ws --env production
To run "release" version: execute command "./target/release/client-rust-ws --env test" in project root/home folder. The environment can be changed to "production" also
n.b. to view command line options e.g. available settings for environment ("--env") flag run the command without any settings ("./target/debug/client-rust-ws") or with no value added for environment flag ("./target/debug/client-rust-ws --env")
- Running the Rust WS Client against various power.trade endpoints
The rust client can be configured to listen for any of the three content types below by setting the ennviroment variables named "PT_SERVER" to the URLs below in the relevant configurwtion file for test (".env.test") or production (".env.prod").
N.B. Current Rust client only supports one of the three content types per installed Rust code (under /target/release/ folder). Listening for more than one set of content from list below requires multiple copies of the Rust runtime files and a custom configuration per instance.
see here for power.trade API docs on balance and position data available from the following test & production API endpoints
see here for details on power.trade's balance & positions response message
Env | Link | Notes |
---|---|---|
Test | wss://api.wss.test.power.trade/v1/position_summary | both balances & positions returned in one response |
Production | wss://api.wss.prod.power.trade/v1/position_summary | both balances & positions returned in one response |
n.b. to customize or filter the data feed content see parameters documented at this page
Env | Link | Notes |
---|---|---|
Test | wss://api.wss.test.power.trade/v1/feeds/?type[]=mbp_snapshot&tradeable_type[]=all_single_leg&mbp_period=1&mbo_period=0 | link returns all tradeable types with full price book snapshot sent but no order book snapshot |
Production | wss://api.wss.prod.power.trade/v1/feeds/?type[]=mbp_snapshot&tradeable_type[]=all_single_leg&mbp_period=1&mbo_period=0 | link returns all tradeable types with full price book snapshot sent but no order book snapshot |
n.b. to customize or filter the data feed content see parameters documented at this page
Env | Link | Notes |
---|---|---|
Test | wss://api.wss.test.power.trade/v1/feeds/multi_leg?type[]=all_multi_leg,multi_leg_mbp_snapshot&mbp_period=1&mbo_period=0" | all multi-leg showing price book snapshot but not order book snapshot. add "market_id[]=none" to retireve RFQs |
Production | wss://api.wss.prod.power.trade/v1/feeds/multi_leg?type[]=all_multi_leg,multi_leg_mbp_snapshot&mbp_period=1&mbo_period=0" | all multi-leg showing price book snapshot but not order book snapshot. add "market_id[]=none" to retireve RFQs |