dwallach1 / prometheus Goto Github PK
View Code? Open in Web Editor NEWAutomated Crypto Trader
Automated Crypto Trader
We have average return per pairing and number of allotments. Assume a constant order size of $100 which pairing generates the best results.
Things to consider:
https://www.coingecko.com/en/api
abstract current code into abstract Trader class. Make current code a CoinbaseTrader
and create a MemecoinTrader
right now we buy if dips below buy_price_percentage_change_threshold
but can we treat this as a flag to enable the buy but add logic to try and guess once its bottomed out. This will try to protect against a fast drop of 10% when the threshold is set to 5%. we can fire off a "watcher" and once it detects rate of change decreasing or improving it inserts the buy
When we start watch dog. Write to a table to mark when it started. Update with last iteration using transactionid
For assets im bullish on and dont mind holding onto for a long time, i set my buy strategy to only need one candle of recovery. My sell strategy will check when we're above the sell threshold and then try to maximize profits by riding a pump if there is one.
{
"name": "Bitcoin",
"symbol": "BTC",
"amount_to_buy_usd": 500,
"buy_price_percentage_change_threshold": -5.0,
"sell_price_percentage_change_threshold": 12.0,
"max_open_buys": 5,
"buy_strategy": {
"candle_size": "ONE_HOUR",
"green_candles_in_a_row": 1
},
"sell_strategy": {
"type": "MAXIMIZE_PROFIT",
"MAXIMIZE_PROFIT": {
"candle_size": "ONE_HOUR",
"red_candles_in_a_row": 1
}
}
}
with riskier assets, i increase the number of candles and sell immediately once i can.
{
"name": "Cardano",
"symbol": "ADA",
"amount_to_buy_usd": 100,
"buy_price_percentage_change_threshold": -5.0,
"sell_price_percentage_change_threshold": 12.0,
"max_open_buys": 1,
"buy_strategy": {
"candle_size": "ONE_HOUR",
"green_candles_in_a_row": 2
},
"sell_strategy": {
"type": "IMMEDIATE_SELL",
"IMMEDIATE_SELL": {}
}
}
i want to use config data to join into the dashboard and also good to have persisted in the db
add LINK
, ADA
and AVAX
to the assets config. These follow similar patterns as other assets, increasing our buy opportunities
import unittest
from unittest.mock import MagicMock
from main import DecisionMaker, DecisionContext, Asset, Enviorment, RESTClient, MongoClient
from decisions import DecisionType
class TestDecisionMaker(unittest.TestCase):
def test_buy_asset(self):
# Mocking necessary dependencies
cb_client = MagicMock(spec=RESTClient)
mongo_client = MagicMock(spec=MongoClient)
# Creating test data
asset_config = Asset(name="TestAsset", symbol="TEST", account_id="123", amount_to_buy=100.0, buy_price_percentage_change_threshold=0.5, sell_price_percentage_change_threshold=1.0, max_open_buys=2)
context = DecisionContext(enviorment=Enviorment.TEST, price=100.0, symbol="TEST", asset_balance=10.0, total_asset_value=1000.0, usdc_balance=1000.0, volume_24h=1000.0, volume_percentage_change_24h=0.5, price_percentage_change_24h=1.0, total_asset_holdings_value=1000.0, price_change_check=True, buy_buffer_check=True, open_buy_check=True, open_buy_count=0, open_buy_decisions=[])
# Creating an instance of DecisionMaker
decision_maker = DecisionMaker(Enviorment.TEST, cb_client, mongo_client, "test_db", "test_collection", asset_config, "usd_account_id")
# Mocking the necessary methods for buying
decision_maker.get_decision_context = MagicMock(return_value=context)
decision_maker.get_buying_power = MagicMock(return_value=1000.0)
decision_maker.place_buy_order = MagicMock(return_value={"mock": "buy_order_result"})
# Running the buy decision
decision_maker.compute_decisions()
# Asserting that the buy order was placed
decision_maker.place_buy_order.assert_called()
if __name__ == '__main__':
unittest.main()
we get 5.0% APY with USDC. keep cash in that, before we do a buy do a transfer from USDC to USD to do they market buy.
After we do a market sell, convert from USD to USDC.
Use Convert Quote
APIs:
https://docs.cloud.coinbase.com/advanced-trade-api/reference/retailbrokerageapi_createconvertquote
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.