Skip to content
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

Open
wants to merge 9 commits into
base: develop
Choose a base branch
from

Conversation

cozed-gh
Copy link
Contributor

No description provided.

@cozed-gh cozed-gh requested a review from a team as a code owner April 16, 2024 07:48
async function fetchAllBalances() {
// Validations:
if (exchange.has['fetchBalance'] === false) {
logError("fetchAllBalances -> Exchange does not support fetchBalance command.");
Copy link
Contributor

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.')
Copy link
Contributor

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]')
Copy link
Contributor

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]')
Copy link
Contributor

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

Copy link
Contributor

@Awhiteweb Awhiteweb left a 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) {
Copy link
Contributor

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.

@cozed-gh cozed-gh requested review from a team as code owners May 13, 2024 05:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants