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

Smart agents #5

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Conversation

avocardio
Copy link

Hello, I added some features that make the simulation dynamics more interesting!

  • Added class SmartMarketTaker, a market participant that trades on flexible strategies
  • Added strategy file
  • Added strategy MovingAverageCrossover, a simple moving average strategy (LSTMs, ARIMA, coming soon)
  • Extended README

I think being able to use guided market participants with random market takers at the same time makes for very interesting simulations. It could also be used to evaluate trading ideas in a more dynamic (and real-world) environment.

Figure_1

^ The strategy agent managed to stay mostly afloat in challenging (market maker) conditions

@martinnmayer
Copy link
Owner

Thank you very much for your pull request! I've taken a look at the code, and I must say that I liked your idea of adding strategies.
I have a few comments and observations, though:

  • Naming conventions: SmartMarketTaker. I assume that "smart" is to contrast with "naive," which makes sense. But, while we can be sure that the latter one is indeed extremely Naive, it would be a little bit misleading to call the first one "Smart."
  • MovingAverageCrossover class: this is an approach that might be good to pursue, but I'm trying to think about more suitable cases in which it would be advantageous to move the 'logic' from the agent's next() function to a strategy class.
  • Strategy class: It would be nice to have a base class for this functionality. In the case of the MovingAverageCrossover class, there's plenty of logic that could be reused by inheriting from a parent class.

@avocardio
Copy link
Author

Thanks for the feedback! Maybe I should have asked first what the overall plans of the project are. Personally, I think besides analyzing market maker / taker behavior, the repo could be interesting to test strategies, which are normally only back-tested through historical data, without any other market participants. I guess that was the idea behind the strategies. Maybe they could just be called 'MarketTaker'?

I like the idea of a parent strategy class. Do you mean something like the tf.keras.Model class for Tensorflow models for example? I would have to think about something like this.

About the strategies themselves, I think it would be best to have separate classes for each strategies, which encourages people to write their own strategy class easily. The main idea is that you only need an .evaluate() function that takes in the prices history and returns a list of weights [buy_prob, sell_prob, idle_prob].

@martinnmayer
Copy link
Owner

The market maker and taker agents are only quick and dirty examples to get a few results and metrics as fast as possible. They inherit from the parent Agent class, which is a barebones agent whose behavior follows whatever we specify in its next function.
If I'm not mistaken, your smart agent class could be replaced with the base Agent class by just calling the strategy's evaluate method inside the agent's 'next' method.
I really like the idea of the Strategy class for handling more complex behavior. For simple logic, I think that handling it inside the next method should be the default approach.

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

Successfully merging this pull request may close these issues.

2 participants