mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-06-03 15:10:49 +00:00
Binance,Okx: Add Leverage, MarginType, Positions and CollateralMode support (#1220)
* init * surprise train commit * basic distinctions * the terms of binance are confusing * renames and introduction of allocatedMargin * add new margin funcs * pulling out wires * implement proper getposition stuff * bad coding day * investigate order manager next * a broken mess, but a progressing one * finally completes some usdtmargined stuff * coinMfutures eludes me * expand to okx * imports fix * completes okx wrapper implementations * cleans and polishes before rpc implementations * rpc setup, order manager features, exch features * more rpc, collateral and margin things * mini test * looking at rpc response, expansion of features * reorganising before the storm * changing how futures requests work * cleanup and tests of cli usage * remove silly client side logic * cleanup * collateral package, typo fix, margin err, rpc derive * uses convert.StringToFloat ONLY ON STRUCTS FROM THIS PR * fix binance order history bug * niteroos * adds new funcs to exchange standards testing * more post merge fixes * fix binance * replace simepletimeformat * fix for merge * merge fixes * micro fixes * order side now required for leverage * fix up the rest * global -> portfolio collateral * Update exchanges/collateral/collateral_test.go Co-authored-by: Adrian Gallagher <adrian.gallagher@thrasher.io> * adds fields and todos * rm field redundancy * lint fix oopsie daisy * fixes panic, expands error and cli explanations (sorry shaz) * ensures casing is appropriate for underlying * Adds a shiny TODO --------- Co-authored-by: Adrian Gallagher <adrian.gallagher@thrasher.io>
This commit is contained in:
197
gctrpc/rpc.proto
197
gctrpc/rpc.proto
@@ -346,6 +346,7 @@ message SubmitOrderRequest {
|
||||
double price = 6;
|
||||
string client_id = 7;
|
||||
string asset_type = 8;
|
||||
string margin_type = 9;
|
||||
}
|
||||
|
||||
message Trades {
|
||||
@@ -366,6 +367,7 @@ message SimulateOrderRequest {
|
||||
CurrencyPair pair = 2;
|
||||
double amount = 3;
|
||||
string side = 4;
|
||||
string margin_type = 5;
|
||||
}
|
||||
|
||||
message SimulateOrderResponse {
|
||||
@@ -1062,6 +1064,18 @@ message FuturesPositionStats {
|
||||
string margin_fraction = 10;
|
||||
string free_collateral = 11;
|
||||
string total_collateral = 12;
|
||||
string frozen_balance = 13;
|
||||
string equity_of_currency = 14;
|
||||
string available_equity = 15;
|
||||
string cash_balance = 16;
|
||||
string discount_equity = 17;
|
||||
string equity_usd = 18;
|
||||
string isolated_equity = 19;
|
||||
string isolated_liabilities = 20;
|
||||
string isolated_upl = 21;
|
||||
string notional_leverage = 22;
|
||||
string total_equity = 23;
|
||||
string strategy_equity = 24;
|
||||
}
|
||||
|
||||
message FuturePosition {
|
||||
@@ -1106,31 +1120,143 @@ message GetManagedPositionsResponse {
|
||||
repeated FuturePosition positions = 1;
|
||||
}
|
||||
|
||||
message GetFuturesPositionsRequest {
|
||||
message GetFuturesPositionsSummaryRequest {
|
||||
string exchange = 1;
|
||||
string asset = 2;
|
||||
CurrencyPair pair = 3;
|
||||
string start_date = 4;
|
||||
string end_date = 5;
|
||||
string status = 6;
|
||||
int64 position_limit = 7;
|
||||
bool overwrite = 8;
|
||||
bool get_position_stats = 9;
|
||||
bool include_full_order_data = 10;
|
||||
bool get_funding_payments = 11;
|
||||
bool include_full_funding_rates = 12;
|
||||
bool include_predicted_rate = 13;
|
||||
CurrencyPair underlying_pair = 4;
|
||||
}
|
||||
|
||||
message GetFuturesPositionsResponse {
|
||||
int64 total_orders = 1;
|
||||
string sub_account = 2;
|
||||
string total_realised_pnl = 3;
|
||||
string total_unrealised_pnl = 4;
|
||||
string total_pnl = 5;
|
||||
message GetFuturesPositionsSummaryResponse {
|
||||
string exchange = 1;
|
||||
string asset = 2;
|
||||
CurrencyPair pair = 3;
|
||||
FuturesPositionStats position_stats = 4;
|
||||
}
|
||||
|
||||
message GetFuturesPositionsOrdersRequest {
|
||||
string exchange = 1;
|
||||
string asset = 2;
|
||||
CurrencyPair pair = 3;
|
||||
CurrencyPair underlying_pair = 4;
|
||||
string start_date = 5;
|
||||
string end_date = 6;
|
||||
bool respect_order_history_limits = 7;
|
||||
bool sync_with_order_manager = 8;
|
||||
}
|
||||
|
||||
message GetFuturesPositionsOrdersResponse {
|
||||
repeated FuturePosition positions = 6;
|
||||
}
|
||||
|
||||
message GetCollateralModeRequest {
|
||||
string exchange = 1;
|
||||
string asset = 2;
|
||||
}
|
||||
|
||||
message GetCollateralModeResponse {
|
||||
string exchange = 1;
|
||||
string asset = 2;
|
||||
string collateral_mode = 3;
|
||||
}
|
||||
|
||||
message SetCollateralModeRequest {
|
||||
string exchange = 1;
|
||||
string asset = 2;
|
||||
string collateral_mode = 3;
|
||||
}
|
||||
|
||||
message SetCollateralModeResponse {
|
||||
string exchange = 1;
|
||||
string asset = 2;
|
||||
bool success = 3;
|
||||
}
|
||||
|
||||
message GetMarginTypeRequest {
|
||||
string exchange = 1;
|
||||
string asset = 2;
|
||||
CurrencyPair pair = 3;
|
||||
}
|
||||
|
||||
message GetMarginTypeResponse {
|
||||
string exchange = 1;
|
||||
string asset = 2;
|
||||
CurrencyPair pair = 3;
|
||||
string margin_type = 4;
|
||||
}
|
||||
|
||||
message ChangePositionMarginRequest {
|
||||
string exchange = 1;
|
||||
string asset = 2;
|
||||
CurrencyPair pair = 3;
|
||||
string margin_type = 4;
|
||||
double original_allocated_margin = 5;
|
||||
double new_allocated_margin = 6;
|
||||
string margin_side = 7;
|
||||
}
|
||||
|
||||
message ChangePositionMarginResponse {
|
||||
string exchange = 1;
|
||||
string asset = 2;
|
||||
CurrencyPair pair = 3;
|
||||
string margin_type = 4;
|
||||
double new_allocated_margin = 5;
|
||||
string margin_side = 6;
|
||||
}
|
||||
|
||||
message SetMarginTypeRequest {
|
||||
string exchange = 1;
|
||||
string asset = 2;
|
||||
CurrencyPair pair = 3;
|
||||
string margin_type = 4;
|
||||
}
|
||||
|
||||
message SetMarginTypeResponse {
|
||||
string exchange = 1;
|
||||
string asset = 2;
|
||||
CurrencyPair pair = 3;
|
||||
bool success = 4;
|
||||
}
|
||||
|
||||
message GetLeverageRequest {
|
||||
string exchange = 1;
|
||||
string asset = 2;
|
||||
CurrencyPair pair = 3;
|
||||
CurrencyPair underlying_pair = 4;
|
||||
string margin_type = 5;
|
||||
string order_side = 6;
|
||||
}
|
||||
|
||||
message GetLeverageResponse {
|
||||
string exchange = 1;
|
||||
string asset = 2;
|
||||
CurrencyPair pair = 3;
|
||||
CurrencyPair underlying_pair = 4;
|
||||
string margin_type = 5;
|
||||
double leverage = 6;
|
||||
string order_side = 7;
|
||||
}
|
||||
|
||||
message SetLeverageRequest {
|
||||
string exchange = 1;
|
||||
string asset = 2;
|
||||
CurrencyPair pair = 3;
|
||||
CurrencyPair underlying_pair = 4;
|
||||
string margin_type = 5;
|
||||
double leverage = 6;
|
||||
string order_side = 7;
|
||||
}
|
||||
|
||||
message SetLeverageResponse {
|
||||
string exchange = 1;
|
||||
string asset = 2;
|
||||
CurrencyPair pair = 3;
|
||||
CurrencyPair underlying_pair = 4;
|
||||
string margin_type = 5;
|
||||
string order_side = 6;
|
||||
bool success = 7;
|
||||
}
|
||||
|
||||
message GetCollateralRequest {
|
||||
string exchange = 1;
|
||||
string asset = 2;
|
||||
@@ -1844,8 +1970,11 @@ service GoCryptoTraderService {
|
||||
rpc CurrencyStateTradingPair(CurrencyStateTradingPairRequest) returns (GenericResponse) {
|
||||
option (google.api.http) = {get: "/v1/currencystatetradingpair"};
|
||||
}
|
||||
rpc GetFuturesPositions(GetFuturesPositionsRequest) returns (GetFuturesPositionsResponse) {
|
||||
option (google.api.http) = {get: "/v1/getfuturespositions"};
|
||||
rpc GetFuturesPositionsSummary(GetFuturesPositionsSummaryRequest) returns (GetFuturesPositionsSummaryResponse) {
|
||||
option (google.api.http) = {get: "/v1/getfuturespositionssummary"};
|
||||
}
|
||||
rpc GetFuturesPositionsOrders(GetFuturesPositionsOrdersRequest) returns (GetFuturesPositionsOrdersResponse) {
|
||||
option (google.api.http) = {get: "/v1/getfuturespositionsorders"};
|
||||
}
|
||||
rpc GetCollateral(GetCollateralRequest) returns (GetCollateralResponse) {
|
||||
option (google.api.http) = {get: "/v1/getcollateral"};
|
||||
@@ -1880,4 +2009,34 @@ service GoCryptoTraderService {
|
||||
rpc GetOrderbookAmountByImpact(GetOrderbookAmountByImpactRequest) returns (GetOrderbookAmountByImpactResponse) {
|
||||
option (google.api.http) = {get: "/v1/getorderbookamountbyimpact"};
|
||||
}
|
||||
rpc GetCollateralMode(GetCollateralModeRequest) returns (GetCollateralModeResponse) {
|
||||
option (google.api.http) = {get: "/v1/getcollateralmode"};
|
||||
}
|
||||
rpc GetLeverage(GetLeverageRequest) returns (GetLeverageResponse) {
|
||||
option (google.api.http) = {get: "/v1/getleverage"};
|
||||
}
|
||||
rpc SetCollateralMode(SetCollateralModeRequest) returns (SetCollateralModeResponse) {
|
||||
option (google.api.http) = {
|
||||
post: "/v1/getcollateralmode"
|
||||
body: "*"
|
||||
};
|
||||
}
|
||||
rpc SetMarginType(SetMarginTypeRequest) returns (SetMarginTypeResponse) {
|
||||
option (google.api.http) = {
|
||||
post: "/v1/getmargintype"
|
||||
body: "*"
|
||||
};
|
||||
}
|
||||
rpc SetLeverage(SetLeverageRequest) returns (SetLeverageResponse) {
|
||||
option (google.api.http) = {
|
||||
post: "/v1/getleverage"
|
||||
body: "*"
|
||||
};
|
||||
}
|
||||
rpc ChangePositionMargin(ChangePositionMarginRequest) returns (ChangePositionMarginResponse) {
|
||||
option (google.api.http) = {
|
||||
post: "/v1/changepositionmargin"
|
||||
body: "*"
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user