metaphorshear / gene-nation Goto Github PK
View Code? Open in Web Editor NEWAutomatically exported from code.google.com/p/gene-nation
Automatically exported from code.google.com/p/gene-nation
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.
The Thread classes seem in particular not to check whether the semaphores and
functions are set to None or not before using them.
Original issue reported on code.google.com by [email protected]
on 22 Oct 2013 at 4:42
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
"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
Currently, per the StackExchange thread, too many exceptions are ignored within
threads. It would be better to find which exact exceptions I don't care about,
and handle the important ones properly.
Original issue reported on code.google.com by [email protected]
on 22 Oct 2013 at 4:45
"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
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
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
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
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
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.