2009年2月16日 星期一

金融吃人魔-讀後心得

A demon of our own design :markets,hedge,funds and the perils of financial innovation
author:Richard Bookstaber
個人覺得想看八卦內幕的可以整本看完,應該可以找到金融業的八卦。
不過我是覺的可以從第八章開始閱讀,因為重點從那邊開始。
1.金融危機是因為高複雜性與高緊密連結的系統,並會回饋的系統。
2."常態事故" 是指預想中會發生的意外,是過程結構不可避免的結果。
3.減少複雜度(法令直接限制複雜度) 與在環結中加入Buffer 是避免事故的解決方法。
4.金融危機是因為流動性不足,導致系統Feedback 而產生滾雪球效應。
5.完美市場是不存在的

6.貨幣數量公式:mv=pq,這4個字母分別代表:
M貨幣需求量
V貨幣流通速度
P商品價格 
Q商品量 

7.避險基金是無法可管,說穿了,是一堆商品的組合,只能利用分類法歸類。
a.資產-固定收異/有價證券/貨幣市場
b.方向-對資產管理的態度(買入/賣出/中立/買賣都作)
c.投資類別(相對價值/策略套利)
d.地理區域(開發 /未開發國家)
e.流動性(周轉百分比)

2009年2月9日 星期一

如何把Excel 轉成UTF-8的資料

1.因為要把EXCEL 的資料轉成UTF-8 的格式才能在Sqlite3 使用,故需要轉碼
2.方法如下:
a.開啟EXCEL 檔,另存新檔,變成 CSV 檔案
b.利用notepad 開啟 CSV 檔案 ,並另存成 UTF-8 檔案
c. 接下來就可用Sqlite3 來開啟中文資料了

2009年1月10日 星期六

Regular expression

字元 代表該字元^ 限制字串必須出現於行首
$ 限制字串必須出現於行末
\ 將特殊字元還原成字面意義的字元
^ 某字元以外的任何字元
- 字元集合中可使用 - 來指定字元的區間

+ 其前的字元或字元集合出現一次或一次以上
? 其前的字元或字元集合可出現一次或不出現
* 其前的字元或字元集合可出現任何次數或不出現
(...) 用以括住一群字元,且將之視成一個集合
{n} 重複 n 次
{n,m} 重複 n 到 m 次
{n,} 至少重複 n 次
[] 其中之一字元可出現可不出現,例如 [abc] 表示不論出現 a 或 b 或 c 都算符合
| 代表「或」, 例如 (Sun|Mon|Tue|Wed|Thu|Fri|Sat), (日|一|二|三|四|五|六) 以左右括號括住

. (句點符號) 代表除了換行符號 (\n) 以外的任一字元。如果要包括換行符號,請使用 [\s\S]
\w (\W) 代表任何英文(以外的) 字元
\s (\S) 代表空白 (以外的) 字元
\d (\D) 代表數字 (以外的) 字元
\b (\B) 代表位於文字邊界的 (以外的) 字元。(在英文中)你可以把 \b 視作空白或 TAB 字元, 例如 \bBB 可符合 "ABB CBB" 中的 CBB 但非 ABB, 因為 ABB 位於行首, 不算是文字邊界; 這是容易混淆的地方。
\r 代表換行字元
\n 代表換行字元 (通常和 \r 一同出現, 所以一般以 \r\n 代表換行)
\t 代表 TAB 字元
\( 代表左括號
\) 代表右括號
\X 以十六進位字元碼代表某個字元; 例如 [\x21-\x7E] 可代表所有看得到的字元 ([\x20-\x7E] 則包括空白字元)

2009年1月7日 星期三

如何利用SVN 去自動備份

我在網路上找到的資料,來源
http://gael-varoquaux.info/computers/svnautocommit/index.html

1.準備工作:
a. SVN 軟體,因為要直接用command mode,請到以下 download:
http://subversion.tigris.org/servlets/ProjectDocumentList?folderID=91
version :svn-win32-1.5.5.zip

2.下載 svncommit.exe ,找一下可以看到
http://gael-varoquaux.info/computers/svnautocommit/index.html
Usage :svncommit.exe [path] => svncommit.exe c:\python-ray

3.因為它是利用排程去 啟動 svncommit.exe ,所以要先把要backup 的資料放到 svn server,
並且在啟動備份的機器上產生一份workcopy ,例如 c:\python-ray

4.利用控制台中的 -> 排定的工作 去設定

2009年1月4日 星期日

如何Reset Django user 密碼


[Windows Platform] : 
c:\: python manage.py shell

your acccount=admin
password=new_password
from django.contrib.auth.models import User
 
user = User.objects.get(username='admin')
user.set_password('new_password')
user.save()

