Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
1e0ad10
Merge pull request #12 from investingbots/feature_framework_setup
Feb 11, 2020
62b6ff4
Setup DataBaseResolver
sadays Jun 6, 2020
022feab
Add check if database is file
sadays Jun 6, 2020
77f5f47
Add tests data base resolver
sadays Jun 10, 2020
552637a
Merge branch 'feature_database_resolver' into develop
sadays Jun 10, 2020
fd38eb4
Update templates
sadays Jun 13, 2020
126af4f
Remove unused data provider attributes
sadays Jun 13, 2020
5259732
Fix data provider state
sadays Jun 13, 2020
8d8d136
Add context configuration
sadays Jun 13, 2020
d2bcb51
Rearange data provider files
sadays Jun 13, 2020
214eec6
Add import module
sadays Jun 13, 2020
d6c0436
Add import module
sadays Jun 13, 2020
522ca05
Fix imports
sadays Jun 13, 2020
b32300c
Update tests
sadays Jun 13, 2020
700e19a
Add logging configuration
sadays Jun 13, 2020
bda6d5f
Add logger
sadays Jun 13, 2020
6de9566
Change config constants to SETTINGS_BOT_CONTEXT_CONFIGURATION
sadays Jun 13, 2020
313bc8c
Remove logger declaration
sadays Jun 13, 2020
09cd2c2
Setup logging config
sadays Jun 13, 2020
5affedb
Add logging
sadays Jun 13, 2020
d28e60b
Add settings configuration for logging
sadays Jun 13, 2020
4a7a6dc
Remove unused settings
sadays Jun 13, 2020
987e63f
Setup logging
sadays Jun 13, 2020
956ac03
Initial commit for scheduled worker
sadays Jun 13, 2020
827a2d6
Change worker to ScheduledWorker
sadays Jun 13, 2020
68db190
Initial commit for Strategy
sadays Jun 13, 2020
7c2f657
Remove data provider executor
sadays Jun 13, 2020
fa4a13c
Add Strategy export
sadays Jun 13, 2020
0bc6d4e
Add Strategy template
sadays Jun 13, 2020
3b59b15
Name template
sadays Jun 13, 2020
1a96a3f
Add StrategyState
sadays Jun 13, 2020
7f06942
Format spacing at the end of the file
sadays Jun 14, 2020
aceba96
Remove unused methods
sadays Jun 14, 2020
135a445
Initial commit for order executors
sadays Jun 14, 2020
6d0a7fc
Put states in dedicated folder
sadays Jun 14, 2020
6dc4e76
Initial commit for OrderingState
sadays Jun 14, 2020
4874e1b
Put BotState in dedicated folder
sadays Jun 14, 2020
59f4076
Add order_executors to templates
sadays Jun 14, 2020
e6419e2
Remove states from context
sadays Jun 14, 2020
a72c903
Update readme
sadays Jun 14, 2020
a9bf50a
Add version utils
MDUYN Jun 18, 2020
6cefc21
Add version tests
MDUYN Jun 18, 2020
da8d2c6
Merge pull request #13 from investingbots/feature_versioning
Jun 18, 2020
7525ba3
Initial travis.ci definition
MDUYN Jun 18, 2020
ccec2f4
Add execution of test.sh
MDUYN Jun 18, 2020
820974d
Update travis.ci definition
MDUYN Jun 18, 2020
169368f
Update travis.ci definition
MDUYN Jun 18, 2020
dc71efb
Update travis.ci definition
MDUYN Jun 18, 2020
da5fd09
Update travis.ci definition
MDUYN Jun 19, 2020
b722207
Update travis.ci definition
MDUYN Jun 19, 2020
7d35c3e
Update travis.ci definition
MDUYN Jun 19, 2020
2462e40
Change to pytest framework
MDUYN Jun 19, 2020
7bf0d66
Change to pytest framework
MDUYN Jun 19, 2020
67af58b
Add pytest framework
MDUYN Jun 19, 2020
d955a39
Add pytest framework
MDUYN Jun 19, 2020
b0b2723
Add codecov
MDUYN Jun 19, 2020
4c800f6
Update readme
MDUYN Jun 19, 2020
449352f
remove unused files
MDUYN Jun 19, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
language: python

install:
- pip install -r requirements.txt

script: pytest # run test

