eliza icon indicating copy to clipboard operation
eliza copied to clipboard

feat: Add advanced trading

Open moondevonyt opened this issue 1 year ago • 11 comments

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.

moondevonyt avatar Dec 21 '24 16:12 moondevonyt

is the goal to convert this to typescript?

vyrnix9582046173 avatar Dec 21 '24 23:12 vyrnix9582046173

yessirEl dic 21, 2024, a la(s) 19:40, chris @.***> escribió: is the goal to convert this to typescript?

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you authored the thread.Message ID: @.***>

moondevonyt avatar Dec 21 '24 23:12 moondevonyt

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

moondevonyt avatar Dec 22 '24 12:12 moondevonyt

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).

shakkernerd avatar Dec 22 '24 13:12 shakkernerd

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

moondevonyt avatar Dec 22 '24 15:12 moondevonyt

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 avatar Dec 23 '24 17:12 shakkernerd

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...

shakkernerd avatar Dec 23 '24 17:12 shakkernerd

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:

  • https://github.com/ghalex/zapcli?tab=readme-ov-file
  • https://github.com/austin-starks/NextTrade?tab=readme-ov-file
  • https://github.com/samc621/stockpros

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

doxometrist avatar Dec 25 '24 22:12 doxometrist

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 avatar Dec 26 '24 13:12 moondevonyt

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?

moondevonyt avatar Jan 01 '25 10:01 moondevonyt

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

odilitime avatar Jan 01 '25 10:01 odilitime