Giter Club home page Giter Club logo

mynt's Introduction

Hi there 👋

  • I’m currently working on my gorgeous MVP app Unfortunately this one got killed by Microsoft 😅
  • I occasionally blog about things I enjoy doing: https://thewissen.io
  • I used to be on a podcast with my best friends in the whole world: https://nullpointers.io
  • Ask me about .NET MAUI/Xamarin or you know...graphical thingamajigs.
  • Reach me on the Twitterverse
  • Pronouns: He/him
  • Fun fact: I love chocolate.

I'm available for freelance work! 🧑‍💻

I’m a .NET developer from the Netherlands with a focus on mobile and web/backend development. However, I will not shy away from new challenges. Sharing with the community and helping people with the content I create is what motivates me on a daily basis. I also have a passion for design that I like to express in all of my work. I’m always eager to learn new things and consider myself to have a growth mindset. When I’m not coding you can find me on Twitter, playing soccer, cycling, being with my family, or just having the occasional drink with my friends. If you bring cookies, chocolate, and/or a nice beer we can quickly become best friends!

mynt's People

Contributors

bogdanbujdea avatar cryptoandrej avatar jgsnijders avatar lordofdoom avatar raimon93 avatar sthewissen avatar

Stargazers

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

Watchers

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

mynt's Issues

Wrong calculation of profit in ExecuteSellOrder method if the AmountOfBtcToInvestPerTrader is changed after the buy

First of all I want to thank you on putting your effort and publishing the source of this awesome project. I'm also in process of playing with creation of trading bots and your project really helped me a lot, especially because it is on Azure and it uses .NET (environment where I'm most comfortable). So thumbs up!

Now on possible issue. I'm looking at the code and trying to understand it and following line in ExecuteSellOrder method confuses me:

var investment = (Constants.AmountOfBtcToInvestPerTrader * (1 - Constants.TransactionFeePercentage));

So if I understood correctly the whole workflow, the problem will arise if I the system generate the buy order for amount of Constants.AmountOfBtcToInvestPerTrader and if after that buy user change the Constants.AmountOfBtcToInvestPerTrader the whole profit will be calculated using the old value which will mess up the calculation.

Should we use trade.StakeAmount which is persisted in the storage when buy is generated?

var investment = (trade.StakeAmount * (1 - Constants.TransactionFeePercentage));

PaperTrade dont fill

I don't know if PaperTrade is a WIP, but should a "PaperTrade" order not always be filled (buy) to get results for proper testing ?

Currently it will get cleaned/canceled with "CancelUnboughtOrders()" because there is no fill.

Cleanup the amount of strategies?

The current amount of strategies may be a bit overkill. A lot of these were added simply to see how they'd perform but never cleaned up. Perhaps it would be a good thing to go for quality instead of quantity. The backtester could be a good tool to help refine some of the better performing ones.

Improve dry running functionality

Currently dry running is not able to update trades because no actual orders are being created on an exchange. To provide a full dry running experience dry running needs to be able to perform all the functionalities that the bot can perform.

Mynt.AspNetCore.Host

Change please appsettings.json

From:
"Telegram": {
"ChatId": null,
"BotToken": null
},

To:
"Telegram": {
"TelegramChatId": null,
"TelegramBotToken": null
},

Can BackTester be run within Azure?

I'm trying to get myself all setup and I'm using Azure for the first time. I've also tried setting it locally but my Mac doesn't seem to want to play nice with it. I think I've got my configuration finally setup in Azure. But I'm not sure how to get BackTester.Console running on the console within my project?

As a side question: Is there a slack/discord/etcetc group setup to discuss this project?

Thanks

Feedback on Develop

Hi guys,

I just wanted to say that I've spent a couple of days on this project and specially on the Develop branch. I know that you're still working on it. Keep up the good work :-)

There are a few problems with the code and therefore the result is wrong. To give you an example in GenericTradeManager.GetAdvice which is one of the most important part of the project this code is used: (at this moment)