after_success:
- codecov # submit coverage
76 changes: 19 additions & 57 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,69 +1,32 @@
# Investing bot
[![Build Status](https://travis-ci.org/investingbots/investing-bot-framework.svg?branch=master)](https://travis-ci.org/investingbots/investing-bot-framework)

The investing bot is a free and open source investing bot written in Python. The goal is to give you a configurable bot
where you can decide on how you implement your data providers, strategies, and brokers/exchanges. Also we want to allow
you to let your bot facilitate multiple users.
# Investing Algorithm Framework

It is designed to be controlled via Telegram. As of now, we are aiming to make the configuration of the different
components by the use of plugins. Please see the documentation on how to make your own plugin.
The Investing Algorithm Framework is a free and open source Python framework that encourages rapid development and clean,
pragmatic design.

### Disclaimer
This software is for educational purposes only. Do not risk money which you are afraid to lose. We can't stress this
enough: BEFORE YOU START USING MONEY WITH THE BOT, MAKE SURE THAT YOU TESTED YOU STRATEGIES AND DATA PROVIDERS.
USE THE SOFTWARE AT YOUR OWN RISK. THE AUTHORS AND ALL AFFILIATES ASSUME NO RESPONSIBILITY FOR YOUR TRADING RESULTS.
The goal is to give you a configurable investing algorithm where you can decide how you implement your data providers,
strategies, and order executors.

Always start by running a investing bot in Dry-run and do not engage money before you understand how it works and what profit/loss you should expect.
#####Disclaimer
If you use this framework for your investments, do not risk money which you are afraid to lose. We can't stress this
enough:

We strongly recommend you to have coding and Python knowledge, or trust the people that created the plugins your using.
Do not hesitate to read the source code and understand the mechanism of this bot or the plugin you're using.

Brokers/Exchange marketplaces supported
------
Will be updated in the future
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.

Documentation
------
Will be updated in the future

## Features

- [x] **Based on Python 3.6+**: Support for all operating systems - Windows, macOS and Linux.
- [x] **Persistence**: Persistence is achieved through sqlite.
- [ ] **Dry-run**: Run the bot without playing money.
- [ ] **REST API**: Manage the bot with the use of a REST API.
- [ ] **Backtesting**: Run a simulation of your buy/sell strategy.
- [ ] **Manageable via Telegram**: Manage the bot with Telegram.
- [ ] **Display profit/loss**: Display your profit/loss.
- [ ] **Daily summary of profit/loss**: Provide a daily summary of your profit/loss.
- [ ] **Performance status report**: Provide a performance status of your current trades.

## Quick start

The investing bot provides a Linux/macOS script to install all dependencies and help you to configure the bot.

The script will come as a future update

### Bot commands


```
usage: main.py [-h] [-V] [-c PATH]

Trading bot based on value principles

optional arguments:
-h, --help show this help message and exit
-V, --version show program's version number and exit
-c PATH, --config PATH
Specify configuration file (default: `config.json`).

```

### Telegram RPC commands

Telegram is not mandatory. However, this is a great way to control your bot.
All documentation is in the "docs" directory and online at "". If you're just getting started, here's how we recommend
you read the docs:

* First, read install for instructions on installing Investing Algorithm Framework.
* Next, work through the tutorials in order. ("Quickstart", "Template algorithm", "Custom algorithm").
* For concrete algorithm examples you probably want to read through the topical guides.


## Development branches

Expand All @@ -74,7 +37,6 @@ The project is currently setup in two main branches:
- `feature/*` - These are feature branches, which are being worked on heavily. Please don't use these unless you want to test a specific feature.
- `hotfix/*` - These are hot fix branches, which are being worked on heavily. Please don't use these unless you really need to.

## Support

### Help / Slack

Expand Down
3 changes: 3 additions & 0 deletions ci/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh

python3 -m unittest discover -s ../
4 changes: 4 additions & 0 deletions investing_bot_framework/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from investing_bot_framework.utils.version import get_version

VERSION = (1, 0, 0, 'alpha', 0)

27 changes: 14 additions & 13 deletions investing_bot_framework/core/configuration/__init__.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import os
import logging.config
from typing import Any
from importlib import import_module
from enum import Enum

from investing_bot_framework.core.exceptions import ImproperlyConfigured, OperationalException
from investing_bot_framework.core.configuration.template import Template
from investing_bot_framework.core.configuration.config_constants import SETTINGS_MODULE_PATH_ENV_NAME, SETTINGS_STRATEGY_REGISTERED_APPS, \
SETTINGS_DATA_PROVIDER_REGISTERED_APPS
from investing_bot_framework.core.configuration.config_constants import SETTINGS_MODULE_PATH_ENV_NAME, \
SETTINGS_STRATEGY_REGISTERED_APPS, SETTINGS_DATA_PROVIDER_REGISTERED_APPS, BASE_DIR, SETTINGS_LOGGING_CONFIG


class TimeUnit(Enum):
Expand Down Expand Up @@ -59,14 +60,17 @@ class BaseSettings:
Base wrapper for settings module. It will load all the default settings for a given settings module
"""

def __init__(self, settings_module: str = None) -> None:
def __init__(self) -> None:
self._configured = False
self._settings_module = settings_module
self._settings_module = None

if self._settings_module is not None:
self.configure()
def configure(self, settings_module: str = None) -> None:
self._settings_module = settings_module

def configure(self) -> None:
if settings_module is None:
self.settings_module = os.environ.get(SETTINGS_MODULE_PATH_ENV_NAME)
else:
self.settings_module = settings_module

if self.settings_module is None:
raise ImproperlyConfigured("There is no settings module defined")
Expand All @@ -93,14 +97,15 @@ def configure(self) -> None:

self._configured = True

logging.config.dictConfig(self[SETTINGS_LOGGING_CONFIG])

@property
def settings_module(self) -> str:
return self._settings_module

@settings_module.setter
def settings_module(self, settings_module: str) -> None:
self._settings_module = settings_module
self.configure()

@property
def configured(self) -> bool:
Expand Down Expand Up @@ -131,8 +136,4 @@ def get(self, key: str, default: Any = None) -> Any:
return default


def resolve_settings():
return BaseSettings(os.environ.get(SETTINGS_MODULE_PATH_ENV_NAME))


settings = resolve_settings()
settings = BaseSettings()
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@
SETTINGS_DATA_PROVIDER_REGISTERED_APPS = 'INSTALLED_DATA_PROVIDER_APPS'
SETTINGS_STRATEGY_REGISTERED_APPS = 'INSTALLED_STRATEGY_APPS'
SETTINGS_MAX_WORKERS = 'DEFAULT_MAX_WORKERS'
SETTINGS_BOT_CONTEXT_CONFIGURATION = 'BOT_CONTEXT_CONFIGURATION'
SETTINGS_LOGGING_CONFIG = 'LOGGING'

# Operational constants
DEFAULT_MAX_WORKERS = 2

# Database related constants
BASE_DIR = 'BASE_DIR'
DATABASE_NAME = 'DATABASE_NAME'
27 changes: 3 additions & 24 deletions investing_bot_framework/core/context/bot_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from investing_bot_framework.core.configuration import settings
from investing_bot_framework.core.exceptions import OperationalException
from investing_bot_framework.core.utils import Singleton
from investing_bot_framework.core.context.states import BotState
from investing_bot_framework.core.states import BotState


class BotContext(metaclass=Singleton):
Expand All @@ -18,19 +18,13 @@ class BotContext(metaclass=Singleton):
# Settings reference
settings = settings

def initialize(self, bot_state: Type[BotState]) -> None:

# Stop the current state of the investing_bot_framework
if self._state:
self._state.stop()

def register_initial_state(self, bot_state: Type[BotState]) -> None:
self._state = bot_state(context=self)

def transition_to(self, bot_state: Type[BotState]) -> None:
"""
Function to change the running BotState at runtime.
"""

self._state = bot_state(context=self)

def _check_state(self, raise_exception: bool = False) -> bool:
Expand All @@ -42,7 +36,7 @@ def _check_state(self, raise_exception: bool = False) -> bool:

if raise_exception:
raise OperationalException(
"Bot context doesn't have a state, Make sure that you set the state of bot either "
"Bot context doesn't have a state. Make sure that you set the state of bot either "
"by initializing it or making sure that you transition to a new valid state."
)
else:
Expand All @@ -66,18 +60,3 @@ def _run_state(self) -> None:
transition_state = self._state.get_transition_state_class()
self.transition_to(transition_state)

def stop(self) -> None:
"""
Stop the current state of the investing_bot_framework
"""

self._check_state(raise_exception=True)
self._state.stop()

def reconfigure(self) -> None:
"""
Reconfigure the current state of the investing_bot_framework
"""

self._check_state(raise_exception=True)
self._state.reconfigure()
4 changes: 2 additions & 2 deletions investing_bot_framework/core/context/state_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
class StateValidator(ABC):
"""
Class StateValidator: validates the given state. Use this class to change the transition process of a state.
Use it as a hook to decide if a state must transition, e.g. only change to a strategy state if all the
provided data meets a certain threshold.
Use it as a hook to decide if a state must transition, e.g. only change to a strategies state if all the
provided data_providers meets a certain threshold.
"""

@abstractmethod
Expand Down
1 change: 0 additions & 1 deletion investing_bot_framework/core/context/states/__init__.py

This file was deleted.

Loading