braverock / braverock/FinancialInstrument

convert P&L in points to USD FinancialInstrument package

Open
#3 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
R
Stars
20
Forks
17
PR merge metrics
No merged PRs in 30d

Description

I have several currency pairs, not necessarily downloaded from online resources, it could be a regular file from disk, but for simplicity of the example and reproducibility I will download from the network.
```
library(quantmod)
getSymbols("AUD/CAD",src="oanda",from="2024-01-01")
getSymbols("CAD/CHF",src="oanda",from="2024-01-01")
getSymbols("USD/JPY",src="oanda",from="2024-01-01")
```
Now let’s calculate a simple “buy and hold” strategy in points

```
# buy and hold P&L in points
BH_AUDCAD <- AUDCAD - c(coredata(AUDCAD[1]))
BH_CADCHF <- CADCHF - c(coredata(CADCHF[1]))
BH_USDJPY <- USDJPY - c(coredata(USDJPY[1]))
```
Now I would like to calculate p&l in USD but I’m a little confused and don’t know how to do it correctly

```
library(FinancialInstrument)
currency(c("AUD", "CAD", "CHF", "USD", "JPY"))
stock(c("AUDCAD", "CADCHF", "USDJPY"), currency="USD")

PnL_USD_AUDCAD <- ....
PnL_USD_CADCHF <- ....
PnL_USD_USDJPY <- ....
```

Contributor guide

No contributing guide indexed for this repository

Research direction

No repository file or test is identified. Start by reviewing the FinancialInstrument currency() and stock() setup in the example, then establish the expected USD conversion for each pair and document reproducible inputs and outputs as the completion criteria.

Written by the indexing model from the issue text.

Assessment

Tech stack
r
Domain
fintech-quant
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.