Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[coinbase-pro] Updating/Adding support for some AccountService and TradeService endpoints. #4763

Open
wants to merge 61 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
30ca446
[CoinbasePro] Updating/Adding support for specified AccountService en…
makarid Aug 16, 2023
2fd927f
Merge branch 'develop' of https://github.com/makarid/XChange into coi…
makarid Aug 16, 2023
5efd92b
[CoinbasePro] Minor fixes and clean ups. Coinbase Pro API has been up…
makarid Aug 16, 2023
1b4b052
[CoinbasePro] Minor fixes
makarid Aug 16, 2023
f903b01
[CoinbasePro-stream] Adding feeAmount for userTrades and adding suppo…
makarid Aug 17, 2023
7c867e1
[CoinbasePro] Add all fields for Coinbase currency and product endpoi…
makarid Aug 21, 2023
1933af1
[CoinbasePro] Add all response params and query params for fills endp…
makarid Aug 21, 2023
51b7683
[CoinbasePro] Clean up
makarid Aug 21, 2023
0499957
[CoinbasePro] Fix some checks after changing variable type from Strin…
makarid Aug 21, 2023
6074e44
[CoinbasePro] Update test after changing type String to Enum
makarid Aug 21, 2023
ee2a32a
[CoinbasePro] Renaming a function
makarid Aug 21, 2023
0bd85b1
[CoinbasePro] CleanUps
makarid Aug 21, 2023
43137b4
[CoinbasePro] Add getCurrencies and getInstruments functions on Coinb…
makarid Aug 22, 2023
0b674f5
[CoinbasePro] Adding support for restProxyFactory in CoinbasePro. Bec…
makarid Aug 23, 2023
e586461
[CoinbasePro] Adding support for restProxyFactory in CoinbasePro. Bec…
makarid Aug 23, 2023
bc3a6c2
[CoinbasePro] Adding more checks in some tests. Move getWebsocketAuth…
makarid Aug 27, 2023
efb50fd
[CoinbasePro] Adding more checks in some tests.
makarid Aug 27, 2023
617435b
[CoinbasePro] Adding new Interface of TradeHistoryParamAccountId
makarid Aug 31, 2023
40123bf
[CoinbasePro] Adding new Interface of TradeHistoryParamAccountId
makarid Aug 31, 2023
d7d5246
Bybit v5
damiano1996 Sep 10, 2023
e66eb5c
linear/spot/option
damiano1996 Sep 11, 2023
5af0087
all coins wallet
damiano1996 Sep 11, 2023
21e2d6b
fee rates
damiano1996 Sep 11, 2023
57e8fe2
end-to-end testing
damiano1996 Sep 12, 2023
a465850
updating authentication method
damiano1996 Sep 13, 2023
8da036e
fixing orders
damiano1996 Sep 13, 2023
f6ed631
[Core] Update FundingRecord to use Lombok
makarid Sep 19, 2023
081dc2d
[Core] Adding more implementations to core AccountService and MarketD…
makarid Sep 19, 2023
9b3bda4
Merge branch 'add-core-functions' into coinbase-pro
makarid Sep 19, 2023
b67a75d
[Coinbase pro] Implement the new MarketDataService functions
makarid Sep 19, 2023
5a4218d
Merge pull request #118 from damiano1996/feature/bybit-v5
makarid Sep 19, 2023
f69d8f3
[Core] Change return class for 2 new functions on AccountService
makarid Sep 21, 2023
1579c80
Merge branch 'add-core-functions' of https://github.com/makarid/XChan…
makarid Sep 21, 2023
9e166a9
[Bybit] Fix issue when secretKey was null, it will not instantiate ex…
makarid Sep 21, 2023
9f445a7
[Bybit] Adding support for all instruments metaData (spot,perpetuals,…
makarid Sep 24, 2023
0dba095
[Bybit] CleanUps
makarid Sep 24, 2023
a826921
[Bybit] Add support for tradeHistory, accountInfo and currencies
makarid Sep 26, 2023
216a97b
[Bybit] Add support for tradeHistory, accountInfo and currencies
makarid Sep 26, 2023
cd7ed8e
[Bybit] Add support for tradeHistory, accountInfo and currencies
makarid Sep 26, 2023
d52ea87
[Core] Use FundingRecord builder instead of constructor
makarid Sep 26, 2023
a3bdbd8
Merge branch 'add-core-functions' into bybit-implementation
makarid Sep 26, 2023
48b1667
[Core] Use only FundingRecord builder and create a new class Internal…
makarid Sep 26, 2023
50aa03c
Merge branch 'add-core-functions' into bybit-implementation
makarid Sep 26, 2023
1d4e40f
[Core] Adding support for more Bybit endpoints
makarid Sep 26, 2023
317b2d8
[Core] Adding support for more Bybit endpoints
makarid Sep 26, 2023
dcc714d
[Core] Minor cleanUps
makarid Sep 26, 2023
5abcb3a
[Core] Adding more authenticated endpoints
makarid Sep 26, 2023
6dfe452
[Bybit] Adding pagination support
makarid Sep 26, 2023
9d21ae1
[Core] Delete mistaken code
makarid Sep 27, 2023
52fdfa9
[Bybit, Core] Delete InternalFundingRecord and use only FundingRecord
makarid Sep 28, 2023
77c45af
[Bybit, Core] Minor CleanUps
makarid Sep 28, 2023
414fb2e
[Bybit] Adding the last endpoints and tests for the implementation.
makarid Sep 28, 2023
09804ef
[Bybit] Fixing issues and refactoring
makarid Sep 29, 2023
8a425da
[Bybit] Fixing withdraw status issue.
makarid Oct 6, 2023
2eb43ac
[Bybit] Adding withrawHistory test
makarid Oct 6, 2023
9e19e7b
[Bybit] Adding proxy support
makarid Oct 8, 2023
601f2be
[Bybit] Make call only to UNIFIED accountType
makarid Oct 9, 2023
a30d8df
[Bybit] Make call only to UNIFIED accountType
makarid Oct 9, 2023
4a65d77
Merge branch 'bybit-implementation' into coinbase-pro
makarid Oct 11, 2023
8f218eb
[CoinbasePro] Update implementation with new AccounService functions.
makarid Oct 11, 2023
dee239c
[CoinbasePro] Fix FundingRecord amount value to never be negative
makarid Oct 19, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@
<module>xchange-stream-service-pubnub</module>
<module>xchange-stream-coincheck</module>
<module>xchange-stream-krakenfutures</module>
<module>xchange-stream-bybit</module>
</modules>

<ciManagement>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,33 +172,25 @@ public static Date convert(String s) {
}

public static FundingRecord adaptDeposit(BiboxDeposit d) {
return new FundingRecord(
d.to,
d.getCreatedAt(),
Currency.getInstance(d.coinSymbol),
d.amount,
null,
null,
Type.DEPOSIT,
convertStatus(d.status),
null,
null,
null);
return FundingRecord.builder()
.address(d.to)
.date(d.getCreatedAt())
.currency(Currency.getInstance(d.coinSymbol))
.amount(d.amount)
.type(Type.DEPOSIT)
.status(convertStatus(d.status))
.build();
}

public static FundingRecord adaptDeposit(BiboxWithdrawal w) {
return new FundingRecord(
w.toAddress,
w.getCreatedAt(),
Currency.getInstance(w.coinSymbol),
w.amountReal,
null,
null,
Type.WITHDRAWAL,
convertStatus(w.status),
null,
null,
null);
return FundingRecord.builder()
.address(w.toAddress)
.date(w.getCreatedAt())
.currency(Currency.getInstance(w.coinSymbol))
.amount(w.amountReal)
.type(Type.WITHDRAWAL)
.status(convertStatus(w.status))
.build();
}

public static Status convertStatus(int status) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -288,57 +288,49 @@ public List<FundingRecord> getFundingHistory(TradeHistoryParams params) throws I
super.withdrawHistory(asset, startTime, endTime)
.forEach(
w -> result.add(
new FundingRecord(
w.getAddress(),
w.getAddressTag(),
BinanceAdapters.toDate(w.getApplyTime()),
Currency.getInstance(w.getCoin()),
w.getAmount(),
w.getId(),
w.getTxId(),
Type.WITHDRAWAL,
withdrawStatus(w.getStatus()),
null,
w.getTransactionFee(),
null)));
FundingRecord.builder()
.address(w.getAddress())
.addressTag(w.getAddressTag())
.date(BinanceAdapters.toDate(w.getApplyTime()))
.currency(Currency.getInstance(w.getCoin()))
.amount(w.getAmount())
.internalId(w.getId())
.blockchainTransactionHash(w.getTxId())
.type(Type.WITHDRAWAL)
.status(withdrawStatus(w.getStatus()))
.fee(w.getTransactionFee())
.build()));
}

