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

Hey @Vikthor, hope you are well.

You syntax to import some of your files are incorrect.
image

Where it should be:
image

then you will find an issue about the indicator not being a function:
image

The error is on a incorrect syntax for module.export.
image

Just have to add an S at the end that you miss for the method to work properly:
image

If you have any more questions, please let us know so we can help you! :slight_smile:

Carlos Z.

Great - it works.

Thanks so much

1 Like

hi @thecil
i tried that and this is what i got
image

1 Like

image

1 Like

Check this answer from a previous student that was facing the same issue than you.

If you have any more questions, please let us know so we can help you! :slight_smile:

Carlos Z.

Thanks for the insight. I just understood that the very basics of JS would be needed to proceed, but it looks like I as wrongā€¦

1 Like

hey can someone help me please? iā€™m having trouble with the Daily Moving Average Indicator
Everything works except the Daily MA indicator iā€™m still getting this error on the power shell:

TypeError: Cannot read property ā€˜closeā€™ of undefined
at D:_WORKING_TEMP__Ivan on Tech_Academy_\Algorithmic Trading_code\indicators.js:64:22
at processTicksAndRejections (node:internal/process/task_queues:94:5)

//  DAILY MA (MOVING AVERAGE) BLOCK-START // THIS IS LINE 51
    DailyMA:function(cryptoAsset, fiatCurrency, days, callback){
      if(days>365){
        console.error("Error: Only up to 365 days allowed!")
        return
      }
      // fetching data from CryptoCompare API
      CryptoCompareAPI.histoDay(cryptoAsset, fiatCurrency)
      .then(data => {
        // calculate MA from past hours
        data = data.reverse()
        var sum = 0;
        for(var i = 0; i<days; i++){
        sum+=data[i].close;
        }
        var Days_movingAverage = sum/days;
        callback(Days_movingAverage)
      })
      .catch(console.error); // listen for any errors
 },    // DAILY MA (MOVING AVERAGE) BLOCK-END //THIS WOULD BE LINE 70

so exactly, the error is sending me to this line (after reversing de data)
specifically, its refering to ā€œ.closeā€
so what to do with this?? I have no clue

sum+=data[i].close;

my best guess is that i need to tell the DailyMA function to fetch the last unix timestamp avaliable (meaning everything exluiding today) ?? but i have no idea on how to exactly do thatā€¦ plz helps?

  • toTs (Number) Last unix timestamp to return data for.
  • limit (Number | 'none' ) Limit the number of days to lookup. Default is 30. If you set it to the string 'none' , you will get all available data.

removing the DailyMA indicator makes everything work fine (Iā€™m starting video 25 ā€œscripting gemini buy bitcoin shortcutā€ so basically everything works fine, just this indicator has been giving me trouble)

1 Like

Hey @Alex_Chaz, hope you are ok.

Could you please provide the entire code so i can test it? But i think it could be a bad declaration for the callback, in my code, i made the functions async because it is more efficient to manage async functions, here is my example function:

/*
// @dev Calculate Daily Moving Average
// @var _asset, string
// @var _pair, string
// @var _days, integer
*/
async function dailyMovingAverage(_asset, _pair, _days, callback){
  if(_days>31){console.log("Only up to 31 days allowed."); return}
  let _data = await cCompare.histoDay(_asset, _pair, function(_res){
    _res.reverse()
    let _sum = 0
    for(let _i = 0; _i < _days; _i++){
      _sum += _res[_i].close
    }
    let _movingAverage = Math.floor(_sum/_days)
    callback(_movingAverage)
  })
}

Carlos Z

1 Like

thank you! im gonna try it this way hoping i dont need to come back asking more questions haha

1 Like

Hi Guys,

I am stuck with Powershell when i try to send the order to Gemini it tell gives me error message about unhandled promise rejection. I have follow allong all why Ivan was saying.
I donā€™t know how to fix this, can someone hepl, please?

1 Like

Hi all! I am trying to sign up with GEMINI. Unfortunately i am stuck at the next step.The link is forwarding me to https://exchange.sandbox.gemini.com/register/confirm-phone but in reality all i see is a blank page. Developer tools telling me there is an an issue with

Request URL: https://static.sandbox.gemini.com/js/xxxxxxxxxxxxx.js
Request Method: GET
Status Code: 404 
Remote Address: 13.32.14.55:443
Referrer Policy: strict-origin-when-cross-origin

My question: Is anybody in the same situation ? And yes i got the email from GEMINI to approve my deviceā€¦ but the next step failed. Any other ideas ?
Cheers CH

1 Like

Hey @Leo1, hope you are ok.

Please provide an screenshot of the error that is being showed to you or you can copy/paste the code by following this guideline: FAQ - How to post code in the forum

Carlos Z

hey @mchoeti, hope you are ok.

You could have an issue with the GEMINI platform, maybe an adblock or something that blocks your signup. Any case i advice you to contact GEMINI support to see what options do they offer.

Carlos Z

Dear Carlos! Thanks for your reply. I did that and i will wait a little bid. As an alternative i can use a different email. I mean it is only sandbox. But unfortunately ma shields have been down. So i was really open for an Kilrathi attack. @Does someone know the famous pc game Wing Commander ? Anyway. Thanks for your reply i will keep you up to date. Cheers Ch

Dear @Grant38 try this oneā€¦ Please replace this values with your secret and your key

/*jshint esversion: 6 */
console.log("Welcome my API Key");

// Basic SETUP
const GeminiAPI = require("gemini-api").default;
const secret = "yourAPISecret";
const key = "yourAPIKey";
const restClient = new GeminiAPI({ key, secret, sandbox: true });

restClient.newOrder({
        amount: 1,
        price: 100,
        side: "buy",
        symbol: "btcusd"
    })
    .then(_res => {
        console.log(_res);
    })
    .catch(console.error);

Yes you do not need the console. But for me this is always a good starting point .
Safe trades :slight_smile:

And if you want it a little bid simpler. Try to use this one. Replace restClient.newOrder and the rest with the following code.

restClient.getAllSymbols()
    .then(response => {
        console.log(response)
    });

Then safe it and give it a try

Thank you have sorted it out

Had the same issue and this worked. Thank You!!!

well i thought it worked, not this comes up.
image
image

@thecil
sorry im basically blowing up this page but i think it worked now. there was a space between gemini and -api when its suppose to be ā€œone wordā€.
image

however now i have a new issue
please help, what am i doing wrong?
image
image

1 Like

when you write getALLSymbols, ALL, is supposed to be ā€”>All, so like this: getAllSymbols (donā€™t forget restclient)

1 Like