Coder Social home page Coder Social logo

gene-nation's Introduction

NOTE: This code contains some silly references at the moment, because it helps keep me entertained while staring a screen for hours. All mentioned names belong to their respective owners.


You can start running the program by typing ./test.py or python test.py.

A Pool object will be created. It will choose 100 random symbols from the NASDAQ (assuming ./csvs is empty, otherwise, it uses as many of those as possible), (down)load the historical fundamental data from Morningstar and the Yahoo historical price data for each Stock, and parse this data to be used by the Genomes.

Initially, it might take a while to download everything.

The Pool also creates the Genomes. There are initially 12. Weights are chosen randomly for each of these based on the keys in Morningstar's historical data. These weights are then used to score Stocks, and sort them by that score. Based on a Genome's assessment of the most valuable Stocks, it will place bids. If a stock can be afforded in the quantity desired, they are bought at "market price" (really the day's open). If the stock is a little too expensive, then a limit order will be queued. Otherwise, the stock will be removed from consideration. That may be tweaked a bit soon.

After a stock has been purchased, there will be a trailing stop sell queued for that stock at 25%. Commission for buys and sells is $5.

Each quarter, the Genome with the lowest worth will be culled from the pool, and the two fittest will breed. Mutation has not been added yet, and crossing over is approached fairly simply.

Most important of all: if you want to stop the simulation, you can press CONTROL+C anytime after stocks have been parsed. Your work will be saved (pickled) and can be resumed later.

gene-nation's People

Watchers

 avatar

gene-nation's Issues

It should be optional for genomes to keep their earned money across pool iterations

Currently, after each iteration of the pool has completed, all remaining 
genomes have their money reset to $1000. A strategy that performed poorly one 
year has a new chance to do well, but there is no way of knowing which strategy 
was truly the best over all iterations.

Recommend making this optional, and also keeping track of money earned by each 
genome for each iteration, so the winner can be chosen with greater accuracy.

Original issue reported on code.google.com by [email protected] on 11 Oct 2013 at 12:19

Need to reduce the number of SQL queries executed

"vals = {key: conn.execute(select([a[1] for a in s.this.c.items() if a[0] != 
'key']).where(s.this.c.key == key)).fetchall() for key in self.keys }" would be 
better constructed as a single query, for speed and efficiency's sake.

Original issue reported on code.google.com by [email protected] on 22 Oct 2013 at 4:47

Remove exact type matching

"if isinstance(func, collections.abc.Sequence):" can replace "if type(func) is 
list", thus supporting all similar data structures.

Original issue reported on code.google.com by [email protected] on 22 Oct 2013 at 4:39

Threads may not be necessary for the trunk version

http://codereview.stackexchange.com/questions/32890/is-this-code-thread-safe

Per suggestions there, I think the non-SQL version of this code might not need 
threading. I will have to give multiprocess a second look.

Original issue reported on code.google.com by [email protected] on 22 Oct 2013 at 4:37

Semaphores are useless

http://codereview.stackexchange.com/questions/32890/is-this-code-thread-safe

From this same thread, semaphores should be replaced with Thread Pool or 
something similar.

Original issue reported on code.google.com by [email protected] on 22 Oct 2013 at 4:37

After running an indeterminate length of time, gene nation hangs

What steps will reproduce the problem?
1. Run the program and leave it alone.
2. Look at the output after at least half an hour, usually during the choose or 
bids routine for a new offspring.
3. Attempts to stop with keyboard interrupt may or may not work.

What is the expected output? What do you see instead?
There should be a continual flow of new data until all iterations of the gene 
pool have been completed. Instead, it hangs. This is probably a multi-threading 
related issue.


Original issue reported on code.google.com by [email protected] on 10 Sep 2013 at 2:26

Multiple threads may print at the same time during the bids function

What steps will reproduce the problem?
1. Run the bids function under genome, preferably under Windows
2. Observe that on occasion, the output from several threads is interleaved, 
resulting in unintelligible messages
3. E.g., "Putting in an order for 4 shares of Putting in an order for 5 shares 
BVLD of GOOG @ 4.15 for a total of @ 62 for a total of 1000" (note, don't try 
to do the math on these numbers; they are fake and do not add up)

I recommend following some of the advice at 
http://stackoverflow.com/questions/3029816/how-do-i-get-a-thread-safe-print-in-p
ython-2-6

Original issue reported on code.google.com by [email protected] on 11 Oct 2013 at 12:11

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.