cmd/exchange_template, exchanges: Update templates and propogate to exchanges (#1777)

* Added TimeInForce type and updated related files

* Linter issue fix and minor coinbasepro type update

* Bitrex consts update

* added unit test and minor changes in bittrex

* Unit tests update

* Fix minor linter issues

* Update TestStringToTimeInForce unit test

* Exchange test template change

* A different approach

* fix conflict with gateio timeInForce

* minor exchange template update

* Minor fix to test_files template

* Update order tests

* Complete updating the order unit tests

* Updating exchange wrapper and test template files

* update kucoin and deribit wrapper to match the time in force change

* minor comment update

* fix time-in-force related test errors

* linter issue fix

* ADD_NEW_EXCHANGE documentation update

* time in force constants, functions and unit tests update

* shift tif policies to TimeInForce

* Update time-in-force, related functions, and unit tests

* fix linter issue and time-in-force processing

* added a good till crossing tif value

* order type fix and fix related tim-in-force entries

* update time-in-force unmarshaling and unit test

* consistency guideline added

* fix time-in-force error in gateio

* linter issue fix

* update based on review comments

* add unit test and fix missing issues

* minor fix and added benchmark unit test

* change GTT to GTC for limit

* fix linter issue

* added time-in-force value to place order param

* fix minor issues based on review comment and move tif code to separate files

* update on exchanges linked to time-in-force

* resolve missing review comments

* minor linter issues fix

* added time-in-force handler and update timeInForce parametered endpoint

* minor fixes based on review

* nits fix

* update based on review

* linter fix

* rm getTimeInForce func and minor change to time-in-force

* minor change

* update based on review comments

* wrappers and time-in-force calling approach

* minor change

* update gateio string to timeInForce conversion and unit test

* update exchange template

* update wrapper template file

* policy comments, and template files update

* rename all exchange types name to Exchange

* update on template files and template generation

* templates and generation code and other updates

* linter issue fix

* added subscriptions and websocket templates

* update ADD_NEW_EXCHANGE.md with recent binance functions and implementations

* rename template files and update unit tests

* minor template and unit test fix

* rename templates and fix on unit tests

* update on template files and documentation

* removed unnecessary tag fix and update templates

* fix Add_NEW_EXCHANGE.md doc file

* formatting, comments, and error checks update on template files

* rename exchange receivers to e and ex for consistency

* rename unit test exchange receiver and minor updates

* linter issues fix

* fix deribit issue and minor style update

* fix test issues caused by receiver change

* raname local variables exchange declaration variables

* update templates comments

* update templates and related comments

* renamed ex to e

* update template comments

* toggle WS to false to improve coverage

* template comments update

* added test coverage to Ws enabled and minor changes

---------

Co-authored-by: Samuel Reid <43227667+cranktakular@users.noreply.github.com>
This commit is contained in:
Samuael A.
2025-07-17 03:46:36 +03:00
committed by GitHub
parent 485397a0c7
commit 3f534a15f1
163 changed files with 20453 additions and 20313 deletions

View File

@@ -42,82 +42,82 @@ const (
lowVolume
)
// Bitflyer is the overarching type across this package
type Bitflyer struct {
// Exchange implements exchange.IBotExchange and contains additional specific api methods for interacting with Bitflyer
type Exchange struct {
exchange.Base
}
// GetLatestBlockCA returns the latest block information from bitflyer chain
// analysis system
func (b *Bitflyer) GetLatestBlockCA(ctx context.Context) (ChainAnalysisBlock, error) {
func (e *Exchange) GetLatestBlockCA(ctx context.Context) (ChainAnalysisBlock, error) {
var resp ChainAnalysisBlock
return resp, b.SendHTTPRequest(ctx, exchange.ChainAnalysis, latestBlock, &resp)
return resp, e.SendHTTPRequest(ctx, exchange.ChainAnalysis, latestBlock, &resp)
}
// GetBlockCA returns block information by blockhash from bitflyer chain
// analysis system
func (b *Bitflyer) GetBlockCA(ctx context.Context, blockhash string) (ChainAnalysisBlock, error) {
func (e *Exchange) GetBlockCA(ctx context.Context, blockhash string) (ChainAnalysisBlock, error) {
var resp ChainAnalysisBlock
return resp, b.SendHTTPRequest(ctx, exchange.ChainAnalysis, blockByBlockHash+blockhash, &resp)
return resp, e.SendHTTPRequest(ctx, exchange.ChainAnalysis, blockByBlockHash+blockhash, &resp)
}
// GetBlockbyHeightCA returns the block information by height from bitflyer chain
// analysis system
func (b *Bitflyer) GetBlockbyHeightCA(ctx context.Context, height int64) (ChainAnalysisBlock, error) {
func (e *Exchange) GetBlockbyHeightCA(ctx context.Context, height int64) (ChainAnalysisBlock, error) {
var resp ChainAnalysisBlock
return resp, b.SendHTTPRequest(ctx, exchange.ChainAnalysis, blockByBlockHeight+strconv.FormatInt(height, 10), &resp)
return resp, e.SendHTTPRequest(ctx, exchange.ChainAnalysis, blockByBlockHeight+strconv.FormatInt(height, 10), &resp)
}
// GetTransactionByHashCA returns transaction information by txHash from
// bitflyer chain analysis system
func (b *Bitflyer) GetTransactionByHashCA(ctx context.Context, txHash string) (ChainAnalysisTransaction, error) {
func (e *Exchange) GetTransactionByHashCA(ctx context.Context, txHash string) (ChainAnalysisTransaction, error) {
var resp ChainAnalysisTransaction
return resp, b.SendHTTPRequest(ctx, exchange.ChainAnalysis, transaction+txHash, &resp)
return resp, e.SendHTTPRequest(ctx, exchange.ChainAnalysis, transaction+txHash, &resp)
}
// GetAddressInfoCA returns balance information for address by addressln string
// from bitflyer chain analysis system
func (b *Bitflyer) GetAddressInfoCA(ctx context.Context, addressln string) (ChainAnalysisAddress, error) {
func (e *Exchange) GetAddressInfoCA(ctx context.Context, addressln string) (ChainAnalysisAddress, error) {
var resp ChainAnalysisAddress
return resp, b.SendHTTPRequest(ctx, exchange.ChainAnalysis, address+addressln, &resp)
return resp, e.SendHTTPRequest(ctx, exchange.ChainAnalysis, address+addressln, &resp)
}
// GetMarkets returns market information
func (b *Bitflyer) GetMarkets(ctx context.Context) ([]MarketInfo, error) {
func (e *Exchange) GetMarkets(ctx context.Context) ([]MarketInfo, error) {
var resp []MarketInfo
return resp, b.SendHTTPRequest(ctx, exchange.RestSpot, pubGetMarkets, &resp)
return resp, e.SendHTTPRequest(ctx, exchange.RestSpot, pubGetMarkets, &resp)
}
// GetOrderBook returns market orderbook depth
func (b *Bitflyer) GetOrderBook(ctx context.Context, symbol string) (Orderbook, error) {
func (e *Exchange) GetOrderBook(ctx context.Context, symbol string) (Orderbook, error) {
var resp Orderbook
v := url.Values{}
v.Set("product_code", symbol)
return resp, b.SendHTTPRequest(ctx, exchange.RestSpot, pubGetBoard+"?"+v.Encode(), &resp)
return resp, e.SendHTTPRequest(ctx, exchange.RestSpot, pubGetBoard+"?"+v.Encode(), &resp)
}
// GetTicker returns ticker information
func (b *Bitflyer) GetTicker(ctx context.Context, symbol string) (Ticker, error) {
func (e *Exchange) GetTicker(ctx context.Context, symbol string) (Ticker, error) {
var resp Ticker
v := url.Values{}
v.Set("product_code", symbol)
return resp, b.SendHTTPRequest(ctx, exchange.RestSpot, pubGetTicker+"?"+v.Encode(), &resp)
return resp, e.SendHTTPRequest(ctx, exchange.RestSpot, pubGetTicker+"?"+v.Encode(), &resp)
}
// GetExecutionHistory returns past trades that were executed on the market
func (b *Bitflyer) GetExecutionHistory(ctx context.Context, symbol string) ([]ExecutedTrade, error) {
func (e *Exchange) GetExecutionHistory(ctx context.Context, symbol string) ([]ExecutedTrade, error) {
var resp []ExecutedTrade
v := url.Values{}
v.Set("product_code", symbol)
return resp, b.SendHTTPRequest(ctx, exchange.RestSpot, pubGetExecutionHistory+"?"+v.Encode(), &resp)
return resp, e.SendHTTPRequest(ctx, exchange.RestSpot, pubGetExecutionHistory+"?"+v.Encode(), &resp)
}
// GetExchangeStatus returns exchange status information
func (b *Bitflyer) GetExchangeStatus(ctx context.Context) (string, error) {
func (e *Exchange) GetExchangeStatus(ctx context.Context) (string, error) {
resp := make(map[string]string)
err := b.SendHTTPRequest(ctx, exchange.RestSpot, pubGetHealth, &resp)
err := e.SendHTTPRequest(ctx, exchange.RestSpot, pubGetHealth, &resp)
if err != nil {
return "", err
}
@@ -138,132 +138,132 @@ func (b *Bitflyer) GetExchangeStatus(ctx context.Context) (string, error) {
// GetChats returns trollbox chat log
// Note: returns vary from instant to infinity
func (b *Bitflyer) GetChats(ctx context.Context, fromDate string) ([]ChatLog, error) {
func (e *Exchange) GetChats(ctx context.Context, fromDate string) ([]ChatLog, error) {
var resp []ChatLog
v := url.Values{}
v.Set("from_date", fromDate)
return resp, b.SendHTTPRequest(ctx, exchange.RestSpot, pubGetChats+"?"+v.Encode(), &resp)
return resp, e.SendHTTPRequest(ctx, exchange.RestSpot, pubGetChats+"?"+v.Encode(), &resp)
}
// GetPermissions returns current permissions for associated with your API
// keys
func (b *Bitflyer) GetPermissions() {
func (e *Exchange) GetPermissions() {
// Needs to be updated
}
// GetAccountBalance returnsthe full list of account funds
func (b *Bitflyer) GetAccountBalance() {
func (e *Exchange) GetAccountBalance() {
// Needs to be updated
}
// GetMarginStatus returns current margin status
func (b *Bitflyer) GetMarginStatus() {
func (e *Exchange) GetMarginStatus() {
// Needs to be updated
}
// GetCollateralAccounts returns a full list of collateralised accounts
func (b *Bitflyer) GetCollateralAccounts() {
func (e *Exchange) GetCollateralAccounts() {
// Needs to be updated
}
// GetCryptoDepositAddress returns an address for cryptocurrency deposits
func (b *Bitflyer) GetCryptoDepositAddress() {
func (e *Exchange) GetCryptoDepositAddress() {
// Needs to be updated
}
// GetDepositHistory returns a full history of deposits
func (b *Bitflyer) GetDepositHistory() {
func (e *Exchange) GetDepositHistory() {
// Needs to be updated
}
// GetTransactionHistory returns a full history of transactions
func (b *Bitflyer) GetTransactionHistory() {
func (e *Exchange) GetTransactionHistory() {
// Needs to be updated
}
// GetBankAccSummary returns a full list of bank accounts assoc. with your keys
func (b *Bitflyer) GetBankAccSummary() {
func (e *Exchange) GetBankAccSummary() {
// Needs to be updated
}
// GetCashDeposits returns a full list of cash deposits to the exchange
func (b *Bitflyer) GetCashDeposits() {
func (e *Exchange) GetCashDeposits() {
// Needs to be updated
}
// WithdrawFunds withdraws funds to a certain bank
func (b *Bitflyer) WithdrawFunds() {
func (e *Exchange) WithdrawFunds() {
// Needs to be updated
}
// GetDepositCancellationHistory returns the cancellation history of deposits
func (b *Bitflyer) GetDepositCancellationHistory() {
func (e *Exchange) GetDepositCancellationHistory() {
// Needs to be updated
}
// SendOrder creates new order
func (b *Bitflyer) SendOrder() {
func (e *Exchange) SendOrder() {
// Needs to be updated
}
// CancelExistingOrder cancels an order
func (b *Bitflyer) CancelExistingOrder() {
func (e *Exchange) CancelExistingOrder() {
// Needs to be updated
}
// SendParentOrder sends a special order
func (b *Bitflyer) SendParentOrder() {
func (e *Exchange) SendParentOrder() {
// Needs to be updated
}
// CancelParentOrder cancels a special order
func (b *Bitflyer) CancelParentOrder() {
func (e *Exchange) CancelParentOrder() {
// Needs to be updated
}
// CancelAllExistingOrders cancels all orders on the exchange
func (b *Bitflyer) CancelAllExistingOrders() {
func (e *Exchange) CancelAllExistingOrders() {
// Needs to be updated
}
// GetAllOrders returns a list of all orders
func (b *Bitflyer) GetAllOrders() {
func (e *Exchange) GetAllOrders() {
// Needs to be updated
}
// GetParentOrders returns a list of all parent orders
func (b *Bitflyer) GetParentOrders() {
func (e *Exchange) GetParentOrders() {
// Needs to be updated
}
// GetParentOrderDetails returns a detailing of a parent order
func (b *Bitflyer) GetParentOrderDetails() {
func (e *Exchange) GetParentOrderDetails() {
// Needs to be updated
}
// GetExecutions returns execution details
func (b *Bitflyer) GetExecutions() {
func (e *Exchange) GetExecutions() {
// Needs to be updated
}
// GetOpenInterestData returns a summary of open interest
func (b *Bitflyer) GetOpenInterestData() {
func (e *Exchange) GetOpenInterestData() {
// Needs to be updated
}
// GetMarginChange returns collateral history
func (b *Bitflyer) GetMarginChange() {
func (e *Exchange) GetMarginChange() {
// Needs to be updated
}
// GetTradingCommission returns trading commission
func (b *Bitflyer) GetTradingCommission() {
func (e *Exchange) GetTradingCommission() {
// Needs to be updated
}
// SendHTTPRequest sends an unauthenticated request
func (b *Bitflyer) SendHTTPRequest(ctx context.Context, ep exchange.URL, path string, result any) error {
endpoint, err := b.API.Endpoints.GetURL(ep)
func (e *Exchange) SendHTTPRequest(ctx context.Context, ep exchange.URL, path string, result any) error {
endpoint, err := e.API.Endpoints.GetURL(ep)
if err != nil {
return err
}
@@ -271,11 +271,11 @@ func (b *Bitflyer) SendHTTPRequest(ctx context.Context, ep exchange.URL, path st
Method: http.MethodGet,
Path: endpoint + path,
Result: result,
Verbose: b.Verbose,
HTTPDebugging: b.HTTPDebugging,
HTTPRecording: b.HTTPRecording,
Verbose: e.Verbose,
HTTPDebugging: e.HTTPDebugging,
HTTPRecording: e.HTTPRecording,
}
return b.SendPayload(ctx, request.UnAuth, func() (*request.Item, error) {
return e.SendPayload(ctx, request.UnAuth, func() (*request.Item, error) {
return item, nil
}, request.UnauthenticatedRequest)
}
@@ -284,7 +284,7 @@ func (b *Bitflyer) SendHTTPRequest(ctx context.Context, ep exchange.URL, path st
// Note: HTTP not done due to incorrect account privileges, please open a PR
// if you have access and update the authenticated requests
// TODO: Fill out this function once API access is obtained
func (b *Bitflyer) SendAuthHTTPRequest() {
func (e *Exchange) SendAuthHTTPRequest() {
//nolint:gocritic // code example
// headers := make(map[string]string)
// headers["ACCESS-KEY"] = b.API.Credentials.Key
@@ -293,7 +293,7 @@ func (b *Bitflyer) SendAuthHTTPRequest() {
// GetFee returns an estimate of fee based on type of transaction
// TODO: Figure out the weird fee structure. Do we use Bitcoin Easy Exchange,Lightning Spot,Bitcoin Market,Lightning FX/Futures ???
func (b *Bitflyer) GetFee(feeBuilder *exchange.FeeBuilder) (float64, error) {
func (e *Exchange) GetFee(feeBuilder *exchange.FeeBuilder) (float64, error) {
var fee float64
switch feeBuilder.FeeType {

View File

@@ -26,17 +26,17 @@ const (
canManipulateRealOrders = false
)
var b *Bitflyer
var e *Exchange
func TestMain(m *testing.M) {
b = new(Bitflyer)
if err := testexch.Setup(b); err != nil {
e = new(Exchange)
if err := testexch.Setup(e); err != nil {
log.Fatalf("Bitflyer Setup error: %s", err)
}
if apiKey != "" && apiSecret != "" {
b.API.AuthenticatedSupport = true
b.SetCredentials(apiKey, apiSecret, "", "", "", "")
e.API.AuthenticatedSupport = true
e.SetCredentials(apiKey, apiSecret, "", "", "", "")
}
os.Exit(m.Run())
@@ -44,7 +44,7 @@ func TestMain(m *testing.M) {
func TestGetLatestBlockCA(t *testing.T) {
t.Parallel()
_, err := b.GetLatestBlockCA(t.Context())
_, err := e.GetLatestBlockCA(t.Context())
if err != nil {
t.Error("Bitflyer - GetLatestBlockCA() error:", err)
}
@@ -52,7 +52,7 @@ func TestGetLatestBlockCA(t *testing.T) {
func TestGetBlockCA(t *testing.T) {
t.Parallel()
_, err := b.GetBlockCA(t.Context(), "000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f")
_, err := e.GetBlockCA(t.Context(), "000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f")
if err != nil {
t.Error("Bitflyer - GetBlockCA() error:", err)
}
@@ -60,7 +60,7 @@ func TestGetBlockCA(t *testing.T) {
func TestGetBlockbyHeightCA(t *testing.T) {
t.Parallel()
_, err := b.GetBlockbyHeightCA(t.Context(), 0)
_, err := e.GetBlockbyHeightCA(t.Context(), 0)
if err != nil {
t.Error("Bitflyer - GetBlockbyHeightCA() error:", err)
}
@@ -68,7 +68,7 @@ func TestGetBlockbyHeightCA(t *testing.T) {
func TestGetTransactionByHashCA(t *testing.T) {
t.Parallel()
_, err := b.GetTransactionByHashCA(t.Context(), "0562d1f063cd4127053d838b165630445af5e480ceb24e1fd9ecea52903cb772")
_, err := e.GetTransactionByHashCA(t.Context(), "0562d1f063cd4127053d838b165630445af5e480ceb24e1fd9ecea52903cb772")
if err != nil {
t.Error("Bitflyer - GetTransactionByHashCA() error:", err)
}
@@ -76,7 +76,7 @@ func TestGetTransactionByHashCA(t *testing.T) {
func TestGetAddressInfoCA(t *testing.T) {
t.Parallel()
v, err := b.GetAddressInfoCA(t.Context(), core.BitcoinDonationAddress)
v, err := e.GetAddressInfoCA(t.Context(), core.BitcoinDonationAddress)
if err != nil {
t.Error("Bitflyer - GetAddressInfoCA() error:", err)
}
@@ -87,7 +87,7 @@ func TestGetAddressInfoCA(t *testing.T) {
func TestGetMarkets(t *testing.T) {
t.Parallel()
markets, err := b.GetMarkets(t.Context())
markets, err := e.GetMarkets(t.Context())
if err != nil {
t.Error("Bitflyer - GetMarkets() error:", err)
}
@@ -103,7 +103,7 @@ func TestGetMarkets(t *testing.T) {
func TestGetOrderBook(t *testing.T) {
t.Parallel()
_, err := b.GetOrderBook(t.Context(), "BTC_JPY")
_, err := e.GetOrderBook(t.Context(), "BTC_JPY")
if err != nil {
t.Error("Bitflyer - GetOrderBook() error:", err)
}
@@ -111,7 +111,7 @@ func TestGetOrderBook(t *testing.T) {
func TestGetTicker(t *testing.T) {
t.Parallel()
_, err := b.GetTicker(t.Context(), "BTC_JPY")
_, err := e.GetTicker(t.Context(), "BTC_JPY")
if err != nil {
t.Error("Bitflyer - GetTicker() error:", err)
}
@@ -119,7 +119,7 @@ func TestGetTicker(t *testing.T) {
func TestGetExecutionHistory(t *testing.T) {
t.Parallel()
_, err := b.GetExecutionHistory(t.Context(), "BTC_JPY")
_, err := e.GetExecutionHistory(t.Context(), "BTC_JPY")
if err != nil {
t.Error("Bitflyer - GetExecutionHistory() error:", err)
}
@@ -127,7 +127,7 @@ func TestGetExecutionHistory(t *testing.T) {
func TestGetExchangeStatus(t *testing.T) {
t.Parallel()
_, err := b.GetExchangeStatus(t.Context())
_, err := e.GetExchangeStatus(t.Context())
if err != nil {
t.Error("Bitflyer - GetExchangeStatus() error:", err)
}
@@ -139,7 +139,7 @@ func TestCheckFXString(t *testing.T) {
if err != nil {
t.Fatal(err)
}
p = b.CheckFXString(p)
p = e.CheckFXString(p)
if p.Base.String() != "FX_BTC" {
t.Error("Bitflyer - CheckFXString() error")
}
@@ -159,11 +159,11 @@ func setFeeBuilder() *exchange.FeeBuilder {
// TestGetFeeByTypeOfflineTradeFee logic test
func TestGetFeeByTypeOfflineTradeFee(t *testing.T) {
feeBuilder := setFeeBuilder()
_, err := b.GetFeeByType(t.Context(), feeBuilder)
_, err := e.GetFeeByType(t.Context(), feeBuilder)
if err != nil {
t.Fatal(err)
}
if !sharedtestvalues.AreAPICredentialsSet(b) {
if !sharedtestvalues.AreAPICredentialsSet(e) {
if feeBuilder.FeeType != exchange.OfflineTradeFee {
t.Errorf("Expected %v, received %v", exchange.OfflineTradeFee, feeBuilder.FeeType)
}
@@ -178,9 +178,9 @@ func TestGetFee(t *testing.T) {
t.Parallel()
feeBuilder := setFeeBuilder()
if sharedtestvalues.AreAPICredentialsSet(b) {
if sharedtestvalues.AreAPICredentialsSet(e) {
// CryptocurrencyTradeFee Basic
if _, err := b.GetFee(feeBuilder); err != nil {
if _, err := e.GetFee(feeBuilder); err != nil {
t.Error(err)
}
@@ -188,28 +188,28 @@ func TestGetFee(t *testing.T) {
feeBuilder = setFeeBuilder()
feeBuilder.Amount = 1000
feeBuilder.PurchasePrice = 1000
if _, err := b.GetFee(feeBuilder); err != nil {
if _, err := e.GetFee(feeBuilder); err != nil {
t.Error(err)
}
// CryptocurrencyTradeFee IsMaker
feeBuilder = setFeeBuilder()
feeBuilder.IsMaker = true
if _, err := b.GetFee(feeBuilder); err != nil {
if _, err := e.GetFee(feeBuilder); err != nil {
t.Error(err)
}
// CryptocurrencyTradeFee Negative purchase price
feeBuilder = setFeeBuilder()
feeBuilder.PurchasePrice = -1000
if _, err := b.GetFee(feeBuilder); err != nil {
if _, err := e.GetFee(feeBuilder); err != nil {
t.Error(err)
}
// CryptocurrencyWithdrawalFee Basic
feeBuilder = setFeeBuilder()
feeBuilder.FeeType = exchange.CryptocurrencyWithdrawalFee
if _, err := b.GetFee(feeBuilder); err != nil {
if _, err := e.GetFee(feeBuilder); err != nil {
t.Error(err)
}
}
@@ -217,7 +217,7 @@ func TestGetFee(t *testing.T) {
// CryptocurrencyDepositFee Basic
feeBuilder = setFeeBuilder()
feeBuilder.FeeType = exchange.CryptocurrencyDepositFee
if _, err := b.GetFee(feeBuilder); err != nil {
if _, err := e.GetFee(feeBuilder); err != nil {
t.Error(err)
}
@@ -225,7 +225,7 @@ func TestGetFee(t *testing.T) {
feeBuilder = setFeeBuilder()
feeBuilder.FeeType = exchange.InternationalBankDepositFee
feeBuilder.FiatCurrency = currency.JPY
if _, err := b.GetFee(feeBuilder); err != nil {
if _, err := e.GetFee(feeBuilder); err != nil {
t.Error(err)
}
@@ -233,7 +233,7 @@ func TestGetFee(t *testing.T) {
feeBuilder = setFeeBuilder()
feeBuilder.FeeType = exchange.InternationalBankWithdrawalFee
feeBuilder.FiatCurrency = currency.JPY
if _, err := b.GetFee(feeBuilder); err != nil {
if _, err := e.GetFee(feeBuilder); err != nil {
t.Error(err)
}
}
@@ -241,7 +241,7 @@ func TestGetFee(t *testing.T) {
func TestFormatWithdrawPermissions(t *testing.T) {
t.Parallel()
expectedResult := exchange.AutoWithdrawFiatText + " & " + exchange.WithdrawCryptoViaWebsiteOnlyText
withdrawPermissions := b.FormatWithdrawPermissions()
withdrawPermissions := e.FormatWithdrawPermissions()
if withdrawPermissions != expectedResult {
t.Errorf("Expected: %s, Received: %s", expectedResult, withdrawPermissions)
}
@@ -255,10 +255,10 @@ func TestGetActiveOrders(t *testing.T) {
Side: order.AnySide,
}
_, err := b.GetActiveOrders(t.Context(), &getOrdersRequest)
if sharedtestvalues.AreAPICredentialsSet(b) && err != nil {
_, err := e.GetActiveOrders(t.Context(), &getOrdersRequest)
if sharedtestvalues.AreAPICredentialsSet(e) && err != nil {
t.Errorf("Could not get open orders: %s", err)
} else if !sharedtestvalues.AreAPICredentialsSet(b) && err == nil {
} else if !sharedtestvalues.AreAPICredentialsSet(e) && err == nil {
t.Error("Expecting an error when no keys are set")
}
}
@@ -271,7 +271,7 @@ func TestGetOrderHistory(t *testing.T) {
Side: order.AnySide,
}
_, err := b.GetOrderHistory(t.Context(), &getOrdersRequest)
_, err := e.GetOrderHistory(t.Context(), &getOrdersRequest)
if err != common.ErrNotYetImplemented {
t.Errorf("Expected '%v', received '%v'", common.ErrNotYetImplemented, err)
}
@@ -282,10 +282,10 @@ func TestGetOrderHistory(t *testing.T) {
func TestSubmitOrder(t *testing.T) {
t.Parallel()
sharedtestvalues.SkipTestIfCredentialsUnset(t, b, canManipulateRealOrders)
sharedtestvalues.SkipTestIfCredentialsUnset(t, e, canManipulateRealOrders)
orderSubmission := &order.Submit{
Exchange: b.Name,
Exchange: e.Name,
Pair: currency.Pair{
Base: currency.BTC,
Quote: currency.LTC,
@@ -297,7 +297,7 @@ func TestSubmitOrder(t *testing.T) {
ClientID: "meowOrder",
AssetType: asset.Spot,
}
_, err := b.SubmitOrder(t.Context(), orderSubmission)
_, err := e.SubmitOrder(t.Context(), orderSubmission)
if err != common.ErrNotYetImplemented {
t.Errorf("Expected 'Not Yet Implemented', received %v", err)
}
@@ -305,7 +305,7 @@ func TestSubmitOrder(t *testing.T) {
func TestCancelExchangeOrder(t *testing.T) {
t.Parallel()
sharedtestvalues.SkipTestIfCredentialsUnset(t, b, canManipulateRealOrders)
sharedtestvalues.SkipTestIfCredentialsUnset(t, e, canManipulateRealOrders)
currencyPair := currency.NewPair(currency.LTC, currency.BTC)
orderCancellation := &order.Cancel{
@@ -315,7 +315,7 @@ func TestCancelExchangeOrder(t *testing.T) {
AssetType: asset.Spot,
}
err := b.CancelOrder(t.Context(), orderCancellation)
err := e.CancelOrder(t.Context(), orderCancellation)
if err != common.ErrNotYetImplemented {
t.Errorf("Expected 'Not Yet Implemented', received %v", err)
@@ -324,7 +324,7 @@ func TestCancelExchangeOrder(t *testing.T) {
func TestCancelAllExchangeOrders(t *testing.T) {
t.Parallel()
sharedtestvalues.SkipTestIfCredentialsUnset(t, b, canManipulateRealOrders)
sharedtestvalues.SkipTestIfCredentialsUnset(t, e, canManipulateRealOrders)
currencyPair := currency.NewPair(currency.LTC, currency.BTC)
orderCancellation := &order.Cancel{
@@ -334,7 +334,7 @@ func TestCancelAllExchangeOrders(t *testing.T) {
AssetType: asset.Spot,
}
_, err := b.CancelAllOrders(t.Context(), orderCancellation)
_, err := e.CancelAllOrders(t.Context(), orderCancellation)
if err != common.ErrNotYetImplemented {
t.Errorf("Expected 'Not Yet Implemented', received %v", err)
@@ -343,10 +343,10 @@ func TestCancelAllExchangeOrders(t *testing.T) {
func TestWithdraw(t *testing.T) {
t.Parallel()
sharedtestvalues.SkipTestIfCredentialsUnset(t, b, canManipulateRealOrders)
sharedtestvalues.SkipTestIfCredentialsUnset(t, e, canManipulateRealOrders)
withdrawCryptoRequest := withdraw.Request{
Exchange: b.Name,
Exchange: e.Name,
Amount: -1,
Currency: currency.BTC,
Description: "WITHDRAW IT ALL",
@@ -355,7 +355,7 @@ func TestWithdraw(t *testing.T) {
},
}
_, err := b.WithdrawCryptocurrencyFunds(t.Context(),
_, err := e.WithdrawCryptocurrencyFunds(t.Context(),
&withdrawCryptoRequest)
if err != common.ErrNotYetImplemented {
t.Errorf("Expected 'Not Yet Implemented', received %v", err)
@@ -364,8 +364,8 @@ func TestWithdraw(t *testing.T) {
func TestModifyOrder(t *testing.T) {
t.Parallel()
sharedtestvalues.SkipTestIfCredentialsUnset(t, b, canManipulateRealOrders)
_, err := b.ModifyOrder(t.Context(),
sharedtestvalues.SkipTestIfCredentialsUnset(t, e, canManipulateRealOrders)
_, err := e.ModifyOrder(t.Context(),
&order.Modify{AssetType: asset.Spot})
if err == nil {
t.Error("ModifyOrder() Expected error")
@@ -374,11 +374,11 @@ func TestModifyOrder(t *testing.T) {
func TestWithdrawFiat(t *testing.T) {
t.Parallel()
sharedtestvalues.SkipTestIfCredentialsUnset(t, b, canManipulateRealOrders)
sharedtestvalues.SkipTestIfCredentialsUnset(t, e, canManipulateRealOrders)
withdrawFiatRequest := withdraw.Request{}
_, err := b.WithdrawFiatFunds(t.Context(), &withdrawFiatRequest)
_, err := e.WithdrawFiatFunds(t.Context(), &withdrawFiatRequest)
if err != common.ErrNotYetImplemented {
t.Errorf("Expected '%v', received: '%v'", common.ErrNotYetImplemented, err)
}
@@ -386,11 +386,11 @@ func TestWithdrawFiat(t *testing.T) {
func TestWithdrawInternationalBank(t *testing.T) {
t.Parallel()
sharedtestvalues.SkipTestIfCredentialsUnset(t, b, canManipulateRealOrders)
sharedtestvalues.SkipTestIfCredentialsUnset(t, e, canManipulateRealOrders)
withdrawFiatRequest := withdraw.Request{}
_, err := b.WithdrawFiatFundsToInternationalBank(t.Context(),
_, err := e.WithdrawFiatFundsToInternationalBank(t.Context(),
&withdrawFiatRequest)
if err != common.ErrNotYetImplemented {
t.Errorf("Expected '%v', received: '%v'", common.ErrNotYetImplemented, err)
@@ -403,7 +403,7 @@ func TestGetRecentTrades(t *testing.T) {
if err != nil {
t.Fatal(err)
}
_, err = b.GetRecentTrades(t.Context(), currencyPair, asset.Spot)
_, err = e.GetRecentTrades(t.Context(), currencyPair, asset.Spot)
if err != nil {
t.Error(err)
}
@@ -415,7 +415,7 @@ func TestGetHistoricTrades(t *testing.T) {
if err != nil {
t.Fatal(err)
}
_, err = b.GetHistoricTrades(t.Context(),
_, err = e.GetHistoricTrades(t.Context(),
currencyPair, asset.Spot, time.Now().Add(-time.Minute*15), time.Now())
if err != nil && err != common.ErrFunctionNotSupported {
t.Fatal(err)
@@ -424,19 +424,19 @@ func TestGetHistoricTrades(t *testing.T) {
func TestUpdateTradablePairs(t *testing.T) {
t.Parallel()
testexch.UpdatePairsOnce(t, b)
testexch.UpdatePairsOnce(t, e)
}
func TestGetCurrencyTradeURL(t *testing.T) {
t.Parallel()
testexch.UpdatePairsOnce(t, b)
err := b.CurrencyPairs.SetAssetEnabled(asset.Futures, false)
testexch.UpdatePairsOnce(t, e)
err := e.CurrencyPairs.SetAssetEnabled(asset.Futures, false)
require.NoError(t, err, "SetAssetEnabled must not error")
for _, a := range b.GetAssetTypes(false) {
pairs, err := b.CurrencyPairs.GetPairs(a, false)
for _, a := range e.GetAssetTypes(false) {
pairs, err := e.CurrencyPairs.GetPairs(a, false)
require.NoErrorf(t, err, "cannot get pairs for %s", a)
require.NotEmptyf(t, pairs, "no pairs for %s", a)
resp, err := b.GetCurrencyTradeURL(t.Context(), a, pairs[0])
resp, err := e.GetCurrencyTradeURL(t.Context(), a, pairs[0])
require.NoError(t, err, "GetCurrencyTradeURL must not error")
assert.NotEmpty(t, resp, "GetCurrencyTradeURL should return an url")
}

View File

@@ -29,12 +29,12 @@ import (
)
// SetDefaults sets the basic defaults for Bitflyer
func (b *Bitflyer) SetDefaults() {
b.Name = "Bitflyer"
b.Enabled = true
b.Verbose = true
b.API.CredentialsValidator.RequiresKey = true
b.API.CredentialsValidator.RequiresSecret = true
func (e *Exchange) SetDefaults() {
e.Name = "Bitflyer"
e.Enabled = true
e.Verbose = true
e.API.CredentialsValidator.RequiresKey = true
e.API.CredentialsValidator.RequiresSecret = true
requestFmt := &currency.PairFormat{
Delimiter: currency.UnderscoreDelimiter,
@@ -44,7 +44,7 @@ func (b *Bitflyer) SetDefaults() {
Delimiter: currency.UnderscoreDelimiter,
Uppercase: true,
}
err := b.SetGlobalPairsManager(requestFmt,
err := e.SetGlobalPairsManager(requestFmt,
configFmt,
asset.Spot,
asset.Futures)
@@ -52,7 +52,7 @@ func (b *Bitflyer) SetDefaults() {
log.Errorln(log.ExchangeSys, err)
}
b.Features = exchange.Features{
e.Features = exchange.Features{
Supports: exchange.FeaturesSupported{
REST: true,
Websocket: false,
@@ -72,14 +72,14 @@ func (b *Bitflyer) SetDefaults() {
},
}
b.Requester, err = request.New(b.Name,
e.Requester, err = request.New(e.Name,
common.NewHTTPClientWithTimeout(exchange.DefaultHTTPTimeout),
request.WithLimiter(GetRateLimit()))
if err != nil {
log.Errorln(log.ExchangeSys, err)
}
b.API.Endpoints = b.NewEndpoints()
err = b.API.Endpoints.SetDefaultEndpoints(map[exchange.URL]string{
e.API.Endpoints = e.NewEndpoints()
err = e.API.Endpoints.SetDefaultEndpoints(map[exchange.URL]string{
exchange.RestSpot: japanURL,
exchange.ChainAnalysis: chainAnalysis,
})
@@ -89,20 +89,20 @@ func (b *Bitflyer) SetDefaults() {
}
// Setup takes in the supplied exchange configuration details and sets params
func (b *Bitflyer) Setup(exch *config.Exchange) error {
func (e *Exchange) Setup(exch *config.Exchange) error {
if err := exch.Validate(); err != nil {
return err
}
if !exch.Enabled {
b.SetEnabled(false)
e.SetEnabled(false)
return nil
}
return b.SetupDefaults(exch)
return e.SetupDefaults(exch)
}
// FetchTradablePairs returns a list of the exchanges tradable pairs
func (b *Bitflyer) FetchTradablePairs(ctx context.Context, a asset.Item) (currency.Pairs, error) {
symbols, err := b.GetMarkets(ctx)
func (e *Exchange) FetchTradablePairs(ctx context.Context, a asset.Item) (currency.Pairs, error) {
symbols, err := e.GetMarkets(ctx)
if err != nil {
return nil, err
}
@@ -130,39 +130,39 @@ func (b *Bitflyer) FetchTradablePairs(ctx context.Context, a asset.Item) (curren
// UpdateTradablePairs updates the exchanges available pairs and stores
// them in the exchanges config
func (b *Bitflyer) UpdateTradablePairs(ctx context.Context, forceUpdate bool) error {
assets := b.CurrencyPairs.GetAssetTypes(false)
func (e *Exchange) UpdateTradablePairs(ctx context.Context, forceUpdate bool) error {
assets := e.CurrencyPairs.GetAssetTypes(false)
for _, a := range assets {
pairs, err := b.FetchTradablePairs(ctx, a)
pairs, err := e.FetchTradablePairs(ctx, a)
if err != nil {
return err
}
err = b.UpdatePairs(pairs, a, false, forceUpdate)
err = e.UpdatePairs(pairs, a, false, forceUpdate)
if err != nil {
return err
}
}
return b.EnsureOnePairEnabled()
return e.EnsureOnePairEnabled()
}
// UpdateTickers updates the ticker for all currency pairs of a given asset type
func (b *Bitflyer) UpdateTickers(_ context.Context, _ asset.Item) error {
func (e *Exchange) UpdateTickers(_ context.Context, _ asset.Item) error {
return common.ErrFunctionNotSupported
}
// GetServerTime returns the current exchange server time.
func (b *Bitflyer) GetServerTime(_ context.Context, _ asset.Item) (time.Time, error) {
func (e *Exchange) GetServerTime(_ context.Context, _ asset.Item) (time.Time, error) {
return time.Time{}, common.ErrFunctionNotSupported
}
// UpdateTicker updates and returns the ticker for a currency pair
func (b *Bitflyer) UpdateTicker(ctx context.Context, p currency.Pair, a asset.Item) (*ticker.Price, error) {
fPair, err := b.FormatExchangeCurrency(p, a)
func (e *Exchange) UpdateTicker(ctx context.Context, p currency.Pair, a asset.Item) (*ticker.Price, error) {
fPair, err := e.FormatExchangeCurrency(p, a)
if err != nil {
return nil, err
}
tickerNew, err := b.GetTicker(ctx, b.CheckFXString(fPair).String())
tickerNew, err := e.GetTicker(ctx, e.CheckFXString(fPair).String())
if err != nil {
return nil, err
}
@@ -173,18 +173,18 @@ func (b *Bitflyer) UpdateTicker(ctx context.Context, p currency.Pair, a asset.It
Bid: tickerNew.BestBid,
Last: tickerNew.Last,
Volume: tickerNew.Volume,
ExchangeName: b.Name,
ExchangeName: e.Name,
AssetType: a,
})
if err != nil {
return nil, err
}
return ticker.GetTicker(b.Name, fPair, a)
return ticker.GetTicker(e.Name, fPair, a)
}
// CheckFXString upgrades currency pair if needed
func (b *Bitflyer) CheckFXString(p currency.Pair) currency.Pair {
func (e *Exchange) CheckFXString(p currency.Pair) currency.Pair {
if strings.Contains(p.Base.String(), "FX") {
p.Base = currency.FX_BTC
return p
@@ -193,26 +193,26 @@ func (b *Bitflyer) CheckFXString(p currency.Pair) currency.Pair {
}
// UpdateOrderbook updates and returns the orderbook for a currency pair
func (b *Bitflyer) UpdateOrderbook(ctx context.Context, p currency.Pair, assetType asset.Item) (*orderbook.Book, error) {
func (e *Exchange) UpdateOrderbook(ctx context.Context, p currency.Pair, assetType asset.Item) (*orderbook.Book, error) {
if p.IsEmpty() {
return nil, currency.ErrCurrencyPairEmpty
}
if err := b.CurrencyPairs.IsAssetEnabled(assetType); err != nil {
if err := e.CurrencyPairs.IsAssetEnabled(assetType); err != nil {
return nil, err
}
book := &orderbook.Book{
Exchange: b.Name,
Exchange: e.Name,
Pair: p,
Asset: assetType,
ValidateOrderbook: b.ValidateOrderbook,
ValidateOrderbook: e.ValidateOrderbook,
}
fPair, err := b.FormatExchangeCurrency(p, assetType)
fPair, err := e.FormatExchangeCurrency(p, assetType)
if err != nil {
return book, err
}
orderbookNew, err := b.GetOrderBook(ctx, b.CheckFXString(fPair).String())
orderbookNew, err := e.GetOrderBook(ctx, e.CheckFXString(fPair).String())
if err != nil {
return book, err
}
@@ -238,34 +238,34 @@ func (b *Bitflyer) UpdateOrderbook(ctx context.Context, p currency.Pair, assetTy
return book, err
}
return orderbook.Get(b.Name, fPair, assetType)
return orderbook.Get(e.Name, fPair, assetType)
}
// UpdateAccountInfo retrieves balances for all enabled currencies on the
// Bitflyer exchange
func (b *Bitflyer) UpdateAccountInfo(_ context.Context, _ asset.Item) (account.Holdings, error) {
func (e *Exchange) UpdateAccountInfo(_ context.Context, _ asset.Item) (account.Holdings, error) {
return account.Holdings{}, common.ErrNotYetImplemented
}
// GetAccountFundingHistory returns funding history, deposits and
// withdrawals
func (b *Bitflyer) GetAccountFundingHistory(_ context.Context) ([]exchange.FundingHistory, error) {
func (e *Exchange) GetAccountFundingHistory(_ context.Context) ([]exchange.FundingHistory, error) {
return nil, common.ErrFunctionNotSupported
}
// GetWithdrawalsHistory returns previous withdrawals data
func (b *Bitflyer) GetWithdrawalsHistory(_ context.Context, _ currency.Code, _ asset.Item) ([]exchange.WithdrawalHistory, error) {
func (e *Exchange) GetWithdrawalsHistory(_ context.Context, _ currency.Code, _ asset.Item) ([]exchange.WithdrawalHistory, error) {
return nil, common.ErrNotYetImplemented
}
// GetRecentTrades returns recent historic trades
func (b *Bitflyer) GetRecentTrades(ctx context.Context, p currency.Pair, assetType asset.Item) ([]trade.Data, error) {
func (e *Exchange) GetRecentTrades(ctx context.Context, p currency.Pair, assetType asset.Item) ([]trade.Data, error) {
var err error
p, err = b.FormatExchangeCurrency(p, assetType)
p, err = e.FormatExchangeCurrency(p, assetType)
if err != nil {
return nil, err
}
tradeData, err := b.GetExecutionHistory(ctx, p.String())
tradeData, err := e.GetExecutionHistory(ctx, p.String())
if err != nil {
return nil, err
}
@@ -278,7 +278,7 @@ func (b *Bitflyer) GetRecentTrades(ctx context.Context, p currency.Pair, assetTy
}
resp[i] = trade.Data{
TID: strconv.FormatInt(tradeData[i].ID, 10),
Exchange: b.Name,
Exchange: e.Name,
CurrencyPair: p,
AssetType: assetType,
Side: side,
@@ -288,7 +288,7 @@ func (b *Bitflyer) GetRecentTrades(ctx context.Context, p currency.Pair, assetTy
}
}
err = b.AddTradesToBuffer(resp...)
err = e.AddTradesToBuffer(resp...)
if err != nil {
return nil, err
}
@@ -298,124 +298,124 @@ func (b *Bitflyer) GetRecentTrades(ctx context.Context, p currency.Pair, assetTy
}
// GetHistoricTrades returns historic trade data within the timeframe provided
func (b *Bitflyer) GetHistoricTrades(_ context.Context, _ currency.Pair, _ asset.Item, _, _ time.Time) ([]trade.Data, error) {
func (e *Exchange) GetHistoricTrades(_ context.Context, _ currency.Pair, _ asset.Item, _, _ time.Time) ([]trade.Data, error) {
return nil, common.ErrFunctionNotSupported
}
// SubmitOrder submits a new order
func (b *Bitflyer) SubmitOrder(_ context.Context, _ *order.Submit) (*order.SubmitResponse, error) {
func (e *Exchange) SubmitOrder(_ context.Context, _ *order.Submit) (*order.SubmitResponse, error) {
return nil, common.ErrNotYetImplemented
}
// ModifyOrder will allow of changing orderbook placement and limit to
// market conversion
func (b *Bitflyer) ModifyOrder(_ context.Context, _ *order.Modify) (*order.ModifyResponse, error) {
func (e *Exchange) ModifyOrder(_ context.Context, _ *order.Modify) (*order.ModifyResponse, error) {
return nil, common.ErrFunctionNotSupported
}
// CancelOrder cancels an order by its corresponding ID number
func (b *Bitflyer) CancelOrder(_ context.Context, _ *order.Cancel) error {
func (e *Exchange) CancelOrder(_ context.Context, _ *order.Cancel) error {
return common.ErrNotYetImplemented
}
// CancelBatchOrders cancels an orders by their corresponding ID numbers
func (b *Bitflyer) CancelBatchOrders(_ context.Context, _ []order.Cancel) (*order.CancelBatchResponse, error) {
func (e *Exchange) CancelBatchOrders(_ context.Context, _ []order.Cancel) (*order.CancelBatchResponse, error) {
return nil, common.ErrNotYetImplemented
}
// CancelAllOrders cancels all orders associated with a currency pair
func (b *Bitflyer) CancelAllOrders(_ context.Context, _ *order.Cancel) (order.CancelAllResponse, error) {
func (e *Exchange) CancelAllOrders(_ context.Context, _ *order.Cancel) (order.CancelAllResponse, error) {
// TODO, implement BitFlyer API
b.CancelAllExistingOrders()
e.CancelAllExistingOrders()
return order.CancelAllResponse{}, common.ErrNotYetImplemented
}
// GetOrderInfo returns order information based on order ID
func (b *Bitflyer) GetOrderInfo(_ context.Context, _ string, _ currency.Pair, _ asset.Item) (*order.Detail, error) {
func (e *Exchange) GetOrderInfo(_ context.Context, _ string, _ currency.Pair, _ asset.Item) (*order.Detail, error) {
return nil, common.ErrNotYetImplemented
}
// GetDepositAddress returns a deposit address for a specified currency
func (b *Bitflyer) GetDepositAddress(_ context.Context, _ currency.Code, _, _ string) (*deposit.Address, error) {
func (e *Exchange) GetDepositAddress(_ context.Context, _ currency.Code, _, _ string) (*deposit.Address, error) {
return nil, common.ErrNotYetImplemented
}
// WithdrawCryptocurrencyFunds returns a withdrawal ID when a withdrawal is
// submitted
func (b *Bitflyer) WithdrawCryptocurrencyFunds(_ context.Context, _ *withdraw.Request) (*withdraw.ExchangeResponse, error) {
func (e *Exchange) WithdrawCryptocurrencyFunds(_ context.Context, _ *withdraw.Request) (*withdraw.ExchangeResponse, error) {
return nil, common.ErrNotYetImplemented
}
// WithdrawFiatFunds returns a withdrawal ID when a
// withdrawal is submitted
func (b *Bitflyer) WithdrawFiatFunds(_ context.Context, _ *withdraw.Request) (*withdraw.ExchangeResponse, error) {
func (e *Exchange) WithdrawFiatFunds(_ context.Context, _ *withdraw.Request) (*withdraw.ExchangeResponse, error) {
return nil, common.ErrNotYetImplemented
}
// WithdrawFiatFundsToInternationalBank returns a withdrawal ID when a
// withdrawal is submitted
func (b *Bitflyer) WithdrawFiatFundsToInternationalBank(_ context.Context, _ *withdraw.Request) (*withdraw.ExchangeResponse, error) {
func (e *Exchange) WithdrawFiatFundsToInternationalBank(_ context.Context, _ *withdraw.Request) (*withdraw.ExchangeResponse, error) {
return nil, common.ErrNotYetImplemented
}
// GetActiveOrders retrieves any orders that are active/open
func (b *Bitflyer) GetActiveOrders(_ context.Context, _ *order.MultiOrderRequest) (order.FilteredOrders, error) {
func (e *Exchange) GetActiveOrders(_ context.Context, _ *order.MultiOrderRequest) (order.FilteredOrders, error) {
return nil, common.ErrNotYetImplemented
}
// GetOrderHistory retrieves account order information
// Can Limit response to specific order status
func (b *Bitflyer) GetOrderHistory(_ context.Context, _ *order.MultiOrderRequest) (order.FilteredOrders, error) {
func (e *Exchange) GetOrderHistory(_ context.Context, _ *order.MultiOrderRequest) (order.FilteredOrders, error) {
return nil, common.ErrNotYetImplemented
}
// GetFeeByType returns an estimate of fee based on the type of transaction
func (b *Bitflyer) GetFeeByType(ctx context.Context, feeBuilder *exchange.FeeBuilder) (float64, error) {
func (e *Exchange) GetFeeByType(ctx context.Context, feeBuilder *exchange.FeeBuilder) (float64, error) {
if feeBuilder == nil {
return 0, fmt.Errorf("%T %w", feeBuilder, common.ErrNilPointer)
}
if !b.AreCredentialsValid(ctx) && // Todo check connection status
if !e.AreCredentialsValid(ctx) && // Todo check connection status
feeBuilder.FeeType == exchange.CryptocurrencyTradeFee {
feeBuilder.FeeType = exchange.OfflineTradeFee
}
return b.GetFee(feeBuilder)
return e.GetFee(feeBuilder)
}
// ValidateAPICredentials validates current credentials used for wrapper
// functionality
func (b *Bitflyer) ValidateAPICredentials(ctx context.Context, assetType asset.Item) error {
_, err := b.UpdateAccountInfo(ctx, assetType)
return b.CheckTransientError(err)
func (e *Exchange) ValidateAPICredentials(ctx context.Context, assetType asset.Item) error {
_, err := e.UpdateAccountInfo(ctx, assetType)
return e.CheckTransientError(err)
}
// GetHistoricCandles returns candles between a time period for a set time interval
func (b *Bitflyer) GetHistoricCandles(_ context.Context, _ currency.Pair, _ asset.Item, _ kline.Interval, _, _ time.Time) (*kline.Item, error) {
func (e *Exchange) GetHistoricCandles(_ context.Context, _ currency.Pair, _ asset.Item, _ kline.Interval, _, _ time.Time) (*kline.Item, error) {
return nil, common.ErrFunctionNotSupported
}
// GetHistoricCandlesExtended returns candles between a time period for a set time interval
func (b *Bitflyer) GetHistoricCandlesExtended(_ context.Context, _ currency.Pair, _ asset.Item, _ kline.Interval, _, _ time.Time) (*kline.Item, error) {
func (e *Exchange) GetHistoricCandlesExtended(_ context.Context, _ currency.Pair, _ asset.Item, _ kline.Interval, _, _ time.Time) (*kline.Item, error) {
return nil, common.ErrFunctionNotSupported
}
// GetFuturesContractDetails returns all contracts from the exchange by asset type
func (b *Bitflyer) GetFuturesContractDetails(context.Context, asset.Item) ([]futures.Contract, error) {
func (e *Exchange) GetFuturesContractDetails(context.Context, asset.Item) ([]futures.Contract, error) {
return nil, common.ErrFunctionNotSupported
}
// GetLatestFundingRates returns the latest funding rates data
func (b *Bitflyer) GetLatestFundingRates(context.Context, *fundingrate.LatestRateRequest) ([]fundingrate.LatestRateResponse, error) {
func (e *Exchange) GetLatestFundingRates(context.Context, *fundingrate.LatestRateRequest) ([]fundingrate.LatestRateResponse, error) {
return nil, common.ErrFunctionNotSupported
}
// UpdateOrderExecutionLimits updates order execution limits
func (b *Bitflyer) UpdateOrderExecutionLimits(_ context.Context, _ asset.Item) error {
func (e *Exchange) UpdateOrderExecutionLimits(_ context.Context, _ asset.Item) error {
return common.ErrNotYetImplemented
}
// GetCurrencyTradeURL returns the URL to the exchange's trade page for the given asset and currency pair
func (b *Bitflyer) GetCurrencyTradeURL(_ context.Context, a asset.Item, cp currency.Pair) (string, error) {
_, err := b.CurrencyPairs.IsPairEnabled(cp, a)
func (e *Exchange) GetCurrencyTradeURL(_ context.Context, a asset.Item, cp currency.Pair) (string, error) {
_, err := e.CurrencyPairs.IsPairEnabled(cp, a)
if err != nil {
return "", err
}