This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from myapp.models.musicians import Musician | |
from myapp.models.albums import Album |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
yf = YahooFinance('GOOG,MSFT') | |
print yf.get_symbols() | |
>> GOOG+MSFT | |
yf.add_symbol('AAPL') | |
print yf.get_symbols() | |
>> GOOG+AAPL+MSFT | |
yf.remove_symbol('GOOG') | |
print yf.get_symbols() | |
>> AAPL+MSFT | |
print yf.get_ask() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import scipy | |
from yahoo_finance import YahooFinance | |
VALUE_TYPE = {'Date': 0, 'Open': 1, 'High': 2, 'Low': 3, 'Close': 4, 'Volume': 5, 'Adj_Close': 6} | |
start_date = "20121101" | |
end_date = "20121201" | |
yf = YahooFinance("AAPL") | |
for (symb, data) in yf.get_historical_prices(start_date, end_date): #get historical data from yahoo finance | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import scipy | |
from yahoo_finance import YahooFinance | |
VALUE_TYPE = {'Date': 0, 'Open': 1, 'High': 2, 'Low': 3, 'Close': 4, 'Volume': 5, 'Adj_Close': 6} | |
start_date = "20121101" | |
end_date = "20121201" | |
yf = YahooFinance("AAPL,GOOG,GLD,USO") | |
percent = scipy.array([0.25, 0.15, 0.4, 0.2]) #investment distribution portfolio |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def brute_force(self): | |
""" | |
check all possibilities: | |
1) best solution for combination of 2 stories (if it exists). | |
2) best solution for combination of 3 stories (if it exists). | |
. | |
. | |
l-1) best solution for combination of l-1 stories (if it exists). | |
l : being the length of the current stories. | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def annealing_simulated(self, T=1000.0,cool=0.35): | |
""" | |
perform the annealing simulated algorithm: | |
1) start with a random solution. | |
2) move to a neighbour solution. | |
(favors better solutions, and accepts worst solutions with a certain probabilities | |
to avoid local minimum until the temperature is totally down) | |
""" | |
#order stories based on their proportioned score | |
ordered_stories = sorted(self._stories, reverse=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
''' | |
Created on Jan 11, 2013 | |
@author: Mourad Mourafiq | |
About: This is an attempt to solve the Quora challenge Feed Optimizer. | |
''' | |
import itertools | |
import copy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Story(object): | |
""" | |
Story object | |
@type _cpt: int | |
@param _cpt: counts the number of instance created. | |
@type _height: int | |
@param _height: The stroy's height. | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Solution(object): | |
""" | |
Potential solution for the upcoming reload | |
@type _stories: list | |
@param _stories: The list of potential items. | |
@type _len_stories : int | |
@param _len_stories: The length of the list of stories. | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Topic(object): | |
""" | |
Topic | |
@type _id: int | |
@param _id: the id of the topic | |
@type _x: float | |
@param _x: the x coordinate in the plane | |