Skip to main content

A framework for creating an investment algorithm

Project description

Build Tests Downloads Current Version

Sponsors

Finterion

Investing Algorithm Framework

The Investing Algorithm Framework is a Python tool that enables swift and elegant development of investment algorithms and trading bots. It comes with all the necessary components for creating algorithms, including data provisioning, portfolio management, and order execution.

Example implementation

The following algorithm connects to binance and buys BTC every 5 seconds. It also exposes an REST API that allows you to interact with the algorithm.

import pathlib
from datetime import datetime, timedelta
from investing_algorithm_framework import create_app, PortfolioConfiguration, \
    RESOURCE_DIRECTORY, TimeUnit, CCXTOHLCVMarketDataSource, Algorithm, \
    CCXTTickerMarketDataSource, MarketCredential

# Define market data sources
bitvavo_btc_eur_ohlcv_2h = CCXTOHLCVMarketDataSource(
    identifier="BTC-ohlcv",
    market="BITVAVO",
    symbol="BTC/EUR",
    timeframe="2h",
    start_date_func=lambda : datetime.utcnow() - timedelta(days=17)
)
# Ticker data for orders, trades and positions
bitvavo_btc_eur_ticker = CCXTTickerMarketDataSource(
    identifier="BTC-ticker",
    market="BITVAVO",
    symbol="BTC/EUR",
)
app = create_app({RESOURCE_DIRECTORY: pathlib.Path(__file__).parent.resolve()})
app.add_market_data_source(bitvavo_btc_eur_ohlcv_2h)
app.add_market_data_source(bitvavo_btc_eur_ticker)
app.add_market_credential(MarketCredential(
    market="bitvavo",
    api_key="<your api key>",
    secret_key="<your secret key>",
))
app.add_portfolio_configuration(
    PortfolioConfiguration(
        market="bitvavo",
        trading_symbol="EUR",
        initial_balance=400
    )
)


@app.strategy(
    # Run every two hours
    time_unit=TimeUnit.HOUR, 
    interval=2, 
    # Specify market data sources that need to be passed to the strategy
    market_data_sources=["BTC-ticker", "BTC-ohlcv"]
)
def perform_strategy(algorithm: Algorithm, market_data: dict):
    print(
        f"Performing trading strategy on market " +
        f"data {market_data['BTC-ohlcv'] and market_data['BTC-ticker']}"
    )

if __name__ == "__main__":
    app.run()

You can find more examples here folder.

Backtesting

The framework also supports backtesting. You can use the same code as above, but instead of running the algorithm, you can run a backtest.

import pathlib
from datetime import datetime, timedelta
from investing_algorithm_framework import create_app, RESOURCE_DIRECTORY, \
    TimeUnit, CCXTOHLCVMarketDataSource, Algorithm, pretty_print_backtest, \
    CCXTTickerMarketDataSource, PortfolioConfiguration

# Define market data sources
bitvavo_btc_eur_ohlcv_2h = CCXTOHLCVMarketDataSource(
    identifier="BTC-ohlcv",
    market="bitvavo",
    symbol="BTC/EUR",
    timeframe="2h", 
    start_date_func=lambda : datetime.utcnow() - timedelta(days=17) 
)
bitvavo_btc_eur_ticker = CCXTTickerMarketDataSource(
    identifier="BTC-ticker",
    market="bitvavo",
    symbol="BTC/EUR",
    backtest_timeframe="2h" # We want the ticker data to 
    # be sampled every 2 hours, inline with the strategy interval
)
app = create_app({RESOURCE_DIRECTORY: pathlib.Path(__file__).parent.resolve()})
app.add_market_data_source(bitvavo_btc_eur_ohlcv_2h)
app.add_market_data_source(bitvavo_btc_eur_ticker)
app.add_portfolio_configuration(PortfolioConfiguration(
    initial_balance=400,
    market="bitvavo",
    trading_symbol="EUR",
))


@app.strategy(
    time_unit=TimeUnit.HOUR, 
    interval=2, 
    market_data_sources=["BTC-ticker", "BTC-ohlcv"]
)
def perform_strategy(algorithm: Algorithm, market_data: dict):
    print(
        f"Performing trading strategy on market " +
        f"data {market_data['BTC-ohlcv'] and market_data['BTC-ticker']}"
    )

