Created
November 20, 2012 05:34
-
-
Save jontonsoup/4116228 to your computer and use it in GitHub Desktop.
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
get_covar_all.pl: ($count, $mean_f1,$std_f1, $mean_f2, $std_f2) = ExecStockSQL("ROW",$sql); | |
get_covar_all.pl: ($covar{$s1}{$s2}) = ExecStockSQL("ROW",$sql); | |
get_covar.pl: ($count, $mean_f1,$std_f1, $mean_f2, $std_f2) = ExecStockSQL("ROW",$sql); | |
get_covar.pl: ($covar{$s1}{$s2}) = ExecStockSQL("ROW",$sql); | |
get_data_for_predict.pl:my $data = ExecStockSQL("TEXT",$sql); | |
get_data_for_strat.pl:my $data = ExecStockSQL("TEXT",$sql); | |
get_data.pl:my $data = ExecStockSQL("TEXT",$sql); | |
get_info_beta.pl: $beta = ExecStockSQL("ROW",$sql2); | |
get_info_cvb.pl: ($n,$mean,$std,$min,$max) = ExecStockSQL("ROW",$sql); | |
get_info_cvb.pl: #$beta = ExecStockSQL("ROW",$sql2); | |
get_info.pl: ($n,$mean,$std,$min,$max) = ExecStockSQL("ROW",$sql); | |
get_random_symbol.pl:print ExecStockSQL("TEXT",$sql); | |
get_symbols.pl:print ExecStockSQL("TEXT", | |
header.pl: eval {@col=ExecSQL($dbuser,$dbpasswd, "select count(*) from stockuser where email='$user' and password='$password'",undef);}; | |
header.pl:# @list=ExecSQL($user, $password, $querystring, $type, @fill); | |
header.pl:# Executes a SQL statement. If $type is "ROW", returns first row in list | |
header.pl:# ExecSQL executes "die" on failure. | |
header.pl:sub ExecSQL { | |
login_register.pl: eval { ExecSQL($dbuser,$dbpasswd,"insert into stockuser (email, password) values (?, ?)", undef, $user, $pass);}; | |
login_register.pl: #eval { ExecSQL($dbuser,$dbpasswd,"insert into transaction (symbol, price, quantity, type, cashholding, email) values (?, ?, ?, ?, ?, ?)", undef, "cash", "0", "0", "cash", $cash, $user);}; | |
manage_portfolios.pl: eval {@row=ExecSQL($dbuser, $dbpasswd, "select sys_guid() from dual", undef)}; | |
manage_portfolios.pl: eval {@row=ExecSQL($dbuser, $dbpasswd, "insert into portfolio (id, email) values ('$portfolio_id', '$login')", undef)}; | |
manage_portfolios.pl: eval {@row=ExecSQL($dbuser, $dbpasswd, "insert into transaction (symbol, price, quantity, type, cashholding, email, portfolio_id) | |
plot_stock.pl:my @rows = ExecStockSQL("2D","select timestamp, close from ".GetStockPrefix()."StocksDaily where symbol=rpad(?,16)",$symbol); | |
README: print ExecStockSQL("TEXT", "select * from ..."); | |
register.pl: eval { ExecSQL($dbuser,$dbpasswd,"insert into stockuser (email, password) values (?, ?)", undef, $user, $pass);}; | |
register.pl: #eval { ExecSQL($dbuser,$dbpasswd,"insert into transaction (symbol, price, quantity, type, cashholding, email) values (?, ?, ?, ?, ?, ?)", undef, "cash", "0", "0", "cash", $cash, $user);}; | |
stock_data_access.pm:@EXPORT=qw(ExecStockSQL GetStockPrefix); | |
stock_data_access.pm:# @list or $string = ExecStockSQL($type, $querystring @fill); | |
stock_data_access.pm:# Executes a SQL statement given in $querystring | |
stock_data_access.pm:# ExecStockSQL executes "die" on failure. | |
stock_data_access.pm:sub ExecStockSQL { | |
stock_data_access.pm: return ExecStockCQL(@_); | |
stock_data_access.pm:# @list = ExecStockCQL($type, $querystring); | |
stock_data_access.pm:# Executes a CQL statement given in $querystring | |
stock_data_access.pm:# ExecStockCQL executes "die" on failure. | |
stock_data_access.pm:sub ExecStockCQL { |
Check if a user is valid
select count(*) from stockuser where email='$user' and password='$password'",undef
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Get CashHoldings in a portfolio:
"select cashholding from (select * from transaction where email='$login' and portfolio_id='$portfolio_id' order by ts DESC) where rownum<=1"
Portfolio Value:
"select sum(close*amount) from most_recent_stockinfo natural join hasstock where portfolio_id = '$portfolio_id'"
All stocks a user owns and the number of shares:
"select symbol, amount from stocks natural join hasstock where portfolio_id='$portfolio_id'"
Withdraw money from an account
insert into transaction (symbol, price, quantity, type, cashholding, email, portfolio_id) values('cash', 0, $amount, 'Withdraw', $new_holdings, '$login', '$portfolio_id')"
Deposit money to an account
"insert into transaction (symbol, price, quantity, type, cashholding, email, portfolio_id) values('cash', 0, $amount, 'Deposit', $new_holdings, '$login', '$portfolio_id')"
Buy a stock
"insert into transaction (symbol, price, quantity, type, cashholding, email, portfolio_id) values('$symbol', $price, $amount, 'buy', $new_holdings, '$login', '$portfolio_id')"
Sell a stock
insert into transaction (symbol, price, quantity, type, cashholding, email, portfolio_id) values('$symbol', $price, $amount, 'sell', $new_holdings, '$login', '$portfolio_id')"