422 lines
13 KiB
Protocol Buffer
422 lines
13 KiB
Protocol Buffer
syntax="proto3";
|
|
package bts.api.account;
|
|
option csharp_namespace="bts.api.account";
|
|
import "lib/api/apioptions.proto";
|
|
import "lib/api/apicore.proto";
|
|
import "lib/api/services/UserService.proto";
|
|
//import "google/protobuf/timestamp.proto";
|
|
import "lib/domain_model/Security.proto";
|
|
|
|
/************************************************************************/
|
|
/********************************Gen (temp)******************************/
|
|
/************************************************************************/
|
|
|
|
message NullableID{
|
|
int32 id = 10;
|
|
}
|
|
|
|
message SecurityResolution{
|
|
// TODO, exchange needs be to abstracted out better
|
|
api.Venue exchange = 10;
|
|
api.SecurityType security_type = 20;
|
|
string security_symbol = 30;
|
|
NullableID security_id = 40;
|
|
}
|
|
|
|
/************************************************************************/
|
|
/*******************************Full Data********************************/
|
|
/************************************************************************/
|
|
|
|
message BTSUserModelData{
|
|
int32 id = 1 [(bts.api.key)=true];
|
|
repeated BTSUserGroup user_groups = 10;
|
|
repeated BTSUser users = 20;
|
|
repeated BTSAccount accounts = 30;
|
|
repeated ExchangeConnection connections = 40;
|
|
}
|
|
|
|
/************************************************************************/
|
|
/********************************BTS User********************************/
|
|
/************************************************************************/
|
|
|
|
message BTSUserGroup{
|
|
int32 id = 10;
|
|
// null for top level groups
|
|
NullableID parent_group_id = 20;
|
|
string name = 30;
|
|
BTSUserDerivableData user_data = 40;
|
|
}
|
|
|
|
message BTSUser{
|
|
int32 id = 10;
|
|
int32 parent_group_id = 20;
|
|
string name = 30;
|
|
string password = 40;
|
|
bool is_active = 50;
|
|
LicenseData license_data = 60;
|
|
LicenseEntitlements license_entitlements = 70;
|
|
BTSUserDerivableData user_data = 80;
|
|
}
|
|
|
|
message BTSUserDerivableData{
|
|
// this is the user, account association. all accounts
|
|
// that the user is interested in are here. what the
|
|
// user can do to the account is in UserPermissions
|
|
// (for example whether a user can trade into an account
|
|
// or not, or can the user administer an account)
|
|
|
|
// if account_permission_map is null, its derived
|
|
// from the parent group
|
|
map<int32, UserPermissions> account_permission_map = 70;
|
|
// absent of internal data in this means it has to be
|
|
// resolved from the parent group
|
|
ExchangeUserData exchange_user_data = 80;
|
|
ExchangeUserMarketDataEntitlementData exchange_md_entitlement_data = 90;
|
|
}
|
|
|
|
message UserAccountPermission{
|
|
bool is_derived = 10;
|
|
map<int32, UserPermissions> account_permission_map = 20;
|
|
}
|
|
|
|
message LicenseData{
|
|
int64 create_date = 10;
|
|
int64 renew_date = 20;
|
|
int64 expiry_date = 30;
|
|
}
|
|
|
|
message LicenseEntitlements{
|
|
bool client_side_api = 10;
|
|
bool server_side_api = 20;
|
|
bool spreader = 30;
|
|
}
|
|
|
|
// this is the functionality permissions
|
|
message UserPermissions{
|
|
message TradingPermissions{
|
|
bool submit_market_orders = 10;
|
|
bool submit_gtc_orders = 20;
|
|
bool submit_spreader_orders = 30;
|
|
message AlgoOrderPermissions{
|
|
bool submit_iceberg_orders = 10;
|
|
bool submit_time_box_orders = 20;
|
|
}
|
|
}
|
|
message AdminPersmission{
|
|
bool has_permissions = 10;
|
|
}
|
|
}
|
|
|
|
// unused now
|
|
message UserSecurityTradingLimit{
|
|
SecurityResolution security = 10;
|
|
uint32 clip_size = 20;
|
|
bool can_trade = 30;
|
|
}
|
|
|
|
/************************************************************************/
|
|
/********************************BTS Account*****************************/
|
|
/************************************************************************/
|
|
|
|
message BTSAccount{
|
|
int32 id = 10;
|
|
NullableID parent_account_id = 20;
|
|
string name = 30;
|
|
string description = 40;
|
|
// is this inherited by sub-accounts ?
|
|
bool is_active = 50;
|
|
repeated AccountProductPositionLimit product_position_limits = 60;
|
|
repeated AccountSecurityPositionLimit security_position_limits = 70;
|
|
AccountMarginLimit margin_limit = 80;
|
|
BTSAccountDerivableData account_data = 90;
|
|
}
|
|
|
|
message BTSAccountDerivableData{
|
|
repeated AccountSecurityClipLimit security_clip_limits = 10;
|
|
// echange connections this account can connect to
|
|
repeated int32 exchange_connections = 30;
|
|
ExchangeAccountData exchange_account_data = 40;
|
|
}
|
|
|
|
message AccountProductPositionLimit{
|
|
SecurityResolution security = 10;
|
|
uint32 long_position_limit = 20;
|
|
uint32 short_position_limit = 30;
|
|
uint32 net_position_limit = 40;
|
|
}
|
|
|
|
message AccountSecurityPositionLimit{
|
|
SecurityResolution security = 10;
|
|
uint32 long_position_limit = 20;
|
|
uint32 short_position_limit = 30;
|
|
uint32 net_position_limit = 40;
|
|
}
|
|
|
|
message AccountSecurityClipLimit{
|
|
SecurityResolution security = 10;
|
|
uint32 clip_size = 20;
|
|
}
|
|
|
|
message AccountMarginLimit{
|
|
bool enforce_margin = 10;
|
|
double cash_balance = 20;
|
|
double leverage_factor_percentage = 30;
|
|
}
|
|
|
|
/************************************************************************/
|
|
/***************************Exchange Data********************************/
|
|
/************************************************************************/
|
|
|
|
message ExchangeUserMarketDataEntitlementData{
|
|
CMEUserMarketDataEntitlementData cme_data = 10;
|
|
ICEUserMarketDataEntitlementData ice_data = 20;
|
|
}
|
|
|
|
message ExchangeUserData{
|
|
CMEUserData cme_data = 10;
|
|
ICEUserData ice_data = 20;
|
|
}
|
|
|
|
message ExchangeAccountData{
|
|
CMEAccountData cme_account_data = 10;
|
|
ICEAccountData ice_account_data = 20;
|
|
}
|
|
|
|
message MarketDataEntitlement{
|
|
bool can_view = 10;
|
|
}
|
|
|
|
message ExchangeConnection{
|
|
int32 connection_id = 10;
|
|
string connection_name = 20;
|
|
oneof connection{
|
|
CMEConnection cme_connection = 30;
|
|
ICEConnection ice_connection = 40;
|
|
}
|
|
}
|
|
|
|
/********************************CME Data*********************************/
|
|
|
|
message CMEConnection{
|
|
oneof connection {
|
|
CMECGWConnection cgw_connection = 10;
|
|
CMEMSGWConnection msgw_connection = 20;
|
|
}
|
|
}
|
|
|
|
message CMECGWConnection{
|
|
string primary_ip = 10;
|
|
uint32 primary_port = 20;
|
|
string session_and_firm_id = 30;
|
|
string password = 40;
|
|
string secret_key = 50;
|
|
string access_secret_key = 60;
|
|
string backup_id = 70;
|
|
}
|
|
|
|
message CMEMSGWConnection{
|
|
uint32 port = 10;
|
|
string session_and_firm_id = 20;
|
|
string password = 30;
|
|
string secret_key = 40;
|
|
string access_key_id = 50;
|
|
}
|
|
|
|
message CMEAccountData{
|
|
// should perhaps be an enum
|
|
string cti = 10;
|
|
string origin = 20;
|
|
string takeup_member_code = 30;
|
|
string clearing_account = 40;
|
|
string direct_electronic_access = 50;
|
|
string trading_capacity = 60;
|
|
string liquidity_provision = 70;
|
|
string commodity_derivative_indicator = 80;
|
|
string investment_decision_id = 90;
|
|
string execution_decision_id = 100;
|
|
string client_id = 110;
|
|
}
|
|
|
|
message CMEUserData{
|
|
string operator_id = 10;
|
|
string ats_operator_id = 20;
|
|
string smp_id = 30;
|
|
string text_a = 40;
|
|
string text_b = 50;
|
|
}
|
|
|
|
message CMEUserMarketDataEntitlementData{
|
|
MarketDataEntitlement cbot_entitlement = 10;
|
|
MarketDataEntitlement cme_entitlement = 20;
|
|
MarketDataEntitlement nymex_entitlement = 30;
|
|
MarketDataEntitlement bmandf_entitlement = 40;
|
|
MarketDataEntitlement comex_entitlement = 50;
|
|
MarketDataEntitlement cme_europe_entitlement = 60;
|
|
}
|
|
|
|
/********************************ICE Data*********************************/
|
|
|
|
message ICEConnection{
|
|
string authorized_member_id = 10;
|
|
string sender_company_id = 20;
|
|
string sender_sub_id = 30;
|
|
string session_id = 40;
|
|
string session_password = 50;
|
|
string host_ip = 60;
|
|
string port = 70;
|
|
string default_routing_trader = 80;
|
|
string routing_trader_password = 90;
|
|
int32 max_order_rate = 100;
|
|
}
|
|
|
|
message ICEAccountData{
|
|
string nybit_house = 10;
|
|
int32 wce_house = 20;
|
|
string clearing_account_override = 30;
|
|
bool direct_electronic_access = 40;
|
|
string trading_capacity = 50;
|
|
bool liquidity_provision = 60;
|
|
bool commodity_derivative_indicator = 70;
|
|
string investment_decision_id = 80;
|
|
string execution_decision_id = 90;
|
|
string client_id = 100;
|
|
string mfid_id = 110;
|
|
}
|
|
|
|
message ICEUserData{
|
|
string authorized_trader = 10;
|
|
string memo_field = 20;
|
|
string text_b = 30;
|
|
uint32 max_order_rate = 40;
|
|
}
|
|
|
|
message ICEUserMarketDataEntitlementData{
|
|
}
|
|
|
|
/************************************************************************/
|
|
/************************************************************************/
|
|
/************************************************************************/
|
|
|
|
|
|
message AccountCreateAPIArgument{
|
|
NullableID parent_account_id = 10;
|
|
string account_name = 20;
|
|
string description = 30;
|
|
}
|
|
message AccountSecurityClipLimitsAPIArgument{
|
|
int32 account_id = 10;
|
|
// for all derivable data setting it to null will
|
|
// derive the values from the parents
|
|
repeated AccountSecurityClipLimit complete_data = 20;
|
|
}
|
|
message AccountProductPositionLimitsAPIArgument{
|
|
int32 account_id = 10;
|
|
repeated AccountProductPositionLimit complete_data = 20;
|
|
}
|
|
message AccountSecurityPositionLimitsAPIArgument{
|
|
int32 account_id = 10;
|
|
repeated AccountSecurityPositionLimit complete_data = 20;
|
|
}
|
|
message AccountMarginLimitAPIArgument{
|
|
int32 account_id = 10;
|
|
AccountMarginLimit complete_data = 20;
|
|
}
|
|
message AccountConnectionsAPIArgument{
|
|
int32 account_id = 10;
|
|
repeated int32 all_connections = 20;
|
|
}
|
|
message AccountExchangeDataAPIArgument{
|
|
int32 account_id = 10;
|
|
ExchangeAccountData complete_data = 20;
|
|
}
|
|
message UserCreateAPIArgument{
|
|
int32 parent_group_id = 20;
|
|
string name = 30;
|
|
string password = 40;
|
|
LicenseEntitlements license_entitlements = 70;
|
|
}
|
|
message UserAccountAssociationAPIArgument{
|
|
int32 user_id = 10;
|
|
map<int32, UserPermissions> complete_data = 20;
|
|
}
|
|
message CMEUserMarketDataEntitlementDataAPIArgument{
|
|
int32 user_id = 10;
|
|
CMEUserMarketDataEntitlementData complete_data = 20;
|
|
}
|
|
message CMEUserDataAPIArgument{
|
|
int32 user_id = 10;
|
|
CMEUserData complete_data = 20;
|
|
}
|
|
service UserModelService {
|
|
option (bts.api.service_description) = "Provides a management interface to the user model";
|
|
// account
|
|
rpc create_account (AccountCreateAPIArgument) returns (bts.api.VoidMessage);
|
|
rpc set_account_clip_limits(AccountSecurityClipLimitsAPIArgument) returns (bts.api.VoidMessage);
|
|
rpc set_account_product_position_limits(AccountProductPositionLimitsAPIArgument) returns (bts.api.VoidMessage);
|
|
rpc set_account_security_position_limits(AccountSecurityPositionLimitsAPIArgument) returns (bts.api.VoidMessage);
|
|
rpc set_account_margin_limits(AccountMarginLimitAPIArgument) returns (bts.api.VoidMessage);
|
|
rpc set_account_connections(AccountConnectionsAPIArgument) returns (bts.api.VoidMessage);
|
|
rpc set_account_exchange_data(AccountExchangeDataAPIArgument) returns (bts.api.VoidMessage);
|
|
// users
|
|
rpc create_user(UserCreateAPIArgument) returns (bts.api.VoidMessage);
|
|
rpc set_user_account_association(UserAccountAssociationAPIArgument) returns (bts.api.VoidMessage);
|
|
rpc set_user_cme_md_entitlement_data(CMEUserMarketDataEntitlementDataAPIArgument) returns (bts.api.VoidMessage);
|
|
rpc set_user_cme_routing_data(CMEUserDataAPIArgument) returns (bts.api.VoidMessage);
|
|
// subscription
|
|
rpc subscribe_user_model(bts.api.VoidMessage) returns (stream BTSUserModelData);
|
|
|
|
}
|
|
|
|
message RiskLimit {
|
|
uint32 max_order_size = 10;
|
|
uint32 max_position_long = 20;
|
|
uint32 max_position_short = 30;
|
|
uint32 max_position_net = 40;
|
|
}
|
|
|
|
message AccountBalance {
|
|
// call it balance
|
|
double cash_position = 10;
|
|
double leverage_factor = 20;
|
|
}
|
|
|
|
message Account {
|
|
string name = 5 [(bts.api.key)=true];
|
|
string tag1 = 10;
|
|
bool can_trade = 20;
|
|
AccountBalance balance = 30;
|
|
|
|
bool enforce_margin = 40;
|
|
repeated bts.api.user.OperatorID allowed_operators = 100;
|
|
map<string, RiskLimit> future_limits = 110;
|
|
map<string, RiskLimit> spread_limits = 120;
|
|
}
|
|
|
|
|
|
|
|
message GetAccountsRequest {}
|
|
message GetAccountsResponse {repeated Account accounts = 1;}
|
|
message AddOrUpdateAccountRequest {bts.api.user.AuthToken token = 1; Account account = 2;}
|
|
message RemoveAccountRequest {bts.api.user.AuthToken token = 1; string name = 2;}
|
|
message UpdateAccountBalanceRequest {string name = 2; AccountBalance new_balance = 3;}
|
|
message AccountOperationResponse {bool is_valid = 1; string reason = 2; }
|
|
|
|
service AccountService {
|
|
option (bts.api.service_description) = "Provides a management interface to the system account list";
|
|
|
|
rpc get_accounts(GetAccountsRequest) returns (GetAccountsResponse)
|
|
{option (bts.api.method_description)="Returns list of valid accounts";}
|
|
|
|
rpc accounts(GetAccountsRequest) returns (stream Account)
|
|
{option (bts.api.method_description)="Returns stream of valid accounts";}
|
|
|
|
rpc add_or_update_account(AddOrUpdateAccountRequest) returns (AccountOperationResponse)
|
|
{option (bts.api.method_description)="Adds or Updates an Account";}
|
|
|
|
rpc remove_account(RemoveAccountRequest) returns (AccountOperationResponse)
|
|
{option (bts.api.method_description)="Removes an Account";}
|
|
|
|
rpc update_account_balance(UpdateAccountBalanceRequest) returns (AccountOperationResponse)
|
|
{option (bts.api.method_description)="Updates account balance without affecting limits or registered operators";}
|
|
}
|