Ejemplo n.º 1
0
 def test_find_closest_store_units_km_negative(self):
     dict_list=data.get_data_from_csv('store-locations.csv')
     val='1455 Market St, San Francisco, CA 94103'
     units,output,addr_zip='km','json','address'
     output=data.find_closest_store(dict_list,val,units,output,addr_zip)
     try:
         result=json.loads(output)
         result=result['Distance']
     except ValueError as error:
         result=0.0
     expected=1.614
     self.assertNotEqual(expected,result)
Ejemplo n.º 2
0
 def test_find_closest_store_output_negative(self):
     dict_list=result=data.get_data_from_csv('store-locations.csv')
     val='1455 Market St, San Francisco, CA 94103'
     units,output,addr_zip='mi','text','address'
     output=data.find_closest_store(dict_list,val,units,output,addr_zip)
     try:
         json.loads(output)
         result=True
     except ValueError as error:
         result=False
     expected=False
     self.assertEqual(expected,result)
Ejemplo n.º 3
0
 def test_find_closest_store_output_zip_code_positive(self):
     dict_list=data.get_data_from_csv('store-locations.csv')
     val='93065'
     units,output,addr_zip='mi','json','zipcode'
     output=data.find_closest_store(dict_list,val,units,output,addr_zip)
     try:
         result=json.loads(output)
         result=result['Store_Name']
     except:
         result='Error'
     expected='Simi Valley West'
     self.assertEqual(expected,result)
Ejemplo n.º 4
0
 def test_find_closest_store_output_address_positive(self):
     dict_list=data.get_data_from_csv('store-locations.csv')
     val='1455 Market St, San Francisco, CA 94103'
     units,output,addr_zip='mi','json','address'
     output=data.find_closest_store(dict_list,val,units,output,addr_zip)
     try:
         result=json.loads(output)
         result=result['Store_Name']
     except:
         result='Error'
     expected='San Francisco Central'
     self.assertEqual(expected,result)
Ejemplo n.º 5
0
"""Usage:
  storeFinder.py find_store --address="<address>"
  storeFinder.py find_store --address="<address>" [--units=(mi|km)] [--output=text|json]
  storeFinder.py find_store --zip=<zip>
  storeFinder.py find_store --zip=<zip> [--units=(mi|km)] [--output=text|json]
  """
from docopt import docopt
import json
import data
import sys

if __name__ == '__main__':

    try:
        dict_list = data.get_data_from_csv('store-locations.csv')
        arguments = docopt(__doc__)
        if not dict_list:
            raise TypeError
    except:
        print(
            'No data found in the csv file / docopt unable to parse the arguments in the cli command'
        )

    try:
        if arguments['--address'] != None:
            address = arguments['--address']
            units = 'mi' if arguments['--units'] is None else arguments[
                '--units']  # check this
            output = 'text' if arguments['--output'] is None else arguments[
                '--output']
            print(
Ejemplo n.º 6
0
"""

import numpy as np

from math import isnan
from portfolio import Portfolio
import data
import queue

symbol_list = []
csv_dir = ""
start_date = None
end_date = None
starting_capital = 100000

symbol_data, latest_symbol_data, start_date, end_date = data.get_data_from_csv(
    symbol_list, csv_dir, start_date, end_date)

pf = Portfolio(symbol_list, starting_capital, start_date)

priority_1_signals = queue.Queue()
priority_2_signals = queue.Queue()

data.update_bars(symbol_list, symbol_data, latest_symbol_data)

count = 0
while True:
    count += 1

    if data.update_bars(symbol_list, symbol_data, latest_symbol_data) == True:
        break
Ejemplo n.º 7
0
 def test_get_data_from_csv(self):
     result=data.get_data_from_csv('store-locations.csv')
     self.assertNotEqual(0,result)