/
command_line.py
81 lines (64 loc) · 2 KB
/
command_line.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# -*- coding: utf-8 -*-
"""
Created on Wed Jan 13 10:21:02 2016
@author: mjchao
"""
'''
Gets the price data for the given commodity.
@param commodityId - the ID of a commodity
@param return - the price data for the given commodity
'''
def get_data_by_id( commodityId ):
from price_data_io import PriceReader
return PriceReader.get_price_data_from_csv( commodityId )
'''
Plots the price of a commodity over time
@param commodityId - the ID of a commodity
'''
def plot_price_by_id( commodityId ):
data = get_data_by_id( commodityId )
data.plot_price_over_time()
'''
Plots the trade volume of a commodity over time
@param commodityId - the ID of a commodity
'''
def plot_volume_by_id( commodityId ):
data = get_data_by_id( commodityId )
data.plot_volume_over_time()
def get_id_from_name( commodityName ):
from data_manager import DataManager
DataManager.init()
commodityName = commodityName.lower()
return DataManager.nameToId[ commodityName ] if commodityName in DataManager.nameToId else None
'''
Gets the price data for the given commodity.
@param commodityName - the in-game name of a commodity
@param return - the price data for the given commodity
'''
def get_data_by_name( commodityName ):
id = get_id_from_name( commodityName )
if ( id is not None ):
return get_data_by_id( id )
else:
print "Invalid commodity name."
return None
'''
Plots the price of a commodity over time
@param commodityName - the name of a commodity
'''
def plot_price_by_name( commodityName ):
id = get_id_from_name( commodityName )
if ( id is not None ):
plot_price_by_id( id )
else:
print "Invalid commodity name."
'''
Plots the trade volume of a commodity over time
@param commodityName - the name of a commodity
'''
def plot_volume_by_name( commodityName ):
id = get_id_from_name( commodityName )
if ( id is not None ):
plot_volume_by_id( id )
else:
print "Invalid commodity name."