Javascript bot programming using Gemini API, NodeJS and CryptoCompare - DISCUSSION

Welcome to this discussion thread. Feel free to ask questions or discuss things related to this section.

Having node errors related to fetch module?
Check Here: Javascript bot programming using Gemini API, NodeJS and CryptoCompare - DISCUSSION

4 Likes

U did choose gemini because americans r banned on coinbase.
Unfortunately germans r not allowed on gemini (i guess other europeans as well).

We are not operational in Germany yet

6 Likes

Hi Ivan, perhaps a follow up to this course using Binance API’s would be great.

3 Likes

Works in Sweden, unfortunately I dont think there is any exchange available world wide

1 Like

They dont have fake money and sandbox mode unfortunately

1 Like

HI guys
I have got a problem. I was messing around with coinList() Method in Cryptocompare API. I would like to console.log just one single coin NOT all of them for example NEO so I need a result
NEO:
{ Id: ‘27368’,
Url: ‘/coins/neo/overview’,
ImageUrl: ‘/media/1383858/neo.jpg’,
Name: ‘NEO’,
Symbol: ‘NEO’,
CoinName: ‘NEO’,
FullName: ‘NEO (NEO)’,
Algorithm: ‘N/A’,
ProofType: ‘N/A’,
FullyPremined: ‘1’,
TotalCoinSupply: ‘100000000’,
BuiltOn: ‘N/A’,
SmartContractAddress: ‘N/A’,
PreMinedValue: ‘N/A’,
TotalCoinsFreeFloat: ‘N/A’,
SortOrder: ‘718’,
Sponsored: false,
IsTrading: true,
TotalCoinsMined: 65000000,
BlockNumber: 0,
NetHashesPerSecond: 0,
BlockReward: 0,
BlockTime: 0 },

I tried to do that in few different ways but still not working. I can console log only all coins but it is not usefull if I am looking for one coin. I tried:
1.
CryptoCompareAPI.coinList(“NEO”).then(coinList => {console.log(coinList)
})
.catch(console.error)
2.
CryptoCompareAPI.coinList().then(coinList =>{ console.log(coinList.NEO)
})
.catch(console.error)
3.
CryptoCompareAPI.coinList().then(coinList =>{ console.log(coinList[‘NEO’])
})
.catch(console.error)

Please give me any direction I should go
thanks

My second issue is with defining additional options. I would like to create histoHour for specified Exchange (Not average default). I put Gemini in options as a string but it doesn’t work.

CryptoCompareAPI.histoHour(‘BTC’, ‘USD’, ‘GEMINI’ ).then(data => {

data = data.reverse();
for(var i = 0; i<100; i++){
console.log(i)
console.log(data[i].close)
}
//console.log(data)
})
.catch(console.error)

I will take a look at this today

TLDR: coinList["Data"]["NEO"] :grinning:

Longer explanation:

Let me explain how you should be thinking when encountering a problem like this.
coinList is an object and we need to figure out the structure so that we can query specific keys in it.

The issue is that it is very big so that when we print it to the console it’s impossible to see the structure because the console gets overflown.

Here is how you can figure out the structure of coinList.

By typing Object.keys(coinList) you can get all the keys. You will get this response:

[ 'Response',
  'Message',
  'Data',
  'BaseImageUrl',
  'BaseLinkUrl',
  'RateLimit',
  'HasWarning',
  'Type' ]

Now you know that there is a key called Data which probably contains the individual coins.
Therefore to get info about individual cons (for example NEO) by typing coinList.Data.NEO or coinList["Data"]["NEO"] (two ways of expressing the same thing).

2 Likes

TLDR: histoHour('BTC', 'USD',{exchange:"gemini"})

Longer explanation, how to think:

  1. Take a look at the documentation for histoHour (picture from npm page below).
  2. You see that options is an Object.
  3. An object is always defined within curly braces {}
  4. The documentation also shows you which keys you can specify in the options object. For example, you can specify aggregate, aggregatePredictableTimePeriods, etc and you can of course define exchange.
  5. The syntax for adding data into an object is KEY: VALUE and to speficy Gemini as the exchange we need to specify key exchange with value GEMINI. Therefore we write exchange: "GEMINI"
  6. The options object looks like this now: {exchange: "GENIMI"}

2 Likes

Hi:)
Thank You for your response. I am in programming for less than a Year and still struggling sometimes with very simple things. Navigating datas in Java Script is greater difficulty for me . I have spent with this Api a few hours and couldn’t go through:). Your advice is really very helpful and I have got some new perspective. THIS COURSE IS REALLY FANTASTIC!!!

3 Likes

Awesome to hear, if you use Facebook, please give us a nice review if you enjoy the courses. https://www.facebook.com/ivanontech/reviews/ That really helps us grow! @filip and I will be endlessly thankful :slight_smile:

1 Like

Hi Ivan and other students
I had problems with installing Yarn on my Macbook but solved it after a while searching. I used the following links:


https://www.macports.org/install.php.

I first tried homebrew to install Yarn but this did not succeed.

Kr. Roland

3 Likes

Hi,

When trying to execute the index program I get an error message in terminal saying it can’t find the gemini-api, although I added the “yarn add gemini -api” previously.

"Error: Cannot find module ‘gemini-api’
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:582:15)
at Function.Module._load (internal/modules/cjs/loader.js:508:25)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:22:18)
at Object. (/Users/jebeljohm/Documents/Crypto/Ivan Programming/Tradingbots/index.js:1:81)
at Module._compile (internal/modules/cjs/loader.js:701:30)
at Object.Module._extensions…js (internal/modules/cjs/loader.js:712:10)
at Module.load (internal/modules/cjs/loader.js:600:32)
at tryModuleLoad (internal/modules/cjs/loader.js:539:12)
at Function.Module._load (internal/modules/cjs/loader.js:531:3)

Hi Jebel… you can try running “yarn list” at the cmd line. https://yarnpkg.com/lang/en/docs/cli/list/

This will display all the yarn packages installed. I would also check your code to make sure the path to the module is correct. Let us know… hope this helps ;o)

2 Likes

Thx Hank,

I ran the list command and this is what I got in regards with gemini.

[email protected]
│ └─ lodash@^4.17.4
├─ [email protected]

[email protected]

[email protected]

I guess I should see “gemini-api” somewhere in the list?

Hey Jebel … that doesn’t look right and looks like you have a space in your cmd between gemini and -api, but could be just copy/paste error… What I would do is:

  1. From cmd line… ensure you are in the root of your bot directory
  2. Run: yarn remove gemini-api
  3. Run: yarn add gemini-api
    image
  4. Run: yarn list and you should see the gemini-api package listed there…
    image

Hope this helps… I just installed it, listed it then removed it for the screenshots so hopefully it works out for you. I’m not using gemini-api, I’m using ccxt for Bitmex/Binance as those are the exchanges I use, but following the course none the less… cheers ;o)

4 Likes

HI guys

I have got a compile error I don’t know where I am going wrong.

Can someone help me please?

Attached is a screenshot of the error

1 Like

You’re right, it wasn’t installed… Now it works, perfect!

Thx a lot Hank :raised_hands:

2 Likes

Hi, I’m not sure but it seems you typed “sandox” instead of “sandbox”

1 Like