hit counter

Timeline

My development logbook

Dependency on MathJax.js

By default, ipython notebook will use MathJax on a CDN

1
2
3
4
5
6
$ ipython notebook
2014-01-06 19:08:43.857 [NotebookApp] Using existing profile dir: u'/Users/antkong/.ipython/profile_default'
2014-01-06 19:08:43.865 [NotebookApp] Using MathJax from CDN: http://cdn.mathjax.org/mathjax/latest/MathJax.js
2014-01-06 19:08:43.888 [NotebookApp] Serving notebooks from local directory: /Users/antkong/wd/py
2014-01-06 19:08:43.889 [NotebookApp] The IPython Notebook is running at: http://127.0.0.1:8888/
2014-01-06 19:08:43.889 [NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).

To download and install the mathjax.js locally, we can run

from IPython.external.mathjax import install_mathjax
install_mathjax()

Inline Plot in Ipython

It is a neat trick

Start your ipython like this ipython qtconsole --pylab inline, and the ipython session will plot graph in the interpreter window.

Make Picker 2 Data Dependent on the Selected Row of Picker 1

It is what I want to achieve: whenever a selection is changed in the top UIPicker, the choices in the second UIPicker will change accordingly.

Useful lessons from this exercise:

  • The use of API reloadAllComponents
  • The use of class extension and category
  • Identification of the UI object – apparently a == is sufficient to find out which picker instance a picker API is handling
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
#import "SOViewController.h"

@interface SOViewController ()

@property (weak, nonatomic) IBOutlet UIPickerView *Picker1;
@property (weak, nonatomic) IBOutlet UIPickerView *Picker2;

@end

@interface SOViewController (SOPickerDelegate) <UIPickerViewDelegate, UIPickerViewDataSource>

@end

@implementation SOViewController
{
    NSArray* list_media;
    NSArray* list_media_channel;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    list_media = @[@"TV", @"Radio"];
    list_media_channel = @[ @[@"ABC", @"SBS"], @[@"TripleJ", @"107.1", @"CBS"]];
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end

@implementation SOViewController(SOPickerDelegate)

- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component{
    if (pickerView == _Picker1) {
        // set Picker 2 accordingly
        [_Picker2 reloadAllComponents];
    }
}

- (NSArray*) getDataByPicker:(UIPickerView *)pickerView
{
    if (pickerView == _Picker1) {
        return list_media;
    } else {
        NSArray* content = [list_media_channel objectAtIndex:[_Picker1 selectedRowInComponent:0]];
        return content;
    }
}

- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component
{
    NSArray* data = [self getDataByPicker:pickerView];
    return [data objectAtIndex:row];
}

- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component{

    NSArray* data = [self getDataByPicker:pickerView];
    return [data count];
}

- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView
{
    return 1;
}

@end

Swap Convention

Floating-rate payer: pay 6-month LIBOR
                     receive a fixed rate of 5.19 percent

Fixed-rate payer: pay a fixed rate of 5.25 percent
                  receive 6-month LIBOR

In this example, the bank is quoting an offer rate of 5.25 percent, which is what the fixed-rate payer will pay, and a bid rate of 5.19 percent, which is what the floating-rate payer will receive. The bid-offer spread is therefore 6 basis points.

from ‘Moorad Choudhry – Fixed Income Securities and Derivatives Handbook (Analysis and Valuation)’

Conda and Ipython

It is a follow-up on my last ipython install issue

Turn out i just need to follow the suggested solution in the conda failure message, which is to use -p /path/to/local/conda

Now I have four set of python runtime installed on my MBP:

  • From Apple

  • From Homebrew

  • From Pythonbrew

  • From conda