version 0.2
A decentralized trading agent built with AO and Lua. This application implements various trading strategies including DCA (Dollar-Cost Averaging) and Value Averaging using AO's permanent computation network.
/process
- AO process (smart contract) code/src/lib
- Core processing and handler logic/src/utils
- Trading strategies and utility functions
/test
- Test suite for the AO process
- Multiple trading strategies:
- Dollar-Cost Averaging (DCA)
- Value Averaging (VA)
- Automated trade execution
- Configurable trading parameters
- Balance and order management
- Decentralized state management via AO
- Node.js (v18 or higher)
- Yarn package manager
- Arweave Wallet (for interacting with AO network)
- Basic understanding of trading strategies
- Invests fixed amounts at regular intervals
- Configurable investment amount and intervals
- Helps average out purchase prices over time
- Targets specific portfolio value growth
- Dynamically adjusts investment based on market conditions
- Buys more when prices are low, sells when high
- Configurable monthly target increase and investment limits
Each strategy can be configured through their respective config objects:
-- Value Averaging Configuration
VA_CONFIG = {
target_monthly_increase = 1000, -- Monthly target increase ($)
max_single_investment = 5000, -- Maximum single trade
min_single_investment = 100 -- Minimum trade size
}
-
Clone the repository:
git clone https://github.com/yourusername/tradeAgent.git
-
Install dependencies:
yarn install
-
Build the AO process:
yarn build:process
-
Deploy the AO process: before doing the deploy add the wallet using
export WALLET_JSON="$(cat ~/.aos.json)"
yarn deploy:process
- install the DbAdmin package first using apm
.editor
.load-blueprint apm
apm.install "@rakis/DbAdmin"
.done
-
run the
yarn run setup_aos_deploy:process
command to modify the dbAdmin import statement before deploying the process. -
.load /path/to_file/process.js
Note: Do not run the yarn build:process command after running the restore:process command because it is going to replace the import statement for dbAdmin and deployments using aos will fail.
To run the test suite:
yarn test:process
We have a script called test.sh which takes in the Action name and data from data.txt which should be in json format. To run the script with new data you have to modify the data.txt file.
chmod +x test.sh ./test.sh
Example:
./test.sh deposit
Send({Target="fH6VuQA4eeCBPRiuNxssKnmU4AaU3MRJv0umoi3iavk",Action="getOrders",Data=""})
The trading agent processes trades through message handlers:
deposit
- Add funds to trading balancewithdraw
- Withdraw fundsgetDeposit
- Check current balancegetOrders
- View order historytrade
- Execute trades based on current strategy
Contributions are welcome! Feel free to:
- Add new trading strategies
- Improve existing strategies
- Enhance risk management
- Add more test cases
This project is licensed under the MIT License - see the LICENSE file for details.