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

You also need to delete the semicolon at the end of this line

1 Like

Hi Andy,

Try the code below:-

If you get an invalidSignature error you probably have got the secret password and the key switched. The key should begin with either account- or master-.

I hope this helps.

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

This error occurred when I tried getting market data from crypto compare. I was wondering why this is happening?

jessiebarbee@Jessies-MacBook-Pro ~ % node index.js
internal/modules/cjs/loader.js:969
throw err;
^

Error: Cannot find module ‘/Users/jessiebarbee/index.js’
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:966:15)
at Function.Module._load (internal/modules/cjs/loader.js:842:27)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
at internal/main/run_main_module.js:17:47 {
code: ‘MODULE_NOT_FOUND’,
requireStack: []
}

Hi Joe,
Thanks for getting back to me, The issue is now fixed, as you said the key needs to begin with account-
So i tried that first without adding the .catch line of code and it worked.

Many thanks

Hi Andy,
If you add .catch error into your code it will give you proper error messages rather than the nonsence that it spews at the moment.

Good luck with programming.

2 Likes

Thanks Nile. :+1:I’ll take a look at terminal.

Germini Yarn Install - Windows PowerShell Warning - No repository field

  1. When attempting to install “npm install yarn – global” I get the following warning:

npm WARN [email protected] No repository field.

+ [email protected]
+ [email protected]
updated 2 packages and audited 5 packages in 1.028s
found 0 vulnerabilities

  1. This leads to the following error when I try to install “yarn add gemini-api”:

yarn : The term ‘yarn’ is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the
path is correct and try again.
At line:1 char:1
+ yarn add gemini-api
*+ ~~~~*

    • CategoryInfo : ObjectNotFound: (yarn:String) [], CommandNotFoundException*
    • FullyQualifiedErrorId : CommandNotFoundException*
  1. I’m assuming this is stems from the npm WARN [email protected] No repository field from above. This has been an issue for others as well. I’m new to this and not sure how to fix. I do not want to mess with this more without knowing what I’m doing and am unable to go forward with the lessons without fixing.

I installed NodeJS on one computer and got an error message so I installed it on another computer and got the same message…the message is, Uncaught ReferenceError: node is not defined. What should I do?

1 Like

Try following this: https://stackoverflow.com/questions/27170037/first-time-using-node-js-referenceerror-node-is-not-defined

Let me know if you have more success by following the steps above. :smile:

1 Like

Has anyone recently been able to use the sandbox API to place a new order?
I get the feeling Gemini adjusted their API policies recently and it seems to me that they made “account-#####” keys to be read-only. I can’t seem to make an order with the “account-####” key as it doesn’t allow assinging trader roles. But if I use a “master-####” key then it complains of MissingAccounts (an optional parameter according to the gemini API doc for the nickname of the account being acted upon). I can’t seem to pass the correct object for that parameter or I think the wrapper is broken due to Gemini API updates. Would appreciate any insight into this…

{
  result: 'error',
  reason: 'MissingAccounts',
  message: 'Expected a JSON payload with accounts'
}

Yes I agree instructions for mac users would be very nice

1 Like

I join the mac users movement, so far, it was a pain I have even tried to install a virtual box and windows10 to use the shell and follow the course…

1 Like

@alexsei

Hi - I was able to use the updated API info

const key = "account-QIXkHGEGWE4SKT7gmbKWZ";

const secret = "3wEfedfewfewdefQf95KAAn6JSm6K";

const restClient = new GeminiAPI({key,secret,sandbox:true});

restClient.newOrder({

    "symbol": "ethusd",

    "amount": "5",

    "price": "300.00",

    "side": "buy",

    })

    .then(response => console.log(response))

    .catch(console.error);

The forum swaps out quotes, so if you copy, replace the quotes. FYI,. Hope that helps

Also - I scrambled my keys in case someone wants to comment on my security habits. =)

1 Like

@iamchaoticcoder

Thanks for your reply. I am unsure how you did this without getting an error (and without editing the index.js within the Gemini-API package). I would expect that if you did this before Gemini’s recent API changes then you would not have faced the errors which I did. Did you do it within the last few days or had you done this course some time ago ( >3 weeks)?
I ask because when I did this for the first time 2 weeks ago and followed the course plan I was unable to produce the expected result. I would like to share my results in case it resonates with other’s experience. When I tried this using an “account-XXxXXXXXXXx” key to open a trade it resulted in a “Missing roles” error (account key cannot be assigned trading role in gemini’s sandbox exchange api settings). When I tried with a “master-XxXXxXXXxX” key and received the “Missing Accounts” error I did some reading of the API documentation and figured out that “accounts: ‘primary’” needs to be added to the REST request through the extra parameters of each API function call. Alternatively one could edit the index.js of Gemini-API node package and add that account reference to line 47 (add bolded):
}, params), {account: ‘primary’};

This change allowed me to use a “master-XxXXXXXXx” key for private API calls and continue the course without too much deviation from the lesson plan.

1 Like

I just recently completed this. - When I set up the key, I looked at the master and primary, decided on primary, but checked the boxes to allow trading. - I believe there were three checkbox options, and one was disabled. I worked through a couple errors, but did not experience the Missing Roles.

Hi Joe,
Is there any reason why the .catch would not be working on my powershell?
I have added this line below to my code and it is giving me a syntax error: unexpected token ‘.’
.catch(error => console.log(error));

Its very frustrating!!

Many thanks
Andy

Sorry, I figured it out,
I had a semicolon at the end of the previous line of code and the .catch line wasnt recognized apparently.

If someone could explain that to me it would be much appreciated.

Many thanks

It literally took me 3 days to do this. Errors :crazy_face: but at least I got thru it. Keep pushing

intall hombrew, brew install yarn

1 Like

Hi
When I place an order with high price in any other coin other than Bitcoin, it gets cancelled.

order_id: ‘636143186’,
id: ‘636143186’,
symbol: ‘ltcusd’,
exchange: ‘gemini’,
avg_execution_price: ‘0.00’,
side: ‘buy’,
type: ‘exchange limit’,
timestamp: ‘1597531514’,
timestampms: 1597531514716,
is_live: false,
is_cancelled: true,
is_hidden: false,
was_forced: false,
executed_amount: ‘0’,
client_order_id: ‘-2AtmSRfn’,
reason: ‘ImmediateOrCancelWouldPost’,
options: [ ‘immediate-or-cancel’ ],
price: ‘100.00’,
original_amount: ‘1’,
remaining_amount: ‘1’

and the prices for the altcoins doesnt seem to be the correct one.
anyone having this issue?

1 Like