private async Task<ITradeAdvice> GetAdvice(string tradeMarket)
    {
        var minimumDate = DateTime.UtcNow.AddHours(**-120**);
        var candleDate = new DateTime(DateTime.**Now**.Year, DateTime.**Now**.Month, DateTime.**UtcNow**.Day, DateTime.**Now**.Hour, 0, 0, 0);
        var candles = await _api.GetTickerHistory(tradeMarket, minimumDate, Core.Models.Period**.Hour**);

        // We eliminate all candles that aren't needed and the last one (if it's the current running candle).
        candles = candles.Where(x => x.Timestamp > minimumDate && x.Timestamp < candleDate).ToList();

        // Get the date for the last candle we have left.
        var signalDate = candles[candles.Count - 1].Timestamp;

        // This is an outdated candle...
        if (signalDate < DateTime.**UtcNow**.AddMinutes**(-120)**)
            return null;

        // This calculates an advice for the next timestamp.
        var advice = _strategy.Forecast(candles);

        return advice;
    }

Shouldn't you use Utc datetime all the time?
And are you always use -120 hours minimumDate and minutes for outdated candles? Are these not the base values for most strategy calculations?

You did a fine job with this project, but adding more and more features doesn't help it I'm afraid. The current basic features doesn't work well. Another example is the dryRunning. It gave me a lot of errors when tryParse the OrderId from "DRY_RUN_SELL_123456" to a long variable and a few other things as well. But don't remember them now.

Another thing was the fact that somehow I get many runtime exceptions on the strategies. But I'm not sure why. Somehow the SMA(200) on The Scalper strategy is always null and there is not null check on it I guess.

Configuration problem

In azure cloud i can't edit configuration values like locally?
When the function is running in Azure, the configuration values are read from App Settings?
So i need to add an app setting, one by one, is it right?

Exit strategies refinement

Currently there are a few ways of exiting trades:

  • Stop loss is hit - This is currently implemented in a way that the bot checks whether or not the stop loss was hit. Ideally this is done by placing a stop loss order which is way more accurate. However, Bittrex does not support this...
  • Trailing stop is hit - See previous.
  • ROI is hit due to trade time constraint

What is currently not implemented:

  • An exit strategy telling you to sell

I'm still looking for a way to refine this. I can imagine someone wants to use these features depending on the strategy they use? Perhaps these should be enabled through that? If the Prepare method returns a sell action we can use that in the ShouldSell method and the options above can be enabled/disabled in the strategy itself?

Run local?

I am very interested in this project but I need it to be able to run local. Is that in the roadmap?

Allow the bot to run in its own bubble

We should allow the bot to be running in its own bubble, independent of any other trades you're doing. When you set the max amount to trade with to 0.2 BTC it should only use its maximum amount of 0.2 BTC. If you make a loss on a trade and only have 0.18 BTC left it should only use that 0.18 BTC for a next trade. Also when selling e.g. ETH for a trade it is currently doing it should not sell any other ETH you have on your account.

This way any profit above 0.2 BTC is also automatically considered profit since it's not being used again. A setting might be added to toggle this behaviour to use profits in next trades.

Use generic API for exchanges

Hi,

I want to suggest the use of a more generic API. I currently use https://github.com/jjxtra/ExchangeSharp it support almost all important Exchanges (e.g. Poloniex, Binance, Kraken...) and support Websockets.

Also I would suggest to make Azure Database optional to make it completely run on own hardware.

Thank you

how to run it as bot

I manage to run it as Backtester but not sure how to run it as actual live Bot..

Aspnetcore.host project is something seems empty, no UI.. hardly has couple of classes but not sure how to use it..

any Wiki page could be created to run it as Bot, explaining some basics would save a lot of time for people i believe. or reply to my post in bit detail to suffice this requirement. I am sure a lot of people wants to use it.

CancelUnboughtOrders function

Hi,
I use your bot to trade (and making profit :-) )
in the CancelUnboughtOrders there is a extra check needed.
if you going to cancel the order you must first check if the order is not partial filled.
if you trade on 15min then not always is the order filled.