if (deposits) {
super.depositHistory(asset, startTime, endTime)
.forEach(
d -> result.add(
new FundingRecord(
d.getAddress(),
d.getAddressTag(),
new Date(d.getInsertTime()),
Currency.getInstance(d.getCoin()),
d.getAmount(),
null,
d.getTxId(),
Type.DEPOSIT,
depositStatus(d.getStatus()),
null,
null,
null)));
FundingRecord.builder()
.address(d.getAddress())
.addressTag(d.getAddressTag())
.date(new Date(d.getInsertTime()))
.currency(Currency.getInstance(d.getCoin()))
.amount(d.getAmount())
.blockchainTransactionHash(d.getTxId())
.type(Type.DEPOSIT)
.status(depositStatus(d.getStatus()))
.build()));
}

if (otherInflow) {
super.getAssetDividend(asset, startTime, endTime)
.forEach(
a -> result.add(
new FundingRecord(
null,
null,
new Date(a.getDivTime()),
Currency.getInstance(a.getAsset()),
a.getAmount(),
null,
String.valueOf(a.getTranId()),
Type.OTHER_INFLOW,
Status.COMPLETE,
null,
null,
a.getEnInfo())));
FundingRecord.builder()
.date(new Date(a.getDivTime()))
.currency(Currency.getInstance(a.getAsset()))
.amount(a.getAmount())
.blockchainTransactionHash(String.valueOf(a.getTranId()))
.type(Type.OTHER_INFLOW)
.status(Status.COMPLETE)
.description(a.getEnInfo())
.build()));
}

