Binance,OKx: Implement fetching funding rates (#1239)

* adds basic groundwork for rates on binance

* more into rates on binance

* rm redudant redundancy, add payments

* mini commit before merging with testnet ability branch

* changes function signature and fixes resulting build

* gets billing data too

* funding rates package, features use, testnet reimpl

* new endpoint, refinements and tests

* cli fix, rpc impl, testing, payments

* fixups from looking at code

* typo fix

* niteroos

* merge fixes

* adds test, fixes cli issues

* woah nelly
This commit is contained in:
Scott
2023-07-26 14:25:43 +10:00
committed by GitHub
parent 2ad9304045
commit 471f4f21c4
39 changed files with 5785 additions and 3416 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1038,12 +1038,15 @@ message FundingData {
string exchange = 1;
string asset = 2;
CurrencyPair pair = 3;
string start_date = 4;
string end_date = 5;
repeated FundingRate rates = 6;
FundingRate latest_rate = 7;
FundingRate upcoming_rate = 8;
string payment_sum = 9;
string payment_currency = 4;
string start_date = 5;
string end_date = 6;
repeated FundingRate rates = 7;
FundingRate latest_rate = 8;
FundingRate upcoming_rate = 9;
string payment_sum = 10;
string payment_message = 11;
string time_of_next_rate = 12;
}
message FuturesPositionStats {
@@ -1190,15 +1193,28 @@ message CollateralUsedBreakdown {
message GetFundingRatesRequest {
string exchange = 1;
string asset = 2;
repeated string pairs = 3;
CurrencyPair pair = 3;
string start_date = 4;
string end_date = 5;
bool include_predicted = 6;
bool include_payments = 7;
string payment_currency = 6;
bool include_predicted = 7;
bool include_payments = 8;
bool respect_history_limits = 9;
}
message GetFundingRatesResponse {
repeated FundingData funding_payments = 1;
FundingData rates = 1;
}
message GetLatestFundingRateRequest {
string exchange = 1;
string asset = 2;
CurrencyPair pair = 3;
bool include_predicted = 4;
}
message GetLatestFundingRateResponse {
FundingData rate = 1;
}
message ShutdownRequest {}
@@ -1852,6 +1868,9 @@ service GoCryptoTraderService {
rpc GetFundingRates(GetFundingRatesRequest) returns (GetFundingRatesResponse) {
option (google.api.http) = {get: "/v1/getfundingrates"};
}
rpc GetLatestFundingRate(GetLatestFundingRateRequest) returns (GetLatestFundingRateResponse) {
option (google.api.http) = {get: "/v1/getlatestfundingrate"};
}
rpc GetOrderbookMovement(GetOrderbookMovementRequest) returns (GetOrderbookMovementResponse) {
option (google.api.http) = {get: "/v1/getorderbookmovement"};
}

View File

@@ -1902,14 +1902,22 @@
"type": "string"
},
{
"name": "pairs",
"name": "pair.delimiter",
"in": "query",
"required": false,
"type": "array",
"items": {
"type": "string"
},
"collectionFormat": "multi"
"type": "string"
},
{
"name": "pair.base",
"in": "query",
"required": false,
"type": "string"
},
{
"name": "pair.quote",
"in": "query",
"required": false,
"type": "string"
},
{
"name": "startDate",
@@ -1923,6 +1931,12 @@
"required": false,
"type": "string"
},
{
"name": "paymentCurrency",
"in": "query",
"required": false,
"type": "string"
},
{
"name": "includePredicted",
"in": "query",
@@ -1934,6 +1948,12 @@
"in": "query",
"required": false,
"type": "boolean"
},
{
"name": "respectHistoryLimits",
"in": "query",
"required": false,
"type": "boolean"
}
],
"tags": [
@@ -2256,6 +2276,66 @@
]
}
},
"/v1/getlatestfundingrate": {
"get": {
"operationId": "GoCryptoTraderService_GetLatestFundingRate",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/gctrpcGetLatestFundingRateResponse"
}
},
"default": {
"description": "An unexpected error response.",
"schema": {
"$ref": "#/definitions/rpcStatus"
}
}
},
"parameters": [
{
"name": "exchange",
"in": "query",
"required": false,
"type": "string"
},
{
"name": "asset",
"in": "query",
"required": false,
"type": "string"
},
{
"name": "pair.delimiter",
"in": "query",
"required": false,
"type": "string"
},
{
"name": "pair.base",
"in": "query",
"required": false,
"type": "string"
},
{
"name": "pair.quote",
"in": "query",
"required": false,
"type": "string"
},
{
"name": "includePredicted",
"in": "query",
"required": false,
"type": "boolean"
}
],
"tags": [
"GoCryptoTraderService"
]
}
},
"/v1/getloggerdetails": {
"get": {
"operationId": "GoCryptoTraderService_GetLoggerDetails",
@@ -4323,6 +4403,7 @@
"currencies": {
"type": "array",
"items": {
"type": "object",
"$ref": "#/definitions/gctrpcAccountCurrencyInfo"
}
}
@@ -4454,6 +4535,7 @@
"orders": {
"type": "array",
"items": {
"type": "object",
"$ref": "#/definitions/gctrpcOrders"
}
},
@@ -4495,6 +4577,7 @@
"orders": {
"type": "array",
"items": {
"type": "object",
"$ref": "#/definitions/gctrpcOrders"
}
}
@@ -4766,6 +4849,7 @@
"currencyStates": {
"type": "array",
"items": {
"type": "object",
"$ref": "#/definitions/gctrpcCurrencyState"
}
}
@@ -4844,6 +4928,7 @@
"jobResults": {
"type": "array",
"items": {
"type": "object",
"$ref": "#/definitions/gctrpcDataHistoryJobResult"
}
},
@@ -4881,6 +4966,7 @@
"results": {
"type": "array",
"items": {
"type": "object",
"$ref": "#/definitions/gctrpcDataHistoryJob"
}
}
@@ -4906,6 +4992,7 @@
"addresses": {
"type": "array",
"items": {
"type": "object",
"$ref": "#/definitions/gctrpcDepositAddress"
}
}
@@ -5015,6 +5102,9 @@
"pair": {
"$ref": "#/definitions/gctrpcCurrencyPair"
},
"paymentCurrency": {
"type": "string"
},
"startDate": {
"type": "string"
},
@@ -5024,6 +5114,7 @@
"rates": {
"type": "array",
"items": {
"type": "object",
"$ref": "#/definitions/gctrpcFundingRate"
}
},
@@ -5035,6 +5126,12 @@
},
"paymentSum": {
"type": "string"
},
"paymentMessage": {
"type": "string"
},
"timeOfNextRate": {
"type": "string"
}
}
},
@@ -5104,6 +5201,7 @@
"orders": {
"type": "array",
"items": {
"type": "object",
"$ref": "#/definitions/gctrpcOrderDetails"
}
},
@@ -5218,6 +5316,7 @@
"scripts": {
"type": "array",
"items": {
"type": "object",
"$ref": "#/definitions/gctrpcGCTScript"
}
}
@@ -5283,6 +5382,7 @@
"accounts": {
"type": "array",
"items": {
"type": "object",
"$ref": "#/definitions/gctrpcAccount"
}
}
@@ -5294,6 +5394,7 @@
"events": {
"type": "array",
"items": {
"type": "object",
"$ref": "#/definitions/gctrpcAuditEvent"
}
}
@@ -5354,12 +5455,14 @@
"currencyBreakdown": {
"type": "array",
"items": {
"type": "object",
"$ref": "#/definitions/gctrpcCollateralForCurrency"
}
},
"positionBreakdown": {
"type": "array",
"items": {
"type": "object",
"$ref": "#/definitions/gctrpcCollateralByPosition"
}
}
@@ -5560,6 +5663,7 @@
"forexProviders": {
"type": "array",
"items": {
"type": "object",
"$ref": "#/definitions/gctrpcForexProvider"
}
}
@@ -5571,6 +5675,7 @@
"forexRates": {
"type": "array",
"items": {
"type": "object",
"$ref": "#/definitions/gctrpcForexRatesConversion"
}
}
@@ -5579,11 +5684,8 @@
"gctrpcGetFundingRatesResponse": {
"type": "object",
"properties": {
"fundingPayments": {
"type": "array",
"items": {
"$ref": "#/definitions/gctrpcFundingData"
}
"rates": {
"$ref": "#/definitions/gctrpcFundingData"
}
}
},
@@ -5609,6 +5711,7 @@
"positions": {
"type": "array",
"items": {
"type": "object",
"$ref": "#/definitions/gctrpcFuturePosition"
}
}
@@ -5635,6 +5738,7 @@
"candle": {
"type": "array",
"items": {
"type": "object",
"$ref": "#/definitions/gctrpcCandle"
}
}
@@ -5674,6 +5778,14 @@
}
}
},
"gctrpcGetLatestFundingRateResponse": {
"type": "object",
"properties": {
"rate": {
"$ref": "#/definitions/gctrpcFundingData"
}
}
},
"gctrpcGetLoggerDetailsResponse": {
"type": "object",
"properties": {
@@ -5697,6 +5809,7 @@
"positions": {
"type": "array",
"items": {
"type": "object",
"$ref": "#/definitions/gctrpcFuturePosition"
}
}
@@ -5708,6 +5821,7 @@
"rates": {
"type": "array",
"items": {
"type": "object",
"$ref": "#/definitions/gctrpcMarginRate"
}
},
@@ -5918,6 +6032,7 @@
"orderbooks": {
"type": "array",
"items": {
"type": "object",
"$ref": "#/definitions/gctrpcOrderbooks"
}
}
@@ -5949,6 +6064,7 @@
"orders": {
"type": "array",
"items": {
"type": "object",
"$ref": "#/definitions/gctrpcOrderDetails"
}
}
@@ -5960,6 +6076,7 @@
"portfolio": {
"type": "array",
"items": {
"type": "object",
"$ref": "#/definitions/gctrpcPortfolioAddress"
}
}
@@ -5971,12 +6088,14 @@
"coinTotals": {
"type": "array",
"items": {
"type": "object",
"$ref": "#/definitions/gctrpcCoin"
}
},
"coinsOffline": {
"type": "array",
"items": {
"type": "object",
"$ref": "#/definitions/gctrpcCoin"
}
},
@@ -5989,6 +6108,7 @@
"coinsOnline": {
"type": "array",
"items": {
"type": "object",
"$ref": "#/definitions/gctrpcCoin"
}
},
@@ -6053,6 +6173,7 @@
"tickers": {
"type": "array",
"items": {
"type": "object",
"$ref": "#/definitions/gctrpcTickers"
}
}
@@ -6140,6 +6261,7 @@
"addresses": {
"type": "array",
"items": {
"type": "object",
"$ref": "#/definitions/gctrpcOfflineCoinSummary"
}
}
@@ -6228,6 +6350,7 @@
"trades": {
"type": "array",
"items": {
"type": "object",
"$ref": "#/definitions/gctrpcTradeHistory"
}
}
@@ -6262,12 +6385,14 @@
"bids": {
"type": "array",
"items": {
"type": "object",
"$ref": "#/definitions/gctrpcOrderbookItem"
}
},
"asks": {
"type": "array",
"items": {
"type": "object",
"$ref": "#/definitions/gctrpcOrderbookItem"
}
},
@@ -6292,6 +6417,7 @@
"orderbooks": {
"type": "array",
"items": {
"type": "object",
"$ref": "#/definitions/gctrpcOrderbookResponse"
}
}
@@ -6411,6 +6537,7 @@
"trades": {
"type": "array",
"items": {
"type": "object",
"$ref": "#/definitions/gctrpcSavedTrades"
}
}
@@ -6443,6 +6570,7 @@
"pairs": {
"type": "array",
"items": {
"type": "object",
"$ref": "#/definitions/gctrpcCurrencyPair"
}
},
@@ -6489,6 +6617,7 @@
"orders": {
"type": "array",
"items": {
"type": "object",
"$ref": "#/definitions/gctrpcOrderbookItem"
}
},
@@ -6556,6 +6685,7 @@
"trades": {
"type": "array",
"items": {
"type": "object",
"$ref": "#/definitions/gctrpcTrades"
}
}
@@ -6613,6 +6743,7 @@
"tickers": {
"type": "array",
"items": {
"type": "object",
"$ref": "#/definitions/gctrpcTickerResponse"
}
}
@@ -6802,6 +6933,7 @@
"subscriptions": {
"type": "array",
"items": {
"type": "object",
"$ref": "#/definitions/gctrpcWebsocketSubscription"
}
}
@@ -6991,6 +7123,7 @@
"event": {
"type": "array",
"items": {
"type": "object",
"$ref": "#/definitions/gctrpcWithdrawalEventResponse"
}
}
@@ -7057,6 +7190,7 @@
"details": {
"type": "array",
"items": {
"type": "object",
"$ref": "#/definitions/protobufAny"
}
}

File diff suppressed because it is too large Load Diff