-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Unknown
committed
Oct 27, 2024
0 parents
commit 1ecd6f4
Showing
154 changed files
with
12,328 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Sphinx build info version 1 | ||
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done. | ||
config: 03ccf93c8bd6aece23460e2b7ff6d9a0 | ||
tags: 645f666f9bcd5a90fca523b33c5a78b7 |
Empty file.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
--- | ||
jupytext: | ||
text_representation: | ||
extension: .md | ||
format_name: myst | ||
format_version: 0.13 | ||
jupytext_version: 1.14.7 | ||
kernelspec: | ||
display_name: Python 3 (ipykernel) | ||
language: python | ||
name: python3 | ||
--- | ||
|
||
# Dates & Periods | ||
|
||
The module is shipped with a ``date`` module for manipulating time periods and | ||
converting dates between different formats. Th *period* function can be use | ||
to create ``Period`` instanc.:: | ||
|
||
```{code-cell} ipython3 | ||
import ccy | ||
p = ccy.period("1m") | ||
p | ||
``` | ||
|
||
```{code-cell} ipython3 | ||
p += "2w" | ||
p | ||
``` | ||
|
||
```{code-cell} ipython3 | ||
p += "3m" | ||
p | ||
``` | ||
|
||
```{code-cell} ipython3 | ||
p -= "1w" | ||
p | ||
``` | ||
|
||
```{code-cell} ipython3 | ||
p -= "1w" | ||
p | ||
``` | ||
|
||
```{code-cell} ipython3 | ||
p -= "1w" | ||
p | ||
``` | ||
|
||
```{code-cell} ipython3 | ||
``` |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
--- | ||
jupytext: | ||
text_representation: | ||
extension: .md | ||
format_name: myst | ||
format_version: 0.13 | ||
jupytext_version: 1.14.7 | ||
kernelspec: | ||
display_name: Python 3 (ipykernel) | ||
language: python | ||
name: python3 | ||
--- | ||
|
||
# Python CCY | ||
|
||
## Getting Started | ||
|
||
* installation | ||
```bash | ||
pip install ccy | ||
``` | ||
* display currencies | ||
|
||
```{code-cell} ipython3 | ||
import ccy | ||
import pandas as pd | ||
df = pd.DataFrame(ccy.dump_currency_table()) | ||
df.head(80) | ||
``` | ||
|
||
## Main Usage | ||
|
||
```{code-cell} ipython3 | ||
import ccy | ||
eur = ccy.currency("aud") | ||
eur.printinfo() | ||
``` | ||
|
||
a currency object has the following properties: | ||
* *code*: the [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) three letters codee. | ||
* *twoletterscode*: two letter crg. | ||
* *default_country*: the default [ISO 3166-1 alpha_2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) country code for the currency. | ||
* *isonumber*: the ISO 4217 number. | ||
* *name*: the name of the currency. | ||
* *order*: default ordering in currency pairs (more of this below). | ||
* *rounding*: number of decimal places | ||
|
||
+++ | ||
|
||
## Currency Crosses | ||
|
||
|
||
You can create currency pairs by using the ``currency_pair`` functn:: | ||
|
||
```{code-cell} ipython3 | ||
c = ccy.currency_pair("eurusd") | ||
c | ||
``` | ||
|
||
```{code-cell} ipython3 | ||
c.mkt() | ||
``` | ||
|
||
```{code-cell} ipython3 | ||
c = ccy.currency_pair("chfusd") | ||
c | ||
``` | ||
|
||
```{code-cell} ipython3 | ||
c.mkt() # market convention pair | ||
``` | ||
|
||
## cross & crossover | ||
|
||
Some shortcuts: | ||
|
||
```{code-cell} ipython3 | ||
ccy.cross("aud") | ||
``` | ||
|
||
```{code-cell} ipython3 | ||
ccy.crossover('eur') | ||
``` | ||
|
||
```{code-cell} ipython3 | ||
ccy.crossover('chf') | ||
``` | ||
|
||
```{code-cell} ipython3 | ||
ccy.crossover('aud') | ||
``` | ||
|
||
Note, the Swiss franc cross is represented as 'USD/CHF', while the Aussie Dollar and Euro crosses are represented with the USD as denominator. This is the market convention which is handled by the order property of a currency object. | ||
|
||
+++ | ||
|
||
## Eurozone | ||
|
||
The euro area, commonly called the eurozone (EZ), is a currency union of 20 member states of the European Union (EU) that have adopted the euro (€) as their primary currency and sole legal tender, and have thus fully implemented EMU policies. | ||
|
||
```{code-cell} ipython3 | ||
ccy.eurozone | ||
``` | ||
|
||
```{code-cell} ipython3 | ||
ccy.print_eurozone() | ||
``` |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
// @ts-check | ||
|
||
// Extra JS capability for selected tabs to be synced | ||
// The selection is stored in local storage so that it persists across page loads. | ||
|
||
/** | ||
* @type {Record<string, HTMLElement[]>} | ||
*/ | ||
let sd_id_to_elements = {}; | ||
const storageKeyPrefix = "sphinx-design-tab-id-"; | ||
|
||
/** | ||
* Create a key for a tab element. | ||
* @param {HTMLElement} el - The tab element. | ||
* @returns {[string, string, string] | null} - The key. | ||
* | ||
*/ | ||
function create_key(el) { | ||
let syncId = el.getAttribute("data-sync-id"); | ||
let syncGroup = el.getAttribute("data-sync-group"); | ||
if (!syncId || !syncGroup) return null; | ||
return [syncGroup, syncId, syncGroup + "--" + syncId]; | ||
} | ||
|
||
/** | ||
* Initialize the tab selection. | ||
* | ||
*/ | ||
function ready() { | ||
// Find all tabs with sync data | ||
|
||
/** @type {string[]} */ | ||
let groups = []; | ||
|
||
document.querySelectorAll(".sd-tab-label").forEach((label) => { | ||
if (label instanceof HTMLElement) { | ||
let data = create_key(label); | ||
if (data) { | ||
let [group, id, key] = data; | ||
|
||
// add click event listener | ||
// @ts-ignore | ||
label.onclick = onSDLabelClick; | ||
|
||
// store map of key to elements | ||
if (!sd_id_to_elements[key]) { | ||
sd_id_to_elements[key] = []; | ||
} | ||
sd_id_to_elements[key].push(label); | ||
|
||
if (groups.indexOf(group) === -1) { | ||
groups.push(group); | ||
// Check if a specific tab has been selected via URL parameter | ||
const tabParam = new URLSearchParams(window.location.search).get( | ||
group | ||
); | ||
if (tabParam) { | ||
console.log( | ||
"sphinx-design: Selecting tab id for group '" + | ||
group + | ||
"' from URL parameter: " + | ||
tabParam | ||
); | ||
window.sessionStorage.setItem(storageKeyPrefix + group, tabParam); | ||
} | ||
} | ||
|
||
// Check is a specific tab has been selected previously | ||
let previousId = window.sessionStorage.getItem( | ||
storageKeyPrefix + group | ||
); | ||
if (previousId === id) { | ||
// console.log( | ||
// "sphinx-design: Selecting tab from session storage: " + id | ||
// ); | ||
// @ts-ignore | ||
label.previousElementSibling.checked = true; | ||
} | ||
} | ||
} | ||
}); | ||
} | ||
|
||
/** | ||
* Activate other tabs with the same sync id. | ||
* | ||
* @this {HTMLElement} - The element that was clicked. | ||
*/ | ||
function onSDLabelClick() { | ||
let data = create_key(this); | ||
if (!data) return; | ||
let [group, id, key] = data; | ||
for (const label of sd_id_to_elements[key]) { | ||
if (label === this) continue; | ||
// @ts-ignore | ||
label.previousElementSibling.checked = true; | ||
} | ||
window.sessionStorage.setItem(storageKeyPrefix + group, id); | ||
} | ||
|
||
document.addEventListener("DOMContentLoaded", ready, false); |
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.