Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Discussion (was: Can't run bots) #10

Open
Lazur opened this issue Jul 24, 2017 · 20 comments
Open

Discussion (was: Can't run bots) #10

Lazur opened this issue Jul 24, 2017 · 20 comments
Assignees

Comments

@Lazur
Copy link

Lazur commented Jul 24, 2017

Hi. Firstly, thanks. Very interesting project, for educate myself also.
I meet some problem. I create strategy and bot. But I can't run any bot, get the error from mysql and a lot of notice messages about undefined constants, mostly about indicators, as I understand. Is this possible on this step test the strategy? Could you please tell little bit, how it should work?
Part of output.

Notice: Use of undefined constant TRADER_MA_TYPE_KAMA - assumed 'TRADER_MA_TYPE_KAMA' in /Applications/MAMP/htdocs/symfony_steps/GTrader-env/GTrader/config/GTrader/Indicators/Trader.php on line 11
PHP Notice:  Use of undefined constant TRADER_MA_TYPE_MAMA - assumed 'TRADER_MA_TYPE_MAMA' in /Applications/MAMP/htdocs/GTrader-env/GTrader/config/GTrader/Indicators/Trader.php on line 12

Notice: Use of undefined constant TRADER_MA_TYPE_MAMA - assumed 'TRADER_MA_TYPE_MAMA' in /Applications/MAMP/htdocs/GTrader-env/GTrader/config/GTrader/Indicators/Trader.php on line 12
PHP Notice:  Use of undefined constant TRADER_MA_TYPE_T3 - assumed 'TRADER_MA_TYPE_T3' in /Applications/MAMP/htdocs/GTrader-env/GTrader/config/GTrader/Indicators/Trader.php on line 13

Notice: Use of undefined constant TRADER_MA_TYPE_T3 - assumed 'TRADER_MA_TYPE_T3' in /Applications/MAMP/htdocs/GTrader-env/GTrader/config/GTrader/Indicators/Trader.php on line 13
  
[Illuminate\Database\QueryException]                                                           
  SQLSTATE[HY000] [2002] Connection refused (SQL: select * from `bots` where `status` = active)                                                       
                                            
  [PDOException]                             
  SQLSTATE[HY000] [2002] Connection refused  
@Lazur
Copy link
Author

Lazur commented Jul 24, 2017

So, I understand my mistake and adjust database in .env. After execute
docker exec -it gtrader_php_1 bash
and inside of container

root@809c749d8270:/gtrader# php artisan bots:run 

                                              
  [ErrorException]                            
  array_merge(): Argument #1 is not an array  
                                              

This is still my mistake or error in code?

@gsoros
Copy link
Owner

gsoros commented Jul 24, 2017

Hi Kiril, thanks for trying out the software.

I have added a check for the case where the strategy does not emit any signals. Can you please try again?

Inside the container:
git pull && su -c "php artisan bots:run" gtrader

Note that if you have any active bots they are automatically run by cron every minute, so be careful if you have entered your real exchange api key/secret and you have any balance on the exchange.

Please test your strategy carefully before activating it. You can check the strategy's performance by adding the "Balance" and "Signals" indicators on the Chart tab.

Good luck and let me know how it goes.

@Lazur
Copy link
Author

Lazur commented Jul 25, 2017

Hi. Thanks for quick response. I did update, but still get error
root@f6ac683d451b:/gtrader# su -c "php artisan bots:run" gtrader
[ErrorException] array_merge(): Argument #1 is not an array

so be careful if you have entered your real exchange api key/secret and you have any balance on the exchange.

Yes sure, I'm not intend to use it with real account, before understand everything.

Please test your strategy carefully before activating it. You can check the strategy's performance by adding the "Balance" and "Signals" indicators on the Chart tab.

What does means "Signals" indicators? Balance is the result of applying strategy, like simulation without opening real orders?
This is very close to what I want to do. I found your project, cos I'm looking in this direction. I want to create strategy and trading simulator for checking strategies and how it works. Is this possible to get you contact and ask few technical and conceptual questions?
Thanks for inspiration 👍

gsoros added a commit that referenced this issue Jul 25, 2017
@gsoros gsoros closed this as completed in 0fabe36 Jul 25, 2017
gsoros added a commit that referenced this issue Jul 25, 2017
@Lazur
Copy link
Author

Lazur commented Jul 25, 2017

Yes. Now it works and I just need to adjust correct API. Thanks.
Wrong API interface

@gsoros
Copy link
Owner

gsoros commented Jul 25, 2017

I think I found the bug that prevented bots from running. Feel free to reopen if still no go.

@gsoros
Copy link
Owner

gsoros commented Jul 25, 2017

Ok, one more thing, the bots will not not actually execute any orders unless APP_ENV=production in .env.

@gsoros
Copy link
Owner

gsoros commented Jul 25, 2017 via email

@Lazur
Copy link
Author

Lazur commented Jul 25, 2017

Basically the logic is: the strategy emits a signal (either short or long)
which you can display on the chart using the Signals indicator.

How I can recognize the type of signal? And this is about buy or sell?
http://prntscr.com/fzyas2
This is looks like strategy is't good and balance was lost? http://prntscr.com/fzybrf

Do you have positive experiments, where strategy with some adjustments may predict the price and get some potential profit?

You did this SPA with just jQuery and bootstrap (and Laravel in back, for sure :) )?
Thank you for answers :)

@gsoros
Copy link
Owner

gsoros commented Jul 25, 2017

How I can recognize the type of signal? And this is about buy or sell?
http://prntscr.com/fzyas2