if __name__ == "__main__":
    backtest_report = app.backtest(
        start_date=datetime(2023, 11, 12) - timedelta(days=10),
        end_date=datetime(2023, 11, 12),
    )
    pretty_print_backtest(backtest_report)

For more examples, check out the examples folder.

Backtesting report

You can use the pretty_print_backtest function to print a backtest report. For example if you run the moving average example trading bot you will get the following backtesting report:

====================Backtest report===============================
* Start date: 2023-01-01 00:00:00
* End date: 2023-12-31 00:00:00
* Number of days: 364
* Number of runs: 4369
====================Portfolio overview============================
* Number of orders: 126
* Initial balance: 400.0000 EUR
* Final balance: 470.5919 EUR
* Total net gain: 70.5919 EUR
* Total net gain percentage: 17.6480%
* Growth rate: 17.6480%
* Growth 70.5919 EUR
====================Positions overview========================
╭────────────┬──────────┬──────────────────┬──────────────┬───────────────┬───────────────────────────┬────────────────┬───────────────╮
│ Position      Amount    Pending amount    Cost (EUR)    Value (EUR)  Percentage of portfolio      Growth (EUR)  Growth_rate   │
├────────────┼──────────┼──────────────────┼──────────────┼───────────────┼───────────────────────────┼────────────────┼───────────────┤
│ EUR          470.592                 0       470.592        470.592  100.0000%                               0  0.0000%       │
╰────────────┴──────────┴──────────────────┴──────────────┴───────────────┴───────────────────────────┴────────────────┴───────────────╯
====================Trades overview===========================
* Number of trades closed: 63
* Number of trades open: 0
* Percentage of positive trades: 31.746031746031743%
* Percentage of negative trades: 68.25396825396825%
* Average trade size: 108.7449 EUR
* Average trade duration: 78.34920634920636 hours
╭─────────┬─────────────────────┬─────────────────────┬────────────────────┬──────────────┬──────────────────┬───────────────────────┬────────────────────┬─────────────────────╮
│ Pair     Open date            Close date             Duration (hours)    Size (EUR)    Net gain (EUR)  Net gain percentage      Open price (EUR)    Close price (EUR) │
├─────────┼─────────────────────┼─────────────────────┼────────────────────┼──────────────┼──────────────────┼───────────────────────┼────────────────────┼─────────────────────┤
│ BTC-EUR  2023-12-19 04:00:00  2023-12-24 12:00:00                 128      113.924             1.3369  1.1735%                             39284                39745 │
├─────────┼─────────────────────┼─────────────────────┼────────────────────┼──────────────┼──────────────────┼───────────────────────┼────────────────────┼─────────────────────┤
│ BTC-EUR  2023-12-16 12:00:00  2023-12-17 08:00:00                  20      116.856            -1.431   -1.2246%                            38952                38475 │
├─────────┼─────────────────────┼─────────────────────┼────────────────────┼──────────────┼──────────────────┼───────────────────────┼────────────────────┼─────────────────────┤
│ BTC-EUR  2023-12-14 04:00:00  2023-12-16 00:00:00                  44      117.978            -2.457   -2.0826%                            39326                38507 │
├─────────┼─────────────────────┼─────────────────────┼────────────────────┼──────────────┼──────────────────┼───────────────────────┼────────────────────┼─────────────────────┤
│ BTC-EUR  2023-11-28 22:00:00  2023-12-11 04:00:00                 294      113.53             16.2756  14.3360%                            34403                39335 │
├─────────┼─────────────────────┼─────────────────────┼────────────────────┼──────────────┼──────────────────┼───────────────────────┼────────────────────┼─────────────────────┤
│ BTC-EUR  2023-11-23 00:00:00  2023-11-26 20:00:00                  92      113.371            -0.3795  -0.3347%                            34355                34240 │
├─────────┼─────────────────────┼─────────────────────┼────────────────────┼──────────────┼──────────────────┼───────────────────────┼────────────────────┼─────────────────────┤
│ BTC-EUR  2023-11-19 22:00:00  2023-11-22 00:00:00                  50      113.144            -4.9665  -4.3895%                            34286                32781 │
├─────────┼─────────────────────┼─────────────────────┼────────────────────┼──────────────┼──────────────────┼───────────────────────┼────────────────────┼─────────────────────┤
│ BTC-EUR  2023-11-16 04:00:00  2023-11-16 22:00:00                  18      114.154            -4.5936  -4.0241%                            34592                33200 │
├─────────┼─────────────────────┼─────────────────────┼────────────────────┼──────────────┼──────────────────┼───────────────────────┼────────────────────┼─────────────────────┤
│ BTC-EUR  2023-11-06 10:00:00  2023-11-13 14:00:00                 172      114.765             6.132   5.3431%                             32790                34542 │
├─────────┼─────────────────────┼─────────────────────┼────────────────────┼──────────────┼──────────────────┼───────────────────────┼────────────────────┼─────────────────────┤
│ BTC-EUR  2023-11-05 10:00:00  2023-11-05 22:00:00                  12      114.635            -1.365   -1.1907%                            32753                32363 │
├─────────┼─────────────────────┼─────────────────────┼────────────────────┼──────────────┼──────────────────┼───────────────────────┼────────────────────┼─────────────────────┤
│ BTC-EUR  2023-10-31 20:00:00  2023-11-03 08:00:00                  60      114.184            -0.588   -0.5150%                            32624                32456 │
├─────────┼─────────────────────┼─────────────────────┼────────────────────┼──────────────┼──────────────────┼───────────────────────┼────────────────────┼─────────────────────┤
│ BTC-EUR  2023-10-29 16:00:00  2023-10-31 16:00:00                  48      114.632            -0.9905  -0.8641%                            32752                32469 │
├─────────┼─────────────────────┼─────────────────────┼────────────────────┼──────────────┼──────────────────┼───────────────────────┼────────────────────┼─────────────────────┤
│ BTC-EUR  2023-10-14 04:00:00  2023-10-27 22:00:00                 330      107.44             27.0732  25.1984%                            25581                32027 │
├─────────┼─────────────────────┼─────────────────────┼────────────────────┼──────────────┼──────────────────┼───────────────────────┼────────────────────┼─────────────────────┤
│ BTC-EUR  2023-10-06 18:00:00  2023-10-09 16:00:00                  70      108.244            -1.4104  -1.3030%                            26401                26057 │
├─────────┼─────────────────────┼─────────────────────┼────────────────────┼──────────────┼──────────────────┼───────────────────────┼────────────────────┼─────────────────────┤
│ BTC-EUR  2023-09-27 10:00:00  2023-10-05 20:00:00                 202      106.424             3.0408  2.8573%                             25339                26063 │
├─────────┼─────────────────────┼─────────────────────┼────────────────────┼──────────────┼──────────────────┼───────────────────────┼────────────────────┼─────────────────────┤
│ BTC-EUR  2023-09-12 16:00:00  2023-09-21 18:00:00                 218      106.304             3.6784  3.4603%                             24160                24996 │
├─────────┼─────────────────────┼─────────────────────┼────────────────────┼──────────────┼──────────────────┼───────────────────────┼────────────────────┼─────────────────────┤
│ BTC-EUR  2023-09-07 02:00:00  2023-09-10 16:00:00                  86      105.943             0.1144  0.1080%                             24078                24104 │
├─────────┼─────────────────────┼─────────────────────┼────────────────────┼──────────────┼──────────────────┼───────────────────────┼────────────────────┼─────────────────────┤
│ BTC-EUR  2023-09-06 00:00:00  2023-09-06 12:00:00                  12      105.772            -0.4136  -0.3910%                            24039                23945 │
├─────────┼─────────────────────┼─────────────────────┼────────────────────┼──────────────┼──────────────────┼───────────────────────┼────────────────────┼─────────────────────┤
│ BTC-EUR  2023-09-04 18:00:00  2023-09-04 22:00:00                   4      107.924            -0.9765  -0.9048%                            23983                23766 │
├─────────┼─────────────────────┼─────────────────────┼────────────────────┼──────────────┼──────────────────┼───────────────────────┼────────────────────┼─────────────────────┤
│ BTC-EUR  2023-08-29 14:00:00  2023-09-01 02:00:00                  60      108.627            -5.6072  -5.1619%                            25262                23958 │
├─────────┼─────────────────────┼─────────────────────┼────────────────────┼──────────────┼──────────────────┼───────────────────────┼────────────────────┼─────────────────────┤
│ BTC-EUR  2023-08-26 10:00:00  2023-08-26 20:00:00                  10      108.617            -0.072   -0.0663%                            24137                24121 │
├─────────┼─────────────────────┼─────────────────────┼────────────────────┼──────────────┼──────────────────┼───────────────────────┼────────────────────┼─────────────────────┤
│ BTC-EUR  2023-08-23 14:00:00  2023-08-26 08:00:00                  66      108.243             0.324   0.2993%                             24054                24126 │
├─────────┼─────────────────────┼─────────────────────┼────────────────────┼──────────────┼──────────────────┼───────────────────────┼────────────────────┼─────────────────────┤
│ BTC-EUR  2023-08-14 06:00:00  2023-08-15 18:00:00                  36      107.344            -0.044   -0.0410%                            26836                26825 │
├─────────┼─────────────────────┼─────────────────────┼────────────────────┼──────────────┼──────────────────┼───────────────────────┼────────────────────┼─────────────────────┤
│ BTC-EUR  2023-08-13 02:00:00  2023-08-14 02:00:00                  24      107.48             -0.476   -0.4429%                            26870                26751 │
├─────────┼─────────────────────┼─────────────────────┼────────────────────┼──────────────┼──────────────────┼───────────────────────┼────────────────────┼─────────────────────┤
│ BTC-EUR  2023-08-08 06:00:00  2023-08-11 04:00:00                  70      108.876             0.779   0.7155%                             26555                26745 │
├─────────┼─────────────────────┼─────────────────────┼────────────────────┼──────────────┼──────────────────┼───────────────────────┼────────────────────┼─────────────────────┤
│ BTC-EUR  2023-08-02 02:00:00  2023-08-04 18:00:00                  64      107.752            -1.8     -1.6705%                            26938                26488 │
├─────────┼─────────────────────┼─────────────────────┼────────────────────┼──────────────┼──────────────────┼───────────────────────┼────────────────────┼─────────────────────┤
│ BTC-EUR  2023-07-31 00:00:00  2023-08-01 00:00:00                  24      109.536            -0.656   -0.5989%                            26716                26556 │
├─────────┼─────────────────────┼─────────────────────┼────────────────────┼──────────────┼──────────────────┼───────────────────────┼────────────────────┼─────────────────────┤
│ BTC-EUR  2023-07-27 12:00:00  2023-07-31 00:00:00                  84      109.614            -0.7298  -0.6658%                            26735                26557 │
├─────────┼─────────────────────┼─────────────────────┼────────────────────┼──────────────┼──────────────────┼───────────────────────┼────────────────────┼─────────────────────┤
│ BTC-EUR  2023-07-20 10:00:00  2023-07-24 12:00:00                  98      108.184            -2.668   -2.4662%                            27046                26379 │
├─────────┼─────────────────────┼─────────────────────┼────────────────────┼──────────────┼──────────────────┼───────────────────────┼────────────────────┼─────────────────────┤
│ BTC-EUR  2023-07-13 22:00:00  2023-07-14 22:00:00                  24      109.415            -4.0872  -3.7355%                            28055                27007 │
├─────────┼─────────────────────┼─────────────────────┼────────────────────┼──────────────┼──────────────────┼───────────────────────┼────────────────────┼─────────────────────┤
│ BTC-EUR  2023-07-11 00:00:00  2023-07-12 22:00:00                  46      111.212            -1.904   -1.7120%                            27803                27327 │
├─────────┼─────────────────────┼─────────────────────┼────────────────────┼──────────────┼──────────────────┼───────────────────────┼────────────────────┼─────────────────────┤
│ BTC-EUR  2023-07-01 10:00:00  2023-07-05 16:00:00                 102      111.9              -0.148   -0.1323%                            27975                27938 │
├─────────┼─────────────────────┼─────────────────────┼────────────────────┼──────────────┼──────────────────┼───────────────────────┼────────────────────┼─────────────────────┤
│ BTC-EUR  2023-06-29 16:00:00  2023-07-01 04:00:00                  36      112.316            -1.032   -0.9188%                            28079                27821 │
├─────────┼─────────────────────┼─────────────────────┼────────────────────┼──────────────┼──────────────────┼───────────────────────┼────────────────────┼─────────────────────┤
│ BTC-EUR  2023-06-28 02:00:00  2023-06-28 06:00:00                   4      111.28              0.008   0.0072%                             27820                27822 │
├─────────┼─────────────────────┼─────────────────────┼────────────────────┼──────────────┼──────────────────┼───────────────────────┼────────────────────┼─────────────────────┤
│ BTC-EUR  2023-06-17 00:00:00  2023-06-26 08:00:00                 224      107.564            17.892   16.6339%                            23903                27879 │
├─────────┼─────────────────────┼─────────────────────┼────────────────────┼──────────────┼──────────────────┼───────────────────────┼────────────────────┼─────────────────────┤
│ BTC-EUR  2023-06-09 12:00:00  2023-06-10 04:00:00                  16      106.386            -1.075   -1.0105%                            24741                24491 │
├─────────┼─────────────────────┼─────────────────────┼────────────────────┼──────────────┼──────────────────┼───────────────────────┼────────────────────┼─────────────────────┤
│ BTC-EUR  2023-06-07 04:00:00  2023-06-07 22:00:00                  18      108.33             -3.1906  -2.9453%                            25193                24451 │
├─────────┼─────────────────────┼─────────────────────┼────────────────────┼──────────────┼──────────────────┼───────────────────────┼────────────────────┼─────────────────────┤
│ BTC-EUR  2023-06-03 10:00:00  2023-06-05 10:00:00                  48      108.996            -1.2943  -1.1875%                            25348                25047 │
├─────────┼─────────────────────┼─────────────────────┼────────────────────┼──────────────┼──────────────────┼───────────────────────┼────────────────────┼─────────────────────┤
│ BTC-EUR  2023-05-26 22:00:00  2023-05-31 14:00:00                 112      107.113             2.021   1.8868%                             24910                25380 │
├─────────┼─────────────────────┼─────────────────────┼────────────────────┼──────────────┼──────────────────┼───────────────────────┼────────────────────┼─────────────────────┤
│ BTC-EUR  2023-05-23 02:00:00  2023-05-24 14:00:00                  36      108.807            -3.1175  -2.8652%                            25304                24579 │
├─────────┼─────────────────────┼─────────────────────┼────────────────────┼──────────────┼──────────────────┼───────────────────────┼────────────────────┼─────────────────────┤
│ BTC-EUR  2023-05-20 22:00:00  2023-05-21 18:00:00                  20      107.883            -0.9933  -0.9207%                            25089                24858 │
├─────────┼─────────────────────┼─────────────────────┼────────────────────┼──────────────┼──────────────────┼───────────────────────┼────────────────────┼─────────────────────┤
│ BTC-EUR  2023-05-18 00:00:00  2023-05-19 04:00:00                  28      108.283            -1.1051  -1.0206%                            25182                24925 │
├─────────┼─────────────────────┼─────────────────────┼────────────────────┼──────────────┼──────────────────┼───────────────────────┼────────────────────┼─────────────────────┤
│ BTC-EUR  2023-05-14 16:00:00  2023-05-17 00:00:00                  56      109.327             0.1804  0.1650%                             24847                24888 │
├─────────┼─────────────────────┼─────────────────────┼────────────────────┼──────────────┼──────────────────┼───────────────────────┼────────────────────┼─────────────────────┤
│ BTC-EUR  2023-05-04 06:00:00  2023-05-07 04:00:00                  70      110.3              -0.2142  -0.1942%                            26262                26211 │
├─────────┼─────────────────────┼─────────────────────┼────────────────────┼──────────────┼──────────────────┼───────────────────────┼────────────────────┼─────────────────────┤
│ BTC-EUR  2023-04-25 22:00:00  2023-05-01 04:00:00                 126      108.339             0.7056  0.6513%                             25795                25963 │
├─────────┼─────────────────────┼─────────────────────┼────────────────────┼──────────────┼──────────────────┼───────────────────────┼────────────────────┼─────────────────────┤
│ BTC-EUR  2023-04-18 20:00:00  2023-04-19 14:00:00                  18      110.756            -3.552   -3.2070%                            27689                26801 │
├─────────┼─────────────────────┼─────────────────────┼────────────────────┼──────────────┼──────────────────┼───────────────────────┼────────────────────┼─────────────────────┤
│ BTC-EUR  2023-04-09 20:00:00  2023-04-17 02:00:00                 174      109.578             5.2332  4.7758%                             26090                27336 │
├─────────┼─────────────────────┼─────────────────────┼────────────────────┼──────────────┼──────────────────┼───────────────────────┼────────────────────┼─────────────────────┤
│ BTC-EUR  2023-04-05 10:00:00  2023-04-06 02:00:00                  16      109.654            -1.3776  -1.2563%                            26108                25780 │
├─────────┼─────────────────────┼─────────────────────┼────────────────────┼──────────────┼──────────────────┼───────────────────────┼────────────────────┼─────────────────────┤
│ BTC-EUR  2023-03-29 10:00:00  2023-04-02 22:00:00                 108      109.507            -0.861   -0.7863%                            26073                25868 │
├─────────┼─────────────────────┼─────────────────────┼────────────────────┼──────────────┼──────────────────┼───────────────────────┼────────────────────┼─────────────────────┤
│ BTC-EUR  2023-03-26 14:00:00  2023-03-27 16:00:00                  26      108.788            -3.9018  -3.5866%                            25902                24973 │
├─────────┼─────────────────────┼─────────────────────┼────────────────────┼──────────────┼──────────────────┼───────────────────────┼────────────────────┼─────────────────────┤
│ BTC-EUR  2023-03-24 02:00:00  2023-03-25 00:00:00                  22      109.628            -2.1252  -1.9385%                            26102                25596 │
├─────────┼─────────────────────┼─────────────────────┼────────────────────┼──────────────┼──────────────────┼───────────────────────┼────────────────────┼─────────────────────┤
│ BTC-EUR  2023-03-12 22:00:00  2023-03-23 00:00:00                 242      105.391            22.9143  21.7421%                            20665                25158 │
├─────────┼─────────────────────┼─────────────────────┼────────────────────┼──────────────┼──────────────────┼───────────────────────┼────────────────────┼─────────────────────┤
│ BTC-EUR  2023-03-01 06:00:00  2023-03-02 06:00:00                  24      104.664            -1.0951  -1.0463%                            22269                22036 │
├─────────┼─────────────────────┼─────────────────────┼────────────────────┼──────────────┼──────────────────┼───────────────────────┼────────────────────┼─────────────────────┤
│ BTC-EUR  2023-02-28 14:00:00  2023-02-28 22:00:00                   8      106.464            -1.368   -1.2849%                            22180                21895 │
├─────────┼─────────────────────┼─────────────────────┼────────────────────┼──────────────┼──────────────────┼───────────────────────┼────────────────────┼─────────────────────┤
│ BTC-EUR  2023-02-28 02:00:00  2023-02-28 08:00:00                   6      106.402            -1.104   -1.0376%                            22167                21937 │
├─────────┼─────────────────────┼─────────────────────┼────────────────────┼──────────────┼──────────────────┼───────────────────────┼────────────────────┼─────────────────────┤
│ BTC-EUR  2023-02-27 06:00:00  2023-02-27 22:00:00                  16      106.603            -0.8352  -0.7835%                            22209                22035 │
├─────────┼─────────────────────┼─────────────────────┼────────────────────┼──────────────┼──────────────────┼───────────────────────┼────────────────────┼─────────────────────┤
│ BTC-EUR  2023-02-14 18:00:00  2023-02-22 02:00:00                 176      103.52             10.055   9.7131%                             20704                22715 │
├─────────┼─────────────────────┼─────────────────────┼────────────────────┼──────────────┼──────────────────┼───────────────────────┼────────────────────┼─────────────────────┤
│ BTC-EUR  2023-02-07 22:00:00  2023-02-09 04:00:00                  30      103.973            -3.2112  -3.0885%                            21661                20992 │
├─────────┼─────────────────────┼─────────────────────┼────────────────────┼──────────────┼──────────────────┼───────────────────────┼────────────────────┼─────────────────────┤
│ BTC-EUR  2023-02-02 04:00:00  2023-02-05 18:00:00                  86      105.894            -2.1658  -2.0453%                            21611                21169 │
├─────────┼─────────────────────┼─────────────────────┼────────────────────┼──────────────┼──────────────────┼───────────────────────┼────────────────────┼─────────────────────┤
│ BTC-EUR  2023-01-26 04:00:00  2023-01-30 22:00:00                 114      106.13             -1.245   -1.1731%                            21226                20977 │
├─────────┼─────────────────────┼─────────────────────┼────────────────────┼──────────────┼──────────────────┼───────────────────────┼────────────────────┼─────────────────────┤
│ BTC-EUR  2023-01-20 18:00:00  2023-01-25 02:00:00                 104      104.924             4.6004  4.3845%                             19797                20665 │
├─────────┼─────────────────────┼─────────────────────┼────────────────────┼──────────────┼──────────────────┼───────────────────────┼────────────────────┼─────────────────────┤
│ BTC-EUR  2023-01-08 22:00:00  2023-01-19 02:00:00                 244       99.6278           19.2324  19.3043%                            16069                19171 │
├─────────┼─────────────────────┼─────────────────────┼────────────────────┼──────────────┼──────────────────┼───────────────────────┼────────────────────┼─────────────────────┤
│ BTC-EUR  2023-01-08 14:00:00  2023-01-08 20:00:00                   6       98.9644           -0.5146  -0.5200%                            15962                15879 │
├─────────┼─────────────────────┼─────────────────────┼────────────────────┼──────────────┼──────────────────┼───────────────────────┼────────────────────┼─────────────────────┤
│ BTC-EUR  2023-01-02 04:00:00  2023-01-08 14:00:00                 154       99.5136            2.1376  2.1480%                             15549                15883 │
╰─────────┴─────────────────────┴─────────────────────┴────────────────────┴──────────────┴──────────────────┴───────────────────────┴────────────────────┴─────────────────────╯
==================================================================