foreach (var trade in _activeTrades.Where(x => x.IsBuying))
                {
                    var exchangeOrder = await _api.GetOrder(trade.BuyOrderId, trade.Market);
                    // if this order is PartiallyFilled, don't cancel
                    if (exchangeOrder?.Status == OrderStatus.PartiallyFilled)
                        continue;  // not yet completed so wait

                    // Cancel our open buy order on the exchange.
                    await _api.CancelOrder(trade.BuyOrderId, trade.Market);

etc.

Bas

Volume Always Empty

Hi,
When creating the Candle data in the Binance API
BinanceApi.cs line 274, the Volume is not set,
so when using a strategy with Volume parameter like the MFI then it always return a 0.
so please adjust the code to:

 new Candle
                {
                    Close = (double)_.Close,
                    High = (double)_.High,
                    Low = (double)_.Low,
                    Open = (double)_.Open,
                    Volume = (double)_.Volume,
                    Timestamp = _.OpenTime
                }

Bas

Stop loss needs to be a negative number

For the stop loss percentage to work it needs to be a negative number. Probably would be a good optimisation to convert whatever the user enters to a negative number to ensure that the user doesn't screw up his current trades when altering the stop loss.

Separate trade start logic from trade monitoring for exit

Currently the trade loop runs once for a given period. If for example you run the loop on 1 hour candles it runs the entire trade loop once every hour. This also means that active trades get checked for their exit conditions only once every hour. I think the trade monitoring for exit conditions could benefit from being a separate process that can run more often compared to the logic for finding a decent entry point.

Binance transaction fee in BNB bug

I believe there might be an issue when paying fees using BNB. Asset quantity that's persisted into the database doesn't match whats in the exchange wallet so there's a tiny amount of the asset left after a sell action.

Find an appropriate license

This software is currently licensed using the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 license. The intention of this piece of software is to free for personal use. However due to the unregulated nature of the crypto world I want to prevent people from selling this piece of software to unsuspecting people and make money from it that way.

However, due to the fact that this piece of software is mainly used to make money the current license might contradict itself.

SQL Server not entirely working as planned

Got the following from a user:

SqlServerData cannot use the native login, and the account password must be required.
There will be bugs using SqlServerData. Maybe the reason why I run locally?

Need to check up on the SQL server side of things, because I don't use it myself.

Doesn't binance send the complete candles?

Hi,

I just looked again in the last code and doubt about how the last candle found and then eliminated. Do you eliminate the last candle because you don't know if it is complete? Because in that case, what is the CloseTime in binance?

I ran a little test and it went like this:
On 9:35 the 2 last hourly candles had respectively CloseTime 8:28 and 9:28. I assume that I have to use the 9:28 candle for getting buy/sell advice. But in your code it looks for candles between 8:00 and 9:00 and so removes the last one and uses the 8:28 candle for buy/sell advice!

You know that that last candle is extremely important ;-)

Exception thrown when placing an order

I'm getting this exception thrown when an order is about to be placed. Any thoughts? I am assuming user error but my AmountToInvestPerTrader is 0.02

