thank you, I’ll try this option
PS C:\Users\ragib\OneDrive\Documents\botjs> Is this OK? (yes)
PS C:\Users\ragib>
PS C:\Users\ragib> cd “C:\Users\ragib\OneDrive\Documents\botjs”
PS C:\Users\ragib\OneDrive\Documents\botjs> npm install yarn --global[email protected] preinstall C:\Users\ragib\AppData\Roaming\npm\node_modules\yarn
:; (node ./preinstall.js > /dev/null 2>&1 || true)C:\Users\ragib\AppData\Roaming\npm\yarn -> C:\Users\ragib\AppData\Roaming\npm\node_modules\yarn\bin\yarn.js
C:\Users\ragib\AppData\Roaming\npm\yarnpkg -> C:\Users\ragib\AppData\Roaming\npm\node_modules\yarn\bin\yarn.js
- [email protected]
added 1 package in 4.944s
PS C:\Users\ragib\OneDrive\Documents\botjs> “C:\Users\ragib\OneDrive\Documents\botjs\bot.js”
C:\Users\ragib\OneDrive\Documents\botjs\bot.js
PS C:\Users\ragib\OneDrive\Documents\botjs> npm install yarn --global[email protected] preinstall C:\Users\ragib\AppData\Roaming\npm\node_modules\yarn
:; (node ./preinstall.js > /dev/null 2>&1 || true)C:\Users\ragib\AppData\Roaming\npm\yarnpkg -> C:\Users\ragib\AppData\Roaming\npm\node_modules\yarn\bin\yarn.js
C:\Users\ragib\AppData\Roaming\npm\yarn -> C:\Users\ragib\AppData\Roaming\npm\node_modules\yarn\bin\yarn.js
- [email protected]
updated 1 package in 0.476s
I followed the path for yarn. When I try to install it does not let me or recognize the file. I went into windows and set it to enable scripting.
the file will not install. What do you suggest?
Thank you, Rachel
Hey @Rachel3, hope you are ok.
What is exactly the issue? you have installed yarn properly (apparently no errors).
Some times powershell might run into issues with some programs. I advice you to use the windows console (CMD) that one will give you less issues.
basically you should learn how to move into folders in CLI (command line interface), cd
is the command keyword you use to go into a folder… the first error in your post is that your path finish with a file, so cd
is not intended to open the file, just the folder, so any time you need to go into a folder, just finish the path with the folder name like your example
Carlos Z
Hi!
Please help me.
I can not mark “Installing NodeJS & Atom” lecture complete. It just doesn not happen. I tried several times, but it just cannot let me move on. In other courses it works.
Hey @balintdaniel13, i assume you refers to the Academy 2.0, please try again, we have done some fixes on those lesson related to the same issue.
If still persist, let us know to solve it asap.
Carlos Z
Hi!
I am trying to do the buy order from the lesson, but my order gets automatically cancelled, below the code and response:
const GeminiAPI = require(“gemini-api”).default;
const secret = “2BhC7gzpYGMQTn3MtKaDUEqg47SN”;
const key = “account-dPQJYSZHgcy06XlZnjkc”;
const restClient = new GeminiAPI({key, secret, sandbox:true});
restClient.newOrder({amount:10, price:100, side:“buy”, symbol:“btcusd”})
.then(response => console.log(response));
======================
{
order_id: ‘945513061’,
id: ‘945513061’,
symbol: ‘btcusd’,
exchange: ‘gemini’,
avg_execution_price: ‘0.00’,
side: ‘buy’,
type: ‘exchange limit’,
timestamp: ‘1623240606’,
timestampms: 1623240606164,
is_live: false,
is_cancelled: true,
is_hidden: false,
was_forced: false,
executed_amount: ‘0’,
client_order_id: ‘U9npblP5i’,
reason: ‘ExceedsPriceLimits’,
options: [],
price: ‘100.00’,
original_amount: ‘10’,
remaining_amount: ‘10’
}
Can you help me? I cannot find the error.
hey @Ana.Barreto, hope you are ok.
Would you please also share an screenshot of the error? that will help us to review properly where is the error of your code.
Also would be great to provide the code in the following way:
https://forum.ivanontech.com/t/faq-how-to-post-code-in-the-forum/3535
Carlos Z
Hey guys,
I’m using MacOS. Node.js and the npm are working fine when using it in the terminal/command line. But when trying to install Yarn I’m getting an error message.
Can’t manage to solve it. Appreciate any help.
Thanks!!!
Robert
hey @Robert12, hope you are ok.
You might have to run the commands with admin privilege try to add sudo
at the start of entire command (Example: sudo npm install
), sudo is the keyword to use admin privileges on the terminal.
Carlos Z
Hi @thecil,
I refer to Ivan’s video “Building MA strategy”. At the end when programming the 2nd if-statement (Sell condition).
Did he forget to amend the function “exchange.marketBuyBitcoin” into "“exchange.marketSellBitcoin”?
Best regards,
Robert
Indeed, nice catch, it should change it to SellBitcoin, but might be that he just forgot on that moment.
Carlos Z
Hi guys
I thought I followed everything that Ivan did, but I must be missing something. Can someone take a look and see if you can see what I’m missing?
Here is my code:
const GeminiAPI = require(“gemini-api”).default;
const secret = “5rWhrEsP2hBjFKLjU7qTJxYSAEw”;
const key = “bAynhBcbELVwPDBrRL5o”;
const restClient = new GeminiAPI({key, secret, sandbox:true});
restClient.newOrder({amount:10,price:100,side:“buy”,symbol:“btcusd”})
.then(response => console.log(response));
And here is my error:
PS E:\BUSINESS\Bitcoin\IvanOnTechAcademy\Bot> node index.js
node:internal/process/promises:246
triggerUncaughtException(err, true /* fromPromise */);
^
[UnhandledPromiseRejection: This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason “#”.] {
code: ←[32m’ERR_UNHANDLED_REJECTION’←[39m
Thanks in advance for your assistance.
I have same problem as you but unfortunatly nobody is there to give us assistance…
Thank you for your response. I thought I was the only one with the issue Hopefully someone notices us and can lend a hand
Hi again Onpo 72. I figured it out. It was the keys. When I downloaded the first set of keys, I downloaded the master key and secret and it didn’t work (as you know). So I downloaded the account key and secret key and now the script worked! I hope this helps you too
Hi,
Does anyone know why I keep getting this msg on powershell?
PS /Users/bruno> cd " /Users/bruno/Documents/Bot.js "
Set-Location: Cannot find path '/Users/bruno/ /Users/bruno/Documents/Bot.js ’ because it does not exist.
PS /Users/bruno>
Thanks for your help
hello,
i tried to follow all the videos but I get this error when trying to launch the bot.
I don’t understand why because I followed step by step the videos…
ReferenceError: Cannot access 'CryptocompareAPI' before initialization
at Object.<anonymous> (C:\Users\Enric\Desktop\CODING\API\indicators.js:2:1)
←[90m at Module._compile (internal/modules/cjs/loader.js:1068:30)←[39m
←[90m at Object.Module._extensions..js (internal/modules/cjs/loader.js:1097:10)←[39m
←[90m at Module.load (internal/modules/cjs/loader.js:933:32)←[39m
←[90m at Function.Module._load (internal/modules/cjs/loader.js:774:14)←[39m
←[90m at Module.require (internal/modules/cjs/loader.js:957:19)←[39m
←[90m at require (internal/modules/cjs/helpers.js:88:18)←[39m
at Object.<anonymous> (C:\Users\Enric\Desktop\CODING\API\index.js:5:20)
←[90m at Module._compile (internal/modules/cjs/loader.js:1068:30)←[39m
←[90m at Object.Module._extensions..js (internal/modules/cjs/loader.js:1097:10)←[39m
this are my programs:
index.js
global.fetch = require("node-fetch"); //questo lo aggiungo per cryptocompare
// è il wrapper che forma la request riceve answer etc
const indicators = require("./indicators.js");
const exchange = require("./exchange.js");
/*
indicators.movingAverage('BTC', 'USD', 100, function(result){
console.log("MA", result)
})
*/
//NON C'E' ORDINE A MERCATO MA USO IL LIMIT IN MODO AGGRESSIVO
var hasPosition = false;
var strategy = function(){
console.log(" ");
console.log("================================");
console.log("execute strategy");
indicators.movingAverage("BTC","USD",100, function(ma){
exchange.bitcoinPrice()
.then(res => {
var price = res.last;
console.log("ma: ", ma);
console.log("price:", price);
if(price < ma && !hasPosition){
console.log("BUY SIGNAL")
exchange.marketBuy("btcusd")
.then(res => {
console.log("buy successfull");
hasPosition = true;
setTimeout(strategy, 1000); //strategy restart once we get moving average and price and not before
})
.catch(error => console.error(error));
}
else if(price > ma && hasPosition){
console.log("SELL SIGNAL")
exchange.marketBuy("btcusd")
.then(res => {
console.log("sell successfull");
hasPosition = false;
setTimeout(strategy, 1000); //strategy restart once we get moving average and price and not before
})
.catch(error => console.error(error));
}
else{
console.log("hold");
setTimeout(strategy, 1000); //strategy restart once we get moving average and price and not before
}
})
});
}
strategy();
exchange
const GeminiAPI = require("gemini-api").default;
const secret = "R9jqvTMkgGDYqsbX7P9ew653hGv";
const key = "account-yyq7AxJcCnbTSuVUZBH1";
const restClient = new GeminiAPI({key, secret, sandbox:true}); // sandbox true per soldi finti
module.export = {
marketBuy: function marketBuy(symbol){
return restClient.neworder({amount:1,
price: 10000000,
side: "buy",
symbol: "btcusd",
options: ["immediate-or-cancel"]})
},
marketSell: function marketSell(symbol){
return restClient.neworder({amount:1,
price: 1,
side: "sell",
symbol: "btcusd",
options: ["immediate-or-cancel"]})
},
bitcoinPrice: function(){
return restClient.getTicker("btcusd");
}
}
indicators
CryptocompareAPI.setApiKey(CCAPIKey);
const CCAPIKey = "373399c85e87a566c82952eaca02ca4c146d55a44e86f3bdc53ff73dc53b9928";
const CryptocompareAPI = require("cryptocompare");
module.export = {
movingAverage: function movingAverage(crypto, fiat, hours, callback){
if (hours > 169) {
console.error("troppo grande")
return
}
CryptocompareAPI.histoHour(crypto, fiat) // default da 169 ore prima
.then(data => {
data=data.reverse()
var sum = 0;
for(var i = 0; i<hours;i++){
//console.log(i)
//console.log(data[i].close)
sum+=data[i].close;
}
var movingAverage = Math.floor(sum/hours);
callback(movingAverage);
//console.log(data[0])
//console.log(data.length) // da la lunghezza dell'array -> il numero di ore tot
})
.catch(console.error)
}
}
You should initialize first the module const CryptoCompareAPI = require("cryptocompare")
, after that one, you can setApiKey()
.
Carlos Z
Thank you I had the same.