final String finalEmail = email;
Expand All @@ -347,13 +339,13 @@ public List<FundingRecord> getFundingHistory(TradeHistoryParams params) throws I
super.getTransferHistory(email, startTime, endTime, page, limit)
.forEach(
a -> result.add(
new FundingRecord.Builder()
.setAddress(finalEmail)
.setDate(new Date(a.getTime()))
.setCurrency(Currency.getInstance(a.getAsset()))
.setAmount(a.getQty())
.setType(Type.INTERNAL_WITHDRAWAL)
.setStatus(transferHistoryStatus(a.getStatus()))
FundingRecord.builder()
.address(finalEmail)
.date(new Date(a.getTime()))
.currency(Currency.getInstance(a.getAsset()))
.amount(a.getQty())
.type(Type.INTERNAL_WITHDRAWAL)
.status(transferHistoryStatus(a.getStatus()))
.build()));
}

Expand All @@ -363,16 +355,16 @@ public List<FundingRecord> getFundingHistory(TradeHistoryParams params) throws I
super.getSubUserHistory(asset, type, startTime, endTime, limit)
.forEach(
a -> result.add(
new FundingRecord.Builder()
.setAddress(a.getEmail())
.setDate(new Date(a.getTime()))
.setCurrency(Currency.getInstance(a.getAsset()))
.setAmount(a.getQty())
.setType(
FundingRecord.builder()
.address(a.getEmail())
.date(new Date(a.getTime()))
.currency(Currency.getInstance(a.getAsset()))
.amount(a.getQty())
.type(
a.getType().equals(1)
? Type.INTERNAL_DEPOSIT
: Type.INTERNAL_WITHDRAWAL)
.setStatus(Status.COMPLETE)
.status(Status.COMPLETE)
.build()));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.TimeZone;
Expand All @@ -13,6 +14,7 @@
import org.knowm.xchange.bitbay.dto.acount.BitbayAccountInfoResponse;
import org.knowm.xchange.currency.Currency;
import org.knowm.xchange.dto.account.FundingRecord;
import org.knowm.xchange.dto.account.FundingRecord.Status;
import org.knowm.xchange.exceptions.ExchangeException;

/** @author Z. Dolezal */
Expand Down Expand Up @@ -103,18 +105,15 @@ else if (map.get("operation_type").toString().equals("-transfer"))
else continue;

res.add(
new FundingRecord(
null,
dateFormat.parse(map.get("time").toString()),
Currency.getInstance(map.get("currency").toString()),
new BigDecimal(map.get("amount").toString()),
map.get("id").toString(),
null,
type,
FundingRecord.Status.COMPLETE,
null,
null,
map.get("comment").toString()));
FundingRecord.builder()
.date(dateFormat.parse(map.get("time").toString()))
.currency(Currency.getInstance(map.get("currency").toString()))
.amount(new BigDecimal(map.get("amount").toString()))
.internalId(map.get("id").toString())
.type(type)
.status(Status.COMPLETE)
.description(map.get("comment").toString())
.build());
} catch (ParseException e) {
throw new IllegalStateException("Should not happen", e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,17 +86,17 @@ private static FundingRecord adaptFundingRecord(BitbayBalanceHistoryEntry item)
? FundingRecord.Type.WITHDRAWAL
: FundingRecord.Type.DEPOSIT;

return new FundingRecord.Builder()
.setType(type)
.setBlockchainTransactionHash(null) // not available in the API yet
.setAddress(null) // not available in the API yet
.setAmount(item.getValue().abs())
.setCurrency(Currency.getInstance(item.getBalance().getCurrency()))
.setDate(DateUtils.fromMillisUtc(item.getTime()))
.setInternalId(item.getHistoryId().toString())
.setFee(null) // not available in the API yet
.setStatus(FundingRecord.Status.COMPLETE)
.setBalance(item.getFundsAfter().getTotal())
return FundingRecord.builder()
.type(type)
.blockchainTransactionHash(null) // not available in the API yet
.address(null) // not available in the API yet
.amount(item.getValue().abs())
.currency(Currency.getInstance(item.getBalance().getCurrency()))
.date(DateUtils.fromMillisUtc(item.getTime()))
.internalId(item.getHistoryId().toString())
.fee(null) // not available in the API yet
.status(FundingRecord.Status.COMPLETE)
.balance(item.getFundsAfter().getTotal())
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -284,29 +284,29 @@ public static List<FundingRecord> adaptFundingHistory(
ledger -> {
FundingRecord.Type type = adaptFundingRecordType(ledger.getType());

FundingRecord.Builder builder =
new FundingRecord.Builder()
.setType(type)
.setDate(ledger.getDate())
.setCurrency(currency)
.setAmount(ledger.getCashflow().abs())
.setBalance(ledger.getBalance())
.setStatus(FundingRecord.Status.COMPLETE)
.setDescription(ledger.getType().getValue());
FundingRecord.FundingRecordBuilder builder =
FundingRecord.builder()
.type(type)
.date(ledger.getDate())
.currency(currency)
.amount(ledger.getCashflow().abs())
.balance(ledger.getBalance())
.status(FundingRecord.Status.COMPLETE)
.description(ledger.getType().getValue());

if (INPAYMENT == ledger.getType() || PAYOUT == ledger.getType()) {
builder.setBlockchainTransactionHash(ledger.getReference());
builder.blockchainTransactionHash(ledger.getReference());
} else {
builder.setInternalId(ledger.getReference());
builder.internalId(ledger.getReference());
}

if (!leaveFeesSeperate && PAYOUT == ledger.getType()) {
Optional<BitcoindeAccountLedger> feeLedger =
findFeeLedger(ledger.getReference(), feeLedgers);
if (feeLedger.isPresent()) {
BigDecimal fee = feeLedger.get().getCashflow().abs();
builder.setAmount(ledger.getCashflow().abs().add(fee));
builder.setFee(fee);
builder.amount(ledger.getCashflow().abs().add(fee));
builder.fee(fee);

/*
* There can be multiple {@code PAYOUTS}s with the same reference/ blockchain
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@
import org.knowm.xchange.dto.account.Balance;
import org.knowm.xchange.dto.account.Fee;
import org.knowm.xchange.dto.account.FundingRecord;
import org.knowm.xchange.dto.account.FundingRecord.Status;
import org.knowm.xchange.dto.account.FundingRecord.Type;
import org.knowm.xchange.dto.account.Wallet;
import org.knowm.xchange.dto.marketdata.OrderBook;
import org.knowm.xchange.dto.marketdata.Ticker;
Expand Down Expand Up @@ -805,19 +807,17 @@ public static List<FundingRecord> adaptFundingHistory(List<Movement> movementHis
}

FundingRecord fundingRecordEntry =
new FundingRecord(
movement.getDestinationAddress(),
null,
movement.getMtsUpdated(),
currency,
amount,
movement.getId(),
movement.getTransactionId(),
type,
status,
null,
fee,
null);
FundingRecord.builder()
.address(movement.getDestinationAddress())
.date(movement.getMtsStarted())
.currency(currency)
.amount(amount)
.internalId(movement.getId())
.blockchainTransactionHash(movement.getTransactionId())
.type(type)
.status(status)
.fee(fee)
.build();

fundingRecords.add(fundingRecordEntry);
}
Expand Down Expand Up @@ -868,18 +868,17 @@ and sometimes like this (with the address in it as well as the txn hash):
}

FundingRecord fundingRecordEntry =
new FundingRecord(
address,
responseEntry.getTimestamp(),
currency,
responseEntry.getAmount(),
String.valueOf(responseEntry.getId()),
txnId,
responseEntry.getType(),
status,
null,
null,
description);
FundingRecord.builder()
.address(address)
.date(responseEntry.getTimestamp())
.currency(currency)
.amount(responseEntry.getAmount())
.internalId(String.valueOf(responseEntry.getId()))
.blockchainTransactionHash(txnId)
.type(responseEntry.getType())
.status(status)
.description(description)
.build();

fundingRecords.add(fundingRecordEntry);
}
Expand Down
Loading
Loading