Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/volumefi/optimized-twap-bot-script
https://github.com/volumefi/optimized-twap-bot-script
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/volumefi/optimized-twap-bot-script
- Owner: VolumeFi
- Created: 2023-09-22T18:14:32.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-09-26T19:27:24.000Z (over 1 year ago)
- Last Synced: 2024-04-16T01:42:25.208Z (9 months ago)
- Language: Python
- Size: 4.88 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Twap Optimizer
## Overview
This Python script finds the optimal number of trades to maximize the output value based on a given input amount and a set of prices. It also takes into account the gas costs for each trade. The optimal interval between trades is also calculated but currently serves as a placeholder.
## Requirements
- Python 3.x
## How to Run
1. Save the Python script in a file, for example `trade_optimizer.py`.
2. Open your terminal or command prompt.
3. Run the script with the `--input_amount` and `--prices` parameters. For example:
```bash
python trade_optimizer.py --input_amount 1e6 --prices 0.995 0.996 0.997 0.998 0.999
```## Arguments
- `--input_amount`: The input amount in USD that you are willing to trade.
- `--prices`: A list of prices corresponding to different input amounts. The i-th entry is the price corresponding to `input_amount / i`.## Functionality
- `get_gas_cost()`: Placeholder function to get the gas cost. Currently returns a fixed value.
- `get_optimal_trades(input_amount, prices, gas_cost)`: Calculates the optimal number of trades and the resulting output amount.
- `get_optimal_interval()`: Placeholder function that returns the optimal time interval between trades in minutes.
- `optimize(input_amount: float, prices: list)`: Main function that returns the optimal number of trades, the interval, and the optimal output.
## Output
The script outputs a tuple containing the optimal number of trades, the interval between trades, and the optimal output amount.