Yes, the green thingy means open long position (= buy), red thingy means open short position (= sell). I'm planning to add support for neutral position and take profit / stop loss in the future.

This is looks like strategy is't good and balance was lost? http://prntscr.com/fzybrf

At the last candle balance is around 197 so your initial balance of 100 has been doubled.

*** Correction
I just noticed your initial cap was 204 so it's indeed a net loss.


Do you have positive experiments, where strategy with some adjustments may predict the price and get some potential profit?

I have had mixed results, some nice profits and some painful losses. Hard to distinguish luck from a good strategy. Given the nearly constant rise of Bitcoin price over longer time frames it has been difficult to beat the "buy and hold" strategy.

You did this SPA with just jQuery and bootstrap (and Laravel in back, for sure :) )?

SPA?

Thank you for answers :)

Thank you for your interest!

@Lazur
Copy link
Author

Lazur commented Jul 26, 2017

SPA I mean - single page application.

@Lazur
Copy link
Author

Lazur commented Jul 26, 2017

Did you think about to clear data in inputs into neural network, I mean remove extremums as first step?
This is the first step in usual data mining process. Maybe it will helps to reduce false triggering of strategy.

@gsoros
Copy link
Owner

gsoros commented Jul 26, 2017

You can use for example EMA(Open, 5), EMA(Close, 5)... as your inputs, this will smooth out any extreme values but also introduce delay. Is this what you mean?

@Lazur
Copy link
Author

Lazur commented Jul 26, 2017

Ah yes, this is very close is what I mean. Like this way how you implement the system.

@gsoros
Copy link
Owner

gsoros commented Jul 26, 2017

I'm glad somebody appreciates it. Make sure you share your reliable winning strategy with me when you find it :)

@Lazur
Copy link
Author

Lazur commented Jul 30, 2017

Is this looks like successful strategy?
screenshot-30-15-07

I don't know if "Balance" indicator is implemented correctly. I try to understand logic, but I can't handle app architecture in general.

@Lazur
Copy link
Author

Lazur commented Jul 30, 2017

When I continue learning network more, result changed, but still not bad.
screenshot 30 20-27-23

@gsoros
Copy link
Owner

gsoros commented Jul 30, 2017

Hi!

Is this looks like successful strategy?

That depends :) Has the network seen the data, i.e. was it trained on this range? It made some good trades but completely missed out on the big wave from 1900 to 2900.

The "mode=dynamic" setting can be deceptive because it invests less and less as the balance decreases and it will never actually lose all the balance. I have added a description on this field.

I don't know if "Balance" indicator is implemented correctly.

Well, it does not consider the liquidation price on leveraged trades, this one is in the todo.

I try to understand logic, but I can't handle app architecture in general.

I agree, the code is difficult to follow. The project started as a simple one-file script and as I added features it became quite complex at places. Maybe time for a complete rewrite?

@gsoros gsoros changed the title Can't run bots Discussion (was: Can't run bots) Jul 30, 2017
@gsoros gsoros reopened this Jul 30, 2017
@Lazur
Copy link
Author

Lazur commented Jul 31, 2017

Very big thanks for comments in code. It should helps me.
Maybe time for a complete rewrite?
I want. But yes, not so much free time. Firstly I'm intend to call in mind theory of neural networks and learn PHP extensions (FANN and Trader, I did't know about it before and was intend to write even EMA by self).
I like the way how strategy is works and generate signals(base on visual results).
But still did't understand how the signals is generated, based on which data?
How do you think, is this possible after training network create a new dataset, based on "expert" vision, where the signals should be placed and "correct" network.

That depends :) Has the network seen the data, i.e. was it trained on this range?
Yes, it was trained on this range, here the little bit present data.
screenshot at 31 12-55-13
Looks like balance works not correct when I try to scale chart. Try to check.

@gsoros
Copy link
Owner

gsoros commented Aug 1, 2017

I like the way how strategy is works and generate signals(base on visual results).
But still did't understand how the signals is generated, based on which data?

It works something like this: Prediction(Strategy) -> Signals -> Balance

So the Strategy has some inputs and one output. The Prediction indicator takes a sample (which is an array of candles with the necessary indicators) and runs the associated Strategy on it. It outputs a single value which is the output of the net. Then it takes the next sample etc.

The Signals indicator takes the Prediction value and compares it to the open price, if Prediction is higher than 100.5% of open, it emits a long (buy) signal. Inverse for short (sell).

This is the default setup, you can customize many aspects of this flow.

How do you think, is this possible after training network create a new dataset, based on "expert" vision, where the signals should be placed and "correct" network.

Hmm, not sure, I think that's called supervised or reinforcement learning, haven't looked into that. You could extend the UI with a system to manually add signals and train the strategy on that data. The question is whether it could improve the performance...

Yes, it was trained on this range, here the little bit present data

Well, I think it's better to judge a strategy by how it performs on data it has not seen before. It is quite easy to train a network on a range and have a beautiful steadily climbing diagonal balance on that range but that does not tell much about how it would work with live data.

Looks like balance works not correct when I try to scale chart. Try to check.

Where do you see an error?

@Lazur
Copy link
Author

Lazur commented Dec 10, 2017

Hi. As a small conclusion after long time investigation a get understanding and want to share with you what only RNN and LSTM especially networks may be useful for predict time series data, because this type remembers the previous state. Prediction of the price itself is a holy grail. I'm start to think in a direction of prediction(with LSTM and may be decisions tree) the right decision when to in and out of market, based on expert choice (select&generate successful decisions) and train network on this basis. Do not have a time and just share the idea.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants