mirror of
https://github.com/NexVeridian/ark-invest-api-rust-data.git
synced 2025-09-02 18:09:12 +00:00
0.3.2
This commit is contained in:
parent
9107445cae
commit
bc28230cbe
4 changed files with 33 additions and 30 deletions
|
@ -15,3 +15,6 @@ RUN BTOP_VERSION=$(curl -s "https://api.github.com/repos/aristocratos/btop/relea
|
||||||
sudo tar -xvf btop-x86_64-linux-musl.tbz && \
|
sudo tar -xvf btop-x86_64-linux-musl.tbz && \
|
||||||
cd btop && ./install.sh && cd .. && \
|
cd btop && ./install.sh && cd .. && \
|
||||||
rm -rf btop-x86_64-linux-musl.tbz btop
|
rm -rf btop-x86_64-linux-musl.tbz btop
|
||||||
|
|
||||||
|
RUN curl -LsSf https://get.nexte.st/latest/linux | tar zxf - -C ${CARGO_HOME:-~/.cargo}/bin
|
||||||
|
# cargo install cargo-nextest --locked
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
"--name",
|
"--name",
|
||||||
"devcontainer-${containerWorkspaceFolderBasename}"
|
"devcontainer-${containerWorkspaceFolderBasename}"
|
||||||
],
|
],
|
||||||
|
"initializeCommand": "docker rm -f devcontainer-${containerWorkspaceFolderBasename} || true",
|
||||||
// Use 'mounts' to make the cargo cache persistent in a Docker Volume.
|
// Use 'mounts' to make the cargo cache persistent in a Docker Volume.
|
||||||
"mounts": [
|
"mounts": [
|
||||||
{
|
{
|
||||||
|
@ -60,7 +61,6 @@
|
||||||
"Gruntfuggly.todo-tree",
|
"Gruntfuggly.todo-tree",
|
||||||
"ms-azuretools.vscode-docker",
|
"ms-azuretools.vscode-docker",
|
||||||
"redhat.vscode-yaml",
|
"redhat.vscode-yaml",
|
||||||
"tomoki1207.pdf",
|
|
||||||
"GitHub.copilot"
|
"GitHub.copilot"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
2
NOTES.md
2
NOTES.md
|
@ -1,4 +1,2 @@
|
||||||
https://ark-funds.com/ark-trade-notifications/
|
https://ark-funds.com/ark-trade-notifications/
|
||||||
https://etfs.ark-funds.com/hubfs/idt/trades/ARK_Trade_06072023_0800PM_EST_6480efd1294b5.xls
|
https://etfs.ark-funds.com/hubfs/idt/trades/ARK_Trade_06072023_0800PM_EST_6480efd1294b5.xls
|
||||||
|
|
||||||
|
|
||||||
|
|
14
src/util.rs
14
src/util.rs
|
@ -248,7 +248,7 @@ pub fn get_api(ticker: Ticker, last_day: Option<i32>) -> Result<LazyFrame, Box<d
|
||||||
format!("https://api.nexveridian.com/ark_holdings?ticker={}", ticker)
|
format!("https://api.nexveridian.com/ark_holdings?ticker={}", ticker)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
get_data_url(url, Reader::Json)
|
Reader::Json.get_data_url(url)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_csv_ark(ticker: Ticker) -> Result<LazyFrame, Box<dyn Error>> {
|
pub fn get_csv_ark(ticker: Ticker) -> Result<LazyFrame, Box<dyn Error>> {
|
||||||
|
@ -256,7 +256,7 @@ pub fn get_csv_ark(ticker: Ticker) -> Result<LazyFrame, Box<dyn Error>> {
|
||||||
Ticker::ARKVC => "https://ark-ventures.com/wp-content/uploads/funds-etf-csv/ARK_VENTURE_FUND_HOLDINGS.csv".to_owned(),
|
Ticker::ARKVC => "https://ark-ventures.com/wp-content/uploads/funds-etf-csv/ARK_VENTURE_FUND_HOLDINGS.csv".to_owned(),
|
||||||
_ => format!("https://ark-funds.com/wp-content/uploads/funds-etf-csv/ARK_{}_ETF_{}_HOLDINGS.csv", ticker.value(), ticker),
|
_ => format!("https://ark-funds.com/wp-content/uploads/funds-etf-csv/ARK_{}_ETF_{}_HOLDINGS.csv", ticker.value(), ticker),
|
||||||
};
|
};
|
||||||
get_data_url(url, Reader::Csv)
|
Reader::Csv.get_data_url(url)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub enum Reader {
|
pub enum Reader {
|
||||||
|
@ -264,7 +264,8 @@ pub enum Reader {
|
||||||
Json,
|
Json,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_data_url(url: String, reader: Reader) -> Result<LazyFrame, Box<dyn Error>> {
|
impl Reader {
|
||||||
|
pub fn get_data_url(&self, url: String) -> Result<LazyFrame, Box<dyn Error>> {
|
||||||
let response = Client::builder()
|
let response = Client::builder()
|
||||||
.user_agent("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3")
|
.user_agent("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3")
|
||||||
.build()?.get(url).send()?;
|
.build()?.get(url).send()?;
|
||||||
|
@ -279,12 +280,12 @@ pub fn get_data_url(url: String, reader: Reader) -> Result<LazyFrame, Box<dyn Er
|
||||||
|
|
||||||
let data = response.text()?.into_bytes();
|
let data = response.text()?.into_bytes();
|
||||||
|
|
||||||
let df = match reader {
|
let df: LazyFrame = match self {
|
||||||
Reader::Csv => CsvReader::new(Cursor::new(data))
|
Self::Csv => CsvReader::new(Cursor::new(data))
|
||||||
.has_header(true)
|
.has_header(true)
|
||||||
.finish()?
|
.finish()?
|
||||||
.lazy(),
|
.lazy(),
|
||||||
Reader::Json => {
|
Self::Json => {
|
||||||
let json_string = String::from_utf8(data)?;
|
let json_string = String::from_utf8(data)?;
|
||||||
let json: Value = serde_json::from_str(&json_string)?;
|
let json: Value = serde_json::from_str(&json_string)?;
|
||||||
JsonReader::new(Cursor::new(json.to_string()))
|
JsonReader::new(Cursor::new(json.to_string()))
|
||||||
|
@ -294,4 +295,5 @@ pub fn get_data_url(url: String, reader: Reader) -> Result<LazyFrame, Box<dyn Er
|
||||||
};
|
};
|
||||||
|
|
||||||
Ok(df)
|
Ok(df)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue