Skip to content

Cron agent with price momentum and portfolio info#93

Merged
zikunukiz merged 52 commits intomainfrom
research-cron-momentum-agent
Feb 21, 2025
Merged

Cron agent with price momentum and portfolio info#93
zikunukiz merged 52 commits intomainfrom
research-cron-momentum-agent

Conversation

@zikunukiz
Copy link
Copy Markdown
Contributor

@zikunukiz zikunukiz commented Feb 21, 2025

An example agent that:

  • uses the cron client to periodically check in short/long windows for potential momentums, specified by thresholds
  • has access to wallet balance information
  • makes a trade decision (or not) based on the above information with additional requirements

Copy link
Copy Markdown
Contributor

@Winston-503 Winston-503 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Comment thread alphaswarm/agent/clients/cron_job.py Outdated
Comment thread examples/agents/portfolio_price_momentum_cron.py Outdated
Comment thread examples/agents/portfolio_price_momentum_cron.py Outdated
Comment thread examples/agents/portfolio_price_momentum_cron.py Outdated
Comment on lines +187 to +191
token_addresses = [
"0x4F9Fd6Be4a90f2620860d680c0d4d5Fb53d1A825", # AIXBT
"0x0b3e328455c4059EEb9e3f84b5543F74E24e7E1b", # VIRTUAL
"0x731814e491571A2e9eE3c5b1F7f3b962eE8f4870", # VADER
]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could read from config with GetTokenAddress but that's good enough for now

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was also thinking it could be cool to just use the intersection of tokens in the wallet and supported ones in the config (or whatever else is determining the universe of tradable tokens) -- but agree I think this is fine for now.

Comment thread examples/agents/portfolio_price_momentum_cron.py Outdated
Comment thread examples/agents/portfolio_price_momentum_cron.py Outdated
Comment thread examples/agents/portfolio_price_momentum_cron.py
Comment thread examples/agents/portfolio_price_momentum_cron.py Outdated
Comment thread examples/agents/portfolio_price_momentum_cron.py Outdated
Comment on lines +124 to +127
"```csv",
"symbol,address,amount",
*[f"{token.token_info.symbol},{token.token_info.address},{token.value}" for token in tokens],
"```",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could implement a toCsv on PortfolioBalance

f" - {self.long_term_periods * 5}min change: {long_term_change:.2f}%\n"
)

def calculate_price_changes(self, prices: List[Decimal]) -> Tuple[Decimal, Decimal]:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would prefer an object, to avoid any confusion.

@dataclass
class PriceChange:
     short_term: Decimal
     long_term: Decimal
     
     @classmethod
     def null() -> PriceChange:
         return PriceChange(..)
     
     def is_above_threshold(short, long) -> bool:
         ....
         
      @classmethod
      def from_prices(prices: Sequence[Decimal],  *, short_period, long_period) -> PriceChange:
         ....
         

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aflament good point, updated according to your suggestions

Comment thread examples/agents/portfolio_price_momentum_cron.py Outdated
Comment thread examples/agents/portfolio_price_momentum_cron.py
@aflament
Copy link
Copy Markdown
Contributor

@zikunukiz approved, but:
can u double-check that the other examples using CronJob are still working
add a description in the examples / Readme.md

@zikunukiz zikunukiz merged commit 2221d3b into main Feb 21, 2025
@zikunukiz zikunukiz deleted the research-cron-momentum-agent branch February 24, 2025 15:18
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.

5 participants