BfxWrapper -> BfxConnector
This commit is contained in:
parent
bb518e6259
commit
0ea8a55a7f
@ -28,16 +28,16 @@ pub trait Connector {
|
|||||||
) -> Result<(), BoxError>;
|
) -> Result<(), BoxError>;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct BfxWrapper {
|
pub struct BitfinexConnector {
|
||||||
bfx: Bitfinex,
|
bfx: Bitfinex,
|
||||||
affiliate_code: Option<String>,
|
affiliate_code: Option<String>,
|
||||||
// account_info: String,
|
// account_info: String,
|
||||||
// ledger: String,
|
// ledger: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl BfxWrapper {
|
impl BitfinexConnector {
|
||||||
pub fn new(api_key: &str, api_secret: &str) -> Self {
|
pub fn new(api_key: &str, api_secret: &str) -> Self {
|
||||||
BfxWrapper {
|
BitfinexConnector {
|
||||||
bfx: Bitfinex::new(Some(api_key.into()), Some(api_secret.into())),
|
bfx: Bitfinex::new(Some(api_key.into()), Some(api_secret.into())),
|
||||||
affiliate_code: None,
|
affiliate_code: None,
|
||||||
}
|
}
|
||||||
@ -97,7 +97,7 @@ impl From<&OrderKind> for bitfinex::orders::OrderKind {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl Connector for BfxWrapper {
|
impl Connector for BitfinexConnector {
|
||||||
async fn active_positions(&self, pair: &SymbolPair) -> Result<Vec<Position>, BoxError> {
|
async fn active_positions(&self, pair: &SymbolPair) -> Result<Vec<Position>, BoxError> {
|
||||||
let active_positions = self.bfx.positions.active_positions().await?;
|
let active_positions = self.bfx.positions.active_positions().await?;
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use tokio::time::{delay_for, Duration};
|
use tokio::time::{delay_for, Duration};
|
||||||
|
|
||||||
use crate::bot::BfxBot;
|
use crate::bot::BfxBot;
|
||||||
use crate::connectors::BfxWrapper;
|
use crate::connectors::BitfinexConnector;
|
||||||
use crate::currency::{Symbol, SymbolPair};
|
use crate::currency::{Symbol, SymbolPair};
|
||||||
use crate::events::SignalKind;
|
use crate::events::SignalKind;
|
||||||
use crate::strategy::TrailingStop;
|
use crate::strategy::TrailingStop;
|
||||||
@ -23,7 +23,7 @@ pub type BoxError = Box<dyn std::error::Error + Send + Sync>;
|
|||||||
async fn main() -> Result<(), BoxError> {
|
async fn main() -> Result<(), BoxError> {
|
||||||
let test_api_key = "P1EVE68DJByDAkGQvpIkTwfrbYXd2Vo2ZaIhTYb9vx2";
|
let test_api_key = "P1EVE68DJByDAkGQvpIkTwfrbYXd2Vo2ZaIhTYb9vx2";
|
||||||
let test_api_secret = "1nicg8z0zKVEt5Rb7ZDpIYjVYVTgvCaCPMZqB0niFli";
|
let test_api_secret = "1nicg8z0zKVEt5Rb7ZDpIYjVYVTgvCaCPMZqB0niFli";
|
||||||
let bfx = BfxWrapper::new(test_api_key, test_api_secret)
|
let bfx = BitfinexConnector::new(test_api_key, test_api_secret)
|
||||||
.with_affiliate_code(Some("XPebOgHxA".into()));
|
.with_affiliate_code(Some("XPebOgHxA".into()));
|
||||||
|
|
||||||
let mut bot = BfxBot::new(
|
let mut bot = BfxBot::new(
|
||||||
|
Loading…
Reference in New Issue
Block a user