Skip to content

Commit 015b3ce

Browse files
committed
surpress waring
1 parent e601a1c commit 015b3ce

13 files changed

Lines changed: 37 additions & 46 deletions

File tree

‎exchanges/binance/src/config.rs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
// Copyright(c) 2022-2024. yasstake. All rights reserved.
33

44
use pyo3::{pyclass, pymethods};
5-
use rust_decimal_macros::dec;
65

7-
use rbot_lib::common::{env_api_key, env_api_secret, FeeType, MarketConfig, SecretString, ExchangeConfig};
6+
use rbot_lib::common::MarketConfig;
7+
use rbot_lib::common::ExchangeConfig;
88

99
use crate::BINANCE;
1010

‎exchanges/binance/src/ws.rs‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ use tokio::time::sleep;
1818
use crate::BinanceRestApi;
1919
use crate::BinanceUserWsMessage;
2020
use crate::BinanceWsRawMessage;
21-
use crate::{BinancePublicWsMessage, BinanceServerConfig};
22-
21+
use crate::BinancePublicWsMessage;
2322
use serde_derive::{Deserialize, Serialize};
2423

2524
use anyhow::anyhow;
@@ -280,6 +279,7 @@ impl BinancePrivateWsClient {
280279
mod tests {
281280
use super::*;
282281
use crate::BinanceConfig;
282+
use crate::BinanceServerConfig;
283283
use rbot_lib::common::init_debug_log;
284284

285285
#[tokio::test]
@@ -315,6 +315,7 @@ mod tests {
315315
}
316316

317317
#[tokio::test]
318+
318319
async fn test_make_connect_url() {
319320
let server = BinanceServerConfig::new(false);
320321
let api = BinanceRestApi::new(&server);

‎exchanges/bybit/src/config.rs‎

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
#![allow(non_snake_case)]
2-
use std::env;
3-
42
use pyo3::prelude::*;
5-
use rust_decimal_macros::dec;
63
use serde_derive::{Deserialize, Serialize};
7-
8-
use rbot_lib::common::{FeeType, MarketConfig, ExchangeConfig};
4+
use rbot_lib::common::{MarketConfig, ExchangeConfig};
95

106
use crate::BYBIT;
117

‎exchanges/bybit/src/market.rs‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ impl Bybit {
103103
self.get_enable_order_feature()
104104
}
105105

106+
#[pyo3(signature = (market_config, side, price, size, client_order_id=None))]
106107
pub fn limit_order(
107108
&self,
108109
market_config: &MarketConfig,
@@ -117,6 +118,7 @@ impl Bybit {
117118
})
118119
}
119120

121+
#[pyo3(signature = (market_config, side, size, client_order_id=None))]
120122
pub fn market_order(
121123
&self,
122124
market_config: &MarketConfig,
@@ -615,7 +617,7 @@ mod bybit_test {
615617
let mut bybit = Bybit::new(false);
616618
assert_eq!(bybit.get_enable_order_feature(), false);
617619

618-
bybit.set_enable_order_feature(true);
620+
bybit.set_enable_order_with_my_own_risk(true);
619621
assert_eq!(bybit.get_enable_order_feature(), true);
620622
}
621623

‎modules/rbot_lib/src/common/bar.rs‎

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@ use std::{
55

66
use pyo3::{
77
types::{IntoPyDict as _, PyAnyMethods as _, PyModule},
8-
Bound, Py, PyAny, Python,
8+
Bound, Py, PyAny, Python, ffi::c_str,
99
};
10+
use std::ffi::{CString, CStr};
1011

1112
use super::{calc_class, is_notebook, MarketConfig};
1213

@@ -49,9 +50,11 @@ impl PyRestBar {
4950
format!("{}{}", PY_TQDM_PYTHON, PY_BAR)
5051
};
5152

53+
let py_script = CString::new(py_script.as_str()).unwrap();
54+
5255
Python::with_gil(|py| {
5356
let py_module =
54-
PyModule::from_code_bound(py, &py_script, "py_file_bar.py", "py_file_bar");
57+
PyModule::from_code(py, py_script.as_c_str(), c_str!("py_file_bar.py"), c_str!("py_file_bar"));
5558

5659
if py_module.is_err() {
5760
log::error!("py_file_bar tqdm bar class create error")
@@ -142,8 +145,10 @@ impl PyFileBar {
142145
};
143146

144147
Python::with_gil(|py| {
148+
let py_script = CString::new(py_script.as_str()).unwrap();
149+
145150
let py_module =
146-
PyModule::from_code_bound(py, &py_script, "py_file_bar.py", "py_file_bar");
151+
PyModule::from_code(py, py_script.as_c_str(), c_str!("py_file_bar.py"), c_str!("py_file_bar"));
147152

148153
if py_module.is_err() {
149154
log::error!("py_file_bar tqdm bar class create error")
@@ -226,11 +231,6 @@ impl PyFileBar {
226231
}
227232

228233

229-
230-
const PY_RUNNING_BAR: &str = r#"
231-
232-
"#;
233-
234234
pub struct PyRunningBar {
235235
bar: Py<PyAny>,
236236
enable: bool,
@@ -258,8 +258,10 @@ impl PyRunningBar {
258258
};
259259

260260
Python::with_gil(|py| {
261+
let py_script = CString::new(py_script.as_str()).unwrap();
262+
261263
let py_module =
262-
PyModule::from_code_bound(py, &py_script, "py_running_bar.py", "py_running_bar");
264+
PyModule::from_code(py, &py_script, c_str!("py_running_bar.py"), c_str!("py_running_bar"));
263265

264266
if py_module.is_err() {
265267
log::error!("py progress tqdm bar class create error")

‎modules/rbot_lib/src/common/config.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ impl ExchangeConfig {
123123
}
124124
}
125125

126-
#[pyclass]
126+
#[pyclass(eq, eq_int)]
127127
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
128128
pub enum FeeType {
129129
Home,

‎modules/rbot_lib/src/common/env.rs‎

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ use std::env::{self, VarError};
77

88
use hmac::digest::{consts::False, typenum::NotEq};
99
use pyo3::{
10-
types::{PyAnyMethods, PyModule},
11-
Python,
10+
ffi::c_str, types::{PyAnyMethods, PyModule}, Python
1211
};
1312

1413
use super::{SecretString, ExchangeConfig};
@@ -145,9 +144,9 @@ pub fn env_rbot_multicast_port() -> i64 {
145144

146145
pub fn is_notebook() -> bool {
147146
Python::with_gil(|py| {
148-
let notebook = PyModule::from_code_bound(
147+
let notebook = PyModule::from_code(
149148
py,
150-
r#"
149+
c_str!(r#"
151150
import sys
152151
153152
def is_notebook() -> bool:
@@ -163,9 +162,9 @@ def is_notebook() -> bool:
163162
164163
except NameError:
165164
return False
166-
"#,
167-
"notebook.py",
168-
"notebook",
165+
"#),
166+
c_str!("notebook.py"),
167+
c_str!("notebook"),
169168
);
170169

171170
if notebook.is_err() {

‎modules/rbot_lib/src/common/order.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ impl From<&String> for OrderType {
253253
}
254254

255255
#[derive(Debug, Clone, Copy, PartialEq, Display, Serialize, Deserialize)]
256-
#[pyclass]
256+
#[pyclass(eq, eq_int)]
257257
pub enum LogStatus {
258258
UnFixStart, // WebSocketデータの取得開始ポイント
259259
UnFix, // データはWebSocketなどから取得されたが、まだ確定していない

‎modules/rbot_lib/src/db/archive.rs‎

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use crate::{
33
date_string, parse_date, time_string, MarketConfig, MicroSec, OrderSide, PyFileBar, Trade,
44
DAYS, FLOOR_DAY, MIN, NOW, TODAY,
55
},
6-
db::{append_df, csv_to_df, df_to_parquet, parquet_to_df, KEY},
6+
db::{append_df, parquet_to_df, KEY},
77
net::{check_exist, RestApi},
88
};
99
use anyhow::{anyhow, Context};
@@ -15,10 +15,6 @@ use rust_decimal::{prelude::FromPrimitive, Decimal};
1515
use tokio::io::{AsyncWriteExt as _, BufWriter};
1616
// Import the `anyhow` crate and the `Result` type.
1717
use super::{db_path_root, select_df_lazy};
18-
use polars::lazy::{
19-
dsl::{col, lit},
20-
frame::IntoLazy,
21-
};
2218
use polars::prelude::{DataFrame, NamedFrom};
2319
use polars::series::Series;
2420

@@ -28,7 +24,6 @@ use std::{
2824
str::FromStr,
2925
vec,
3026
};
31-
use tempfile::tempdir;
3227

3328
const EXTENSION: &str = "parquet";
3429

@@ -732,7 +727,7 @@ where
732727
mod archive_test {
733728
use std::{path::PathBuf, str::FromStr};
734729

735-
use crate::{common::{init_debug_log, NOW}, db::TradeArchive};
730+
use crate::{common::{init_debug_log, NOW}};
736731

737732
use super::log_download_tmp;
738733

‎modules/rbot_lib/src/db/df.rs‎

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
use std::fs::File;
44
use std::io::{BufReader, Cursor, Read};
5-
use std::path::{Path, PathBuf};
5+
use std::path::PathBuf;
66

77
use crate::common::{OrderSide, Trade};
88
use crate::common::{time_string, MicroSec, SEC};
@@ -25,8 +25,6 @@ use anyhow::anyhow;
2525
#[allow(non_upper_case_globals)]
2626
#[allow(non_snake_case)]
2727
pub mod KEY {
28-
use polars::prelude::PlSmallStr;
29-
3028
pub const timestamp: &str = "timestamp";
3129

3230
// for trade
@@ -616,8 +614,7 @@ pub fn vap_df(df: &DataFrame, start_time: MicroSec, end_time: MicroSec, size: i6
616614
.fill_null(FillNullStrategy::Zero)
617615
.unwrap();
618616

619-
buy_vol.rename(KEY::buy_volume.into()).clone();
620-
617+
buy_vol.rename(KEY::buy_volume.into());
621618

622619
let mut sell_vol = vap
623620
.column("false")
@@ -757,7 +754,6 @@ pub fn convert_timems_to_datetime(df: &mut DataFrame) -> anyhow::Result<()> {
757754
Ok(())
758755
}
759756

760-
use tokio::time::error::Elapsed;
761757
use ::zip::ZipArchive;
762758
use polars::prelude::*;
763759
use rust_decimal::prelude::ToPrimitive;

0 commit comments

Comments
 (0)