Crates.io | spread_tracker |
lib.rs | spread_tracker |
version | 0.1.0 |
source | src |
created_at | 2024-04-08 05:27:07.003771 |
updated_at | 2024-04-08 05:27:07.003771 |
description | Spread tracker for forex pairs |
homepage | |
repository | |
max_upload_size | |
id | 1199855 |
size | 110,093 |
spread_tracker
is a library for tracking the spread of various symbols in the forex market.
Every forex broker has a different spread for each symbol. This library is used to track the spread of various symbols in the forex market. Retrieve & scrape the spread of various symbols from different brokers.
Add this to your Cargo.toml
:
[dependencies]
spread_tracker = "0.1.0"
use spread_tracker::config::{
SpreadBrokerUrl,
Brokers
};
use spread_tracker::config::SpreadBrokerUrl;
use spread_tracker::model::{
Symbol,
SymbolSpread
};
let config: SpreadBrokerUrl = SpreadBrokerUrl::new();
// In this example, we are tracking the spread of the symbols from the Vantage and EightCap brokers.
let brokers: Vec<Brokers> = vec![
Brokers::Vantage,
Brokers::EightCap,
];
// Get the spread of the symbols from the brokers
let spread: Value = SpreadTracker::get_spread(
config,
brokers
).await.unwrap();
println!("Spread: {:#?}", spread);
// Result:
{
"spread": {
"eightcap": [
{
"ask": 2197.92,
"bid": 2209.92,
"spread": 12.0,
"symbol": "XAUUSD"
},
{
"ask": 2031.57,
"bid": 2060.8973,
"spread": 29.3273,
"symbol": "XAUEUR"
},
{
---------------- cut for brevity ----------------
The return type is a serde_json::Value
object, which is a JSON object.
Object[spread]Vector[broker] -> Object[symbol, ask, bid, spread]
spread
is the key for the spread data.broker
is the key for the broker name, which will differ based on the broker.The config.yaml
is used to store the broker URLs for the spread tracking, and the model.rs
is used to store the data model for the spread tracking. The config.yaml
file should be in the following format:
BrokerSpreadUrls:
Vantage: "https://www.vantagefx.com/trading-info/forex-market-hours/"
MyFxBook: "https://www.myfxbook.com/forex-broker-quotes/vantage/6052"
Where Vantage
and MyFxBook
are the broker names and the URLs are the URLs of the brokers for spread tracking, derived from the MyFxBook website.