2008年12月4日 星期四

Easy_Install 與Buildout介紹

Easy_install 主要是Python 用來Download,install,uninstall Python package Buildout 也是Python 安裝套件的工具,不過它是把一堆套件打成一包並檢查相依性 Easy_intall 介紹 -
  1. where to get more information http://pypi.python.org/pypi/setuptools#windows
  2. Python 安裝的package 都放在 D:\"your python dict"\Lib\site-packages 下
  3. 找一下 網頁最下方看自己是python 哪一版,windows 版都是 exe file,只要執行它就好了
  4. 如果有安裝過前一版本,記得delete 所有的 setuptools*.eg/site-packages 下的setuptools
    for examples:
    site-packages/setuptools-0.6c9-py2.5.egg-info/
    /site-packages/setuptools
  5. 新增 path ,如 D:\Python25\Scripts 到你的windows 環境中 ( 方法:控制台-->系統-->進階-->環境變數-->path)
  6. 用DOS mode, key " easy_install --help" ,如果有訊息,應該就可以用了
  7. Easy_install 細節說明 http://peak.telecommunity.com/DevCenter/EasyInstall
  8. 要安裝程式 easy_install xxx
Buildout介紹 -

Setting Up Your Environment:

Before we dive into the fun that is Buildout we need to ensure that we have a few things. Firstly make sure you have the following installed on your system:

Once you have these run the following commands to grab the tools you'll need to setup your buildout:

$: python ez_setup.py

This will download and install the setuptools and easy_install script which you will next use to grab the final tranche of setup tools.

$: easy_install -U ZopeSkel

Now that you have everything, run the following command:

$: paster create --list-templates

Paster is a tool that creates a skeleton of a project depending on the template that you feed it. So long as the templates for plone3_buildout and plone you should be fine.


2008年11月28日 星期五

Debugging django with PyScripter

Debugging django with PyScripter

Here is how you can debug Django applications with Pyscripter in six simple steps:
  1. In the File explorer locate the root directory of your Django application. You may want to right click on the directory name and select File Explorer, Explore here.
  2. Open the project files in Pyscripter (e.g., models,py, views.py etc.) and set whatever breakpoints you want.
  3. Select Run, Command Line Parameters... and set the command line to "runserver --noreload". Also check the "Use Command line" checkbox.
  4. Make sure the remote engine is selected (Run, Python Engine, Remote).
  5. Open the manage.py file and press the debug button (or press F9).
  6. Start a web browser and test your application. Pyscripter should now stop at whatever breakpoints you have set and you can use the various debugging facilities (call stack, variables, interpreter prompt etc.)

To stop debugging, right-click on the interpreter window and select "Reinitialize Interpreter", then go to the browser and reload the document.

Django 學習筆記(1)

如何安裝: 現在version Django-1.0.2-Final
1.Django Homepage and Download
Homepage => http://www.djangoproject.com/
Download =>http://www.djangoproject.com/download/

2.解壓縮方法: window 就用 7-zip 解,然後放到你的 Python中
把Django\"Django" 放到 如:C:\Python25\Lib\site-packages\django

3.把 django-admin.py copy 到 "C:\Python25\Scripts"
django-admin.py 應該在"C:\Python25\Lib\site-packages\django\bin"

4.把 c:\python25\scripts 加到環境變數中
[window版] 控制台-->系統-->進階 -->環境變數 -->path

5.如何產生網站:django-admin.py startproject mysite
看一下目錄 c:\mysite

6.mysite 內容:
mysite/
__init__.py

manage.py

settings.py
urls.py

7.開起web server -> 到 c:\mysite 打 python mange.py runserver ,
然後 http://127.0.0.1:8000/
要換port 就用 ==> python mange.py runserver
8080

8.Edit
c:\mysite\settings.py
  • DATABASE_ENGINE = 'sqlite3'
  • DATABASE_NAME = r'c:\mysite\django.db'
7. 先把admin 裝起來 Edit c:\mysite\settings.py ,找一下INSTALLED_APPS
加入 'django.contrib.admin',
'mysite.blog',
改成中文/台灣地區
TIME_ZONE = 'Asia/Taipei'
LANGUAGE_CODE = 'zh-tw'

8. python manage.py syncdb 產生DB table

2008年11月21日 星期五

動物農莊

當一個團體以服從為最高原則,當命令來自人,團體將變成那就是那個人的工具
所有法律也將沒有效果,一切只是虛幻,只有那個人說了才算!
這就是我們的處境呀!

自由尊重是這麼的薄弱,當恐懼佔據人心,我將指使你,你終將成為我的奴隸,
你是害怕這個恐懼,看不透恐懼,還是害怕他的權力 ?
這就是我們的處境呀!