Broker/Exchange configuration

The framework has by default support for ccxt. This should allow you to connect to a lot of brokers/exchanges.

from investing_algorithm_framework import PortfolioConfiguration, \
    MarketCredential, create_app
app = create_app()
app.add_market_credential(
    MarketCredential(
        market="<your market>", 
        api_key="<your api key>",
        secret_key="<your secret key>",
    )
)
app.add_portfolio_configuration(
    PortfolioConfiguration(
        market="<your market>", 
        initial_balance=400,
        track_from="01/01/2022",
        trading_symbol="EUR"
    )
)

Download

You can download the framework with pypi.

pip install investing-algorithm-framework

Disclaimer

If you use this framework for your investments, do not risk money which you are afraid to lose, until you have clear understanding how the framework works. We can't stress this enough:

BEFORE YOU START USING MONEY WITH THE FRAMEWORK, MAKE SURE THAT YOU TESTED YOUR COMPONENTS THOROUGHLY. USE THE SOFTWARE AT YOUR OWN RISK. THE AUTHORS AND ALL AFFILIATES ASSUME NO RESPONSIBILITY FOR YOUR INVESTMENT RESULTS.

Also, make sure that you read the source code of any plugin you use or implementation of an algorithm made with this framework.

For further information regarding usage and licensing we recommend going to the licensing page at the website.

Documentation

All the documentation can be found online at the documentation webstie

In most cases, you'll probably never have to change code on this repo directly if you are building your algorithm/bot. But if you do, check out the contributing page at the website.

If you'd like to chat with investing-algorithm-framework users and developers, join us on Slack or join us on reddit

Acknowledgements

We want to thank all contributors to this project. A full list of all the people that contributed to the project can be found here

Bugs / Issues

If you discover a bug in the framework, please search our issue tracker first. If it hasn't been reported, please create a new issue.

Contributing

Feel like the framework is missing a feature? We welcome your pull requests! If you want to contribute to the project roadmap, please take a look at the project board. You can pick up a task by assigning yourself to it.

Note before starting any major new feature work, please open an issue describing what you are planning to do. This will ensure that interested parties can give valuable feedback on the feature, and let others know that you are working on it.

Important: Always create your feature or hotfix against the develop branch, not master.

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

investing_algorithm_framework-2.2.4.tar.gz (86.4 kB view hashes)

Uploaded Source

Built Distribution

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page