Giter Site home page Giter Site logo

winster332 / farmmachine Goto Github PK

View Code? Open in Web Editor NEW
19.0 2.0 6.0 142.61 MB

Autonomous trading

License: GNU General Public License v3.0

C# 96.03% JavaScript 1.86% PowerShell 1.04% Dockerfile 1.07%
tradeview pinescript trade autotrader cryptocurrency bittrex bitcoin smart-mining

farmmachine's Introduction

Icon FarmMachine

I tried to write a system of autonomous earnings using TradeView and PineScript. It was an experimental project. Unfortunately, this project was not successful due to the principle of the TradeView platform using their backtesting strategies. At the moment, I suspend work on this project.

Project closed

It was experimentally found that this method is not profitable or working. The reason is that the TradeView platform dynamically changes the results of strategies, making them unstable. For this reason, it is not possible to be sure that the placed order is true, because TradeView can change the indicators at any time.

This is a service consisting of two microservices that allows you to configure offline trading. For this, services are integrated with external exchanges, and TradeView. TradeView is necessary for conducting backtests and receiving signals. Since there is currently no suitable tool for executing PineScript in the local system, I had to put TradeView into the Chromium engine, and already through it execute js scripts on the TradeView side. The FarmMachine.MonitorStrategy microservice is responsible for this. Microservices are connected by the RabbitMQ bus, and the MongoDB database is used for storage. When a new signal arrives, FarmMachine.MonitorStrategy sends the RabbitMQ bus signal. This signal is caught by the FarmMachine.ExchangeBroker service. He is responsible for integration with exchanges. When a buy / sell signal arrives, some calculations occur, after which a conclusion is made - what to buy, at what price and in what volume.

The data project is experimental, and is not recommended for reliable use.

Reports on the work of Rabbit can be seen in this table.
The project works exclusively on Windows. Since the project uses the chromium engine, this greatly complicates the transfer of the project to other OS.

Supported exchanges

Name Version Support
BITTREX 1.0.0 Yes
BINANCE 1.0.0 Yes
POLONIEX future No
HitBTC future No
Bitstamp future No
Bitfinex future No

Use the api key and secret to authorize your api exchange

Services

Scheme

orange - development in progress
red - part due to which docker is not used
blue - direct functions not available

N|Solid

Google Drive - Draw.IO scheme

Build and start

Before you start building a project, you need to install a Docker. After installation and configuration. And after the launch of the infrastructure, you can start assembling the project services

Start infrastructure

You must go to the configuration/docker/ directive, and then run the following commands:

PS> FarmMachine\configuration\docker> docker-compose -f docker-compose.infrastructure.local.yml build

Wait for the completion of the containers.
After that, you can begin to deploy the infrastructure.

PS> FarmMachine\configuration\docker> docker-compose -f docker-compose.infrastructure.local.yml up

Also worth noting, docker is not a required link. You can deploy everything on a real host. The minimum list consists of MongoDB and RabbitMQ.

If no errors appear, then the infrastructure is deployed correctly and you can proceed to the next step - to services.

Start services

Before that, you need to configure RabbitMq and MongoDB. Then change the settings appsettings.json for yourself, and after that you can execute these commands

PS> .\farmmachine.ps1 build
Microsoft (R) Build Engine version 16.2.0-preview-19278-01+d635043bd for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

  Restore completed in 512.73 ms for C:\Users\Winster332\Desktop\FarmMachine\FarmMachine.ExchangeBroker\FarmMachine.ExchangeBroker.csproj.
...
...

PS> .\farmmachine.ps1 start
Begin start FarmMachine.ExchangeBroker
Begin start FarmMachine.MonitorStrategy

After that, the integration service with exchanges should start. If everything went well, a terminal with your settings will appear. And after it, a second service will be launched to monitor the strategy

Configurations

The configuration file is located in FarmMachine/FarmMachine.ExchangeBroker/appsettings.json

{
  "database": { // MongoDB config section
    "dataBaseName": "FarmMachine",
    "connectionString": "mongodb://localhost:27017/"
  },
  "rabbitMq": { // RabbitMQ config section
    "host": "rabbitmq://127.0.0.1/yuor_virtual_host", 
    "concurrencyLimit": 64
  },
  "bittrex": {
    "key": "your_bittrex_key", // Need set your key from bittrex api
    "secret": "your_bittrex_secret", // Need set your secret from bittrex api
    "market": "USD-BTC", // Maker name
    "riskManager": {
      "baseCurrency": "USD", // Your base currency
      "type": "percent", // types risk manager: percent and fixed
      "amount": 0, // for type fixed. Need if you selected type fixed. Fixed amount
      "percent": 100, // // for type percent
      "balanceMinLimit": 15 // minimal balance on you wallet
    }
  },
  "telegram": {
    "enabled": false,
    "apiKey": your_telegram_api_key,
    "apiHash": "your_telegram_api_hash",
    "phoneNumber": "your_phone_number"
  }
}

Logs

All logs are stored in the upper directory Log, and are divided by type of service, and by day.
They look like this:

N|Solid

Integration through RabbitMQ

If you want to use only part of this project. You can easily integrate through the RabbitMQ bus. To do this, you need to connect to the queue

farm_machine

and after that send messages to buy or sell:

FarmMachine.Domain.Commands.Exchange:SellCurrency

public interface BuyCurrency
{
    Guid Id { get; set; }
    DateTime Created { get; set; }
    decimal Amount { get; set; }
    decimal Bid { get; set; }
}

FarmMachine.Domain.Commands.Exchange:BuyCurrency

public interface SellCurrency
{
  Guid Id { get; set; }
  DateTime Created { get; set; }
  decimal Amount { get; set; }
  decimal Ask { get; set; }
}

Links

MassTransit - for RabbitMQ
TradeView - read strategy
Chromium - load and integration with TradeView
Bittrex.Net - for integration with BITTREX API
Binance.Net - for integration with Binance API
Topshelf - run app as service
CQ - html parser
Serilog - logger
Autofac - DI
MongoDB - as load and save documents
TLSharp - telegram integrations

LICENCE

GNU General Public License v3.0

farmmachine's People

Contributors

winster332 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

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.