Skip to content

Commit

Permalink
CdC Ex : implement Spot Trade CSV
Browse files Browse the repository at this point in the history
  • Loading branch information
fiscafacile committed Jun 5, 2021
1 parent 0b501e5 commit e0cc71b
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 0 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -324,13 +324,17 @@ Cette méthode vous permet de récupérer les `Deposits` et `Withdrawals`, les `

- Exchange avec CSV:
```
--cdc-ex-spot-trade
Crypto.com Exchange Spot Trade CSV file
--cdc-ex-transfer
Crypto.com Exchange Deposit/Withdrawal CSV file
```
Il faut fournir les CSV récupérés dans l'Exchange Crypto.com.

Préférez la methode JS+JSON ci dessus, elle est plus complète.

Les colones du CSV de l'Exchange Spot Trade doivent être : `account_type,order_id,trade_id,create_time_utc,symbol,side,liquditiy_indicator,traded_price,traded_quantity,fee,fee_currency`

Les colones du CSV de l'Exchange Transfer doivent être : `create_time_utc,currency,amount,fee,address,status`

- Exchange avec API:
Expand Down
1 change: 1 addition & 0 deletions cfg/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ func LoadConfig() (*Config, error) {
pflag.StringVar(&config.Exchanges.CdcEx.API.Secret, "cdc-ex-api-secret", config.Exchanges.CdcEx.API.Secret, "Crypto.com Exchange Secret Key")
pflag.StringVar(&config.Exchanges.CdcEx.JSON, "cdc-ex-exportjs", config.Exchanges.CdcEx.JSON, "Crypto.com Exchange JSON file from json-exporter.js")
pflag.StringSliceVar(&config.Exchanges.CdcEx.CSV.Transfers, "cdc-ex-transfer", config.Exchanges.CdcEx.CSV.Transfers, "Crypto.com Exchange Deposit/Withdrawal CSV file")
pflag.StringSliceVar(&config.Exchanges.CdcEx.CSV.Trades, "cdc-ex-spot-trade", config.Exchanges.CdcEx.CSV.Trades, "Crypto.com Exchange Spot Trade CSV file")
// pflag.StringSliceVar(&config.Exchanges.CdcEx.CSV.Staking, "cdc-ex-stake", config.Exchanges.CdcEx.CSV.Staking, "Crypto.com Exchange Stake CSV file")
// pflag.StringSliceVar(&config.Exchanges.CdcEx.CSV.Supercharger, "cdc-ex-supercharger", config.Exchanges.CdcEx.CSV.Supercharger, "Crypto.com Exchange Supercharger CSV file")
pflag.StringVar(&config.Exchanges.Kraken.API.Key, "kraken-api-key", config.Exchanges.Kraken.API.Key, "Kraken API key")
Expand Down
8 changes: 8 additions & 0 deletions cryptocom/cryptocom.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@ import (
type CryptoCom struct {
apiEx apiEx
jsonEx jsonEx
csvSpotTrade csvSpotTrade
csvStake csvStake
csvSupercharger csvSupercharger
csvTransfer csvTransfer
csvAppCryptoTXs []csvAppCryptoTX
csvExTransferTXs []csvExTransferTX
csvExSpotTradeTXs []csvExSpotTradeTX
csvExStakeTXs []csvExStakeTX
csvExSuperchargerTXs []csvExSuperchargerTX
done chan error
Expand All @@ -26,6 +28,11 @@ func New() *CryptoCom {
cdc := &CryptoCom{}
cdc.done = make(chan error)
cdc.TXsByCategory = make(wallet.TXsByCategory)
cdc.jsonEx.txsByCategory = make(wallet.TXsByCategory)
cdc.csvSpotTrade.txsByCategory = make(wallet.TXsByCategory)
cdc.csvStake.txsByCategory = make(wallet.TXsByCategory)
cdc.csvSupercharger.txsByCategory = make(wallet.TXsByCategory)
cdc.csvTransfer.txsByCategory = make(wallet.TXsByCategory)
cdc.Sources = make(source.Sources)
return cdc
}
Expand All @@ -45,6 +52,7 @@ func (cdc *CryptoCom) MergeTXs() {
cdc.TXsByCategory.AddUniq(cdc.apiEx.txsByCategory)
cdc.TXsByCategory.AddUniq(cdc.csvStake.txsByCategory)
cdc.TXsByCategory.AddUniq(cdc.csvSupercharger.txsByCategory)
cdc.TXsByCategory.AddUniq(cdc.csvSpotTrade.txsByCategory)
cdc.TXsByCategory.AddUniq(cdc.csvTransfer.txsByCategory)
}

Expand Down
10 changes: 10 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,16 @@ func main() {
log.Fatal("Error parsing Crypto.com Exchange Stake CSV file:", err)
}
}
for _, file := range config.Exchanges.CdcEx.CSV.Trades {
recordFile, err := os.Open(file)
if err != nil {
log.Fatal("Error opening Crypto.com Exchange Spot Trade CSV file:", err)
}
err = cdc.ParseCSVExchangeSpotTrade(recordFile)
if err != nil {
log.Fatal("Error parsing Crypto.com Exchange Spot Trade CSV file:", err)
}
}
for _, file := range config.Exchanges.CdcEx.CSV.Supercharger {
recordFile, err := os.Open(file)
if err != nil {
Expand Down

0 comments on commit e0cc71b

Please sign in to comment.