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

feat: Add advanced trading #1340

Closed
wants to merge 9 commits into from

Conversation

moondevonyt
Copy link

@moondevonyt moondevonyt commented Dec 21, 2024

sup fam, today i put in a few hours to extend the Eliza framework by adding some core trading functionality for on-chain solana bots. my focus was to create a set of tools that will allow agents to execute trades, manage risk, and pull critical data. here's what I added and worked on:

What I Added/Completed Today:

  1. nice_funcs.py:
  • Added a library of helpful functions tailored for Solana on-chain trading.
  • Functions now include position management, wallet holdings fetching, and other utilities to make trading more efficient.
  • This has been tested with my personal bots but should integrate well with Eliza’s architecture.
  1. bot.py:
  • Built a script that allows agents to perform trading actions such as:
  • Closing a position (action 0).
  • Opening a position (action 1).
  • Adding stop-loss logic (action 2).
  • Implementing breakout trades (action 3).
  • Market-making logic (action 5).
  • Currently, it uses basic user input to decide the action, but this will soon be fully bot-driven.
  1. get_ohlcv_data.py
  • this allows the agent to get open, high, low, close and volume data
  • also have moving averages and examples of other technical indicators
  1. dontshare.py (ignored):
  • Added placeholders for sensitive information such as:
  • Solana private keys.
  • BirdEye API keys.
  • RPC URLs.
  • Added this file to .gitignore to ensure it doesn’t get accidentally pushed.
  1. Updated README.md:
  • Wrote a comprehensive README to document how to use these new tools and scripts.
  • It includes detailed steps for configuration, usage, and what each action/script does.

Why This Matters:

  • These tools lay the groundwork for enabling AI agents to perform advanced trading strategies directly on-chain.
  • The added functionality simplifies interaction with Solana contracts while maintaining flexibility for future enhancements.
  • It ensures agents can operate autonomously with minimal human intervention—just plug in the strategy, and they're good to go.

What's Next?

  • I'm researching the best way to transition from Python to TypeScript or add a shell for TS compatibility, depending on the project direction.
  • Planning to integrate more trading actions like:
  • Funding buys (action 6).
  • Liquidation monitoring (action 7).
  • Always happy to hear feedback on how this integrates with Eliza’s current architecture and if there are specific improvements to focus on.

Thanks for the opportunity to contribute. Let me know if there’s anything you’d like me to adjust or refine for tomorrow.

@odilitime odilitime changed the base branch from main to develop December 21, 2024 18:52
@odilitime odilitime changed the title Add advanced trading feat: Add advanced trading Dec 21, 2024
@chrislatorres
Copy link

is the goal to convert this to typescript?

@moondevonyt
Copy link
Author

moondevonyt commented Dec 21, 2024 via email

@shakkernerd shakkernerd deleted the branch elizaOS:develop December 22, 2024 07:02
@madjin madjin reopened this Dec 22, 2024
@moondevonyt
Copy link
Author

hey fam, thank you for reviewing. please lmk if it is necessary to convert to typescript prior to a PR. all of my quant stuff is in python but im willing to learn ts and convert it if needed

also the integration tests are failing due to the need of api keys: birdeye, helius rpc and solana private key. is there a secure way i can send mine?

im @moondev on discord

cheers

@shakkernerd
Copy link
Contributor

shakkernerd commented Dec 22, 2024

Hey @moondevonyt good stuffs! I would need to do an extensive test and also bring it up with other team members before deciding if port to typescript or not (I might be able to help and support if that will be the case though).

Also, the integration tests failure is due to script not finding the OPEN API key (not from your end).

@moondevonyt
Copy link
Author

hey @shakkernerd thank you very much for your help w review and ts.

tomorrow i was planning on building a python shell to make it all useable from typescript, but i would be curious do you think it is a better use of time doing that, or re-writing in ts?

i have a ton to contribute from the quant side, virtually all in python so i will do whatever is needed to be done to allow the agents to leverage my libraries

thank you sir

new

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
@shakkernerd
Copy link
Contributor

Hey @moondevonyt tbh, I don't know how much work it would be to port the code from python to typescript. I can take a look to see how much work it would be. Another thing that comes to mind is if the libs used in your code will be available in typescript.

Thank you for doing all these really!

@shakkernerd
Copy link
Contributor

shakkernerd commented Dec 23, 2024

UPDATE: looks like we might allow python in but we need to see how its going to sync with the entire framework.
BTW, this is still under discussion...

@doxometrist
Copy link

the dataframe import and the financial classes seem the oddest to replicate, with d3 (https://stackoverflow.com/questions/30610675/python-pandas-equivalent-in-javascript) for the former and for the latter as inspo:

@moondevonyt have you done python with pyiodide (https://pyodide.org/en/stable/)?

@moondevonyt
Copy link
Author

hey fellas, thank you for your help and hope you had nice holidays!

@shakkernerd thats exciting to hear you may allow python in! that will really open the doors to the quant world. as you mentioned we use packages like pandas, numpy, talib, pandas_ta, scikitlearn, matplotlib and more and those packages are scaring me from converting to typescript

@doxometrist super helpful resources, thank you for sending. i had never heard of pyodide but after researching it a bit it seems like a great solution to atleast do a proof of concept. i will start looking into how i can get eliza to interact with my python code via pyodide and get back to you. pyodide looks really neat - ive been wanting to run py on web, i appreciate the share

@moondevonyt
Copy link
Author

sup fam, i was able to convert my entire python code to typescript and get actions set up for each of the buy, sell, stop loss, breakout, etc functions.

been having a bit of trouble implementing it into the agent tho. should i push the new code how it is, or keep working on getting it implemented into eliza first?

@odilitime
Copy link
Collaborator

I’d just finish getting it integrated into the agent. If you need help, we’re on discord

@wtfsayo wtfsayo self-requested a review January 6, 2025 18:30
@wtfsayo wtfsayo added the testing label Jan 6, 2025
@lalalune lalalune closed this Feb 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants