145 lines
3.7 KiB
Protocol Buffer
145 lines
3.7 KiB
Protocol Buffer
syntax="proto3";
|
|
package bts.api.position;
|
|
option csharp_namespace="bts.api.position";
|
|
import "lib/api/apioptions.proto";
|
|
import "lib/api/apicore.proto";
|
|
import "lib/domain_model/Security.proto";
|
|
import "google/protobuf/timestamp.proto";
|
|
|
|
message PositionEntry{
|
|
double long_pos = 10;
|
|
double long_avg_price = 20;
|
|
double short_pos = 30;
|
|
double short_avg_price = 40;
|
|
}
|
|
|
|
message PositionUnit{
|
|
int32 record_id = 1 [(bts.api.key)=true];
|
|
string account = 10;
|
|
uint32 account_id = 15;
|
|
uint32 security_id = 20;
|
|
// all these doubles will be retired
|
|
// to be replaced by the 5 PositionEntry
|
|
// entries below
|
|
double sod_long_pos = 30;
|
|
double sod_long_avg_price = 40;
|
|
double sod_short_pos = 50;
|
|
double sod_short_avg_price = 60;
|
|
double day_long_pos = 70;
|
|
double day_long_avg_price = 80;
|
|
double day_short_pos = 90;
|
|
double day_short_avg_price = 100;
|
|
PositionEntry sod = 110;
|
|
PositionEntry day = 120;
|
|
// this is the position without the spread legs
|
|
// being incorporated into the outright position
|
|
// (for spreads, day == raw_day)
|
|
PositionEntry raw_day = 125;
|
|
PositionEntry local = 130;
|
|
PositionEntry admin_sod = 140;
|
|
PositionEntry admin_day = 150;
|
|
}
|
|
|
|
message PNLUnit{
|
|
int32 record_id = 1 [(bts.api.key)=true];
|
|
PositionUnit pos = 10;
|
|
double cash_value = 20;
|
|
CppOverride cpp_override = 21;
|
|
double bid_price = 30;
|
|
double ask_price = 40;
|
|
double last_price = 50;
|
|
double settlement_price = 60;
|
|
}
|
|
|
|
message AccountPNL{
|
|
uint32 account_id = 1 [(bts.api.key)=true];
|
|
string account_name = 10;
|
|
double day_pnl = 20;
|
|
}
|
|
|
|
message ManualFill {
|
|
enum FillType {
|
|
LOCAL = 0;
|
|
ADMIN_DAY = 1;
|
|
ADMIN_SOD = 2;
|
|
}
|
|
int32 record_id = 1 [(bts.api.key)=true];
|
|
uint32 security_key = 2;
|
|
uint32 account_id = 3;
|
|
string account_name = 8;
|
|
uint32 user_id = 4;
|
|
api.Side side = 5;
|
|
uint32 quantity = 6;
|
|
double price = 7;
|
|
FillType fill_type = 9;
|
|
google.protobuf.Timestamp timestamp = 10;
|
|
}
|
|
|
|
message ManualFillBatch {
|
|
repeated ManualFill manual_fill = 1;
|
|
}
|
|
|
|
message PositionServiceOpResponse {
|
|
bool ok = 1;
|
|
string msg = 2;
|
|
}
|
|
|
|
message PositionServiceResponse {
|
|
repeated PositionServiceOpResponse response = 1;
|
|
}
|
|
|
|
message BasePosition {
|
|
uint32 security_id = 1;
|
|
uint32 account_id = 2;
|
|
double avg_price = 3;
|
|
api.Side side = 4;
|
|
uint32 quantity = 6;
|
|
}
|
|
|
|
message SetBasePositionResponse {
|
|
bool ok = 1;
|
|
string msg = 2;
|
|
}
|
|
|
|
message BasePositionBatch {
|
|
repeated BasePosition positions = 1;
|
|
google.protobuf.Timestamp current_as_of = 10; // UTC
|
|
}
|
|
|
|
// security overrides /////////////////////////////////////
|
|
message CppOverride{
|
|
double value = 1;
|
|
}
|
|
|
|
message SecurityParameters{
|
|
uint32 security_key = 1;
|
|
CppOverride cpp_override = 2;
|
|
// other overrides
|
|
}
|
|
|
|
message SecurityParametersBatchOp{
|
|
repeated SecurityParameters op_params = 1;
|
|
}
|
|
|
|
message SecurityParametersBatchOpResponse {
|
|
bool ok = 1;
|
|
string msg = 2;
|
|
}
|
|
|
|
service PositionService {
|
|
option (bts.api.service_description) = "Provides Position and PNL, per security, per account";
|
|
|
|
rpc create_manual_fill (ManualFillBatch) returns (PositionServiceResponse);
|
|
rpc update_manual_fill (ManualFillBatch) returns (PositionServiceResponse);
|
|
rpc remove_manual_fill (ManualFillBatch) returns (PositionServiceResponse);
|
|
rpc set_base_position (BasePositionBatch) returns (SetBasePositionResponse);
|
|
rpc update_security_parameters (SecurityParametersBatchOp) returns (SecurityParametersBatchOpResponse);
|
|
|
|
// subscription
|
|
rpc manual_fills(bts.api.VoidMessage) returns (stream ManualFill);
|
|
rpc position_data(bts.api.VoidMessage) returns (stream PositionUnit);
|
|
rpc pnl_data(bts.api.VoidMessage) returns (stream PNLUnit);
|
|
rpc pnl_account_data(bts.api.VoidMessage) returns (stream AccountPNL);
|
|
|
|
|
|
} |