Giter Site home page Giter Site logo

trsathya / cryptex Goto Github PK

View Code? Open in Web Editor NEW
64.0 14.0 23.0 246 KB

Gemini, GDAX, Bitfinex, Poloniex, Binance, Kraken, Cryptopia, Koinex, BitGrail and CoinMarketCap cryptocurrency exchange API clients in Swift / iOS SDK. Check prices and account balances using Sample iOS app.

License: MIT License

Swift 98.37% Ruby 1.36% C 0.06% Objective-C 0.22%
swift koinex cryptocurrency crypto cryptocurrencies bitcoin ethereum litecoin altcoin coinmarketcap

cryptex's Introduction

Hi there 👋

cryptex's People

Contributors

monomadic avatar trsathya avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cryptex's Issues

Binance Exchange example, documentation.

@trsathya Hello again. This Cryptex package installs fine using Swift Package Manager 4.

I would like to import Cryptex but would be grateful for an example of how to use the Cryptex package with the Binance exchange.

I'm guessing that I will need to generate an Api Key and Api Secret, but I'm unsure of how to use your module.

Carthage won't install

user$ carthage update --platform iOS
*** Fetching Cryptex
*** Checking out Cryptex at "0.0.4"
*** xcodebuild output can be found in /var/folders/vd/3y7vj2s57t1b03cvgxqftrxsdmgrzf/T/carthage-xcodebuild.n7CbMX.log
*** Skipped building Cryptex due to the error:
Dependency "Cryptex" has no shared framework schemes for any of the platforms: iOS

If you believe this to be an error, please file an issue with the maintainers at https://github.com/trsathya/Cryptex/issues/new

Cartfile contents:
github "trsathya/Cryptex" ~> 0.0.4

Problem with retrieving getAccountBalances or getBalances for Kraken

Hey Sathya,

Both functions getAccountBalances and getBalances are failing at the guard statement:
print("Error: Cast Failed in \(#function)")

It seems like that response.json is actually not of the type [[String: String]] but actually gives back an answer. I adjusted the function now to this one here which seems works since I am creating a new Balance object and assign the values, though the rest of the krakenService.store.balances object later is then messed up e.g. ...xxx.currency.code etc. My function:

        public func getAccountBalances(completion: @escaping (ResponseType) -> Void) {
            let apiType = Kraken.API.getAccountBalance
            if apiType.checkInterval(response: store.balanceResponse) {
                completion(.cached)
            } else {
                krakenDataTaskFor(api: apiType) { (response) in
                    
                    guard let json = response.json as? Dictionary<String, Any> else {
                        print("Error: Cast Failed in \(#function)")
                        return
                    }
                    let arrayOfCryptoBalances = json["result"] as! Dictionary<String,String>
                    var balances: [Balance] = []

                    for cryptoBalance in arrayOfCryptoBalances {
                        let newBalance = ["type": cryptoBalance.key,
                                       "amount": cryptoBalance.value,
                                       "available": cryptoBalance.value]
                        
                        balances.append(Balance(json: newBalance, currencyStore: self))
                    }

                    self.store.balances = balances
                    self.store.balanceResponse = response.httpResponse
                    completion(.fetched)
                    }.resume()
            }
        }

Do you want me to create a pull request with my solution or are you taking care of it yourself? Maybe Kraken has updated the API since you wrote it. Also I found it annoying by Kraken that they decided to call most of the crypto currencies with own symbols. e.g. XBT instead of BTC for Bitcoin... is this what your overwrite function is for?

Best,
Matt

Kraken invalid nonce

Hey,

I tried to make a pull request but I can't due to access rights. Kraken has a problem with the nonce, I fixed it on my local branch. You have to change Line 178 in ´Kraken.swift´ from:

let nonce = "\(getTimestampInSeconds())"
postDataDictionary["nonce"] = nonce

to something like this:

let timestamp = NSDate().timeIntervalSince1970
let nonce = "\(Int64(timestamp*1000))"
postDataDictionary["nonce"] = nonce

I assume it has a problem with the format of the nonce, but didn't dig deeper into it, since this fixed it for me.

Best,
Mathias

Update getAccountBalances method in Kraken to safely unrwarp arrayOfCryptoBalances

Hey,

you should update the getAccountBalances method to this once here and safely unwrap arrayOfCryptoBalances since it will lead to a fatal crash in case a user has once set up the API correctly but then deletes the keys on the website and comes back to the App. This here at least won't lead to the App crashing:

public func getAccountBalances(completion: @escaping (ResponseType) -> Void) {
            let apiType = Kraken.API.getAccountBalance
            if apiType.checkInterval(response: store.balanceResponse) {
                completion(.cached)
            } else {
                krakenDataTaskFor(api: apiType) { (response) in
                    
                    guard let json = response.json as? Dictionary<String, Any> else {
                        print("Error: Cast Failed in \(#function)")
                        return
                    }
                    if let arrayOfCryptoBalances = json["result"] as? Dictionary<String,String> {
                        var balances: [Balance] = []
                        
                        for cryptoBalance in arrayOfCryptoBalances {
                            let newBalance = ["type": cryptoBalance.key,
                                              "amount": cryptoBalance.value,
                                              "available": cryptoBalance.value]
                            
                            balances.append(Balance(json: newBalance, currencyStore: self))
                        }
                        
                        self.store.balances = balances
                        self.store.balanceResponse = response.httpResponse
                        completion(.fetched)
                    }
                }.resume()
            }
        }

Cryptex doesn't build with carthage

Hello, xcode 9.3 and swift 4.1 for an ios app.
I have only github "trsathya/Cryptex" ~> 0.0.5 in my cartfile and i launch carthage update --platform iOS then i have the following error :

*** Fetching Cryptex
*** Fetching CryptoSwift
*** Checking out Cryptex at "0.0.5"
*** Checking out CryptoSwift at "0.9.0"
*** xcodebuild output can be found in /var/folders/v3/tmrdqb7j52n5v0bj0_l_d2dm0000gn/T/carthage-xcodebuild.NpjKoX.log
*** Downloading CryptoSwift.framework binary at "CMAC, AEAD and Swift 4.1"
*** Building scheme "Cryptex" in Cryptex.xcworkspace
Build Failed
	Task failed with exit code 6:
	/usr/bin/xcrun simctl list devices

This usually indicates that project itself failed to compile. Please check the xcodebuild log for more details: /var/folders/v3/tmrdqb7j52n5v0bj0_l_d2dm0000gn/T/carthage-xcodebuild.NpjKoX.log

And here is the log : https://pastebin.com/cWsZMWeU

Thanks !

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.