rust_okx/api/account/api.rs
1use crate::client::OkxClient;
2use crate::error::Error;
3use crate::transport::Transport;
4
5use super::endpoints::*;
6use super::requests::*;
7use super::responses::*;
8use crate::model::EmptyRequest;
9
10/// Accessor for the authenticated account endpoints.
11///
12/// Obtain one via [`OkxClient::account`](crate::OkxClient::account). All methods
13/// require credentials; calling them without credentials returns
14/// [`RestError::Configuration`](crate::RestError::Configuration).
15pub struct Account<'a, T> {
16 client: &'a OkxClient<T>,
17}
18
19impl<'a, T: Transport> Account<'a, T> {
20 pub(crate) fn new(client: &'a OkxClient<T>) -> Self {
21 Self { client }
22 }
23
24 /// Retrieve the trading-account balance.
25 ///
26 /// `GET /api/v5/account/balance`. Authenticated.
27 ///
28 /// # Errors
29 ///
30 /// Returns [`RestError::Configuration`](crate::RestError::Configuration) if no credentials are set,
31 /// [`RestError::Okx`](crate::RestError::Okx) on a non-zero OKX code, or transport/decode errors.
32 pub async fn get_balance(
33 &self,
34 request: BalanceRequest<'_>,
35 ) -> Result<Vec<AccountBalance>, Error> {
36 self.client.get(BALANCE, &request, true).await
37 }
38
39 /// Retrieve open positions.
40 ///
41 /// `GET /api/v5/account/positions`. Authenticated.
42 ///
43 /// # Errors
44 ///
45 /// Returns [`RestError::Configuration`](crate::RestError::Configuration) if no credentials are set,
46 /// [`RestError::Okx`](crate::RestError::Okx) on a non-zero OKX code, or transport/decode errors.
47 pub async fn get_positions(
48 &self,
49 request: &PositionsRequest<'_>,
50 ) -> Result<Vec<Position>, Error> {
51 self.client.get(POSITIONS, request, true).await
52 }
53
54 /// Retrieve account position risk.
55 ///
56 /// `GET /api/v5/account/account-position-risk`. Authenticated.
57 ///
58 /// # Errors
59 ///
60 /// Returns [`RestError::Configuration`](crate::RestError::Configuration) if no credentials are set,
61 /// [`RestError::Okx`](crate::RestError::Okx) on a non-zero OKX code, or transport/decode errors.
62 pub async fn get_position_risk(
63 &self,
64 request: &PositionRiskRequest,
65 ) -> Result<Vec<PositionRisk>, Error> {
66 self.client.get(POSITION_RISK, request, true).await
67 }
68
69 /// Retrieve account configuration.
70 ///
71 /// `GET /api/v5/account/config`. Authenticated.
72 ///
73 /// # Errors
74 ///
75 /// Returns [`RestError::Configuration`](crate::RestError::Configuration) if no credentials are set,
76 /// [`RestError::Okx`](crate::RestError::Okx) on a non-zero OKX code, or transport/decode errors.
77 pub async fn get_account_config(&self) -> Result<Vec<AccountConfig>, Error> {
78 self.client
79 .get(ACCOUNT_CONFIG, &EmptyRequest {}, true)
80 .await
81 }
82
83 /// Retrieve recent account bills.
84 ///
85 /// `GET /api/v5/account/bills`. Authenticated.
86 ///
87 /// # Errors
88 ///
89 /// Returns [`RestError::Configuration`](crate::RestError::Configuration) if no credentials are set,
90 /// [`RestError::Okx`](crate::RestError::Okx) on a non-zero OKX code, or transport/decode errors.
91 pub async fn get_account_bills(
92 &self,
93 request: &BillsRequest<'_>,
94 ) -> Result<Vec<AccountBill>, Error> {
95 self.client.get(BILLS, request, true).await
96 }
97
98 /// Retrieve archived account bills.
99 ///
100 /// `GET /api/v5/account/bills-archive`. Authenticated.
101 ///
102 /// # Errors
103 ///
104 /// Returns [`RestError::Configuration`](crate::RestError::Configuration) if no credentials are set,
105 /// [`RestError::Okx`](crate::RestError::Okx) on a non-zero OKX code, or transport/decode errors.
106 pub async fn get_account_bills_archive(
107 &self,
108 request: &BillsArchiveRequest<'_>,
109 ) -> Result<Vec<AccountBill>, Error> {
110 self.client.get(BILLS_ARCHIVE, request, true).await
111 }
112
113 /// Apply for historical account-bills archive generation.
114 ///
115 /// `POST /api/v5/account/bills-history-archive`. Authenticated.
116 ///
117 /// # Errors
118 ///
119 /// Returns [`RestError::Configuration`](crate::RestError::Configuration) if no credentials are set,
120 /// [`RestError::Okx`](crate::RestError::Okx) on a non-zero OKX code, or transport/decode errors.
121 pub async fn apply_bills_history_archive(
122 &self,
123 request: &ApplyBillsHistoryArchiveRequest<'_>,
124 ) -> Result<Vec<ApplyBillsHistoryArchiveResult>, Error> {
125 self.client.post(BILLS_HISTORY_ARCHIVE, request, true).await
126 }
127
128 /// Retrieve historical account-bills archive download links.
129 ///
130 /// `GET /api/v5/account/bills-history-archive`. Authenticated.
131 ///
132 /// # Errors
133 ///
134 /// Returns [`RestError::Configuration`](crate::RestError::Configuration) if no credentials are set,
135 /// [`RestError::Okx`](crate::RestError::Okx) on a non-zero OKX code, or transport/decode errors.
136 pub async fn get_bills_history_archive(
137 &self,
138 request: &BillsHistoryArchiveRequest<'_>,
139 ) -> Result<Vec<BillsHistoryArchiveFile>, Error> {
140 self.client.get(BILLS_HISTORY_ARCHIVE, request, true).await
141 }
142
143 /// Retrieve account bill types and subtype mappings.
144 ///
145 /// `GET /api/v5/account/subtypes`. Authenticated.
146 ///
147 /// # Errors
148 ///
149 /// Returns [`RestError::Configuration`](crate::RestError::Configuration) if no credentials are set,
150 /// [`RestError::Okx`](crate::RestError::Okx) on a non-zero OKX code, or transport/decode errors.
151 pub async fn get_bill_subtypes(
152 &self,
153 request: &BillSubtypesRequest<'_>,
154 ) -> Result<Vec<BillSubtypeMapping>, Error> {
155 self.client.get(SUBTYPES, request, true).await
156 }
157
158 /// Set the account position mode.
159 ///
160 /// `POST /api/v5/account/set-position-mode`. Authenticated.
161 ///
162 /// # Errors
163 ///
164 /// Returns [`RestError::Configuration`](crate::RestError::Configuration) if no credentials are set,
165 /// [`RestError::Okx`](crate::RestError::Okx) on a non-zero OKX code, or transport/decode errors.
166 pub async fn set_position_mode(
167 &self,
168 request: &SetPositionModeRequest<'_>,
169 ) -> Result<Vec<SetPositionModeResult>, Error> {
170 self.client.post(SET_POSITION_MODE, request, true).await
171 }
172
173 /// Set whether all or custom assets are used as collateral.
174 ///
175 /// `POST /api/v5/account/set-collateral-assets`. Authenticated.
176 ///
177 /// # Errors
178 ///
179 /// Returns [`RestError::Configuration`](crate::RestError::Configuration) if no credentials are set,
180 /// [`RestError::Okx`](crate::RestError::Okx) on a non-zero OKX code, or transport/decode errors.
181 pub async fn set_collateral_assets(
182 &self,
183 request: &SetCollateralAssetsRequest<'_>,
184 ) -> Result<Vec<SetCollateralAssetsResult>, Error> {
185 self.client.post(SET_COLLATERAL_ASSETS, request, true).await
186 }
187
188 /// Set leverage for an instrument or currency.
189 ///
190 /// `POST /api/v5/account/set-leverage`. Authenticated.
191 ///
192 /// # Errors
193 ///
194 /// Returns [`RestError::Configuration`](crate::RestError::Configuration) if no credentials are set,
195 /// [`RestError::Okx`](crate::RestError::Okx) on a non-zero OKX code, or transport/decode errors.
196 pub async fn set_leverage(
197 &self,
198 request: &SetLeverageRequest<'_>,
199 ) -> Result<Vec<LeverageInfo>, Error> {
200 self.client.post(SET_LEVERAGE, request, true).await
201 }
202
203 /// Retrieve leverage settings.
204 ///
205 /// `GET /api/v5/account/leverage-info`. Authenticated.
206 ///
207 /// # Errors
208 ///
209 /// Returns [`RestError::Configuration`](crate::RestError::Configuration) if no credentials are set,
210 /// [`RestError::Okx`](crate::RestError::Okx) on a non-zero OKX code, or transport/decode errors.
211 pub async fn get_leverage(
212 &self,
213 request: &LeverageRequest<'_>,
214 ) -> Result<Vec<LeverageInfo>, Error> {
215 self.client.get(GET_LEVERAGE, request, true).await
216 }
217
218 /// Estimate account state after adjusting leverage.
219 ///
220 /// `GET /api/v5/account/adjust-leverage-info`. Authenticated.
221 ///
222 /// # Errors
223 ///
224 /// Returns [`RestError::Configuration`](crate::RestError::Configuration) if no credentials are set,
225 /// [`RestError::Okx`](crate::RestError::Okx) on a non-zero OKX code, or transport/decode errors.
226 pub async fn get_adjust_leverage_info(
227 &self,
228 request: &AdjustLeverageInfoRequest<'_>,
229 ) -> Result<Vec<AdjustLeverageInfo>, Error> {
230 self.client.get(ADJUST_LEVERAGE_INFO, request, true).await
231 }
232
233 /// Retrieve maximum tradable size for an instrument.
234 ///
235 /// `GET /api/v5/account/max-size`. Authenticated.
236 ///
237 /// # Errors
238 ///
239 /// Returns [`RestError::Configuration`](crate::RestError::Configuration) if no credentials are set,
240 /// [`RestError::Okx`](crate::RestError::Okx) on a non-zero OKX code, or transport/decode errors.
241 pub async fn get_max_order_size(
242 &self,
243 request: &MaxOrderSizeRequest<'_>,
244 ) -> Result<Vec<MaxOrderSize>, Error> {
245 self.client.get(MAX_ORDER_SIZE, request, true).await
246 }
247
248 /// Retrieve maximum available size for an instrument.
249 ///
250 /// `GET /api/v5/account/max-avail-size`. Authenticated.
251 ///
252 /// # Errors
253 ///
254 /// Returns [`RestError::Configuration`](crate::RestError::Configuration) if no credentials are set,
255 /// [`RestError::Okx`](crate::RestError::Okx) on a non-zero OKX code, or transport/decode errors.
256 pub async fn get_max_avail_size(
257 &self,
258 request: &MaxAvailableSizeRequest<'_>,
259 ) -> Result<Vec<MaxAvailableSize>, Error> {
260 self.client.get(MAX_AVAILABLE_SIZE, request, true).await
261 }
262
263 /// Increase or decrease margin for a position.
264 ///
265 /// `POST /api/v5/account/position/margin-balance`. Authenticated.
266 ///
267 /// # Errors
268 ///
269 /// Returns [`RestError::Configuration`](crate::RestError::Configuration) if no credentials are set,
270 /// [`RestError::Okx`](crate::RestError::Okx) on a non-zero OKX code, or transport/decode errors.
271 pub async fn adjust_margin(
272 &self,
273 request: &AdjustMarginRequest<'_>,
274 ) -> Result<Vec<AdjustMarginResult>, Error> {
275 self.client.post(ADJUST_MARGIN, request, true).await
276 }
277
278 /// Retrieve trade fee rates.
279 ///
280 /// `GET /api/v5/account/trade-fee`. Authenticated.
281 ///
282 /// # Errors
283 ///
284 /// Returns [`RestError::Configuration`](crate::RestError::Configuration) if no credentials are set,
285 /// [`RestError::Okx`](crate::RestError::Okx) on a non-zero OKX code, or transport/decode errors.
286 pub async fn get_fee_rates(
287 &self,
288 request: &FeeRatesRequest<'_>,
289 ) -> Result<Vec<FeeRate>, Error> {
290 self.client.get(FEE_RATES, request, true).await
291 }
292
293 /// Retrieve account-available instruments.
294 ///
295 /// `GET /api/v5/account/instruments`. Authenticated.
296 ///
297 /// # Errors
298 ///
299 /// Returns [`RestError::Configuration`](crate::RestError::Configuration) if no credentials are set,
300 /// [`RestError::Okx`](crate::RestError::Okx) on a non-zero OKX code, or transport/decode errors.
301 pub async fn get_account_instruments(
302 &self,
303 request: &AccountInstrumentsRequest<'_>,
304 ) -> Result<Vec<AccountInstrument>, Error> {
305 self.client.get(ACCOUNT_INSTRUMENTS, request, true).await
306 }
307
308 /// Retrieve the maximum loan amount.
309 ///
310 /// `GET /api/v5/account/max-loan`. Authenticated.
311 ///
312 /// # Errors
313 ///
314 /// Returns [`RestError::Configuration`](crate::RestError::Configuration) if no credentials are set,
315 /// [`RestError::Okx`](crate::RestError::Okx) on a non-zero OKX code, or transport/decode errors.
316 pub async fn get_max_loan(&self, request: &MaxLoanRequest<'_>) -> Result<Vec<MaxLoan>, Error> {
317 self.client.get(MAX_LOAN, request, true).await
318 }
319
320 /// Retrieve interest-accrued records.
321 ///
322 /// `GET /api/v5/account/interest-accrued`. Authenticated.
323 ///
324 /// # Errors
325 ///
326 /// Returns [`RestError::Configuration`](crate::RestError::Configuration) if no credentials are set,
327 /// [`RestError::Okx`](crate::RestError::Okx) on a non-zero OKX code, or transport/decode errors.
328 pub async fn get_interest_accrued(
329 &self,
330 request: &InterestAccruedRequest<'_>,
331 ) -> Result<Vec<InterestAccrued>, Error> {
332 self.client.get(INTEREST_ACCRUED, request, true).await
333 }
334
335 /// Retrieve interest rates.
336 ///
337 /// `GET /api/v5/account/interest-rate`. Authenticated.
338 ///
339 /// # Errors
340 ///
341 /// Returns [`RestError::Configuration`](crate::RestError::Configuration) if no credentials are set,
342 /// [`RestError::Okx`](crate::RestError::Okx) on a non-zero OKX code, or transport/decode errors.
343 pub async fn get_interest_rate(
344 &self,
345 request: BalanceRequest<'_>,
346 ) -> Result<Vec<InterestRate>, Error> {
347 self.client.get(INTEREST_RATE, &request, true).await
348 }
349
350 /// Set the greeks display type.
351 ///
352 /// `POST /api/v5/account/set-greeks`. Authenticated.
353 ///
354 /// # Errors
355 ///
356 /// Returns [`RestError::Configuration`](crate::RestError::Configuration) if no credentials are set,
357 /// [`RestError::Okx`](crate::RestError::Okx) on a non-zero OKX code, or transport/decode errors.
358 pub async fn set_greeks(
359 &self,
360 request: &SetGreeksRequest<'_>,
361 ) -> Result<Vec<SetGreeksResult>, Error> {
362 self.client.post(SET_GREEKS, request, true).await
363 }
364
365 /// Set isolated margin transfer mode.
366 ///
367 /// `POST /api/v5/account/set-isolated-mode`. Authenticated.
368 ///
369 /// # Errors
370 ///
371 /// Returns [`RestError::Configuration`](crate::RestError::Configuration) if no credentials are set,
372 /// [`RestError::Okx`](crate::RestError::Okx) on a non-zero OKX code, or transport/decode errors.
373 pub async fn set_isolated_mode(
374 &self,
375 request: &SetIsolatedModeRequest<'_>,
376 ) -> Result<Vec<SetIsolatedModeResult>, Error> {
377 self.client.post(SET_ISOLATED_MODE, request, true).await
378 }
379
380 /// Retrieve maximum withdrawal amounts.
381 ///
382 /// `GET /api/v5/account/max-withdrawal`. Authenticated.
383 ///
384 /// # Errors
385 ///
386 /// Returns [`RestError::Configuration`](crate::RestError::Configuration) if no credentials are set,
387 /// [`RestError::Okx`](crate::RestError::Okx) on a non-zero OKX code, or transport/decode errors.
388 pub async fn get_max_withdrawal(
389 &self,
390 request: BalanceRequest<'_>,
391 ) -> Result<Vec<MaxWithdrawal>, Error> {
392 self.client.get(MAX_WITHDRAWAL, &request, true).await
393 }
394
395 /// Retrieve borrowing rate and limit information.
396 ///
397 /// `GET /api/v5/account/interest-limits`. Authenticated.
398 ///
399 /// # Errors
400 ///
401 /// Returns [`RestError::Configuration`](crate::RestError::Configuration) if no credentials are set,
402 /// [`RestError::Okx`](crate::RestError::Okx) on a non-zero OKX code, or transport/decode errors.
403 pub async fn get_interest_limits(
404 &self,
405 request: &InterestLimitsRequest<'_>,
406 ) -> Result<Vec<InterestLimit>, Error> {
407 self.client.get(INTEREST_LIMITS, request, true).await
408 }
409
410 /// Calculate simulated margin information.
411 ///
412 /// `POST /api/v5/account/simulated_margin`. Authenticated.
413 ///
414 /// # Errors
415 ///
416 /// Returns [`RestError::Configuration`](crate::RestError::Configuration) if no credentials are set,
417 /// [`RestError::Okx`](crate::RestError::Okx) on a non-zero OKX code, or transport/decode errors.
418 pub async fn get_simulated_margin(
419 &self,
420 request: &SimulatedMarginRequest<'_>,
421 ) -> Result<Vec<SimulatedMargin>, Error> {
422 self.client.post(SIMULATED_MARGIN, request, true).await
423 }
424
425 /// Retrieve greeks.
426 ///
427 /// `GET /api/v5/account/greeks`. Authenticated.
428 ///
429 /// # Errors
430 ///
431 /// Returns [`RestError::Configuration`](crate::RestError::Configuration) if no credentials are set,
432 /// [`RestError::Okx`](crate::RestError::Okx) on a non-zero OKX code, or transport/decode errors.
433 pub async fn get_greeks(&self, request: BalanceRequest<'_>) -> Result<Vec<Greek>, Error> {
434 self.client.get(GREEKS, &request, true).await
435 }
436
437 /// Retrieve position history.
438 ///
439 /// `GET /api/v5/account/positions-history`. Authenticated.
440 ///
441 /// # Errors
442 ///
443 /// Returns [`RestError::Configuration`](crate::RestError::Configuration) if no credentials are set,
444 /// [`RestError::Okx`](crate::RestError::Okx) on a non-zero OKX code, or transport/decode errors.
445 pub async fn get_positions_history(
446 &self,
447 request: &PositionsHistoryRequest<'_>,
448 ) -> Result<Vec<PositionHistory>, Error> {
449 self.client.get(POSITIONS_HISTORY, request, true).await
450 }
451
452 /// Retrieve account position tiers.
453 ///
454 /// `GET /api/v5/account/position-tiers`. Authenticated.
455 ///
456 /// # Errors
457 ///
458 /// Returns [`RestError::Configuration`](crate::RestError::Configuration) if no credentials are set,
459 /// [`RestError::Okx`](crate::RestError::Okx) on a non-zero OKX code, or transport/decode errors.
460 pub async fn get_account_position_tiers(
461 &self,
462 request: &AccountPositionTiersRequest<'_>,
463 ) -> Result<Vec<AccountPositionTier>, Error> {
464 self.client.get(ACCOUNT_POSITION_TIERS, request, true).await
465 }
466
467 /// Retrieve the account risk state.
468 ///
469 /// `GET /api/v5/account/risk-state`. Authenticated.
470 ///
471 /// # Errors
472 ///
473 /// Returns [`RestError::Configuration`](crate::RestError::Configuration) if no credentials are set,
474 /// [`RestError::Okx`](crate::RestError::Okx) on a non-zero OKX code, or transport/decode errors.
475 pub async fn get_risk_state(&self) -> Result<Vec<RiskState>, Error> {
476 self.client.get(RISK_STATE, &EmptyRequest {}, true).await
477 }
478
479 /// Set the spot risk offset amount.
480 ///
481 /// `POST /api/v5/account/set-riskOffset-amt`. Authenticated.
482 ///
483 /// Only applicable to Portfolio Margin Mode.
484 ///
485 /// # Errors
486 ///
487 /// Returns [`RestError::Configuration`](crate::RestError::Configuration) if no credentials are set,
488 /// [`RestError::Okx`](crate::RestError::Okx) on a non-zero OKX code, or transport/decode errors.
489 pub async fn set_risk_offset_amount(
490 &self,
491 request: &SetRiskOffsetAmountRequest<'_>,
492 ) -> Result<Vec<SetRiskOffsetAmountResult>, Error> {
493 self.client
494 .post(SET_RISK_OFFSET_AMOUNT, request, true)
495 .await
496 }
497
498 /// Set account auto-loan mode.
499 ///
500 /// `POST /api/v5/account/set-auto-loan`. Authenticated.
501 ///
502 /// # Errors
503 ///
504 /// Returns [`RestError::Configuration`](crate::RestError::Configuration) if no credentials are set,
505 /// [`RestError::Okx`](crate::RestError::Okx) on a non-zero OKX code, or transport/decode errors.
506 pub async fn set_auto_loan(
507 &self,
508 request: &SetAutoLoanRequest,
509 ) -> Result<Vec<SetAutoLoanResult>, Error> {
510 self.client.post(SET_AUTO_LOAN, request, true).await
511 }
512
513 /// Set the account level.
514 ///
515 /// `POST /api/v5/account/set-account-level`. Authenticated.
516 ///
517 /// # Errors
518 ///
519 /// Returns [`RestError::Configuration`](crate::RestError::Configuration) if no credentials are set,
520 /// [`RestError::Okx`](crate::RestError::Okx) on a non-zero OKX code, or transport/decode errors.
521 pub async fn set_account_level(
522 &self,
523 request: &SetAccountLevelRequest<'_>,
524 ) -> Result<Vec<SetAccountLevelResult>, Error> {
525 self.client.post(SET_ACCOUNT_LEVEL, request, true).await
526 }
527
528 /// Activate option trading.
529 ///
530 /// `POST /api/v5/account/activate-option`. Authenticated.
531 ///
532 /// # Errors
533 ///
534 /// Returns [`RestError::Configuration`](crate::RestError::Configuration) if no credentials are set,
535 /// [`RestError::Okx`](crate::RestError::Okx) on a non-zero OKX code, or transport/decode errors.
536 pub async fn activate_option(&self) -> Result<Vec<ActivateOptionResult>, Error> {
537 self.client
538 .post(ACTIVATE_OPTION, &EmptyRequest {}, true)
539 .await
540 }
541
542 /// Build simulated positions and equity.
543 ///
544 /// `POST /api/v5/account/position-builder`. Authenticated.
545 ///
546 /// # Errors
547 ///
548 /// Returns [`RestError::Configuration`](crate::RestError::Configuration) if no credentials are set,
549 /// [`RestError::Okx`](crate::RestError::Okx) on a non-zero OKX code, or transport/decode errors.
550 pub async fn position_builder(
551 &self,
552 request: &PositionBuilderRequest<'_>,
553 ) -> Result<Vec<PositionBuilderResult>, Error> {
554 self.client.post(POSITION_BUILDER, request, true).await
555 }
556
557 /// Manually borrow or repay spot liabilities.
558 ///
559 /// `POST /api/v5/account/spot-manual-borrow-repay`. Authenticated.
560 ///
561 /// # Errors
562 ///
563 /// Returns [`RestError::Configuration`](crate::RestError::Configuration) if no credentials are set,
564 /// [`RestError::Okx`](crate::RestError::Okx) on a non-zero OKX code, or transport/decode errors.
565 pub async fn spot_manual_borrow_repay(
566 &self,
567 request: &SpotManualBorrowRepayRequest<'_>,
568 ) -> Result<Vec<SpotBorrowRepayResult>, Error> {
569 self.client
570 .post(SPOT_MANUAL_BORROW_REPAY, request, true)
571 .await
572 }
573
574 /// Set automatic repayment for spot borrow/repay.
575 ///
576 /// `POST /api/v5/account/set-auto-repay`. Authenticated.
577 ///
578 /// # Errors
579 ///
580 /// Returns [`RestError::Configuration`](crate::RestError::Configuration) if no credentials are set,
581 /// [`RestError::Okx`](crate::RestError::Okx) on a non-zero OKX code, or transport/decode errors.
582 pub async fn set_auto_repay(
583 &self,
584 request: &SetAutoRepayRequest,
585 ) -> Result<Vec<SetAutoRepayResult>, Error> {
586 self.client.post(SET_AUTO_REPAY, request, true).await
587 }
588
589 /// Retrieve spot borrow/repay history.
590 ///
591 /// `GET /api/v5/account/spot-borrow-repay-history`. Authenticated.
592 ///
593 /// # Errors
594 ///
595 /// Returns [`RestError::Configuration`](crate::RestError::Configuration) if no credentials are set,
596 /// [`RestError::Okx`](crate::RestError::Okx) on a non-zero OKX code, or transport/decode errors.
597 pub async fn get_spot_borrow_repay_history(
598 &self,
599 request: &SpotBorrowRepayHistoryRequest<'_>,
600 ) -> Result<Vec<SpotBorrowRepayHistory>, Error> {
601 self.client
602 .get(SPOT_BORROW_REPAY_HISTORY, request, true)
603 .await
604 }
605
606 /// Set automatic earn for the account.
607 ///
608 /// `POST /api/v5/account/set-auto-earn`. Authenticated.
609 ///
610 /// # Errors
611 ///
612 /// Returns [`RestError::Configuration`](crate::RestError::Configuration) if no credentials are set,
613 /// [`RestError::Okx`](crate::RestError::Okx) on a non-zero OKX code, or transport/decode errors.
614 pub async fn set_auto_earn(
615 &self,
616 request: &SetAutoEarnRequest<'_>,
617 ) -> Result<Vec<SetAutoEarnResult>, Error> {
618 self.client.post(SET_AUTO_EARN, request, true).await
619 }
620}