-
Notifications
You must be signed in to change notification settings - Fork 5.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Contribution: fetchBalance() from Trading Session #5131
base: develop
Are you sure you want to change the base?
Conversation
async function fetchAllBalances() { | ||
// Validations: | ||
if (exchange.has['fetchBalance'] === false) { | ||
logError("fetchAllBalances -> Exchange does not support fetchBalance command."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This if statement needs to return false, otherwise it will try and run the next statement.
} | ||
try { | ||
let balances = await exchange.fetchBalance(); | ||
console.log(' -> Succesfully executed "fetchBalance" and retrieved actual account balances from the exchange.') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please change to use the SA.logger.info call instead of console.log
if (tradingEngine.tradingCurrent.tradingEpisode.userDefinedVariables.userDefinedVariable[0].value === 0) { | ||
tradingEngine.tradingCurrent.tradingEpisode.userDefinedVariables.userDefinedVariable[0] = [] | ||
tradingEngine.tradingCurrent.tradingEpisode.userDefinedVariables.userDefinedVariable[0][0] = balances | ||
console.log(' -> Stored INITIAL raw data from fetchBalance() at userDefinedVariable[0][0]') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change to use SA.logger.info
console.log(' -> Stored INITIAL raw data from fetchBalance() at userDefinedVariable[0][0]') | ||
} | ||
tradingEngine.tradingCurrent.tradingEpisode.userDefinedVariables.userDefinedVariable[0][1] = balances | ||
console.log(' -> Stored CURRENT raw data from fetchBalance() at userDefinedVariable[0][1]') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change to use SA.logger.info
...ts/Algorithmic-Trading/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/TradingSimulation.js
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nearly there
exchangeAPIModuleObject.initialize() | ||
balances = await exchangeAPIModuleObject.fetchAllBalances() | ||
|
||
if (balances !== undefined || balances !== false) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replace || with && as you want both conditions to be true to enter the function.
No description provided.