2021-01-02 14:10:16 +00:00
|
|
|
use bitfinex::api::Bitfinex;
|
2021-01-04 10:45:54 +00:00
|
|
|
use bitfinex::ticker::TradingPairTicker;
|
|
|
|
use tokio::time::Duration;
|
|
|
|
|
|
|
|
use crate::bot::BfxBot;
|
|
|
|
use crate::currency::{BTC, ETH, SymbolPair, USD, XMR};
|
2021-01-02 14:10:16 +00:00
|
|
|
|
2021-01-02 12:15:19 +00:00
|
|
|
mod ticker;
|
|
|
|
mod events;
|
|
|
|
mod pairs;
|
2021-01-02 14:10:16 +00:00
|
|
|
mod positions;
|
|
|
|
mod strategy;
|
2021-01-02 19:01:39 +00:00
|
|
|
mod bot;
|
|
|
|
mod currency;
|
2021-01-01 14:07:16 +00:00
|
|
|
|
|
|
|
|
|
|
|
pub type BoxError = Box<dyn std::error::Error + Send + Sync>;
|
|
|
|
|
|
|
|
#[tokio::main]
|
|
|
|
async fn main() -> Result<(), BoxError> {
|
2021-01-04 10:45:54 +00:00
|
|
|
let test_api_key = "P1EVE68DJByDAkGQvpIkTwfrbYXd2Vo2ZaIhTYb9vx2";
|
|
|
|
let test_api_secret = "1nicg8z0zKVEt5Rb7ZDpIYjVYVTgvCaCPMZqB0niFli";
|
|
|
|
|
|
|
|
let mut bot = BfxBot::new(test_api_key, test_api_secret, vec![BTC, XMR, ETH], USD, Duration::new(20, 0));
|
|
|
|
let btcusd = SymbolPair::new("USD".into(), "BTC".into());
|
|
|
|
|
|
|
|
loop {
|
|
|
|
bot.update().await;
|
2021-01-02 14:10:16 +00:00
|
|
|
|
2021-01-04 10:45:54 +00:00
|
|
|
let ticker: TradingPairTicker = bot.bfx.current_prices(&btcusd).await?;
|
|
|
|
println!("{:?}", ticker);
|
|
|
|
if (2 < 1) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2021-01-02 14:10:16 +00:00
|
|
|
|
2021-01-01 14:07:16 +00:00
|
|
|
Ok(())
|
|
|
|
}
|