Coder Social home page Coder Social logo

dwallach1 / prometheus Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 28.36 MB

Automated Crypto Trader

Home Page: https://charts.mongodb.com/charts-prometheus-wblan/public/dashboards/445551b4-ff95-4297-be27-4ce1188f1470

Python 98.83% Dockerfile 0.39% Makefile 0.77%
crypto trading

prometheus's Issues

Analysis get most "profitable" pairings

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:

  • in a bull market right now. Should we stop before the bull market to see how it would perform? Etc.

detect relative local minimum

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

Strategies in asset config

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": {}
    }
}

expand to more assets

add LINK, ADA and AVAX to the assets config. These follow similar patterns as other assets, increasing our buy opportunities

add unit tests

You can write a unit test using a testing framework like pytest to validate the buy functionality of the DecisionMaker class.

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.