-
Notifications
You must be signed in to change notification settings - Fork 830
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
Add trade log capability #107
base: master
Are you sure you want to change the base?
Conversation
Add capability to log trades into a journal file
helpers/trade.ts
Outdated
// Trade sold, compute profit. | ||
confirmedSell(amountOut: number) { | ||
this.data.amountOut = amountOut; | ||
this.data.profit = this.data.amountOut - this.data.amountIn.valueOf(); |
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.
NOTE: profit computation does not account for fee
account for solana transaction fee
@@ -275,7 +317,20 @@ export class Bot { | |||
} | |||
} catch (error) { | |||
logger.error({ mint: rawAccount.mint.toString(), error }, `Failed to sell token`); | |||
if (trade) { | |||
trade.close(0, 0, 'sell_failed'); | |||
this.balance += trade.profit; |
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 is not really needed since we later on call this.updatebalance
, but that's paving the way for a future dry run mode implementation.
This PR add capability to log trades into a journal file.
Here is an example of journal log entry
It uses the
LOG_FILENAME
variable to define the journal file and can be set tonone
to disable logging.