2018-05-26T08:19:43.164 [Error] ExchangeSharp.APIException : {"code":-1100,"msg":"Illegal characters found in parameter 'quantity'; legal range is '^([0-9]{1,20})(\\.[0-9]{1,20})?$'."}
   at ExchangeSharp.BaseAPI.MakeRequest(String url,String baseUrl,Dictionary`2 payload,String method)
   at ExchangeSharp.ExchangeBinanceAPI.PlaceOrder(ExchangeOrderRequest order)
   at System.Threading.Tasks.Task`1.InnerInvoke()
   at System.Threading.Tasks.Task.Execute()
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at async Mynt.Core.Exchanges.BaseExchange.Buy(String market,Decimal quantity,Decimal rate)
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at async Mynt.Core.TradeManagers.LiveTradeManager.CreateBuyOrder(Trader freeTrader,String pair,Candle signalCandle)
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at async Mynt.Core.TradeManagers.LiveTradeManager.CreateNewTrade(Trader freeTrader,TradeSignal signal)
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at async Mynt.Core.TradeManagers.LiveTradeManager.LookForNewTrades()
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at async Mynt.Functions.BuyTimer.Run(TimerInfo buyTimer,TraceWriter log)

Abstract data storage away from TradeManager

Currently the trade manager is intimately related to the Azure Blob Storage data storage. It would be great if the data storage could be abstracted away so that other data storage methods can be supported in the future.

Wiki Update - local installation

Mynt.AspNetCore.Host local installation on Windows

The Core.Host will be in the near futur the first Mynt UI and will let give you visual output instead of log files. We will work hard on it to make it easy to use for everyone.

This is a step-by-step instruction for installing all the needed software for running mynt local on windows client or server with sql express and iis express. If you don't get it there is a very good youtube video which explains it maybe a little bit more detailed. Youtube
Microsoft did also a very good article for publishing on iis you can find it here Microsoft.

Prepare solution for SQL Server

In your solution you have to change the bindings of the Mynt.AspNetCore.Host project.
bindings
bindings2

After you changed the bindings you have to change the used database in your startup.cs.
Remove:
.AddSingleton<IDataStore, AzureTableStorageDataStore>() .AddSingleton(i => Configuration.GetSection("AzureTableStorageOptions").Get<AzureTableStorageOptions>())

And add:
.AddSingleton<IDataStore, SqlServerDataStore>() .AddSingleton(i => Configuration.GetSection("SqlServerOptions").Get<SqlServerOptions>())

Publishing

Since in the project is the Mynt.AspNetCore.Host you can choose between two modes.
<TargetFrameworks>netcoreapp2.0;net471</TargetFrameworks>

  1. To edit this you have right click on the Mynt.AspNetCore.Host project and then click on Mynt.AspNetCore.Host edit.

  2. Choose on of them but you can run both target frameworks on Windows.

  3. Right click on the Mynt.AspNetCore.Host and click Publish (check picture 1). Select the target folder maybe you have first to create a profile which includes the target folder.
    1

Install IIS express and SQL express

Download the latest versions from the links and install all of them. Most of the time you just can click next.. next.. next.

IIS Server

On Windows Server operating systems it is a little bit different you have to enable the Web Server (IIS) server role and establish role services.

  1. Use the Add Roles and Features wizard from the Manage menu or the link in Server Manager. On the Server Roles step, check the box for Web Server (IIS).
    server-roles-ws2016

  2. After the Features step, the Role services step loads for Web Server (IIS). Select the IIS role services desired or accept the default role services provided.
    role-services-ws2016

Install .Net Core or .Net471

It depends on what you choosed but there are the links for both of them. You just have to install what you need.

Quick and dirty (Only .Net47)

You also can install it directly in windows just goto:

  • Start>Control Panel>Windows features activate or deactivate
  • Select .Net Framework 4.7 Advanced Services
  • and Internet information services
    windowsfeatures

Create site in IIS

As note the physical path has to be your folder with the publish output.

  1. On the hosting system, create a folder to contain the app's published folders and files. An app's deployment layout is described in the Directory Structure topic.

  2. Within the new folder, create a logs folder to hold ASP.NET Core Module stdout logs when stdout logging is enabled. If the app is deployed with a logs folder in the payload, skip this step. For instructions on how to enable MSBuild to create the logs folder automatically when the project is built locally, see the Directory structure topic.

  3. In IIS Manager, open the server's node in the Connections panel. Right-click the Sites folder. Select Add Website from the contextual menu.

  4. Provide a Site name and set the Physical path to the app's deployment folder. Provide the Binding configuration and create the website by selecting OK:
    add-website-ws2016

Very important if your ip is set to localhost you have to place a adress into hostname as example mynt.bot.com in case of this you have to edit you local host file. for this goto and open the host file.
C:\Windows\System32\drivers\etc
In the host file you have to add now this line.
127.0.0.1 mynt.bot.com

Prepare SQL express

Just add an empty database named as you want as example Mynt.

Add Connection string to your configs

Add now the connection string in the appsettings.json
Mynt/src/Mynt.AspNetCore.Host/appsettings.json

It should look like this
"SqlServerOptions": { "SqlServerConnectionString": "Data Source=.\\YOUR_SQL_SERVER_NAME;Initial Catalog=Mynt;Integrated Security=True;MultipleActiveResultSets=True" },
Replace YOUR_SQL_SERVER_NAME with your sql express server name

Start the game

Now you can run the site in IIS just with start page. Have fun :)

Error Solving

Just go to the log file and check the errors. ;)

If anything is wrong or not understandable you are welcome to edit this small description. :-)

Problem with installation and configuration

Hello!
I'm using the master version, but I think the bot is not working.

I'm running in the cloud. I followed the installation and configuration step by step, I created all the resources and sql server database, but no table was created. I configurated it to receive the notifications by the telegram, but I did not receive any.

Can you help me identify the problem?
app_settings
resources

Add Huobi support

Hope to support the Huobi exchange in the near future. This should be easy: update ExchangeSharp. Add the Huobi request API code to the market summary (they are different).

image

Integrate Websockets

Exchanges have a limited request limit over API. Since Steven did a new branch called Rework, he is using now ExchangeSharp. This Nuget has several integrated Websockets from many Exchanges.

The following cryptocurrency exchanges are supported in ExchangeSharp:
Binance (public REST, basic private REST, public web socket (tickers))
Bitfinex (public REST, basic private REST, public web socket (tickers), private web socket (orders))
Bithumb (public REST)
Bitstamp (public REST, basic private REST)
Bittrex (public REST, basic private REST, public web socket (tickers))
Gemini (public REST, basic private REST)
GDAX (public REST, basic private REST, public web socket (tickers))
Kraken (public REST, basic private REST)
Okex (basic public REST)
Poloniex (public REST, basic private REST, public web socket (tickers))

If we could integrate in the Projekt that in each created IExchangeAPI the program should decide if it could use Websockets or only API. The Buy&Sell could be still in the API if it would be to much effort.

Result: There could be a lot more traffic and the bot could check Orders, trades, history and lot more more often.

Is there a simple way to allow for hedging?

It seems the prepare() method of each strategy defines a buy-sell -> buy-sell -> buy-sell pattern by populating the result list which is returned form the method.

Is there any way to support hedging with this workflow? Ie., allow the same coin to be purchased more than one time before reaching a sell point (profit or stoploss). Obviously, the logic for this is simple, but I'm just trying to figure out what needs to be modified in the code (if its at all possible) to allow this.

I should also add that I'm currently looking at this in backtesting context.

Multiple Quote Assets

Hi Guys, I really like this project...great work! Can I suggest extending the scope of trade functionality to use multiple Quote Assets rather than just BTC where you can exclude Quote Assets you don't wish to trade with in the settings?

Also, I haven't checked in detail but is there a feature where you can send an exit market signal where the bot will perform a graceful shutdown after closing all active trades?

Cheers
D

Web interface to gain insights in your trades

A web interface to be able to see what kind of trades you're running would be a great enhancement. It should take into account #24 when it's done and in my opinion should have features such as:

Must:

  • Current trades
  • Trade history

Optional:

  • Immediately sell a trade

Back tester rework

Currently the back tester has a lot of overhead functionality. Ideally you'd want the following features in my opinion:

  • Test buy signals and check forward for a sell signal - decide profit based on that
  • Run one strategy
  • Compare multiple strategies to one another
  • Fixed dataset to run the tests over
  • Ability to update this dataset

The current bot has a lot of features that influence how it trades. Among others you have a stop loss, a ROI mechanism, immediate sell orders etc. Creating a back tester that covers all these scenario's is simply very hard to pull off because a lot of these features rely on ticker info that is not available in candlestick datasets. Therefore it would probably be best to rework the back tester to only support the things mentioned above.

Improve trading performance

Currently the trading process has a serial nature to it. It retrieves all the markets, checks them all for possible trades and then creates all the found trades until no traders are available anymore. This means that a trade may be placed minutes after it was found which is not optimal. The process takes some time and could be optimised further:

  • Stop checking for more trades when the amount of possible trades is exceeded
  • Immediately place a trade as soon as TA has found it
  • Run the TA in parallel instead of one after another?

Decide on what the -1 means in a strategy

Currently some of the strategies use -1 to indicate an opportunity to go short while others use it as a sell signal. It should probably be altered to act in a more uniform way. Perhaps the integers should be removed alltogether and be replaced by an enum so multiple scenarios can be supported. On the other hand the current implemented exchanges don’t support shorting anyway.

Something should probably be done though to prevent people from using a strategy in a way that it isn’t meant to be used.

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.